vue-virtual-draglist
Advanced tools
Comparing version 2.8.4 to 2.8.5
@@ -1,1 +0,11 @@ | ||
!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 L(t){return(L="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 K(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 P(){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!==P()?(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(j(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 j(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),N.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,x,Q,_,T,O,E,z,tt,I,D,et,C,k,R,B,M,it,A,N,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,K(t),a(t,"translate3d(".concat(i,"px, ").concat(e,"px, 0)")),t.offsetWidth,K(t,this.options.animation),a(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout(function(){K(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")}},N=[],nt=function(t){var e={},i=t.group;i&&"object"==L(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;w||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},w=i,l(I=e?w: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(w);C=this.el,k=this.el,it=M=B=i,A=w,b=this.el,_=w.cloneNode(!0),O=w.parentNode,R=this.options.group.pull,p.clone=_,p.active=this,h(p.dragged=w,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(_,this.options.chosenClass,!0),this._appendGhost(),this.multiplayer.onDrag(this),f({sortable:this,name:"onDrag",params:this._getParams(E.original)}),d(w,"display","none"),h(w,this.options.chosenClass,!1),w.parentNode.insertBefore(_,w),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:[w]):this.multiplayer.getGhostElement()||w},_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(w)).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||!w||(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:P()}}while(e=e.parentNode)}return P()}(e),this.autoScroller.update(i,E,z)),o=l.clientX,s=l.clientY,N.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),e=(Q=t<0?x.nextSibling:x,m(x)),i="vertical"===(o="function"==typeof this.options.direction?this.options.direction.call(z.original,w,this):this.options.direction),n=i?z.clientY:z.clientX,o=x["vertical"===o?"offsetHeight":"offsetWidth"],n=n>=(i?e.top:e.left)&&n<(i?e.bottom:e.right)-o/2?-1:1;return tt!==x?(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)?(x=c(e,this.options.draggable,this.el))&&!x.animated&&this._allowSwap()&&(x===_||j(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=x):(x=tt=null,this._onInsert(t)))},_onInsert:function(t){var e=x||_,i="clone"===R&&this.el!==b&&k===b,n="clone"===R&&this.el===b&&k!==b;C=this.el,B=o(_),A=e,O=x?x.parentNode:this.el,k[S].animator.collect(_.parentNode),this.animator.collect(O),i&&(d(w,"display",""),b[S].multiplayer.toggleVisible(!0),b[S].options.group.revertDrag||k.insertBefore(w,_)),n&&(B=o(w),d(w,"display","none"),this.multiplayer.toggleVisible(!1)),x?O.insertBefore(_,D<0?x:x.nextSibling):O.appendChild(_),M=o(_),i&&b[S].options.group.revertDrag&&f({sortable:b[S],name:"onChange",params:this._getParams(t,{to:b,target:w,newIndex:it,revertDrag:!0})}),i||f({sortable:k[S],name:"onRemove",params:this._getParams(t)}),n&&x!==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){x!==w&&(O=x.parentNode,B=o(_),A=x,this.animator.collect(O),O.insertBefore(_,Q),M=o(_),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(w,this.options.chosenClass,!1),b&&(k=b,B=it,A===_&&(A=w),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,w,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,R),this.options.swapOnDrop);("clone"!==R||k===C)&&("function"==typeof e?e(t):e)&&O.insertBefore(w,_),"clone"!==R||k===C||this.multiplayer.active()?_&&_.parentNode&&_.parentNode.removeChild(_):h(_,this.options.chosenClass,!1),d(w,"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=w,i.clone=_,i.target=A,i.oldIndex=B,i.newIndex=M,i.pullMode=R,this.multiplayer.setParams(i),r(i,e),i.relative=i.target===w?0:s(i.target,_),i},_nulling:function(){C=k=b=w=x=Q=_=T=O=R=B=M=it=E=z=A=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),N.splice(N.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,e={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:""}},i={tag:{type:String,default:"div"},event:{type:String},dataKey:{type:[String,Number]},sizeKey:{type:String}};function a(o,s){function t(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];r||(s<=0?o.apply(this,i):r=setTimeout(function(){r=void 0,o.apply(t,i)},s))}var r=null;return t.cancel=function(){r&&(clearTimeout(r),r=null)},t}function c(t,e){function i(){n.cancel(),n.apply(this,arguments)}var n=a(t,e);return i.cancel=function(){n.cancel()},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 h,u=["delay","group","handle","disabled","draggable","animation","autoScroll","ghostClass","ghostStyle","chosenClass","fallbackOnBody","scrollThreshold","delayOnTouchOnly"];function p(t,e){this.el=t,this.options=e,this.list=[],this.store={},this.reRendered=!1,this.attrs=u,this.init()}p.prototype={constructor:p,destroy:function(){this.sortable&&this.sortable.destroy(),this.sortable=this.store=this.reRendered=null},option:function(t,e){"list"===t?this.list=r(e):this.sortable.option(t,e)},init:function(){for(var e=this,t={},i=0;i<u.length;i++){var n=u[i];t[n]=this.options[n]}this.sortable=new l(this.el,d(d({},t),{},{swapOnDrop:function(t){return t.from===t.to},onDrag:function(t){return e.onDrag(t)},onAdd:function(t){return e.onAdd(t)},onRemove:function(t){return e.onRemove(t)},onChange:function(t){return e.onChange(t)},onDrop:function(t){return e.onDrop(t)}})),this.list=r(this.options.list)},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.dispatchEvent("onDrag",{item:i,key:t,index:e})},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.dispatchEvent("onRemove",{item:i,key:t,index:e})},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);0===t?i=this.list.length:-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.dispatchEvent("onAdd",{item:e,key:n,index:i})},onChange:function(t){var e,i,n,o,s=l.get(t.from).option("store");t.revertDrag?(this.list=r(this.options.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.dispatchEvent("onDrop",{changed:n,list:this.list,item:i.item,key:i.key,from:i.origin,to:e.to}),t.from===this.el&&this.reRendered&&null!=(n=l.dragged)&&n.remove(),t.from!==t.to&&"clone"===t.pullMode&&null!=(i=l.clone)&&i.remove(),this.reRendered=!1},getIndex:function(t,e){for(var i=0;i<t.length;i++)if(f(t[i],this.options.dataKey)==e)return i;return-1},getStore:function(t){return{from:l.get(t.from).option("store"),to:l.get(t.to).option("store")}},dispatchEvent:function(t,e){t=this.options[t];t&&t(e)}};var m=["size","keeps","scroller","direction","debounceTime","throttleTime"],g="INIT",y="FIXED",v="DYNAMIC",S="FRONT",b="BEHIND",w="STATIONARY",x="horizontal",_="vertical",T=(o(h={},_,"scrollTop"),o(h,x,"scrollLeft"),h),O=(o(h={},_,"offsetTop"),o(h,x,"offsetLeft"),h),E=(o(h={},_,"scrollHeight"),o(h,x,"scrollWidth"),h),z=(o(h={},_,"offsetHeight"),o(h,x,"offsetWidth"),h);function I(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=g,this.calcSize={average:0,total:0,fixed:0,header:0},this.scrollEl=this.getScrollElement(t.scroller),this.direction="",this.useWindowScroll=null,this.onScroll=null,this.updateOnScrollFunction(),this.addScrollEventListener(),this.checkIfUpdate(0,t.keeps-1)}I.prototype={constructor:I,isFront:function(){return this.direction===S},isBehind:function(){return this.direction===b},isFixed:function(){return this.calcType===y},getSize:function(t){return this.sizes.get(t)||this.getItemSize()},getOffset:function(){return this.scrollEl[T[this.options.direction]]},getScrollSize:function(){return this.scrollEl[E[this.options.direction]]},getClientSize:function(){return this.scrollEl[z[this.options.direction]]},scrollToOffset:function(t){this.scrollEl[T[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)},option: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&&(e&&l.utils.off(e,"scroll",this.onScroll),this.scrollEl=this.getScrollElement(i),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)))},onItemResized:function(t,e){this.sizes.set(t,e),this.calcType===g?(this.calcType=y,this.calcSize.fixed=e):this.isFixed()&&this.calcSize.fixed!==e&&(this.calcType=v,this.calcSize.fixed=void 0),this.calcType!==y&&(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))},onSlotResized:function(t,e){this.calcSize[t]=e},addScrollEventListener:function(){this.options.scroller&&l.utils.on(this.options.scroller,"scroll",this.onScroll)},removeScrollEventListener:function(){this.options.scroller&&l.utils.off(this.options.scroller,"scroll",this.onScroll)},updateOnScrollFunction:function(){var t=this,e=this.options,i=e.debounceTime,e=e.throttleTime;this.onScroll=i?c(function(){return t.handleScroll()},i):e?a(function(){return t.handleScroll()},e):function(){return t.handleScroll()}},handleScroll:function(){var t=this.getOffset(),e=this.getClientSize(),i=this.getScrollSize(),n=(t===this.offset?this.direction=w:this.direction=t<this.offset?S:b,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[O[this.options.direction]],(e=e.offsetParent)&&e!==this.options.wrapper.ownerDocument;);return t}};var _={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}}},D=t.component("virtual-draglist-items",{mixins:[_],props:i,render:function(t){var e=this.tag,i=this.dataKey;return t(e,{key:i,attrs:{"data-key":i}},this.$slots.default)}}),C=t.component("virtual-draglist-slots",{mixins:[_],props:i,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:e,data:function(){return{list:[],start:0,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 m.reduce(function(t,e){return t[e]=i[e],t},{})},sortableAttributes:function(){var i=this;return u.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.option(i,t[i])},deep:!0},sortableAttributes:{handler:function(t,e){if(this.sortable)for(var i in t)t[i]!=e[i]&&this.sortable.option(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.option("wrapper",this.$refs.groupRef),this.scroller||this.virtual.option("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._updateRange(e,this.list),this.sortable?this.sortable.option("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 I({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 p(this.$refs.groupRef,d(d({list:this.list,dataKey:this.dataKey},this.sortableAttributes),{},{onDrag:function(t){e.start=e.range.start,e.$emit("drag",t)},onAdd:function(t){e.$emit("add",t)},onRemove:function(t){e.$emit("remove",t)},onDrop:function(t){t.list.length===e.list.length&&e.start<e.range.start&&(e.range.front+=l.clone[e.itemSizeKey],e.start=e.range.start),e.$emit("updateDataSource",t.list),e.$emit("drop",t)}}))},_updateRange:function(t,e){var i=d({},this.range);e.length>t.length&&this.range.end===t.length-1&&this._scrolledToBottom()&&(i.end++,i.start=Math.max(0,i.end-this.keeps)),this.virtual.updateRange(i)},_scrolledToBottom:function(){var t=this.getOffset(),e=this.getClientSize();return this.getScrollSize()<=t+e+1},_handleToTop:c(function(){this.$emit("top"),this.lastLength=this.list.length}),_handleToBottom:c(function(){this.$emit("bottom")}),_onItemResized:function(t,e){var i=this.virtual.sizes.size;this.virtual.onItemResized(t,e),0===i&&this._updateRange(this.list,this.list)},_onSlotResized:function(t,e){this.virtual.onSlotResized(t,e)},_updateUniqueKeys:function(){var e=this;this.uniqueKeys=this.list.map(function(t){return f(t,e.dataKey)}),this.virtual.option("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(C,{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(D,{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)])}})}); | ||
/*! | ||
* vue-virtual-drag-list v2.8.5 | ||
* open source under the MIT license | ||
* https://github.com/mfuu/vue-virtual-drag-list#readme | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).VirtualDragList=e(t.Vue)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=e(t);function n(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function o(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(Object(i),!0).forEach((function(e){r(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return l(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return l(t,e)}(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 l(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}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c={exports:{}}; | ||
/*! | ||
* sortable-dnd v0.6.6 | ||
* open source under the MIT license | ||
* https://github.com/mfuu/sortable-dnd#readme | ||
*/!function(t,e){t.exports=function(){function t(e){return(t="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})(e)}function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},e.apply(this,arguments)}var i={capture:!1,passive:!1},n=/\s+/g;function o(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var r=o(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),s=o(/Edge/i),l=o(/safari/i)&&!o(/chrome/i)&&!o(/android/i),a=function(){var t=!1;return document.addEventListener("checkIfSupportPassive",null,{get passive(){return t=!0,!0}}),t}(),c=function(){if("undefined"==typeof window||"undefined"==typeof document)return{};var t=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],e=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.OLink&&["","o"])[1];return{dom:"WebKit|Moz|MS|O".match(new RegExp("("+e+")","i"))[1],lowercase:e,css:"-"+e+"-",js:e[0].toUpperCase()+e.substr(1)}}();function h(t,e){t.style["".concat(c.css,"transition-duration")]=e?"".concat(e,"ms"):""}function u(t,e){t.style["".concat(c.css,"transform")]=e?"".concat(e):""}function d(t,e,n){window.addEventListener?t.addEventListener(e,n,!(!a&&r)&&i):window.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function f(t,e,n){window.removeEventListener?t.removeEventListener(e,n,!(!a&&r)&&i):window.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function p(){return document.scrollingElement||document.documentElement}function m(t,e,i){if(t.getBoundingClientRect||t===window){var n,o,r,s,l,a,c;if(t!==window&&t.parentNode&&t!==p()?(o=(n=t.getBoundingClientRect()).top,r=n.left,s=n.bottom,l=n.right,a=n.height,c=n.width):(o=0,r=0,s=window.innerHeight,l=window.innerWidth,a=window.innerHeight,c=window.innerWidth),e&&t!==window){i=i||t.parentNode;do{if(i&&i.getBoundingClientRect){var h=i.getBoundingClientRect();o-=h.top+parseInt(T(i,"border-top-width")),r-=h.left+parseInt(T(i,"border-left-width")),s=o+n.height,l=r+n.width;break}}while(i=i.parentNode)}return{top:o,left:r,bottom:s,right:l,width:c,height:a}}}function g(t,e,i,n){if(!t)return null;if(i&&!e){var o=Array.prototype.slice.call(i.children),r=o.indexOf(t);if(r>-1)return o[r];for(var s=0;s<o.length;s++)if(v(t,o[s]))return o[s]}i=i||document;do{if(null!=e&&(">"===e[0]?t.parentNode===i&&_(t,e):_(t,e))||n&&t===i)return t;if(t===i)break}while(t=t.parentNode);return null}function v(t,e){if(!t||!e)return!1;if(e.compareDocumentPosition)return!!(16&e.compareDocumentPosition(t));if(e.contains&&1===t.nodeType)return e.contains(t)&&e!==t;for(;t=t.parentNode;)if(t===e)return!0;return!1}function y(t,e){for(var i=t.lastElementChild;i&&(i===nt.ghost||"none"===T(i,"display")||e&&!_(i,e));)i=i.previousElementSibling;return i||null}function b(t,e){if(!t||!t.parentNode)return-1;for(var i=0;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||e&&!_(t,e)||"none"===T(t,"display")||i++;return i}function S(t,e,i,n){for(var o=0,r=0,s=t.children;o<s.length;){if(s[o]!==nt.ghost&&"none"!==T(s[o],"display")&&g(s[o],i,t,!1)&&(n||s[o]!==nt.dragged)){if(r===e)return s[o];r++}o++}return null}function w(t,e){var i=T(t),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=S(t,0,e),l=S(t,1,e),a=o&&T(o),c=l&&T(l),h=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+m(o).width,u=c&&parseInt(c.marginLeft)+parseInt(c.marginRight)+m(l).width,d=s||r?"cssFloat":"float";if("flex"===i.display)return"column"===i.flexDirection||"column-reverse"===i.flexDirection?"vertical":"horizontal";if("grid"===i.display)return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&"none"!==a.float){var f="left"===a.float?"left":"right";return!l||"both"!==c.clear&&c.clear!==f?"horizontal":"vertical"}return o&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||h>=n&&"none"===i[d]||l&&"none"===i[d]&&h+u>n)?"vertical":"horizontal"}function x(t,e,i){if(t&&e)if(t.classList)t.classList[i?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(n," ").replace(" "+e+" "," ");t.className=(o+(i?" "+e:"")).replace(n," ")}}function _(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function T(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];e in n||-1!==e.indexOf("webkit")||(e="-webkit-"+e),n[e]=i+("string"==typeof i?"":"px")}}function E(t,e){var i,n,o=(n=e,(i=t).compareDocumentPosition?i.compareDocumentPosition(n):i.contains?(i!=n&&i.contains(n)&&16)+(i!=n&&n.contains(i)&&8)+(i.sourceIndex>=0&&n.sourceIndex>=0?(i.sourceIndex<n.sourceIndex&&4)+(i.sourceIndex>n.sourceIndex&&2):1):0);return 2===o?1:4===o?-1:0}function O(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault()}function z(t){var i=t.sortable,n=t.name,o=t.params,r=i.options[n];"function"==typeof r&&r(e({},o))}var D,I,C="Sortable"+Date.now();function k(t){this.options=t,this.autoScrollAnimationFrame=null}function A(t){this.options=t,this.animations=[]}function M(t){this.options=t||{},this.selectedElements=[]}window.requestAnimationFrame||(window.requestAnimationFrame=function(t){return setTimeout(t,17)}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),k.prototype={destroy:function(){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){if(t&&void 0!==e.clientX&&void 0!==e.clientY){var i=m(t);if(i){var n=e.clientX,o=e.clientY,r=i.top,s=i.right,l=i.bottom,a=i.left,c=i.height,h=i.width;if(!(o<r||n>s||o>l||n<a)){var u=this.options,d=u.scrollThreshold,f=u.scrollSpeed,p=t.scrollTop,g=t.scrollLeft,v=t.scrollHeight,y=p>0&&o>=r&&o<=r+d,b=g+h<t.scrollWidth&&n<=s&&n>=s-d,S=p+c<v&&o<=l&&o>=l-d,w=0,x=0;g>0&&n>=a&&n<=a+d&&(w=Math.floor(Math.max(-1,(n-a)/d-1)*f.x)),b&&(w=Math.ceil(Math.min(1,(n-s)/d+1)*f.x)),y&&(x=Math.floor(Math.max(-1,(o-r)/d-1)*f.y)),S&&(x=Math.ceil(Math.min(1,(o-l)/d+1)*f.y)),t.scrollTop+=x,t.scrollLeft+=w}}}}},A.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),r=Math.min(e.bottom,n),s=Array.prototype.slice.call(t.children),l=[],a=0;a<=s.length;a++){var c=s[a];if(c&&c!==nt.ghost&&"none"!==T(c,"display")){var h=m(c);if(!(h.bottom<0||h.right<0)){if(h.top-h.height>r||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=t[e],o=n.node,r=n.rect;this._excute(o,r)}},_excute:function(t,e){var i=e.left,n=e.top,o=m(t);if(o.top!==n||o.left!==i){var r=n-o.top,s=i-o.left;h(t),u(t,"translate3d(".concat(s,"px, ").concat(r,"px, 0)")),t.offsetWidth,h(t,this.options.animation),u(t,"translate3d(0px, 0px, 0px)"),clearTimeout(t.animated),t.animated=setTimeout((function(){h(t),u(t,""),t.animated=null}),this.options.animation)}}},M.prototype={destroy:function(){D=I=null},active:function(){return!!D},setParams:function(t){t.nodes=D||[],t.clones=I||[]},select:function(t){x(t,this.options.selectedClass,!0),this.selectedElements.push(t),this.selectedElements.sort((function(t,e){return E(t,e)}))},deselect:function(t){var e=this.selectedElements.indexOf(t);e>-1&&(x(t,this.options.selectedClass,!1),this.selectedElements.splice(e,1))},getGhostElement:function(){if(!D)return null;var t=document.createElement("div");return this.selectedElements.forEach((function(e,i){var n=e.cloneNode(!0),o=0===i?1:.5;n.style="position: absolute;left: 0;top: 0;bottom: 0;right: 0;opacity: ".concat(o,";z-index: ").concat(i,";"),t.appendChild(n)})),t},toggleSelected:function(t,e){var i=this;e?t.forEach((function(t){return i.selectedElements.push(t)})):this.selectedElements=this.selectedElements.filter((function(e){return t.indexOf(e)<0}))},toggleClass:function(t){if(D)for(var e=0;e<D.length;e++)x(D[e],this.options.chosenClass,t)},toggleVisible:function(t){if(D)if(t){var e=D.indexOf(nt.dragged);this._viewElements(D,e,nt.dragged)}else this._hideElements(D)},onChoose:function(){!this.options.multiple||!this.selectedElements.length||this.selectedElements.indexOf(nt.dragged)<0||(this.selectedElements.sort((function(t,e){return E(t,e)})),D=this.selectedElements,this.toggleClass(!0))},onDrag:function(t){D&&(t.animator.collect(nt.dragged.parentNode),this._hideElements(D),t.animator.animate(),this.toggleClass(!1))},onDrop:function(t,e,i){if(D){var n=nt.dragged,o=nt.clone,r=D.indexOf(n);e[C].animator.collect(o.parentNode),t!==e&&"clone"===i?(T(o,"display","none"),I=D.map((function(t){return t.cloneNode(!0)})),this._viewElements(I,r,o),this._viewElements(D,r,n)):this._viewElements(D,r,o),e[C].animator.animate(),t!==e&&(e[C].multiplayer.toggleSelected(I||D,!0),"clone"!==i&&t[C].multiplayer.toggleSelected(D,!1))}},onSelect:function(t,e,i){var n=this.selectedElements.indexOf(e);x(e,this.options.selectedClass,n<0);var o={from:i.el,event:t,node:e,index:b(e)};n<0?(this.selectedElements.push(e),z({sortable:i,name:"onSelect",params:o})):(this.selectedElements.splice(n,1),z({sortable:i,name:"onDeselect",params:o})),this.selectedElements.sort((function(t,e){return E(t,e)}))},_viewElements:function(t,e,i){for(var n=0;n<t.length;n++)if(T(t[n],"display",""),n<e)i.parentNode.insertBefore(t[n],i);else{var o=n>0?t[n-1]:i;i.parentNode.insertBefore(t[n],o.nextSibling)}},_hideElements:function(t){for(var e=0;e<t.length;e++)t[e]!=nt.dragged&&T(t[e],"display","none")}};var B,R,N,P,L,j,F,K,H,q,$,W,Y,U,X,V,G,Z,J,Q,tt,et=[],it=function(e){var i={},n=e.group;n&&"object"==t(n)||(n={name:n,pull:!0,put:!0,revertDrag:!0}),i.name=n.name,i.pull=n.pull,i.put=n.put,i.revertDrag=n.revertDrag,e.group=i};function nt(t,i){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(t));t[C]=this,this.el=t,this.options=i=e({},i);var n={store:null,disabled:!1,group:"",lockAxis:"",animation:150,draggable:null,handle:null,multiple:!1,selectHandle:null,customGhost:null,direction:"",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(var o in n)!(o in this.options)&&(this.options[o]=n[o]);for(var r in it(i),this)"_"===r.charAt(0)&&"function"==typeof this[r]&&(this[r]=this[r].bind(this));d(t,this.options.supportTouch?"touchstart":"mousedown",this._onDrag),et.push(t),this.autoScroller=new k(this.options),this.multiplayer=new M(this.options),this.animator=new A(this.options)}return nt.prototype={constructor:nt,_onDrag:function(t){var e=this;if(!R&&!this.options.disabled&&this.options.group.pull&&(!/mousedown|pointerdown/.test(t.type)||0===t.button)){var i=t.touches&&t.touches[0],n=(i||t).target;if(!l||!n||"SELECT"!==n.tagName.toUpperCase()){var o=g(n,this.options.draggable,this.el);if(o&&!o.animated){K={original:t,clientX:(i||t).clientX,clientY:(i||t).clientY},R=o,d($=i?R:document,"mouseup",this._onDrop),d($,"touchend",this._onDrop),d($,"touchcancel",this._onDrop);var a=this.options,c=a.handle,h=a.selectHandle;if("function"==typeof h&&h(t)||"string"==typeof h&&_(n,h))U=!0;else if(("function"!=typeof c||c(t))&&("string"!=typeof c||_(n,c))){var u=this.options,f=u.delay,p=u.delayOnTouchOnly;!f||p&&!i||s||r?this._onStart(i,t):(d(this.el.ownerDocument,"touchmove",this._delayMoveHandler),d(this.el.ownerDocument,"mousemove",this._delayMoveHandler),d(this.el.ownerDocument,"mouseup",this._cancelStart),d(this.el.ownerDocument,"touchend",this._cancelStart),d(this.el.ownerDocument,"touchcancel",this._cancelStart),Y=setTimeout((function(){return e._onStart(i,t)}),f)),d(document,"selectstart",O),l&&T(document.body,"user-select","none")}}}}},_delayMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-K.clientX),Math.abs(e.clientY-K.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){clearTimeout(Y),f(this.el.ownerDocument,"touchmove",this._delayMoveHandler),f(this.el.ownerDocument,"mousemove",this._delayMoveHandler),f(this.el.ownerDocument,"mouseup",this._cancelStart),f(this.el.ownerDocument,"touchend",this._cancelStart),f(this.el.ownerDocument,"touchcancel",this._cancelStart),f(document,"selectstart",O),l&&T(document.body,"user-select","")},_onStart:function(t,e){var i=b(R);X=this.el,V=this.el,Z=i,J=i,Q=i,tt=R,B=this.el,L=R.cloneNode(!0),F=R.parentNode,G=this.options.group.pull,nt.clone=L,nt.active=this,nt.dragged=R,x(R,this.options.chosenClass,!0),this.multiplayer.onChoose(),z({sortable:this,name:"onChoose",params:this._getParams(e)}),d($,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout((function(){return document.selection.empty()}),0):window.getSelection().removeAllRanges()}catch(t){}},_onStarted:function(){x(L,this.options.chosenClass,!0),this._appendGhost(),this.multiplayer.onDrag(this),z({sortable:this,name:"onDrag",params:this._getParams(K.original)}),T(R,"display","none"),x(R,this.options.chosenClass,!1),R.parentNode.insertBefore(L,R)},_getGhostElement:function(){var t=this.options.customGhost;if("function"==typeof t){var e=this.multiplayer.selectedElements;return t(e.length?e:[R])}return this.multiplayer.getGhostElement()||R},_appendGhost:function(){if(!j){var t=this.options.fallbackOnBody?document.body:this.el,i=this._getGhostElement();x(j=i.cloneNode(!0),this.options.ghostClass,!0);var n,o=m(R),r=e({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"},this.options.ghostStyle);for(var s in r)T(j,s,r[s]);n="none",j.style["".concat(c.css,"transition")]=n?"none"===n?"none":"".concat(n):"",u(j,"translate3d(0px, 0px, 0px)"),nt.ghost=j,t.appendChild(j);var l=(K.clientX-o.left)/parseInt(j.style.width)*100,a=(K.clientY-o.top)/parseInt(j.style.height)*100;T(j,"transform-origin","".concat(l,"% ").concat(a,"%")),T(j,"transform","translateZ(0)"),T(j,"will-change","transform")}},_nearestSortable:function(t){O(t);var e=t.touches&&t.touches[0]||t;if(R&&function(t){var e=H||K;return!(void 0!==t.clientX&&void 0!==t.clientY&&Math.abs(t.clientX-e.clientX)<=0&&Math.abs(t.clientY-e.clientY)<=0)}(e)){!H&&this._onStarted();var i=this.options.lockAxis,n="x"===i?K.clientX:e.clientX,o="y"===i?K.clientY:e.clientY,r=document.elementFromPoint(n,o),s=n-K.clientX,l=o-K.clientY;if(H={original:t,clientX:n,clientY:o},u(j,"translate3d(".concat(s,"px, ").concat(l,"px, 0)")),this.options.autoScroll){var a=function(t,e){if(!t||!t.getBoundingClientRect)return p();var i=t,n=!1;do{if(i.clientWidth<i.scrollWidth||i.clientHeight<i.scrollHeight){var o=T(i);if(i.clientWidth<i.scrollWidth&&("auto"==o.overflowX||"scroll"==o.overflowX)||i.clientHeight<i.scrollHeight&&("auto"==o.overflowY||"scroll"==o.overflowY)){if(!i.getBoundingClientRect||i===document.body)return p();if(n||e)return i;n=!0}}}while(i=i.parentNode);return p()}(r,!0);this.autoScroller.update(a,K,H)}var c,h,d,f=(c=n,h=o,et.some((function(t){var e=t[C].options.emptyInsertThreshold;if(null!=e){var i=m(t),n=c>=i.left-e&&c<=i.right+e,o=h>=i.top-e&&h<=i.bottom+e;return n&&o?d=t:void 0}})),d);f&&f[C]._onMove(t,r)}},_allowPut:function(){if(B===this.el)return!0;if(this.options.group.put){var t=this.options.group,e=t.name,i=t.put,n=B[C].options.group;return i.join&&i.indexOf(n.name)>-1||n.name&&e&&n.name===e}return!1},_getDirection:function(){var t=this.options,e=t.draggable,i=t.direction;return i?"function"==typeof i?i.call(H.original,R,this):i:w(F,e)},_allowSwap:function(){var t=m(N),e="vertical"===this._getDirection(),i=e?"top":"left",n=e?"bottom":"right",o=N[e?"offsetHeight":"offsetWidth"],r=e?H.clientY:H.clientX,s=r>=t[i]&&r<t[n]-o/2?-1:1,l=S(F,0,this.options.draggable),a=y(F),c=m(l),h=m(a);if(N===F||v(F,N))return L===l&&r<c[i]?(P=N,!0):L===a&&r>h[n]&&(P=N.nextSibling,!0);var u=E(L,N);return P=u<0?N.nextSibling:N,q!==N?(W=s,!0):W!==s&&(W=s,s<0?u>0:u<0)},_onMove:function(t,e){if(this._allowPut()){if(z({sortable:this,name:"onMove",params:this._getParams(t)}),this.el!==V&&(e===this.el||!y(this.el)))return N=q=null,void this._onInsert(t);(N=g(e,this.options.draggable,this.el))&&!N.animated&&this._allowSwap()&&(N!==L&&P!==L?(this.el!==V?this._onInsert(t):N!==R&&this._onChange(t),q=N):q=N)}},_onInsert:function(t){var e=N||L,i="clone"===G&&this.el!==B&&V===B,n="clone"===G&&this.el===B&&V!==B;X=this.el,Z=b(L),tt=e,F=N?N.parentNode:this.el,V[C].animator.collect(L.parentNode),this.animator.collect(F),i&&(T(R,"display",""),B[C].multiplayer.toggleVisible(!0),B[C].options.group.revertDrag||V.insertBefore(R,L)),n&&(Z=b(R),T(R,"display","none"),this.multiplayer.toggleVisible(!1)),N?F.insertBefore(L,W<0?N:N.nextSibling):F.appendChild(L),J=b(L),i&&B[C].options.group.revertDrag&&z({sortable:B[C],name:"onChange",params:this._getParams(t,{to:B,target:R,newIndex:Q,revertDrag:!0})}),i||z({sortable:V[C],name:"onRemove",params:this._getParams(t)}),n&&N!==R&&z({sortable:this,name:"onChange",params:this._getParams(t,{from:B,backToOrigin:!0})}),n||z({sortable:this,name:"onAdd",params:this._getParams(t)}),V[C].animator.animate(),this.animator.animate(),V=this.el},_onChange:function(t){F=N.parentNode,Z=b(L),tt=N,this.animator.collect(F),F.insertBefore(L,P),J=b(L),z({sortable:this,name:"onChange",params:this._getParams(t)}),this.animator.animate(),V=this.el},_onDrop:function(t){O(t),this._cancelStart(),f($,"touchmove",this._nearestSortable),f($,"mousemove",this._nearestSortable),f($,"mouseup",this._onDrop),f($,"touchend",this._onDrop),f($,"touchcancel",this._onDrop),x(R,this.options.chosenClass,!1),B&&(V=B,Z=Q,tt===L&&(tt=R),this.multiplayer.toggleClass(!1),z({sortable:this,name:"onUnchoose",params:this._getParams(t)}),H&&this._onEnd(t));var e=this.options,i=e.multiple,n=e.selectHandle;if(i&&(n&&U||!n&&!B)){var o=t.changedTouches?t.changedTouches[0]:t,r=o.clientX-K.clientX,s=o.clientY-K.clientY,l=Math.sqrt(r*r+s*s);l>=0&&l<=1&&this.multiplayer.onSelect(t,R,this)}j&&j.parentNode&&j.parentNode.removeChild(j),this.multiplayer.destroy(),this.autoScroller.destroy(),this._nulling()},_onEnd:function(t){var e=this._getParams(t);this.multiplayer.onDrop(V,X,G);var i=this.options.swapOnDrop;"clone"===G&&V!==X||!("function"==typeof i?i(e):i)||F.insertBefore(R,L),"clone"!==G||V===X||this.multiplayer.active()?L&&L.parentNode&&L.parentNode.removeChild(L):x(L,this.options.chosenClass,!1),T(R,"display",""),V!==X&&z({sortable:V[C],name:"onDrop",params:e}),z({sortable:X[C],name:"onDrop",params:e})},_getParams:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};return n.event=t,n.to=X,n.from=V,n.node=R,n.clone=L,n.target=tt,n.oldIndex=Z,n.newIndex=J,n.pullMode=G,this.multiplayer.setParams(n),e(n,i),n.relative=n.target===R?0:E(n.target,L),n},_nulling:function(){X=V=B=R=N=P=L=j=F=G=Z=J=Q=K=H=tt=q=$=W=Y=U=nt.clone=nt.ghost=nt.active=nt.dragged=null},destroy:function(){this._cancelStart(),this._nulling(),f(this.el,"touchstart",this._onDrag),f(this.el,"mousedown",this._onDrag),et.splice(et.indexOf(this.el),1),this.el[C]=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&&it(this.options)},select:function(t){this.multiplayer.select(t)},deselect:function(t){this.multiplayer.deselect(t)},getSelectedElements:function(){return this.multiplayer.selectedElements}},nt.utils={on:d,off:f,css:T,index:b,closest:g,getRect:m,toggleClass:x,detectDirection:w},nt.get=function(t){return t[C]},nt.create=function(t,e){return new nt(t,e)},nt}()}(c);var h=a(c.exports),u={dataSource:{type:Array,default:function(){return[]}},dataKey:{type:String,required:!0},scroller:{type:[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]},lockAxis:{type:String,default:""},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"},itemTag:{type:String,default:"div"},wrapClass:{type:String,default:""},wrapStyle:{type:Object},itemStyle:{type:Object},itemClass:{type:String,default:""},ghostClass:{type:String,default:""},ghostStyle:{type:Object,default:function(){return{}}},chosenClass:{type:String,default:""}},d={tag:{type:String,default:"div"},dataKey:{type:[String,Number]},sizeKey:{type:String}};function f(t,e){var i=null,n=function(){for(var n=this,o=arguments.length,r=new Array(o),s=0;s<o;s++)r[s]=arguments[s];i||(e<=0?t.apply(this,r):i=setTimeout((function(){i=void 0,t.apply(n,r)}),e))};return n.cancel=function(){i&&(clearTimeout(i),i=null)},n}function p(t,e){var i=f(t,e),n=function(){i.cancel(),i.apply(this,arguments)};return n.cancel=function(){i.cancel()},n}function m(t,e){return(Array.isArray(e)?e:e.replace(/\[/g,".").replace(/\]/g,".").split(".")).reduce((function(t,e){return(t||{})[e]}),t)}var g,v,y,b,S=["delay","group","handle","lockAxis","disabled","draggable","animation","autoScroll","ghostClass","ghostStyle","chosenClass","fallbackOnBody","scrollThreshold","delayOnTouchOnly"];function w(t,e){this.el=t,this.options=e,this.list=[],this.store={},this.reRendered=!1,this.init()}w.prototype={constructor:w,destroy:function(){this.sortable&&this.sortable.destroy(),this.sortable=this.store=this.reRendered=null},option:function(t,e){"list"===t?this.list=s(e):this.sortable.option(t,e)},init:function(){var t=this,e=S.reduce((function(e,i){return e[i]=t.options[i],e}),{});this.sortable=new h(this.el,o(o({},e),{},{swapOnDrop:function(t){return t.from===t.to},onDrag:function(e){return t.onDrag(e)},onAdd:function(e){return t.onAdd(e)},onRemove:function(e){return t.onRemove(e)},onChange:function(e){return t.onChange(e)},onDrop:function(e){return t.onDrop(e)}})),this.list=s(this.options.list)},onDrag:function(t){var e=t.node.dataset.key,i=this.getIndex(this.list,e),n=this.list[i];this.store={item:n,key:e,start:{index:i,list:this.list},from:{index:i,list:this.list},to:{index:i,list:this.list}},this.sortable.option("store",this.store),this.dispatchEvent("onDrag",{item:n,key:e,index:i})},onRemove:function(t){var e=t.node.dataset.key,i=this.getIndex(this.list,e),n=this.list[i];this.list.splice(i,1),Object.assign(this.store,{key:e,item:n}),this.sortable.option("store",this.store),this.dispatchEvent("onRemove",{item:n,key:e,index:i})},onAdd:function(t){var e=t.from,i=t.target,n=t.relative,o=h.get(e).option("store"),r=o.key,s=o.item,l=this.getIndex(this.list,i.dataset.key);0===n?l=this.list.length:-1===n&&(l+=1),this.list.splice(l,0,s),Object.assign(this.store,{to:{index:l,list:this.list}}),this.sortable.option("store",this.store),this.dispatchEvent("onAdd",{item:s,key:r,index:l})},onChange:function(t){var e=h.get(t.from).option("store");if(t.revertDrag)return this.list=s(this.options.list),void Object.assign(this.store,{from:e.start});var i=t.node,n=t.target,o=t.relative,r=t.backToOrigin,l=this.getIndex(this.list,i.dataset.key),a=this.list[l],c=this.getIndex(this.list,n.dataset.key);r&&(1===o&&e.from.index<c&&(c-=1),-1===o&&e.from.index>c&&(c+=1)),this.list.splice(l,1),this.list.splice(c,0,a),Object.assign(this.store,{from:{index:c,list:this.list},to:{index:c,list:this.list}})},onDrop:function(t){var e,i,n=h.get(t.from).option("store"),o=n.start,r=n.item,s=n.key,l=h.get(t.to).option("store").to,a=t.from!==t.to||o.index!==l.index;(this.dispatchEvent("onDrop",{changed:a,list:this.list,item:r,key:s,from:o,to:l}),t.from===this.el&&this.reRendered)&&(null===(e=h.dragged)||void 0===e||e.remove());t.from!==t.to&&"clone"===t.pullMode&&(null===(i=h.clone)||void 0===i||i.remove());this.reRendered=!1},getIndex:function(t,e){for(var i=0;i<t.length;i++)if(m(t[i],this.options.dataKey)==e)return i;return-1},dispatchEvent:function(t,e){var i=this.options[t];i&&i(e)}};var x=["size","keeps","scroller","direction","debounceTime","throttleTime"],_="INIT",T="FIXED",E="DYNAMIC",O="FRONT",z="BEHIND",D="STATIONARY",I="horizontal",C="vertical",k=(r(g={},C,"top"),r(g,I,"left"),g),A=(r(v={},C,"scrollTop"),r(v,I,"scrollLeft"),v),M=(r(y={},C,"scrollHeight"),r(y,I,"scrollWidth"),y),B=(r(b={},C,"offsetHeight"),r(b,I,"offsetWidth"),b);function R(t){this.options=t;var e={size:0,keeps:0,buffer:0,wrapper:null,scroller:null,direction:"vertical",uniqueKeys:[],debounceTime:null,throttleTime:null};for(var i in e)!(i in this.options)&&(this.options[i]=e[i]);this.sizes=new Map,this.range={start:0,end:0,front:0,behind:0},this.offset=0,this.calcType=_,this.calcSize={average:0,total:0,fixed:0},this.scrollEl=this.getScrollElement(t.scroller),this.scrollDir="",this.updateOnScrollFunction(),this.addScrollEventListener(),this.checkIfUpdate(0,t.keeps-1)}R.prototype={constructor:R,isFront:function(){return this.scrollDir===O},isBehind:function(){return this.scrollDir===z},isFixed:function(){return this.calcType===T},getSize:function(t){return this.sizes.get(t)||this.getItemSize()},getOffset:function(){return this.scrollEl[A[this.options.direction]]},getScrollSize:function(){return this.scrollEl[M[this.options.direction]]},getClientSize:function(){return this.scrollEl[B[this.options.direction]]},scrollToOffset:function(t){this.scrollEl[A[this.options.direction]]=t},scrollToIndex:function(t){if(t>=this.options.uniqueKeys.length-1)this.scrollToBottom();else{var e=this.getOffsetByIndex(t),i=this.getScrollStartOffset();this.scrollToOffset(e+i)}},scrollToBottom:function(){var t=this,e=this.getScrollSize();this.scrollToOffset(e),setTimeout((function(){var e=t.getClientSize(),i=t.getScrollSize();t.getOffset()+e+1<i&&t.scrollToBottom()}),5)},option:function(t,e){var i=this,n=this.options[t];this.options[t]=e,"uniqueKeys"===t&&this.sizes.forEach((function(t,n){e.includes(n)||i.sizes.delete(n)})),"scroller"===t&&(n&&h.utils.off(n,"scroll",this.onScroll),this.scrollEl=this.getScrollElement(e),this.addScrollEventListener())},updateRange:function(t){if(t)this.handleUpdate(t.start,t.end);else{var e=this.range.start;e=Math.max(e,0),this.handleUpdate(e,this.getEndByStart(e))}},onItemResized:function(t,e){this.sizes.set(t,e),this.calcType===_?(this.calcType=T,this.calcSize.fixed=e):this.isFixed()&&this.calcSize.fixed!==e&&(this.calcType=E,this.calcSize.fixed=void 0),this.calcType!==T&&(this.calcSize.total=s(this.sizes.values()).reduce((function(t,e){return t+e}),0),this.calcSize.average=Math.round(this.calcSize.total/this.sizes.size))},addScrollEventListener:function(){this.options.scroller&&h.utils.on(this.options.scroller,"scroll",this.onScroll)},removeScrollEventListener:function(){this.options.scroller&&h.utils.off(this.options.scroller,"scroll",this.onScroll)},updateOnScrollFunction:function(){var t=this,e=this.options,i=e.debounceTime,n=e.throttleTime;this.onScroll=i?p((function(){return t.handleScroll()}),i):n?f((function(){return t.handleScroll()}),n):function(){return t.handleScroll()}},handleScroll:function(){var t=this.getOffset(),e=this.getClientSize(),i=this.getScrollSize();t===this.offset?this.scrollDir=D:this.scrollDir=t<this.offset?O:z,this.offset=t;var n=this.isFront()&&t<=0,o=this.isBehind()&&e+t>=i;this.options.onScroll({top:n,bottom:o,offset:t,direction:this.scrollDir}),this.isFront()?this.handleScrollFront():this.isBehind()&&this.handleScrollBehind()},handleScrollFront:function(){var t=this.getScrollItems();if(!(t>this.range.start)){var e=Math.max(t-this.options.buffer,0);this.checkIfUpdate(e,this.getEndByStart(e))}},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=0,i=this.options.uniqueKeys.length,n=0,o=0;e<=i;){if(n=e+Math.floor((i-e)/2),(o=this.getOffsetByIndex(n))===t)return n;o<t?e=n+1:o>t&&(i=n-1)}return e>0?--e: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(o({},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,i=t.keeps;return e.length>0?e.length-1:i-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?document.scrollingElement||document.documentElement||document.body:t},getScrollStartOffset:function(){var t=0,e=this.options,i=e.wrapper,n=e.scroller;if(i&&i){var o=h.utils.getRect(i,!0,n);t=this.offset+o[k[this.options.direction]]}return t}};var N={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.$emit("resized",this.dataKey,this.getCurrentSize())},getCurrentSize:function(){return this.$el?this.$el[this.sizeKey]:0}}},P=i.default.component("virtual-draglist-items",{mixins:[N],props:d,render:function(t){var e=this.tag,i=this.dataKey;return t(e,{key:i,attrs:{"data-key":i}},this.$slots.default)}});return i.default.component("virtual-drag-list",{model:{prop:"dataSource",event:"updateDataSource"},props:u,data:function(){return{list:[],range:{start:0,end:0,front:0,behind:0},virtual:null,sortable:null,lastLength:null,uniqueKeys:[]}},computed:{isHorizontal:function(){return"vertical"!==this.direction},itemSizeKey:function(){return this.isHorizontal?"offsetWidth":"offsetHeight"},virtualAttributes:function(){var t=this;return x.reduce((function(e,i){return e[i]=t[i],e}),{})},sortableAttributes:function(){var t=this;return S.reduce((function(e,i){return e[i]=t[i],e}),{})}},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.option(i,t[i])},deep:!0},sortableAttributes:{handler:function(t,e){if(this.sortable)for(var i in t)t[i]!=e[i]&&this.sortable.option(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.option("wrapper",this.$refs.groupRef),this.scroller||this.virtual.option("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){var e=this.uniqueKeys.indexOf(t);e>-1&&this.virtual.scrollToIndex(e)},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=s(this.list);if(this.list=this.dataSource,this._updateUniqueKeys(),this._updateRange(e,this.list),this.sortable?this.sortable.option("list",this.list):this.$nextTick((function(){return t._initSortable()})),this.lastLength&&this.keepOffset){var i=this.list.length-this.lastLength;i>0&&this.scrollToIndex(i),this.lastLength=null}},_initVirtual:function(){var t=this;this.virtual=new R({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(e){t.lastLength=null,t.list.length&&e.top?t._handleToTop():e.bottom&&t._handleToBottom()},onUpdate:function(e){h.dragged&&e.start!==t.range.start&&(t.sortable.reRendered=!0),t.range=e}})},_initSortable:function(){var t=this;this.sortable=new w(this.$refs.groupRef,o(o({list:this.list,dataKey:this.dataKey},this.sortableAttributes),{},{onDrag:function(e){t.$emit("drag",e)},onAdd:function(e){t.$emit("add",e)},onRemove:function(e){t.$emit("remove",e)},onDrop:function(e){e.changed&&t.$emit("updateDataSource",e.list),t.$emit("drop",e)}}))},_updateRange:function(t,e){var i=o({},this.range);e.length>t.length&&this.range.end===t.length-1&&this._scrolledToBottom()&&(i.end++,i.start=Math.max(0,i.end-this.keeps+1)),this.virtual.updateRange(i)},_scrolledToBottom:function(){return this.getOffset()+this.getClientSize()+1>=this.getScrollSize()},_handleToTop:p((function(){this.$emit("top"),this.lastLength=this.list.length})),_handleToBottom:p((function(){this.$emit("bottom")})),_onItemResized:function(t,e){var i=this.virtual.sizes.size;this.virtual.onItemResized(t,e),0===i&&this._updateRange(this.list,this.list)},_updateUniqueKeys:function(){var t=this;this.uniqueKeys=this.list.map((function(e){return m(e,t.dataKey)})),this.virtual.option("uniqueKeys",this.uniqueKeys)},_getItemStyle:function(t){var e;return t==(null===(e=h.dragged)||void 0===e?void 0:e.dataset.key)?{display:"none"}:{}},_renderItems:function(t){for(var e=[],i=this.range,n=i.start,r=i.end,s=n;s<=r;s++){var l=this.list[s];if(l){var a=m(l,this.dataKey),c=o(o({},this.itemStyle),this._getItemStyle(a));e.push(this.$scopedSlots.item?t(P,{key:a,props:{dataKey:a,tag:this.itemTag,sizeKey:this.itemSizeKey},on:{resized:this._onItemResized},style:c,class:this.itemClass},this.$scopedSlots.item({record:l,index:s,dataKey:a})):null)}}return e}},render:function(t){var e=this.range,i=e.front,n=e.behind,r=this.isHorizontal,s=this.rootTag,l=this.wrapTag,a=r?"0px ".concat(n,"px 0px ").concat(i,"px"):"".concat(i,"px 0px ").concat(n,"px");return t(s,{ref:"rootRef",style:!this.scroller&&{overflow:r?"auto hidden":"hidden auto"}},[this.$slots.header,t(l,{ref:"groupRef",class:this.wrapClass,style:o(o({},this.wrapStyle),{},{padding:a})},this._renderItems(t)),this.$slots.footer])}})})); |
{ | ||
"name": "vue-virtual-draglist", | ||
"version": "2.8.4", | ||
"version": "2.8.5", | ||
"description": "A virtual scrolling list component that can be sorted by dragging", | ||
@@ -12,4 +12,3 @@ "main": "dist/virtual-drag-list.min.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rollup --config", | ||
"updateSubtree": "git subtree pull --prefix=src/core https://github.com/mfuu/virtual-dnd-list-core.git master --squash" | ||
"build": "rollup --config" | ||
}, | ||
@@ -41,3 +40,3 @@ "repository": { | ||
"dependencies": { | ||
"sortable-dnd": "0.6.3" | ||
"sortable-dnd": "0.6.6" | ||
}, | ||
@@ -48,2 +47,6 @@ "devDependencies": { | ||
"@babel/preset-env": "^7.8.7", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@vue/compiler-sfc": "^3.2.26", | ||
@@ -58,8 +61,3 @@ "babel-core": "^7.0.0-bridge.0", | ||
"prettier": "^2.8.4", | ||
"rollup": "^1.32.1", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"uglifyjs-webpack-plugin": "^2.2.0", | ||
"rollup": "^2.79.1", | ||
"vue": "^2.6.14", | ||
@@ -66,0 +64,0 @@ "vue-loader": "^17.2.2", |
@@ -25,10 +25,9 @@ # vue-virtual-draglist | ||
:handle="'#handle'" // use id | ||
:data-source="list" // or replace with `v-model` | ||
--> | ||
<virtual-drag-list | ||
<virtual-list | ||
v-model="list" | ||
:data-key="'id'" | ||
:handle="'.handle'" | ||
@top="handleToTop" | ||
@bottom="handleToBottom" | ||
@top="toTop" | ||
@bottom="toBottom" | ||
@drag="onDrag" | ||
@@ -49,3 +48,3 @@ @drop="onDrop" | ||
</template> | ||
</virtual-drag-list> | ||
</virtual-list> | ||
</div> | ||
@@ -55,17 +54,17 @@ </template> | ||
<script> | ||
import virtualDragList from 'vue-virtual-draglist' | ||
import virtualList from 'vue-virtual-draglist'; | ||
export default { | ||
name: 'root', | ||
components: { virtualDragList }, | ||
components: { virtualList }, | ||
data () { | ||
return { | ||
list: [{id: '1', text: 'asd'}, {id: '2', text: 'fgh'}, ...] | ||
list: [{ id: '1', text: 'a' }, { id: '2', text: 'b' }, ...]; | ||
} | ||
}, | ||
methods: { | ||
handleToTop() { | ||
toTop() { | ||
// code here | ||
}, | ||
handleToBottom() { | ||
toBottom() { | ||
// code here | ||
@@ -76,4 +75,6 @@ }, | ||
}, | ||
onDrop({ list, from, to, changed }) { | ||
// code here | ||
onDrop(params) { | ||
if (params.changed) { | ||
// list item position changed | ||
} | ||
}, | ||
@@ -94,8 +95,8 @@ onAdd({ item, key, index }) { | ||
|--------------|-----------------| | ||
| `top` | Event fired when scroll to top | | ||
| `bottom` | Event fired when scroll to bottom | | ||
| `drag` | Event fired when the drag is started | | ||
| `drop` | Event fired when the drag is completed | | ||
| `add` | Event fired when element is dropped into the list from another | | ||
| `remove` | Event fired when element is removed from the list into another | | ||
| `top` | scrolled to top | | ||
| `bottom` | scrolled to bottom | | ||
| `drag` | drag is started | | ||
| `drop` | drag is completed | | ||
| `add` | element is dropped into the list from another | | ||
| `remove` | element is removed from the list into another | | ||
@@ -122,4 +123,5 @@ ## Props | ||
| `keepOffset` | `Boolean` | `false` | When scrolling up to load data, keep the same offset as the previous scroll | | ||
| `direction` | `String` | `vertical` | `vertical/horizontal`, scroll direction | | ||
| `scroller` | `HTMLElement` | `-` | Virtual list scrolling element | | ||
| `direction` | `vertical \| horizontal` | `vertical` | Scroll direction | | ||
| `scroller` | `Document \| HTMLElement` | `-` | Virtual list scrolling element | | ||
| `lockAxis` | `x \| y` | `-` | Axis on which dragging will be locked | | ||
| `debounceTime` | `Number` | `0` | debounce time on scroll | | ||
@@ -144,6 +146,2 @@ | `throttleTime` | `Number` | `0` | throttle time on scroll | | ||
| `itemTag` | `String` | `div` | Label type for list item element | | ||
| `headerTag` | `String` | `div` | Label type for header slot element | | ||
| `headerStyle`| `Object` | `{}` | Header slot element style | | ||
| `footerTag` | `String` | `div` | Label type for footer slot element | | ||
| `footerStyle`| `Object` | `{}` | Footer slot element style | | ||
| `wrapClass` | `String` | `''` | List wrapper element class | | ||
@@ -150,0 +148,0 @@ | `wrapStyle` | `Object` | `{}` | List wrapper element style | |
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
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
117241
20
2068
164
+ Addedsortable-dnd@0.6.6(transitive)
- Removedsortable-dnd@0.6.3(transitive)
Updatedsortable-dnd@0.6.6