vue-virtual-draglist
Advanced tools
Comparing version 2.8.1 to 2.8.2
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):(t=t||self).VirtualDragList=e(t.Vue)}(this,function(t){"use strict";function n(e,t){var i,n=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)),n}function d(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(Object(i),!0).forEach(function(t){o(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function o(t,e,i){(e=function(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);i=i.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:String(t)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}function r(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){var i;if(t)return"string"==typeof t?s(t,e):"Map"===(i="Object"===(i=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:i)||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?s(t,e):void 0}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;(function(t){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function e(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}function j(t,e){t.style["".concat(J.css,"transition-duration")]=null==e?"":"".concat(e,"ms")}function a(t,e){t.style["".concat(J.css,"transform")]=e?"".concat(e):""}function r(t,e,i){window.addEventListener?t.addEventListener(e,i,!(!Z&&y)&&q):window.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}function i(t,e,i){window.removeEventListener?t.removeEventListener(e,i,!(!Z&&y)&&q):window.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=null}function P(t){var e=t,i=t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0],t=i?document.elementFromPoint(i.clientX,i.clientY):t.target;return!i||"clientX"in e||(e.clientX=i.clientX,e.clientY=i.clientY,e.pageX=i.pageX,e.pageY=i.pageY,e.screenX=i.screenX,e.screenY=i.screenY),{touch:i,event:e,target:t}}function R(){return document.scrollingElement||document.documentElement}function m(t,e,i){if(t.getBoundingClientRect||t===window){var n,o,s,r,l,a,c=t!==window&&t.parentNode&&t!==R()?(o=(n=t.getBoundingClientRect()).top,s=n.left,r=n.bottom,l=n.right,a=n.height,n.width):(s=o=0,r=window.innerHeight,l=window.innerWidth,a=window.innerHeight,window.innerWidth);if(e&&t!==window){i=i||t.parentNode;do{if(i&&i.getBoundingClientRect){var h=i.getBoundingClientRect();o-=h.top+parseInt(u(i,"border-top-width")),s-=h.left+parseInt(u(i,"border-left-width")),r=o+n.height,l=s+n.width;break}}while(i=i.parentNode)}return{top:o,left:s,bottom:r,right:l,width:c,height:a}}}function l(t,e,i,n){if(t){i=i||document;do{if(null==e){var o=Array.prototype.slice.call(i.children),s=o.indexOf(t);if(-1<s)return o[s];for(var r=0;r<o.length;r++)if(K(t,o[r]))return o[r]}else if((">"!==e[0]||t.parentNode===i)&&h(t,e)||n&&t===i)return t}while(t=t.parentNode)}return null}function K(t,e){if(t&&e){if(e.compareDocumentPosition)return e===t||16&e.compareDocumentPosition(t);if(e.contains&&1===t.nodeType)return e.contains(t)&&e!==t;for(;t=t.parentNode;)if(t===e)return 1}}function o(t,e){var i=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||e&&!h(t,e)||"none"===u(t,"display")||i++;return i}function F(t,e,i,n){for(var o=0,s=0,r=t.children;o<r.length;){if(r[o]!==f.ghost&&"none"!==u(r[o],"display")&&l(r[o],i,t,!1)&&(n||r[o]!==f.dragged)){if(s===e)return r[o];s++}o++}return null}function H(t,e){var i,n=u(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=F(t,0,e),t=F(t,1,e),e=s&&u(s),r=t&&u(t),l=e&&parseInt(e.marginLeft)+parseInt(e.marginRight)+m(s).width,a=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+m(t).width,c=G||y?"cssFloat":"float";return"flex"===n.display?"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal":"grid"===n.display?n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal":s&&e.float&&"none"!==e.float?(i="left"===e.float?"left":"right",!t||"both"!==r.clear&&r.clear!==i?"horizontal":"vertical"):s&&("block"===e.display||"flex"===e.display||"table"===e.display||"grid"===e.display||o<=l&&"none"===n[c]||t&&"none"===n[c]&&o<l+a)?"vertical":"horizontal"}function c(t,e,i){var n;t&&e&&(t.classList?t.classList[i?"add":"remove"](e):(n=(" "+t.className+" ").replace($," ").replace(" "+e+" "," "),t.className=(n+(i?" "+e:"")).replace($," ")))}function h(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{return t.matches?t.matches(e):t.msMatchesSelector?t.msMatchesSelector(e):t.webkitMatchesSelector&&t.webkitMatchesSelector(e)}catch(t){}}function u(t,e,i){var n=t&&t.style;if(n){if(void 0===i)return document.defaultView&&document.defaultView.getComputedStyle?i=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(i=t.currentStyle),void 0===e?i:i[e];n[e=e in n||-1!==e.indexOf("webkit")?e:"-webkit-"+e]=i+("string"==typeof i?"":"px")}}function s(t,e){return 2===(t=t.compareDocumentPosition?t.compareDocumentPosition(e):t.contains?(t!=e&&t.contains(e)&&16)+(t!=e&&e.contains(t)&&8)+(0<=t.sourceIndex&&0<=e.sourceIndex?(t.sourceIndex<e.sourceIndex&&4)+(t.sourceIndex>e.sourceIndex&&2):1)+0:0)?1:4===t?-1:0}function W(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault()}function d(t){var e=t.sortable,i=t.name,t=t.params;"function"==typeof(e=e.options[i])&&e(Object.assign({},t))}function X(t){this.options=t,this.autoScrollAnimationFrame=null}function Y(t){this.options=t,this.animations=[]}function U(t){this.options=t||{},this.selectedElements=[]}function f(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[L]=this).el=t,this.options=e=Object.assign({},e);var i,n,o={store:null,disabled:!1,group:"",animation:150,draggable:null,handle:null,multiple:!1,selectHandle:null,customGhost:null,direction:function(){return H(t,e.draggable)},autoScroll:!0,scrollThreshold:55,scrollSpeed:{x:10,y:10},delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",swapOnDrop:!0,fallbackOnBody:!1,supportTouch:"ontouchstart"in window,emptyInsertThreshold:-5};for(i in o)i in this.options||(this.options[i]=o[i]);for(n in nt(e),this)"_"===n.charAt(0)&&"function"==typeof this[n]&&(this[n]=this[n].bind(this));var s=this.options.supportTouch;r(t,s?"touchstart":"mousedown",this._onDrag),A.push(t),this.autoScroller=new X(this.options),this.multiplayer=new U(this.options),this.animator=new Y(this.options)}var q,$,V,p,g,y,G,v,Z,J,S,b,_,Q,w,x,T,O,E,tt,z,C,et,I,D,k,M,B,it,N,L,A,nt;t.exports=(q={capture:!1,passive:!1},$=/\s+/g,y=e(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),G=e(/Edge/i),v=e(/safari/i)&&!e(/chrome/i)&&!e(/android/i),V=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return V=!0}}),Z=V,J="undefined"==typeof window||"undefined"==typeof document?{}:(t=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1],{dom:"WebKit|Moz|MS|O".match(new RegExp("("+t+")","i"))[1],lowercase:t,css:"-"+t+"-",js:t[0].toUpperCase()+t.substr(1)}),window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),X.prototype={destroy:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,i){var n=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){e&&i&&n.autoScroll(t,i),n.update(t,e,i)})},autoScroll:function(t,e){var i,n,o,s,r,l,a,c,h,u,d,f,p;t&&void 0!==e.clientX&&void 0!==e.clientY&&(u=m(t))&&(i=e.clientX,e=e.clientY,n=u.top,o=u.right,s=u.bottom,r=u.left,f=u.height,u=u.width,e<n||o<i||s<e||i<r||(l=(a=this.options).scrollThreshold,a=a.scrollSpeed,d=t.scrollTop,c=t.scrollLeft,p=t.scrollHeight,h=0<d&&n<=e&&e<=n+l,u=c+u<t.scrollWidth&&i<=o&&o-l<=i,d=d+f<p&&e<=s&&s-l<=e,(p=f=0)<c&&r<=i&&i<=r+l&&(f=Math.floor(Math.max(-1,(i-r)/l-1)*a.x)),u&&(f=Math.ceil(Math.min(1,(i-o)/l+1)*a.x)),h&&(p=Math.floor(Math.max(-1,(e-n)/l-1)*a.y)),(p=d?Math.ceil(Math.min(1,(e-s)/l+1)*a.y):p)&&(t.scrollTop+=p),f&&(t.scrollLeft+=f)))}},Y.prototype={collect:function(t){if(t){for(var e=m(t),i=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,n=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,o=Math.min(e.right,i),s=Math.min(e.bottom,n),r=Array.prototype.slice.call(t.children),l=[],a=0;a<=r.length;a++){var c=r[a];if(c&&c!==f.ghost&&"none"!==u(c,"display")){var h=m(c);if(!(h.bottom<0||h.right<0)){if(h.top>s||h.left>o)break;l.push({node:c,rect:h})}}}this.animations.push(l)}},animate:function(){for(var t=this.animations.pop(),e=0,i=t.length;e<i;e++){var n=(o=t[e]).node,o=o.rect;this._excute(n,o)}},_excute:function(t,e){var i=e.left,e=e.top,n=m(t);n.top===e&&n.left===i||(e-=n.top,i-=n.left,j(t),a(t,"translate3d(".concat(i,"px, ").concat(e,"px, 0)")),t.offsetWidth,j(t,this.options.animation),a(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){j(t),a(t,""),t.animated=null},this.options.animation))}},U.prototype={destroy:function(){p=g=null},active:function(){return!!p},setParams:function(t){t.nodes=p||[],t.clones=g||[]},select:function(t){c(t,this.options.selectedClass,!0),this.selectedElements.push(t),this.selectedElements.sort(s)},deselect:function(t){var e=this.selectedElements.indexOf(t);-1<e&&(c(t,this.options.selectedClass,!1),this.selectedElements.splice(e,1))},getGhostElement:function(){var i;return p?(i=document.createElement("div"),this.selectedElements.forEach(function(t,e){(t=t.cloneNode(!0)).style="position: absolute;left: 0;top: 0;bottom: 0;right: 0;opacity: ".concat(0===e?1:.5,";z-index: ").concat(e,";"),i.appendChild(t)}),i):null},toggleSelected:function(e,t){var i=this;t?e.forEach(function(t){return i.selectedElements.push(t)}):this.selectedElements=this.selectedElements.filter(function(t){return e.indexOf(t)<0})},toggleClass:function(t){if(p)for(var e=0;e<p.length;e++)c(p[e],this.options.chosenClass,t)},toggleVisible:function(t){p&&(t?(t=p.indexOf(f.dragged),this._viewElements(p,t,f.dragged)):this._hideElements(p))},onChoose:function(){!this.options.multiple||!this.selectedElements.length||this.selectedElements.indexOf(f.dragged)<0||(this.selectedElements.sort(s),p=this.selectedElements,this.toggleClass(!0))},onDrag:function(t){p&&(t.animator.collect(f.dragged.parentNode),this._hideElements(p),t.animator.animate(),this.toggleClass(!1))},onDrop:function(t,e,i){var n,o,s;p&&(o=f.clone,s=p.indexOf(n=f.dragged),e.animator.collect(o.parentNode),t!==e&&"clone"===i?(u(o,"display","none"),g=p.map(function(t){return t.cloneNode(!0)}),this._viewElements(g,s,o),this._viewElements(p,s,n)):this._viewElements(p,s,o),e.animator.animate(),t!==e)&&(e.multiplayer.toggleSelected(g||p,!0),"clone"!==i)&&t.multiplayer.toggleSelected(p,!1)},onSelect:function(t,e,i,n){e=P(e).event;!f.dragged&&this._isClick(t,e)&&(t=this.selectedElements.indexOf(i),c(i,this.options.selectedClass,t<0),e={from:n.el,event:e,node:i,index:o(i)},t<0?(this.selectedElements.push(i),d({sortable:n,name:"onSelect",params:e})):(this.selectedElements.splice(t,1),d({sortable:n,name:"onDeselect",params:e})),this.selectedElements.sort(s))},_viewElements:function(t,e,i){for(var n,o=0;o<t.length;o++)u(t[o],"display",""),o<e?i.parentNode.insertBefore(t[o],i):(n=0<o?t[o-1]:i,i.parentNode.insertBefore(t[o],n.nextSibling))},_hideElements:function(t){for(var e=0;e<t.length;e++)t[e]!=f.dragged&&u(t[e],"display","none")},_isClick:function(t,e){var i=e.clientX-t.clientX,e=e.clientY-t.clientY;return 0<=(t=Math.sqrt(i*i+e*e))&&t<=1}},L="Sortable"+Date.now(),A=[],nt=function(t){var e={},i=t.group;i&&"object"==n(i)||(i={name:i,pull:!0,put:!0,revertDrag:!0}),e.name=i.name,e.pull=i.pull,e.put=i.put,e.revertDrag=i.revertDrag,t.group=e},f.prototype={constructor:f,_onDrag:function(t){var e,i,n,o,s=this;b||this.options.disabled||!this.options.group.pull||/mousedown|pointerdown/.test(t.type)&&0!==t.button||(t=P(t),e=t.touch,i=t.event,t=t.target,v&&t&&"SELECT"===t.tagName.toUpperCase())||!(n=l(t,this.options.draggable,this.el))||n.animated||(b=n,O=i,r(z=e?b:document,"mouseup",this._onDrop),r(z,"touchend",this._onDrop),r(z,"touchcancel",this._onDrop),o=(n=this.options).handle,"function"==typeof(n=n.selectHandle)&&n(i))||"string"==typeof n&&h(t,n)||"function"==typeof o&&!o(i)||"string"==typeof o&&!h(t,o)||(t=(n=this.options).delay,o=n.delayOnTouchOnly,!t||o&&!e||G||y?this._onStart(e,i):(r(this.el.ownerDocument,"touchmove",this._delayMoveHandler),r(this.el.ownerDocument,"mousemove",this._delayMoveHandler),r(this.el.ownerDocument,"mouseup",this._cancelStart),r(this.el.ownerDocument,"touchend",this._cancelStart),r(this.el.ownerDocument,"touchcancel",this._cancelStart),et=setTimeout(function(){return s._onStart(e,i)},t)))},_delayMoveHandler:function(t){t=t.touches?t.touches[0]:t,Math.max(Math.abs(t.clientX-O.clientX),Math.abs(t.clientY-O.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout(et),i(this.el.ownerDocument,"touchmove",this._delayMoveHandler),i(this.el.ownerDocument,"mousemove",this._delayMoveHandler),i(this.el.ownerDocument,"mouseup",this._cancelStart),i(this.el.ownerDocument,"touchend",this._cancelStart),i(this.el.ownerDocument,"touchcancel",this._cancelStart)},_onStart:function(t,e){var i=o(b);I=this.el,D=this.el,it=B=M=i,N=b,S=this.el,w=b.cloneNode(!0),T=b.parentNode,k=this.options.group.pull,f.clone=w,f.active=this,c(f.dragged=b,this.options.chosenClass,!0),this.multiplayer.onChoose(),d({sortable:this,name:"onChoose",params:this._getParams(e)}),r(z,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout(function(){return document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onStarted:function(){c(w,this.options.chosenClass,!0),this._appendGhost(),this.multiplayer.onDrag(this),d({sortable:this,name:"onDrag",params:this._getParams(O)}),u(b,"display","none"),c(b,this.options.chosenClass,!1),b.parentNode.insertBefore(w,b),v&&u(document.body,"user-select","none")},_getGhostElement:function(){var t=this.options.customGhost;return"function"==typeof t?t((t=this.multiplayer.selectedElements).length?t:[b]):this.multiplayer.getGhostElement()||b},_appendGhost:function(){if(!x){var t,e=(n=this.options).fallbackOnBody,i=n.ghostClass,n=n.ghostStyle,e=e?document.body:this.el,o=this._getGhostElement(),o=(c(x=o.cloneNode(!0),i,!0),m(b)),s=Object.assign({position:"fixed",top:o.top,left:o.left,width:o.width,height:o.height,minWidth:o.width,minHeight:o.height,opacity:"0.8",overflow:"hidden","z-index":"100000","box-sizing":"border-box","pointer-events":"none"},n);for(t in s)u(x,t,s[t]);x.style["".concat(J.css,"transition")]="none",a(x,"translate3d(0px, 0px, 0px)"),f.ghost=x,e.appendChild(x),n=(O.clientX-o.left)/parseInt(x.style.width)*100,i=(O.clientY-o.top)/parseInt(x.style.height)*100,u(x,"transform-origin","".concat(n,"% ").concat(i,"%")),u(x,"transform","translateZ(0)"),u(x,"will-change","transform")}},_nearestSortable:function(t){var e,i,n,o,s,r,l;W(t),!O||!b||(n=E||O,o=(e=t).clientX,e=e.clientY,i=o-n.clientX,n=e-n.clientY,void 0!==o&&void 0!==e&&Math.abs(i)<=0&&Math.abs(n)<=0)||(E||this._onStarted(),e=(o=P(t)).event,i=o.target,n=(E=e).clientX-O.clientX,t=e.clientY-O.clientY,a(x,"translate3d(".concat(n,"px, ").concat(t,"px, 0)")),this.options.autoScroll&&(o=function(t){if(t&&t.getBoundingClientRect){var e=t;do{if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var i=u(e);if(e.clientWidth<e.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||e.clientHeight<e.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY))return e.getBoundingClientRect&&e!==document.body?e:R()}}while(e=e.parentNode)}return R()}(i),this.autoScroller.update(o,O,E)),s=e.clientX,r=e.clientY,A.some(function(t){var e,i,n=t[L].options.emptyInsertThreshold;if(null!=n)return i=m(t),e=s>=i.left-n&&s<=i.right+n,i=r>=i.top-n&&r<=i.bottom+n,e&&i?l=t:void 0}),l&&l[L]._onMove(e,i))},_allowPut:function(){var t,e,i;return S===this.el||!!this.options.group.put&&(t=(e=this.options.group).name,e=e.put,i=S[L].options.group,e.join&&-1<e.indexOf(i.name)||i.name&&t&&i.name===t)},_allowSwap:function(){var t=s(w,_),e=(Q=t<0?_.nextSibling:_,m(_)),i="vertical"===(o="function"==typeof this.options.direction?this.options.direction.call(E,b,this):this.options.direction),n=i?E.clientY:E.clientX,o=_["vertical"===o?"offsetHeight":"offsetWidth"],n=n>=(i?e.top:e.left)&&n<(i?e.bottom:e.right)-o/2?-1:1;return tt!==_?(C=n,!0):C!==n&&((C=n)<0?0<t:t<0)},_onMove:function(t,e){var i,n;this._allowPut()&&(d({sortable:this,name:"onMove",params:this._getParams(t)}),this.el===D||e!==this.el&&function(t){for(var e=t.lastElementChild;e&&(e===f.ghost||"none"===u(e,"display"));)e=e.previousElementSibling;return e}(this.el)?(_=l(e,this.options.draggable,this.el))&&!_.animated&&this._allowSwap()&&(_===w||K(_,w)||(this.el!==D?this._onInsert(t):(i=t,n=n||m(T),i.clientX<=n.right&&i.clientX>=n.left&&i.clientY>=n.top&&i.clientY<=n.bottom&&e===T||this._onChange(t))),tt=_):(_=tt=null,this._onInsert(t)))},_onInsert:function(t){var e=_||w,i="clone"===k&&this.el!==S&&D===S,n="clone"===k&&this.el===S&&D!==S;I=this.el,M=o(w),N=e,T=_?_.parentNode:this.el,D[L].animator.collect(w.parentNode),this.animator.collect(T),i&&(u(b,"display",""),S[L].multiplayer.toggleVisible(!0),S[L].options.group.revertDrag||D.insertBefore(b,w)),n&&(M=o(b),u(b,"display","none"),this.multiplayer.toggleVisible(!1)),_?T.insertBefore(w,C<0?_:_.nextSibling):T.appendChild(w),B=o(w),i&&S[L].options.group.revertDrag&&d({sortable:S[L],name:"onChange",params:this._getParams(t,{to:S,target:b,newIndex:it,revertDrag:!0})}),i||d({sortable:D[L],name:"onRemove",params:this._getParams(t)}),n&&_!==b&&d({sortable:this,name:"onChange",params:this._getParams(t,{from:S,backToOrigin:!0})}),n||d({sortable:this,name:"onAdd",params:this._getParams(t)}),D[L].animator.animate(),this.animator.animate(),D=this.el},_onChange:function(t){_!==b&&(T=_.parentNode,M=o(w),N=_,this.animator.collect(T),T.insertBefore(w,Q),B=o(w),d({sortable:this,name:"onChange",params:this._getParams(t)}),this.animator.animate(),D=this.el)},_onDrop:function(t){W(t),this._cancelStart(),i(z,"touchmove",this._nearestSortable),i(z,"mousemove",this._nearestSortable),i(z,"mouseup",this._onDrop),i(z,"touchend",this._onDrop),i(z,"touchcancel",this._onDrop),c(b,this.options.chosenClass,!1),S&&(D=S,M=it,N===w&&(N=b),this.multiplayer.toggleClass(!1),d({sortable:this,name:"onUnchoose",params:this._getParams(t)}),E)&&this._onEnd(t),!E&&this.options.multiple&&this.multiplayer.onSelect(O,t,b,this),x&&x.parentNode&&x.parentNode.removeChild(x),this.multiplayer.destroy(),this.autoScroller.destroy(),this._nulling()},_onEnd:function(t){t=this._getParams(t),this.multiplayer.onDrop(D[L],I[L],k),!this.options.swapOnDrop||"clone"===k&&D!==I||T.insertBefore(b,w),"clone"!==k||D===I||this.multiplayer.active()?w&&w.parentNode&&w.parentNode.removeChild(w):c(w,this.options.chosenClass,!1),u(b,"display",""),v&&u(document.body,"user-select",""),D!==I&&d({sortable:D[L],name:"onDrop",params:t}),d({sortable:I[L],name:"onDrop",params:t})},_getParams:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=Object.create(null);return i.event=t,i.to=I,i.from=D,i.node=b,i.clone=w,i.target=N,i.oldIndex=M,i.newIndex=B,i.pullMode=k,this.multiplayer.setParams(i),Object.assign(i,e),i.relative=i.target===b?0:s(i.target,w),i},_nulling:function(){I=D=S=b=_=Q=w=x=T=k=M=B=it=O=E=N=tt=z=C=et=f.clone=f.ghost=f.active=f.dragged=null},destroy:function(){this._nulling(),this._cancelStart(),i(this.el,"touchstart",this._onDrag),i(this.el,"mousedown",this._onDrag),A.splice(A.indexOf(this.el),1),this.el[L]=this.animator=this.multiplayer=this.autoScroller=null},option:function(t,e){if(void 0===e)return this.options[t];this.options[t]=e,this.animator.options[t]=e,this.multiplayer.options[t]=e,this.autoScroller.options[t]=e,"group"===t&&nt(this.options)},select:function(t){this.multiplayer.select(t)},deselect:function(t){this.multiplayer.deselect(t)},getSelectedElements:function(){return this.multiplayer.selectedElements}},f.utils={on:r,off:i,css:u,index:o,closest:l,getRect:m,toggleClass:c,detectDirection:H},f.get=function(t){return t[L]},f.create=function(t,e){return new f(t,e)},f)})(e={exports:{}});var l=e.exports;function a(s,t,e){function i(){for(var t,e=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return c&&clearTimeout(c),a?(t=!c,c=setTimeout(function(){c=null},l),t&&(r=s.apply(this,n))):c=setTimeout(function(){s.apply(e,n)},l),r}var r,l=1<arguments.length&&void 0!==t?t:50,a=2<arguments.length&&void 0!==e&&e,c=null;return i.cancel=function(){clearTimeout(c),c=null},i}function f(t,e){return(Array.isArray(e)?e:e.replace(/\[/g,".").replace(/\]/g,".").split(".")).reduce(function(t,e){return(t||{})[e]},t)}var c="INIT",i="FIXED",h="DYNAMIC",u="FRONT",p="BEHIND",m="STATIONARY",e="horizontal",g="vertical",y=(o(O={},g,"scrollTop"),o(O,e,"scrollLeft"),O),v=(o(O={},g,"scrollHeight"),o(O,e,"scrollWidth"),O),S=(o(O={},g,"offsetHeight"),o(O,e,"offsetWidth"),O),b=(o(O={},g,"offsetTop"),o(O,e,"offsetLeft"),O),_=["size","keeps","scroller","direction","debounceTime","throttleTime"];function w(t){this.options=t;var e,i={size:0,keeps:0,buffer:0,wrapper:null,scroller:null,direction:"vertical",uniqueKeys:[],debounceTime:null,throttleTime:null};for(e in i)e in this.options||(this.options[e]=i[e]);this.sizes=new Map,this.range={start:0,end:0,front:0,behind:0},this.offset=0,this.calcType=c,this.calcSize={average:0,total:0,fixed:0,header:0},this.direction="",this.useWindowScroll=null,this._updateScrollElement(),this._updateOnScrollFunction(),this.addScrollEventListener(),this._checkIfUpdate(0,t.keeps-1)}w.prototype={constructor:w,isFront:function(){return this.direction===u},isBehind:function(){return this.direction===p},isFixed:function(){return this.calcType===i},getSize:function(t){return this.sizes.get(t)||this._getItemSize()},getOffset:function(){return this.scrollEl[y[this.options.direction]]},getScrollSize:function(){return this.scrollEl[v[this.options.direction]]},getClientSize:function(){return this.scrollEl[S[this.options.direction]]},scrollToOffset:function(t){this.scrollEl[y[this.options.direction]]=t},scrollToIndex:function(t){t>=this.options.uniqueKeys.length-1?this.scrollToBottom():(t=this._getOffsetByIndex(t),this.scrollToOffset(t))},scrollToBottom:function(){var i=this,t=this.getScrollSize();this.scrollToOffset(t),setTimeout(function(){var t=i.getClientSize(),e=i.getScrollSize();i.getOffset()+t+1<e&&i.scrollToBottom()},5)},updateOptions:function(t,i){var n=this,e=this.options[t];this.options[t]=i,"uniqueKeys"===t?this.sizes.forEach(function(t,e){i.includes(e)||n.sizes.delete(e)}):"scroller"===t&&(null!=e&&e.removeEventListener("scroll",this._onScroll),this._updateScrollElement(),this.addScrollEventListener())},updateRange:function(t){t?this._handleUpdate(t.start,t.end):(t=this.range.start,t=Math.max(t,0),this._handleUpdate(t,this._getEndByStart(t)))},handleItemSizeChange:function(t,e){this.sizes.set(t,e),this.calcType===c?(this.calcType=i,this.calcSize.fixed=e):this.isFixed()&&this.calcSize.fixed!==e&&(this.calcType=h,this.calcSize.fixed=void 0),this.calcType!==i&&(this.calcSize.total=r(this.sizes.values()).reduce(function(t,e){return t+e},0),this.calcSize.average=Math.round(this.calcSize.total/this.sizes.size))},handleSlotSizeChange:function(t,e){this.calcSize[t]=e},addScrollEventListener:function(){var t;null!=(t=this.options.scroller)&&t.addEventListener("scroll",this._onScroll,!1)},removeScrollEventListener:function(){var t;null!=(t=this.options.scroller)&&t.removeEventListener("scroll",this._onScroll)},_updateOnScrollFunction:function(){var i,n,o,t=this,e=this.options,s=e.debounceTime,e=e.throttleTime;this._onScroll=s?a(function(){return t._handleScroll()},s):e?(i=function(){return t._handleScroll()},n=e,o=null,function(){var t=this,e=arguments;o=o||setTimeout(function(){o=null,i.apply(t,e)},n)}):function(){return t._handleScroll()},this._onScroll=this._onScroll.bind(this)},_updateScrollElement:function(){this.scrollEl=this._getScrollElement(this.options.scroller)},_handleScroll:function(){var t=this.getOffset(),e=this.getClientSize(),i=this.getScrollSize(),n=(t===this.offset?this.direction=m:this.direction=t<this.offset?u:p,this.offset=t,this.isFront()&&t<=0),i=this.isBehind()&&i<=e+t;this.options.onScroll({top:n,bottom:i,offset:t,direction:this.direction}),this.isFront()?this._handleScrollFront():this.isBehind()&&this._handleScrollBehind()},_handleScrollFront:function(){var t=this._getScrollItems();t>this.range.start||(t=Math.max(t-this.options.buffer,0),this._checkIfUpdate(t,this._getEndByStart(t)))},_handleScrollBehind:function(){var t=this._getScrollItems();t<this.range.start+this.options.buffer||this._checkIfUpdate(t,this._getEndByStart(t))},_getScrollItems:function(){var t=this.offset-this._getScrollStartOffset();if(t<=0)return 0;if(this.isFixed())return Math.floor(t/this.calcSize.fixed);for(var e,i,n=0,o=this.options.uniqueKeys.length;n<=o;){if(e=n+Math.floor((o-n)/2),(i=this._getOffsetByIndex(e))===t)return e;i<t?n=e+1:t<i&&(o=e-1)}return 0<n?--n:0},_checkIfUpdate:function(t,e){var i=this.options.keeps;this.options.uniqueKeys.length<=i?(t=0,e=this._getLastIndex()):e-t<i-1&&(t=e-i+1),this.range.start!==t&&this._handleUpdate(t,e)},_handleUpdate:function(t,e){this.range.start=t,this.range.end=e,this.range.front=this._getFrontOffset(),this.range.behind=this._getBehindOffset(),this.options.onUpdate(d({},this.range))},_getFrontOffset:function(){return this.isFixed()?this.calcSize.fixed*this.range.start:this._getOffsetByIndex(this.range.start)},_getBehindOffset:function(){var t=this.range.end,e=this._getLastIndex();return this.isFixed()?(e-t)*this.calcSize.fixed:(e-t)*this._getItemSize()},_getOffsetByIndex:function(t){if(!t)return 0;for(var e=0,i=0;i<t;i++){var n=this.sizes.get(this.options.uniqueKeys[i]);e+="number"==typeof n?n:this._getItemSize()}return e},_getEndByStart:function(t){return Math.min(t+this.options.keeps-1,this._getLastIndex())},_getLastIndex:function(){var t=this.options,e=t.uniqueKeys,t=t.keeps;return 0<e.length?e.length-1:t-1},_getItemSize:function(){return this.isFixed()?this.calcSize.fixed:this.calcSize.average||this.options.size},_getScrollElement:function(t){return t instanceof Document&&9===t.nodeType||t instanceof Window?(this.useWindowScroll=!0,document.scrollingElement||document.documentElement||document.body):(this.useWindowScroll=!1,t)},_getScrollStartOffset:function(){var t=this.calcSize.header;if(this.useWindowScroll&&this.options.wrapper)for(var e=this.options.wrapper;t+=e[b[this.options.direction]],(e=e.offsetParent)&&e!==this.options.wrapper.ownerDocument;);return t}};var x=["delay","group","handle","disabled","draggable","animation","autoScroll","ghostClass","ghostStyle","chosenClass","fallbackOnBody","scrollThreshold","delayOnTouchOnly"];function T(t,e,i){var n=this,e=(this.ctx=t,this.onDrag=e,this.onDrop=i,this.list=r(t.list),this.store={},x.reduce(function(t,e){return t[e]=n.ctx[e],t},{}));this.sortable=new l(this.ctx.$refs.groupRef,d(d({},e),{},{swapOnDrop:!1,onDrag:function(t){return n._onDrag(t)},onAdd:function(t){return n._onAdd(t)},onRemove:function(t){return n._onRemove(t)},onChange:function(t){return n._onChange(t)},onChoose:function(t){return n._onChoose(t)},onUnchoose:function(t){return n._onUnchoose(t)},onDrop:function(t){return n._onDrop(t)}}))}T.prototype={constructor:T,destroy:function(){this.sortable&&this.sortable.destroy(),this.sortable=this.store=null},setValue:function(t,e){"list"===t?this.list=r(e):this.sortable.option(t,e)},_onChoose:function(t){var t=t.node.dataset.key,e=this._getIndex(this.list,t),i=this.list[e];this.store={item:i,key:t,origin:{index:e,list:this.list},from:{index:e,list:this.list},to:{index:e,list:this.list}},this.sortable.option("store",this.store)},_onDrag:function(t){var e=this.store,i=e.item,n=e.key,e=e.origin;this.onDrag({list:this.list}),this.ctx.$emit("drag",{item:i,key:n,index:e.index})},_onRemove:function(t){var t=t.node.dataset.key,e=this._getIndex(this.list,t),i=this.list[e];this.list.splice(e,1),Object.assign(this.store,{key:t,item:i}),this.sortable.option("store",this.store),this.ctx.$emit("remove",{item:i,index:e,key:t})},_onAdd:function(t){var e=t.from,i=t.target,t=t.relative,e=l.get(e).option("store"),n=e.key,e=e.item,i=this._getIndex(this.list,i.dataset.key);-1===t&&(i+=1),this.list.splice(i,0,e),Object.assign(this.store,{to:{index:i,list:this.list}}),this.sortable.option("store",this.store),this.ctx.$emit("add",{item:e,index:i,key:n})},_onChange:function(t){var e,i,n,o,s=l.get(t.from).option("store");t.revertDrag?(this.list=r(this.ctx.list),Object.assign(this.store,{from:s.origin})):(i=t.node,o=t.target,e=t.relative,t=t.backToOrigin,i=this._getIndex(this.list,i.dataset.key),n=this.list[i],o=this._getIndex(this.list,o.dataset.key),t&&(1===e&&s.from.index<o&&--o,-1===e)&&s.from.index>o&&(o+=1),this.list.splice(i,1),this.list.splice(o,0,n),Object.assign(this.store,{from:{index:o,list:this.list},to:{index:o,list:this.list}}))},_onUnchoose:function(t){var e=this._getStore(t),i=e.from,e=e.to;t.from===t.to&&i.origin.index===e.to.index&&this.sortable.option("swapOnDrop",!0)},_onDrop:function(t){var e=this._getStore(t),i=e.from,e=e.to,n=t.from!==t.to||i.origin.index!==e.to.index;this.onDrop({list:this.list}),this.ctx.$emit("drop",{changed:n,list:this.list,item:i.item,key:i.key,from:i.origin,to:e.to}),t.from!==t.to&&"clone"===t.pullMode&&null!=(n=t.clone)&&n.remove(),t.from===t.to&&i.origin.index!==e.to.index&&null!=(n=l.dragged)&&n.remove(),this.sortable.option("swapOnDrop",!1)},_getIndex:function(t,e){for(var i=0;i<t.length;i++)if(f(t[i],this.ctx.dataKey)==e)return i;return-1},_getStore:function(t){return{from:l.get(t.from).option("store"),to:l.get(t.to).option("store")}}};var g={dataSource:{type:Array,default:function(){return[]}},dataKey:{type:String,required:!0},scroller:{type:[Window,Document,HTMLElement]},direction:{type:String,default:"vertical"},keeps:{type:Number,default:30},size:{type:Number},draggable:{type:[Function,String]},handle:{type:[Function,String]},group:{type:[String,Object]},debounceTime:{type:Number,default:0},animation:{type:Number,default:150},autoScroll:{type:Boolean,default:!0},scrollThreshold:{type:Number,default:55},keepOffset:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},fallbackOnBody:{type:Boolean,default:!1},delay:{type:Number,default:0},delayOnTouchOnly:{type:Boolean,default:!1},rootTag:{type:String,default:"div"},wrapTag:{type:String,default:"div"},headerTag:{type:String,default:"div"},footerTag:{type:String,default:"div"},itemTag:{type:String,default:"div"},wrapClass:{type:String,default:""},wrapStyle:{type:Object},itemStyle:{type:Object},headerStyle:{type:Object},footerStyle:{type:Object},itemClass:{type:String,default:""},ghostClass:{type:String,default:""},ghostStyle:{type:Object,default:function(){return{}}},chosenClass:{type:String,default:""}},e={tag:{type:String,default:"div"},event:{type:String},dataKey:{type:[String,Number]},sizeKey:{type:String}},O={inject:["virtualList"],data:function(){return{observer:null}},mounted:function(){var t=this;"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver(function(){t.onSizeChange()}),this.$el)&&this.observer.observe(this.$el)},updated:function(){this.onSizeChange()},beforeDestroy:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},methods:{onSizeChange:function(){this.virtualList[this.event](this.dataKey,this.getCurrentSize())},getCurrentSize:function(){return this.$el?this.$el[this.sizeKey]:0}}},E=t.component("virtual-draglist-items",{mixins:[O],props:e,render:function(t){var e=this.tag,i=this.dataKey;return t(e,{key:i,attrs:{"data-key":i}},this.$slots.default)}}),z=t.component("virtual-draglist-slots",{mixins:[O],props:e,render:function(t){var e=this.tag,i=this.dataKey;return t(e,{key:i,attrs:{role:i}},this.$slots.default)}});return t.component("virtual-drag-list",{model:{prop:"dataSource",event:"updateDataSource"},props:g,data:function(){return{list:[],start:0,timer:null,range:{start:0,end:0,front:0,behind:0},virtual:null,sortable:null,lastLength:null,uniqueKeys:[]}},provide:function(){return{virtualList:this}},computed:{isHorizontal:function(){return"vertical"!==this.direction},itemSizeKey:function(){return this.isHorizontal?"offsetWidth":"offsetHeight"},virtualAttributes:function(){var i=this;return _.reduce(function(t,e){return t[e]=i[e],t},{})},sortableAttributes:function(){var i=this;return x.reduce(function(t,e){return t[e]=i[e],t},{})}},watch:{dataSource:{handler:function(){this._onUpdate()},deep:!0},virtualAttributes:{handler:function(t,e){if(this.virtual)for(var i in t)t[i]!=e[i]&&this.virtual.updateOptions(i,t[i])},deep:!0},sortableAttributes:{handler:function(t,e){if(this.sortable)for(var i in t)t[i]!=e[i]&&this.sortable.setValue(i,t[i])},deep:!0}},activated:function(){this.scrollToOffset(this.virtual.offset),this.virtual.addScrollEventListener()},deactivated:function(){this.virtual.removeScrollEventListener()},created:function(){this.range.end=this.keeps-1,this._initVirtual(),this._onUpdate()},mounted:function(){this.virtual.updateOptions("wrapper",this.$refs.groupRef),this.scroller||this.virtual.updateOptions("scroller",this.$refs.rootRef)},beforeDestroy:function(){this.sortable&&this.sortable.destroy(),this.virtual.removeScrollEventListener(),this.sortable=this.virtual=null},methods:{getSize:function(t){return this.virtual.getSize(t)},getOffset:function(){return this.virtual.getOffset()},getClientSize:function(){return this.virtual.getClientSize()},getScrollSize:function(){return this.virtual.getScrollSize()},scrollToKey:function(t){t=this.uniqueKeys.indexOf(t);-1<t&&this.virtual.scrollToIndex(t)},scrollToIndex:function(t){this.virtual.scrollToIndex(t)},scrollToOffset:function(t){this.virtual.scrollToOffset(t)},scrollToTop:function(){this.virtual.scrollToOffset(0)},scrollToBottom:function(){this.virtual.scrollToBottom()},_onUpdate:function(){var t=this,e=r(this.list);this.list=this.dataSource,this._updateUniqueKeys(),this.virtual.sizes.size?this._updateRange(e,this.list):(clearTimeout(this.timer),this.timer=setTimeout(function(){return t.virtual.updateRange()},17)),this.sortable?this.sortable.setValue("list",this.list):this.$nextTick(function(){return t._initSortable()}),this.lastLength&&this.keepOffset&&(e=Math.abs(this.list.length-this.lastLength),this.scrollToIndex(e),this.lastLength=null),this.$forceUpdate()},_initVirtual:function(){var e=this;this.virtual=new w({size:this.size,keeps:this.keeps,buffer:Math.round(this.keeps/3),scroller:this.scroller,direction:this.direction,uniqueKeys:this.uniqueKeys,debounceTime:this.debounceTime,throttleTime:this.throttleTime,onScroll:function(t){e.list.length&&t.top?e._handleToTop():t.bottom&&e._handleToBottom()},onUpdate:function(t){e.range=t}})},_initSortable:function(){var e=this;this.sortable=new T(this,function(){e.start=e.range.start},function(t){t=t.list;t.length===e.list.length&&e.start<e.range.start&&(e.range.front+=l.clone[e.isHorizontal?"offsetWidth":"offsetHeight"],e.start=e.range.start),e.$emit("updateDataSource",t)})},_updateRange:function(t,e){var i,n=d({},this.range);0<this.range.start&&-1<(i=e.indexOf(t[this.range.start]))&&(n.start=i,n.end=i+this.keeps-1),e.length>t.length&&this.range.end===t.length-1&&this._scrolledToBottom()&&(n.end++,n.start=Math.max(0,n.end-this.keeps+1)),this.virtual.updateRange(n)},_scrolledToBottom:function(){var t=this.getOffset(),e=this.getClientSize();return this.getScrollSize()<=t+e+1},_handleToTop:a(function(){this.$emit("top"),this.lastLength=this.list.length}),_handleToBottom:a(function(){this.$emit("bottom")}),_onItemResized:function(t,e){this.virtual.handleItemSizeChange(t,e)},_onSlotResized:function(t,e){this.virtual.handleSlotSizeChange(t,e)},_updateUniqueKeys:function(){var e=this;this.uniqueKeys=this.list.map(function(t){return f(t,e.dataKey)}),this.virtual.updateOptions("uniqueKeys",this.uniqueKeys)},_getItemStyle:function(t){return t==(null==(t=l.dragged)?void 0:t.dataset.key)?{display:"none"}:{}},_renderSlots:function(t,e,i){var n=this.itemSizeKey,o=this.$slots[e],s=d({},this.headerStyle),r=d({},this.footerStyle);return o?t(z,{props:{tag:i,dataKey:e,sizeKey:n,event:"_onSlotResized"},style:"header"===e?s:"footer"===e?r:void 0},o):null},_renderItems:function(t){for(var e=[],i=this.range,n=i.start,o=i.end,s=this.itemTag,r=this.itemClass,l=this.itemSizeKey,a=n;a<=o;a++){var c,h,u=this.list[a];u&&(c=f(u,this.dataKey),h=d(d({},this.itemStyle),this._getItemStyle(c)),e.push(this.$scopedSlots.item?t(E,{key:c,props:{dataKey:c,tag:s,sizeKey:l,event:"_onItemResized"},style:h,class:r},this.$scopedSlots.item({record:u,index:a,dataKey:c})):null))}return e}},render:function(t){var e=this.virtual.useWindowScroll,i=this.range,n=i.front,i=i.behind,o=this.isHorizontal,s=this.headerTag,r=this.footerTag,l=this.rootTag,a=this.wrapTag,c=this.wrapClass,n=d(d({},this.wrapStyle),{},{padding:o?"0px ".concat(i,"px 0px ").concat(n,"px"):"".concat(n,"px 0px ").concat(i,"px")});return t(l,{ref:"rootRef",style:!e&&{overflow:o?"auto hidden":"hidden auto"}},[this._renderSlots(t,"header",s),t(a,{ref:"groupRef",class:c,style:n},this._renderItems(t)),this._renderSlots(t,"footer",r)])}})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):(t=t||self).VirtualDragList=e(t.Vue)}(this,function(t){"use strict";function n(e,t){var i,n=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)),n}function d(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(Object(i),!0).forEach(function(t){o(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function o(t,e,i){(e=function(t){t=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);i=i.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:String(t)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}function r(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){var i;if(t)return"string"==typeof t?s(t,e):"Map"===(i="Object"===(i=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:i)||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?s(t,e):void 0}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;(function(t){function R(t){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(){return(r=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i,n=arguments[e];for(i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function e(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}function P(t,e){t.style["".concat(J.css,"transition-duration")]=null==e?"":"".concat(e,"ms")}function a(t,e){t.style["".concat(J.css,"transform")]=e?"".concat(e):""}function l(t,e,i){window.addEventListener?t.addEventListener(e,i,!(!Z&&g)&&$):window.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}function n(t,e,i){window.removeEventListener?t.removeEventListener(e,i,!(!Z&&g)&&$):window.detachEvent?t.detachEvent("on"+e,i):t["on"+e]=null}function j(){return document.scrollingElement||document.documentElement}function m(t,e,i){if(t.getBoundingClientRect||t===window){var n,o,s,r,l,a,c=t!==window&&t.parentNode&&t!==j()?(o=(n=t.getBoundingClientRect()).top,s=n.left,r=n.bottom,l=n.right,a=n.height,n.width):(s=o=0,r=window.innerHeight,l=window.innerWidth,a=window.innerHeight,window.innerWidth);if(e&&t!==window){i=i||t.parentNode;do{if(i&&i.getBoundingClientRect){var h=i.getBoundingClientRect();o-=h.top+parseInt(d(i,"border-top-width")),s-=h.left+parseInt(d(i,"border-left-width")),r=o+n.height,l=s+n.width;break}}while(i=i.parentNode)}return{top:o,left:s,bottom:r,right:l,width:c,height:a}}}function c(t,e,i,n){if(t){i=i||document;do{if(null==e){var o=Array.prototype.slice.call(i.children),s=o.indexOf(t);if(-1<s)return o[s];for(var r=0;r<o.length;r++)if(K(t,o[r]))return o[r]}else if((">"!==e[0]||t.parentNode===i)&&u(t,e)||n&&t===i)return t}while(t=t.parentNode)}return null}function K(t,e){if(t&&e){if(e.compareDocumentPosition)return e===t||16&e.compareDocumentPosition(t);if(e.contains&&1===t.nodeType)return e.contains(t)&&e!==t;for(;t=t.parentNode;)if(t===e)return 1}}function o(t,e){var i=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||e&&!u(t,e)||"none"===d(t,"display")||i++;return i}function F(t,e,i,n){for(var o=0,s=0,r=t.children;o<r.length;){if(r[o]!==p.ghost&&"none"!==d(r[o],"display")&&c(r[o],i,t,!1)&&(n||r[o]!==p.dragged)){if(s===e)return r[o];s++}o++}return null}function H(t,e){var i,n=d(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=F(t,0,e),t=F(t,1,e),e=s&&d(s),r=t&&d(t),l=e&&parseInt(e.marginLeft)+parseInt(e.marginRight)+m(s).width,a=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+m(t).width,c=V||g?"cssFloat":"float";return"flex"===n.display?"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal":"grid"===n.display?n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal":s&&e.float&&"none"!==e.float?(i="left"===e.float?"left":"right",!t||"both"!==r.clear&&r.clear!==i?"horizontal":"vertical"):s&&("block"===e.display||"flex"===e.display||"table"===e.display||"grid"===e.display||o<=l&&"none"===n[c]||t&&"none"===n[c]&&o<l+a)?"vertical":"horizontal"}function h(t,e,i){var n;t&&e&&(t.classList?t.classList[i?"add":"remove"](e):(n=(" "+t.className+" ").replace(U," ").replace(" "+e+" "," "),t.className=(n+(i?" "+e:"")).replace(U," ")))}function u(t,e){if(e&&(">"===e[0]&&(e=e.substring(1)),t))try{return t.matches?t.matches(e):t.msMatchesSelector?t.msMatchesSelector(e):t.webkitMatchesSelector&&t.webkitMatchesSelector(e)}catch(t){}}function d(t,e,i){var n=t&&t.style;if(n){if(void 0===i)return document.defaultView&&document.defaultView.getComputedStyle?i=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(i=t.currentStyle),void 0===e?i:i[e];n[e=e in n||-1!==e.indexOf("webkit")?e:"-webkit-"+e]=i+("string"==typeof i?"":"px")}}function s(t,e){return 2===(t=t.compareDocumentPosition?t.compareDocumentPosition(e):t.contains?(t!=e&&t.contains(e)&&16)+(t!=e&&e.contains(t)&&8)+(0<=t.sourceIndex&&0<=e.sourceIndex?(t.sourceIndex<e.sourceIndex&&4)+(t.sourceIndex>e.sourceIndex&&2):1)+0:0)?1:4===t?-1:0}function W(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault()}function f(t){var e=t.sortable,i=t.name,t=t.params;"function"==typeof(e=e.options[i])&&e(r({},t))}function Y(t){this.options=t,this.autoScrollAnimationFrame=null}function X(t){this.options=t,this.animations=[]}function q(t){this.options=t||{},this.selectedElements=[]}function p(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(t));(t[S]=this).el=t,this.options=e=r({},e);var i,n,o={store:null,disabled:!1,group:"",animation:150,draggable:null,handle:null,multiple:!1,selectHandle:null,customGhost:null,direction:function(){return H(t,e.draggable)},autoScroll:!0,scrollThreshold:55,scrollSpeed:{x:10,y:10},delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,ghostClass:"",ghostStyle:{},chosenClass:"",selectedClass:"",swapOnDrop:!0,fallbackOnBody:!1,supportTouch:"ontouchstart"in window,emptyInsertThreshold:-5};for(i in o)i in this.options||(this.options[i]=o[i]);for(n in nt(e),this)"_"===n.charAt(0)&&"function"==typeof this[n]&&(this[n]=this[n].bind(this));var s=this.options.supportTouch;l(t,s?"touchstart":"mousedown",this._onDrag),A.push(t),this.autoScroller=new Y(this.options),this.multiplayer=new q(this.options),this.animator=new X(this.options)}var $,U,i,g,V,G,Z,J,y,v,S,b,_,w,Q,x,T,O,E,z,tt,I,D,et,C,k,B,M,L,it,N,A,nt;t.exports=($={capture:!1,passive:!1},U=/\s+/g,g=e(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),V=e(/Edge/i),G=e(/safari/i)&&!e(/chrome/i)&&!e(/android/i),i=!1,document.addEventListener("checkIfSupportPassive",null,{get passive(){return i=!0}}),Z=i,J="undefined"==typeof window||"undefined"==typeof document?{}:(t=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1],{dom:"WebKit|Moz|MS|O".match(new RegExp("("+t+")","i"))[1],lowercase:t,css:"-"+t+"-",js:t[0].toUpperCase()+t.substr(1)}),S="Sortable"+Date.now(),window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),Y.prototype={destroy:function(){null!=this.autoScrollAnimationFrame&&(cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=null)},update:function(t,e,i){var n=this;cancelAnimationFrame(this.autoScrollAnimationFrame),this.autoScrollAnimationFrame=requestAnimationFrame(function(){e&&i&&n.autoScroll(t,i),n.update(t,e,i)})},autoScroll:function(t,e){var i,n,o,s,r,l,a,c,h,u,d,f,p;t&&void 0!==e.clientX&&void 0!==e.clientY&&(u=m(t))&&(i=e.clientX,e=e.clientY,n=u.top,o=u.right,s=u.bottom,r=u.left,f=u.height,u=u.width,e<n||o<i||s<e||i<r||(l=(a=this.options).scrollThreshold,a=a.scrollSpeed,d=t.scrollTop,c=t.scrollLeft,p=t.scrollHeight,h=0<d&&n<=e&&e<=n+l,u=c+u<t.scrollWidth&&i<=o&&o-l<=i,d=d+f<p&&e<=s&&s-l<=e,(p=f=0)<c&&r<=i&&i<=r+l&&(f=Math.floor(Math.max(-1,(i-r)/l-1)*a.x)),u&&(f=Math.ceil(Math.min(1,(i-o)/l+1)*a.x)),h&&(p=Math.floor(Math.max(-1,(e-n)/l-1)*a.y)),(p=d?Math.ceil(Math.min(1,(e-s)/l+1)*a.y):p)&&(t.scrollTop+=p),f&&(t.scrollLeft+=f)))}},X.prototype={collect:function(t){if(t){for(var e=m(t),i=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,n=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,o=Math.min(e.right,i),s=Math.min(e.bottom,n),r=Array.prototype.slice.call(t.children),l=[],a=0;a<=r.length;a++){var c=r[a];if(c&&c!==p.ghost&&"none"!==d(c,"display")){var h=m(c);if(!(h.bottom<0||h.right<0)){if(h.top-h.height>s||h.left-h.width>o)break;l.push({node:c,rect:h})}}}this.animations.push(l)}},animate:function(){for(var t=this.animations.pop(),e=0,i=t.length;e<i;e++){var n=(o=t[e]).node,o=o.rect;this._excute(n,o)}},_excute:function(t,e){var i=e.left,e=e.top,n=m(t);n.top===e&&n.left===i||(e-=n.top,i-=n.left,P(t),a(t,"translate3d(".concat(i,"px, ").concat(e,"px, 0)")),t.offsetWidth,P(t,this.options.animation),a(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){P(t),a(t,""),t.animated=null},this.options.animation))}},q.prototype={destroy:function(){y=v=null},active:function(){return!!y},setParams:function(t){t.nodes=y||[],t.clones=v||[]},select:function(t){h(t,this.options.selectedClass,!0),this.selectedElements.push(t),this.selectedElements.sort(s)},deselect:function(t){var e=this.selectedElements.indexOf(t);-1<e&&(h(t,this.options.selectedClass,!1),this.selectedElements.splice(e,1))},getGhostElement:function(){var i;return y?(i=document.createElement("div"),this.selectedElements.forEach(function(t,e){(t=t.cloneNode(!0)).style="position: absolute;left: 0;top: 0;bottom: 0;right: 0;opacity: ".concat(0===e?1:.5,";z-index: ").concat(e,";"),i.appendChild(t)}),i):null},toggleSelected:function(e,t){var i=this;t?e.forEach(function(t){return i.selectedElements.push(t)}):this.selectedElements=this.selectedElements.filter(function(t){return e.indexOf(t)<0})},toggleClass:function(t){if(y)for(var e=0;e<y.length;e++)h(y[e],this.options.chosenClass,t)},toggleVisible:function(t){y&&(t?(t=y.indexOf(p.dragged),this._viewElements(y,t,p.dragged)):this._hideElements(y))},onChoose:function(){!this.options.multiple||!this.selectedElements.length||this.selectedElements.indexOf(p.dragged)<0||(this.selectedElements.sort(s),y=this.selectedElements,this.toggleClass(!0))},onDrag:function(t){y&&(t.animator.collect(p.dragged.parentNode),this._hideElements(y),t.animator.animate(),this.toggleClass(!1))},onDrop:function(t,e,i){var n,o,s;y&&(o=p.clone,s=y.indexOf(n=p.dragged),e[S].animator.collect(o.parentNode),t!==e&&"clone"===i?(d(o,"display","none"),v=y.map(function(t){return t.cloneNode(!0)}),this._viewElements(v,s,o),this._viewElements(y,s,n)):this._viewElements(y,s,o),e[S].animator.animate(),t!==e)&&(e[S].multiplayer.toggleSelected(v||y,!0),"clone"!==i)&&t[S].multiplayer.toggleSelected(y,!1)},onSelect:function(t,e,i){var n=this.selectedElements.indexOf(e),t=(h(e,this.options.selectedClass,n<0),{from:i.el,event:t,node:e,index:o(e)});n<0?(this.selectedElements.push(e),f({sortable:i,name:"onSelect",params:t})):(this.selectedElements.splice(n,1),f({sortable:i,name:"onDeselect",params:t})),this.selectedElements.sort(s)},_viewElements:function(t,e,i){for(var n,o=0;o<t.length;o++)d(t[o],"display",""),o<e?i.parentNode.insertBefore(t[o],i):(n=0<o?t[o-1]:i,i.parentNode.insertBefore(t[o],n.nextSibling))},_hideElements:function(t){for(var e=0;e<t.length;e++)t[e]!=p.dragged&&d(t[e],"display","none")}},A=[],nt=function(t){var e={},i=t.group;i&&"object"==R(i)||(i={name:i,pull:!0,put:!0,revertDrag:!0}),e.name=i.name,e.pull=i.pull,e.put=i.put,e.revertDrag=i.revertDrag,t.group=e},p.prototype={constructor:p,_onDrag:function(t){var e,i,n,o,s=this;_||this.options.disabled||!this.options.group.pull||/mousedown|pointerdown/.test(t.type)&&0!==t.button||(n=((e=t.touches&&t.touches[0])||t).target,G&&n&&"SELECT"===n.tagName.toUpperCase())||!(i=c(n,this.options.draggable,this.el))||i.animated||(E={original:t,clientX:(e||t).clientX,clientY:(e||t).clientY},_=i,l(I=e?_:document,"mouseup",this._onDrop),l(I,"touchend",this._onDrop),l(I,"touchcancel",this._onDrop),o=(i=this.options).handle,"function"==typeof(i=i.selectHandle)&&i(t))||"string"==typeof i&&u(n,i)||"function"==typeof o&&!o(t)||"string"==typeof o&&!u(n,o)||(n=(i=this.options).delay,o=i.delayOnTouchOnly,!n||o&&!e||V||g?this._onStart(e,t):(l(this.el.ownerDocument,"touchmove",this._delayMoveHandler),l(this.el.ownerDocument,"mousemove",this._delayMoveHandler),l(this.el.ownerDocument,"mouseup",this._cancelStart),l(this.el.ownerDocument,"touchend",this._cancelStart),l(this.el.ownerDocument,"touchcancel",this._cancelStart),et=setTimeout(function(){return s._onStart(e,t)},n)))},_delayMoveHandler:function(t){t=t.touches?t.touches[0]:t,Math.max(Math.abs(t.clientX-E.clientX),Math.abs(t.clientY-E.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout(et),n(this.el.ownerDocument,"touchmove",this._delayMoveHandler),n(this.el.ownerDocument,"mousemove",this._delayMoveHandler),n(this.el.ownerDocument,"mouseup",this._cancelStart),n(this.el.ownerDocument,"touchend",this._cancelStart),n(this.el.ownerDocument,"touchcancel",this._cancelStart)},_onStart:function(t,e){var i=o(_);C=this.el,k=this.el,it=L=M=i,N=_,b=this.el,x=_.cloneNode(!0),O=_.parentNode,B=this.options.group.pull,p.clone=x,p.active=this,h(p.dragged=_,this.options.chosenClass,!0),this.multiplayer.onChoose(),f({sortable:this,name:"onChoose",params:this._getParams(e)}),l(I,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout(function(){return document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}},_onStarted:function(){h(x,this.options.chosenClass,!0),this._appendGhost(),this.multiplayer.onDrag(this),f({sortable:this,name:"onDrag",params:this._getParams(E.original)}),d(_,"display","none"),h(_,this.options.chosenClass,!1),_.parentNode.insertBefore(x,_),G&&d(document.body,"user-select","none")},_getGhostElement:function(){var t=this.options.customGhost;return"function"==typeof t?t((t=this.multiplayer.selectedElements).length?t:[_]):this.multiplayer.getGhostElement()||_},_appendGhost:function(){if(!T){var t,e=(n=this.options).fallbackOnBody,i=n.ghostClass,n=n.ghostStyle,e=e?document.body:this.el,o=this._getGhostElement();h(T=o.cloneNode(!0),i,!0);var s=r({position:"fixed",top:(o=m(_)).top,left:o.left,width:o.width,height:o.height,minWidth:o.width,minHeight:o.height,opacity:"0.8",overflow:"hidden","z-index":"100000","box-sizing":"border-box","pointer-events":"none"},n);for(t in s)d(T,t,s[t]);T.style["".concat(J.css,"transition")]="none",a(T,"translate3d(0px, 0px, 0px)"),p.ghost=T,e.appendChild(T),n=(E.clientX-o.left)/parseInt(T.style.width)*100,i=(E.clientY-o.top)/parseInt(T.style.height)*100,d(T,"transform-origin","".concat(n,"% ").concat(i,"%")),d(T,"transform","translateZ(0)"),d(T,"will-change","transform")}},_nearestSortable:function(t){W(t);var e,i,o,s,r,n=t.touches&&t.touches[0],l=n||t;!E||!_||(i=z||E,void 0!==(e=l).clientX&&void 0!==e.clientY&&Math.abs(e.clientX-i.clientX)<=0&&Math.abs(e.clientY-i.clientY)<=0)||(z||this._onStarted(),z={original:t,clientX:l.clientX,clientY:l.clientY},e=n?document.elementFromPoint(l.clientX,l.clientY):l.target,i=l.clientX-E.clientX,n=l.clientY-E.clientY,a(T,"translate3d(".concat(i,"px, ").concat(n,"px, 0)")),this.options.autoScroll&&(i=function(t){if(t&&t.getBoundingClientRect){var e=t;do{if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var i=d(e);if(e.clientWidth<e.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||e.clientHeight<e.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY))return e.getBoundingClientRect&&e!==document.body?e:j()}}while(e=e.parentNode)}return j()}(e),this.autoScroller.update(i,E,z)),o=l.clientX,s=l.clientY,A.some(function(t){var e,i,n=t[S].options.emptyInsertThreshold;if(null!=n)return i=m(t),e=o>=i.left-n&&o<=i.right+n,i=s>=i.top-n&&s<=i.bottom+n,e&&i?r=t:void 0}),r&&r[S]._onMove(t,e))},_allowPut:function(){var t,e,i;return b===this.el||!!this.options.group.put&&(t=(e=this.options.group).name,e=e.put,i=b[S].options.group,e.join&&-1<e.indexOf(i.name)||i.name&&t&&i.name===t)},_allowSwap:function(){var t=s(x,w),e=(Q=t<0?w.nextSibling:w,m(w)),i="vertical"===(o="function"==typeof this.options.direction?this.options.direction.call(z.original,_,this):this.options.direction),n=i?z.clientY:z.clientX,o=w["vertical"===o?"offsetHeight":"offsetWidth"],n=n>=(i?e.top:e.left)&&n<(i?e.bottom:e.right)-o/2?-1:1;return tt!==w?(D=n,!0):D!==n&&((D=n)<0?0<t:t<0)},_onMove:function(t,e){var i,n;this._allowPut()&&(f({sortable:this,name:"onMove",params:this._getParams(t)}),this.el===k||e!==this.el&&function(t){for(var e=t.lastElementChild;e&&(e===p.ghost||"none"===d(e,"display"));)e=e.previousElementSibling;return e}(this.el)?(w=c(e,this.options.draggable,this.el))&&!w.animated&&this._allowSwap()&&(w===x||K(w,x)||(this.el!==k?this._onInsert(t):(i=t,n=n||m(O),i.clientX<=n.right&&i.clientX>=n.left&&i.clientY>=n.top&&i.clientY<=n.bottom&&e===O||this._onChange(t))),tt=w):(w=tt=null,this._onInsert(t)))},_onInsert:function(t){var e=w||x,i="clone"===B&&this.el!==b&&k===b,n="clone"===B&&this.el===b&&k!==b;C=this.el,M=o(x),N=e,O=w?w.parentNode:this.el,k[S].animator.collect(x.parentNode),this.animator.collect(O),i&&(d(_,"display",""),b[S].multiplayer.toggleVisible(!0),b[S].options.group.revertDrag||k.insertBefore(_,x)),n&&(M=o(_),d(_,"display","none"),this.multiplayer.toggleVisible(!1)),w?O.insertBefore(x,D<0?w:w.nextSibling):O.appendChild(x),L=o(x),i&&b[S].options.group.revertDrag&&f({sortable:b[S],name:"onChange",params:this._getParams(t,{to:b,target:_,newIndex:it,revertDrag:!0})}),i||f({sortable:k[S],name:"onRemove",params:this._getParams(t)}),n&&w!==_&&f({sortable:this,name:"onChange",params:this._getParams(t,{from:b,backToOrigin:!0})}),n||f({sortable:this,name:"onAdd",params:this._getParams(t)}),k[S].animator.animate(),this.animator.animate(),k=this.el},_onChange:function(t){w!==_&&(O=w.parentNode,M=o(x),N=w,this.animator.collect(O),O.insertBefore(x,Q),L=o(x),f({sortable:this,name:"onChange",params:this._getParams(t)}),this.animator.animate(),k=this.el)},_onDrop:function(t){var e,i;W(t),this._cancelStart(),n(I,"touchmove",this._nearestSortable),n(I,"mousemove",this._nearestSortable),n(I,"mouseup",this._onDrop),n(I,"touchend",this._onDrop),n(I,"touchcancel",this._onDrop),h(_,this.options.chosenClass,!1),b&&(k=b,M=it,N===x&&(N=_),this.multiplayer.toggleClass(!1),f({sortable:this,name:"onUnchoose",params:this._getParams(t)}),z)&&this._onEnd(t),b||z||!this.options.multiple||(i=(e=t.changedTouches?t.changedTouches[0]:t).clientX-E.clientX,e=e.clientY-E.clientY,0<=(i=Math.sqrt(i*i+e*e))&&i<=1&&this.multiplayer.onSelect(t,_,this)),T&&T.parentNode&&T.parentNode.removeChild(T),this.multiplayer.destroy(),this.autoScroller.destroy(),this._nulling()},_onEnd:function(t){var t=this._getParams(t),e=(this.multiplayer.onDrop(k,C,B),this.options.swapOnDrop);("clone"!==B||k===C)&&("function"==typeof e?e(t):e)&&O.insertBefore(_,x),"clone"!==B||k===C||this.multiplayer.active()?x&&x.parentNode&&x.parentNode.removeChild(x):h(x,this.options.chosenClass,!1),d(_,"display",""),G&&d(document.body,"user-select",""),k!==C&&f({sortable:k[S],name:"onDrop",params:t}),f({sortable:C[S],name:"onDrop",params:t})},_getParams:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i={};return i.event=t,i.to=C,i.from=k,i.node=_,i.clone=x,i.target=N,i.oldIndex=M,i.newIndex=L,i.pullMode=B,this.multiplayer.setParams(i),r(i,e),i.relative=i.target===_?0:s(i.target,x),i},_nulling:function(){C=k=b=_=w=Q=x=T=O=B=M=L=it=E=z=N=tt=I=D=et=p.clone=p.ghost=p.active=p.dragged=null},destroy:function(){this._nulling(),this._cancelStart(),n(this.el,"touchstart",this._onDrag),n(this.el,"mousedown",this._onDrag),A.splice(A.indexOf(this.el),1),this.el[S]=this.animator=this.multiplayer=this.autoScroller=null},option:function(t,e){if(void 0===e)return this.options[t];this.options[t]=e,this.animator.options[t]=e,this.multiplayer.options[t]=e,this.autoScroller.options[t]=e,"group"===t&&nt(this.options)},select:function(t){this.multiplayer.select(t)},deselect:function(t){this.multiplayer.deselect(t)},getSelectedElements:function(){return this.multiplayer.selectedElements}},p.utils={on:l,off:n,css:d,index:o,closest:c,getRect:m,toggleClass:h,detectDirection:H},p.get=function(t){return t[S]},p.create=function(t,e){return new p(t,e)},p)})(e={exports:{}});var l=e.exports;function a(s,t,e){function i(){for(var t,e=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return c&&clearTimeout(c),a?(t=!c,c=setTimeout(function(){c=null},l),t&&(r=s.apply(this,n))):c=setTimeout(function(){s.apply(e,n)},l),r}var r,l=1<arguments.length&&void 0!==t?t:50,a=2<arguments.length&&void 0!==e&&e,c=null;return i.cancel=function(){clearTimeout(c),c=null},i}function f(t,e){return(Array.isArray(e)?e:e.replace(/\[/g,".").replace(/\]/g,".").split(".")).reduce(function(t,e){return(t||{})[e]},t)}var c="INIT",i="FIXED",h="DYNAMIC",u="FRONT",p="BEHIND",m="STATIONARY",e="horizontal",g="vertical",y=(o(O={},g,"scrollTop"),o(O,e,"scrollLeft"),O),v=(o(O={},g,"scrollHeight"),o(O,e,"scrollWidth"),O),S=(o(O={},g,"offsetHeight"),o(O,e,"offsetWidth"),O),b=(o(O={},g,"offsetTop"),o(O,e,"offsetLeft"),O),_=["size","keeps","scroller","direction","debounceTime","throttleTime"];function w(t){this.options=t;var e,i={size:0,keeps:0,buffer:0,wrapper:null,scroller:null,direction:"vertical",uniqueKeys:[],debounceTime:null,throttleTime:null};for(e in i)e in this.options||(this.options[e]=i[e]);this.sizes=new Map,this.range={start:0,end:0,front:0,behind:0},this.offset=0,this.calcType=c,this.calcSize={average:0,total:0,fixed:0,header:0},this.direction="",this.useWindowScroll=null,this._updateScrollElement(),this._updateOnScrollFunction(),this.addScrollEventListener(),this._checkIfUpdate(0,t.keeps-1)}w.prototype={constructor:w,isFront:function(){return this.direction===u},isBehind:function(){return this.direction===p},isFixed:function(){return this.calcType===i},getSize:function(t){return this.sizes.get(t)||this._getItemSize()},getOffset:function(){return this.scrollEl[y[this.options.direction]]},getScrollSize:function(){return this.scrollEl[v[this.options.direction]]},getClientSize:function(){return this.scrollEl[S[this.options.direction]]},scrollToOffset:function(t){this.scrollEl[y[this.options.direction]]=t},scrollToIndex:function(t){t>=this.options.uniqueKeys.length-1?this.scrollToBottom():(t=this._getOffsetByIndex(t),this.scrollToOffset(t))},scrollToBottom:function(){var i=this,t=this.getScrollSize();this.scrollToOffset(t),setTimeout(function(){var t=i.getClientSize(),e=i.getScrollSize();i.getOffset()+t+1<e&&i.scrollToBottom()},5)},updateOptions:function(t,i){var n=this,e=this.options[t];this.options[t]=i,"uniqueKeys"===t?this.sizes.forEach(function(t,e){i.includes(e)||n.sizes.delete(e)}):"scroller"===t&&(null!=e&&e.removeEventListener("scroll",this._onScroll),this._updateScrollElement(),this.addScrollEventListener())},updateRange:function(t){t?this._handleUpdate(t.start,t.end):(t=this.range.start,t=Math.max(t,0),this._handleUpdate(t,this._getEndByStart(t)))},handleItemSizeChange:function(t,e){this.sizes.set(t,e),this.calcType===c?(this.calcType=i,this.calcSize.fixed=e):this.isFixed()&&this.calcSize.fixed!==e&&(this.calcType=h,this.calcSize.fixed=void 0),this.calcType!==i&&(this.calcSize.total=r(this.sizes.values()).reduce(function(t,e){return t+e},0),this.calcSize.average=Math.round(this.calcSize.total/this.sizes.size))},handleSlotSizeChange:function(t,e){this.calcSize[t]=e},addScrollEventListener:function(){var t;null!=(t=this.options.scroller)&&t.addEventListener("scroll",this._onScroll,!1)},removeScrollEventListener:function(){var t;null!=(t=this.options.scroller)&&t.removeEventListener("scroll",this._onScroll)},_updateOnScrollFunction:function(){var i,n,o,t=this,e=this.options,s=e.debounceTime,e=e.throttleTime;this._onScroll=s?a(function(){return t._handleScroll()},s):e?(i=function(){return t._handleScroll()},n=e,o=null,function(){var t=this,e=arguments;o=o||setTimeout(function(){o=null,i.apply(t,e)},n)}):function(){return t._handleScroll()},this._onScroll=this._onScroll.bind(this)},_updateScrollElement:function(){this.scrollEl=this._getScrollElement(this.options.scroller)},_handleScroll:function(){var t=this.getOffset(),e=this.getClientSize(),i=this.getScrollSize(),n=(t===this.offset?this.direction=m:this.direction=t<this.offset?u:p,this.offset=t,this.isFront()&&t<=0),i=this.isBehind()&&i<=e+t;this.options.onScroll({top:n,bottom:i,offset:t,direction:this.direction}),this.isFront()?this._handleScrollFront():this.isBehind()&&this._handleScrollBehind()},_handleScrollFront:function(){var t=this._getScrollItems();t>this.range.start||(t=Math.max(t-this.options.buffer,0),this._checkIfUpdate(t,this._getEndByStart(t)))},_handleScrollBehind:function(){var t=this._getScrollItems();t<this.range.start+this.options.buffer||this._checkIfUpdate(t,this._getEndByStart(t))},_getScrollItems:function(){var t=this.offset-this._getScrollStartOffset();if(t<=0)return 0;if(this.isFixed())return Math.floor(t/this.calcSize.fixed);for(var e,i,n=0,o=this.options.uniqueKeys.length;n<=o;){if(e=n+Math.floor((o-n)/2),(i=this._getOffsetByIndex(e))===t)return e;i<t?n=e+1:t<i&&(o=e-1)}return 0<n?--n:0},_checkIfUpdate:function(t,e){var i=this.options.keeps;this.options.uniqueKeys.length<=i?(t=0,e=this._getLastIndex()):e-t<i-1&&(t=e-i+1),this.range.start!==t&&this._handleUpdate(t,e)},_handleUpdate:function(t,e){this.range.start=t,this.range.end=e,this.range.front=this._getFrontOffset(),this.range.behind=this._getBehindOffset(),this.options.onUpdate(d({},this.range))},_getFrontOffset:function(){return this.isFixed()?this.calcSize.fixed*this.range.start:this._getOffsetByIndex(this.range.start)},_getBehindOffset:function(){var t=this.range.end,e=this._getLastIndex();return this.isFixed()?(e-t)*this.calcSize.fixed:(e-t)*this._getItemSize()},_getOffsetByIndex:function(t){if(!t)return 0;for(var e=0,i=0;i<t;i++){var n=this.sizes.get(this.options.uniqueKeys[i]);e+="number"==typeof n?n:this._getItemSize()}return e},_getEndByStart:function(t){return Math.min(t+this.options.keeps-1,this._getLastIndex())},_getLastIndex:function(){var t=this.options,e=t.uniqueKeys,t=t.keeps;return 0<e.length?e.length-1:t-1},_getItemSize:function(){return this.isFixed()?this.calcSize.fixed:this.calcSize.average||this.options.size},_getScrollElement:function(t){return t instanceof Document&&9===t.nodeType||t instanceof Window?(this.useWindowScroll=!0,document.scrollingElement||document.documentElement||document.body):(this.useWindowScroll=!1,t)},_getScrollStartOffset:function(){var t=this.calcSize.header;if(this.useWindowScroll&&this.options.wrapper)for(var e=this.options.wrapper;t+=e[b[this.options.direction]],(e=e.offsetParent)&&e!==this.options.wrapper.ownerDocument;);return t}};var x=["delay","group","handle","disabled","draggable","animation","autoScroll","ghostClass","ghostStyle","chosenClass","fallbackOnBody","scrollThreshold","delayOnTouchOnly"];function T(t,e,i){var n=this,e=(this.ctx=t,this.onDrag=e,this.onDrop=i,this.list=r(t.list),this.store={},this.reRendered=!1,x.reduce(function(t,e){return t[e]=n.ctx[e],t},{}));this.sortable=new l(this.ctx.$refs.groupRef,d(d({},e),{},{swapOnDrop:function(t){return t.from===t.to},onDrag:function(t){return n._onDrag(t)},onAdd:function(t){return n._onAdd(t)},onRemove:function(t){return n._onRemove(t)},onChange:function(t){return n._onChange(t)},onDrop:function(t){return n._onDrop(t)}}))}T.prototype={constructor:T,destroy:function(){this.sortable&&this.sortable.destroy(),this.sortable=this.store=null},setValue:function(t,e){"list"===t?this.list=r(e):this.sortable.option(t,e)},_onDrag:function(t){var t=t.node.dataset.key,e=this._getIndex(this.list,t),i=this.list[e];this.store={item:i,key:t,origin:{index:e,list:this.list},from:{index:e,list:this.list},to:{index:e,list:this.list}},this.sortable.option("store",this.store),this.onDrag({list:this.list}),this.ctx.$emit("drag",{item:i,key:t,index:origin.index})},_onRemove:function(t){var t=t.node.dataset.key,e=this._getIndex(this.list,t),i=this.list[e];this.list.splice(e,1),Object.assign(this.store,{key:t,item:i}),this.sortable.option("store",this.store),this.ctx.$emit("remove",{item:i,index:e,key:t})},_onAdd:function(t){var e=t.from,i=t.target,t=t.relative,e=l.get(e).option("store"),n=e.key,e=e.item,i=this._getIndex(this.list,i.dataset.key);-1===t&&(i+=1),this.list.splice(i,0,e),Object.assign(this.store,{to:{index:i,list:this.list}}),this.sortable.option("store",this.store),this.ctx.$emit("add",{item:e,index:i,key:n})},_onChange:function(t){var e,i,n,o,s=l.get(t.from).option("store");t.revertDrag?(this.list=r(this.ctx.list),Object.assign(this.store,{from:s.origin})):(i=t.node,o=t.target,e=t.relative,t=t.backToOrigin,i=this._getIndex(this.list,i.dataset.key),n=this.list[i],o=this._getIndex(this.list,o.dataset.key),t&&(1===e&&s.from.index<o&&--o,-1===e)&&s.from.index>o&&(o+=1),this.list.splice(i,1),this.list.splice(o,0,n),Object.assign(this.store,{from:{index:o,list:this.list},to:{index:o,list:this.list}}))},_onDrop:function(t){var e=this._getStore(t),i=e.from,e=e.to,n=t.from!==t.to||i.origin.index!==e.to.index;this.onDrop({list:this.list}),this.ctx.$emit("drop",{changed:n,list:this.list,item:i.item,key:i.key,from:i.origin,to:e.to}),t.from===t.to&&this.reRendered&&null!=(n=l.dragged)&&n.remove(),t.from!==t.to&&"clone"===t.pullMode&&null!=(i=l.clone)&&i.remove(),this.sortable.option("swapOnDrop",!1),this.reRendered=!1},_getIndex:function(t,e){for(var i=0;i<t.length;i++)if(f(t[i],this.ctx.dataKey)==e)return i;return-1},_getStore:function(t){return{from:l.get(t.from).option("store"),to:l.get(t.to).option("store")}}};var g={dataSource:{type:Array,default:function(){return[]}},dataKey:{type:String,required:!0},scroller:{type:[Window,Document,HTMLElement]},direction:{type:String,default:"vertical"},keeps:{type:Number,default:30},size:{type:Number},draggable:{type:[Function,String]},handle:{type:[Function,String]},group:{type:[String,Object]},debounceTime:{type:Number,default:0},animation:{type:Number,default:150},autoScroll:{type:Boolean,default:!0},scrollThreshold:{type:Number,default:55},keepOffset:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},fallbackOnBody:{type:Boolean,default:!1},delay:{type:Number,default:0},delayOnTouchOnly:{type:Boolean,default:!1},rootTag:{type:String,default:"div"},wrapTag:{type:String,default:"div"},headerTag:{type:String,default:"div"},footerTag:{type:String,default:"div"},itemTag:{type:String,default:"div"},wrapClass:{type:String,default:""},wrapStyle:{type:Object},itemStyle:{type:Object},headerStyle:{type:Object},footerStyle:{type:Object},itemClass:{type:String,default:""},ghostClass:{type:String,default:""},ghostStyle:{type:Object,default:function(){return{}}},chosenClass:{type:String,default:""}},e={tag:{type:String,default:"div"},event:{type:String},dataKey:{type:[String,Number]},sizeKey:{type:String}},O={inject:["virtualList"],data:function(){return{observer:null}},mounted:function(){var t=this;"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver(function(){t.onSizeChange()}),this.$el)&&this.observer.observe(this.$el)},updated:function(){this.onSizeChange()},beforeDestroy:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},methods:{onSizeChange:function(){this.virtualList[this.event](this.dataKey,this.getCurrentSize())},getCurrentSize:function(){return this.$el?this.$el[this.sizeKey]:0}}},E=t.component("virtual-draglist-items",{mixins:[O],props:e,render:function(t){var e=this.tag,i=this.dataKey;return t(e,{key:i,attrs:{"data-key":i}},this.$slots.default)}}),z=t.component("virtual-draglist-slots",{mixins:[O],props:e,render:function(t){var e=this.tag,i=this.dataKey;return t(e,{key:i,attrs:{role:i}},this.$slots.default)}});return t.component("virtual-drag-list",{model:{prop:"dataSource",event:"updateDataSource"},props:g,data:function(){return{list:[],start:0,timer:null,range:{start:0,end:0,front:0,behind:0},virtual:null,sortable:null,lastLength:null,uniqueKeys:[]}},provide:function(){return{virtualList:this}},computed:{isHorizontal:function(){return"vertical"!==this.direction},itemSizeKey:function(){return this.isHorizontal?"offsetWidth":"offsetHeight"},virtualAttributes:function(){var i=this;return _.reduce(function(t,e){return t[e]=i[e],t},{})},sortableAttributes:function(){var i=this;return x.reduce(function(t,e){return t[e]=i[e],t},{})}},watch:{dataSource:{handler:function(){this._onUpdate()},deep:!0},virtualAttributes:{handler:function(t,e){if(this.virtual)for(var i in t)t[i]!=e[i]&&this.virtual.updateOptions(i,t[i])},deep:!0},sortableAttributes:{handler:function(t,e){if(this.sortable)for(var i in t)t[i]!=e[i]&&this.sortable.setValue(i,t[i])},deep:!0}},activated:function(){this.scrollToOffset(this.virtual.offset),this.virtual.addScrollEventListener()},deactivated:function(){this.virtual.removeScrollEventListener()},created:function(){this.range.end=this.keeps-1,this._initVirtual(),this._onUpdate()},mounted:function(){this.virtual.updateOptions("wrapper",this.$refs.groupRef),this.scroller||this.virtual.updateOptions("scroller",this.$refs.rootRef)},beforeDestroy:function(){this.sortable&&this.sortable.destroy(),this.virtual.removeScrollEventListener(),this.sortable=this.virtual=null},methods:{getSize:function(t){return this.virtual.getSize(t)},getOffset:function(){return this.virtual.getOffset()},getClientSize:function(){return this.virtual.getClientSize()},getScrollSize:function(){return this.virtual.getScrollSize()},scrollToKey:function(t){t=this.uniqueKeys.indexOf(t);-1<t&&this.virtual.scrollToIndex(t)},scrollToIndex:function(t){this.virtual.scrollToIndex(t)},scrollToOffset:function(t){this.virtual.scrollToOffset(t)},scrollToTop:function(){this.virtual.scrollToOffset(0)},scrollToBottom:function(){this.virtual.scrollToBottom()},_onUpdate:function(){var t=this,e=r(this.list);this.list=this.dataSource,this._updateUniqueKeys(),this.virtual.sizes.size?this._updateRange(e,this.list):(clearTimeout(this.timer),this.timer=setTimeout(function(){return t.virtual.updateRange()},17)),this.sortable?this.sortable.setValue("list",this.list):this.$nextTick(function(){return t._initSortable()}),this.lastLength&&this.keepOffset&&(0<(e=this.list.length-this.lastLength)&&this.scrollToIndex(e),this.lastLength=null)},_initVirtual:function(){var e=this;this.virtual=new w({size:this.size,keeps:this.keeps,buffer:Math.round(this.keeps/3),scroller:this.scroller,direction:this.direction,uniqueKeys:this.uniqueKeys,debounceTime:this.debounceTime,throttleTime:this.throttleTime,onScroll:function(t){e.lastLength=null,e.list.length&&t.top?e._handleToTop():t.bottom&&e._handleToBottom()},onUpdate:function(t){l.dragged&&t.start!==e.range.start&&(e.sortable.reRendered=!0),e.range=t}})},_initSortable:function(){var e=this;this.sortable=new T(this,function(){e.start=e.range.start},function(t){t=t.list;t.length===e.list.length&&e.start<e.range.start&&(e.range.front+=l.clone[e.isHorizontal?"offsetWidth":"offsetHeight"],e.start=e.range.start),e.$emit("updateDataSource",t)})},_updateRange:function(t,e){var i,n=d({},this.range);0<this.range.start&&-1<(i=e.indexOf(t[this.range.start]))&&(n.start=i,n.end=i+this.keeps-1),e.length>t.length&&this.range.end===t.length-1&&this._scrolledToBottom()&&(n.end++,n.start=Math.max(0,n.end-this.keeps+1)),this.virtual.updateRange(n)},_scrolledToBottom:function(){var t=this.getOffset(),e=this.getClientSize();return this.getScrollSize()<=t+e+1},_handleToTop:a(function(){this.$emit("top"),this.lastLength=this.list.length}),_handleToBottom:a(function(){this.$emit("bottom")}),_onItemResized:function(t,e){this.virtual.handleItemSizeChange(t,e)},_onSlotResized:function(t,e){this.virtual.handleSlotSizeChange(t,e)},_updateUniqueKeys:function(){var e=this;this.uniqueKeys=this.list.map(function(t){return f(t,e.dataKey)}),this.virtual.updateOptions("uniqueKeys",this.uniqueKeys)},_getItemStyle:function(t){return t==(null==(t=l.dragged)?void 0:t.dataset.key)?{display:"none"}:{}},_renderSlots:function(t,e,i){var n=this.itemSizeKey,o=this.$slots[e],s=d({},this.headerStyle),r=d({},this.footerStyle);return o?t(z,{props:{tag:i,dataKey:e,sizeKey:n,event:"_onSlotResized"},style:"header"===e?s:"footer"===e?r:void 0},o):null},_renderItems:function(t){for(var e=[],i=this.range,n=i.start,o=i.end,s=this.itemTag,r=this.itemClass,l=this.itemSizeKey,a=n;a<=o;a++){var c,h,u=this.list[a];u&&(c=f(u,this.dataKey),h=d(d({},this.itemStyle),this._getItemStyle(c)),e.push(this.$scopedSlots.item?t(E,{key:c,props:{dataKey:c,tag:s,sizeKey:l,event:"_onItemResized"},style:h,class:r},this.$scopedSlots.item({record:u,index:a,dataKey:c})):null))}return e}},render:function(t){var e=this.virtual.useWindowScroll,i=this.range,n=i.front,i=i.behind,o=this.isHorizontal,s=this.headerTag,r=this.footerTag,l=this.rootTag,a=this.wrapTag,c=this.wrapClass,n=d(d({},this.wrapStyle),{},{padding:o?"0px ".concat(i,"px 0px ").concat(n,"px"):"".concat(n,"px 0px ").concat(i,"px")});return t(l,{ref:"rootRef",style:!e&&{overflow:o?"auto hidden":"hidden auto"}},[this._renderSlots(t,"header",s),t(a,{ref:"groupRef",class:c,style:n},this._renderItems(t)),this._renderSlots(t,"footer",r)])}})}); |
{ | ||
"name": "vue-virtual-draglist", | ||
"version": "2.8.1", | ||
"version": "2.8.2", | ||
"description": "A virtual scrolling list component that can be sorted by dragging", | ||
@@ -39,3 +39,3 @@ "main": "dist/virtual-drag-list.min.js", | ||
"dependencies": { | ||
"sortable-dnd": "0.6.2" | ||
"sortable-dnd": "0.6.3" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
117077
1
1
+ Addedsortable-dnd@0.6.3(transitive)
- Removedsortable-dnd@0.6.2(transitive)
Updatedsortable-dnd@0.6.3