uk-dnd
Version:
It is a uikit drag and drop component for vue.
1 lines • 9.46 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("uk-dnd",[],t):"object"==typeof exports?exports["uk-dnd"]=t():e["uk-dnd"]=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1);t.default=o.a},function(e,t,n){"use strict";function o(e){i||n(2)}var r=n(8),s=n(9),i=!1,d=n(7),a=o,u=d(r.a,s.a,a,"data-v-1952df7c",null);u.options.__file="src/uk-dnd.vue",u.esModule&&Object.keys(u.esModule).some(function(e){return"default"!==e&&"__"!==e.substr(0,2)})&&console.error("named exports are not supported in *.vue files."),u.options.functional&&console.error("[vue-loader] uk-dnd.vue: functional components are not supported with templates, they should use render functions."),t.a=u.exports},function(e,t,n){var o=n(3);"string"==typeof o&&(o=[[e.i,o,""]]),o.locals&&(e.exports=o.locals);n(5)("7afc0586",o,!1)},function(e,t,n){t=e.exports=n(4)(void 0),t.push([e.i,"\n.uk-draggable[data-v-1952df7c] {\n position: absolute;\n box-sizing: border-box;\n cursor: move;\n}\n",""])},function(e,t){function n(e,t){var n=e[1]||"",r=e[3];if(!r)return n;if(t&&"function"==typeof btoa){var s=o(r);return[n].concat(r.sources.map(function(e){return"/*# sourceURL="+r.sourceRoot+e+" */"})).concat([s]).join("\n")}return[n].join("\n")}function o(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var o=n(t,e);return t[2]?"@media "+t[2]+"{"+o+"}":o}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var o={},r=0;r<this.length;r++){var s=this[r][0];"number"==typeof s&&(o[s]=!0)}for(r=0;r<e.length;r++){var i=e[r];"number"==typeof i[0]&&o[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]="("+i[2]+") and ("+n+")"),t.push(i))}},t}},function(e,t,n){function o(e){for(var t=0;t<e.length;t++){var n=e[t],o=l[n.id];if(o){o.refs++;for(var r=0;r<o.parts.length;r++)o.parts[r](n.parts[r]);for(;r<n.parts.length;r++)o.parts.push(s(n.parts[r]));o.parts.length>n.parts.length&&(o.parts.length=n.parts.length)}else{for(var i=[],r=0;r<n.parts.length;r++)i.push(s(n.parts[r]));l[n.id]={id:n.id,refs:1,parts:i}}}}function r(){var e=document.createElement("style");return e.type="text/css",c.appendChild(e),e}function s(e){var t,n,o=document.querySelector('style[data-vue-ssr-id~="'+e.id+'"]');if(o){if(h)return m;o.parentNode.removeChild(o)}if(v){var s=p++;o=f||(f=r()),t=i.bind(null,o,s,!1),n=i.bind(null,o,s,!0)}else o=r(),t=d.bind(null,o),n=function(){o.parentNode.removeChild(o)};return t(e),function(o){if(o){if(o.css===e.css&&o.media===e.media&&o.sourceMap===e.sourceMap)return;t(e=o)}else n()}}function i(e,t,n,o){var r=n?"":o.css;if(e.styleSheet)e.styleSheet.cssText=g(t,r);else{var s=document.createTextNode(r),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(s,i[t]):e.appendChild(s)}}function d(e,t){var n=t.css,o=t.media,r=t.sourceMap;if(o&&e.setAttribute("media",o),r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var a="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!a)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var u=n(6),l={},c=a&&(document.head||document.getElementsByTagName("head")[0]),f=null,p=0,h=!1,m=function(){},v="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,t,n){h=n;var r=u(e,t);return o(r),function(t){for(var n=[],s=0;s<r.length;s++){var i=r[s],d=l[i.id];d.refs--,n.push(d)}t?(r=u(e,t),o(r)):r=[];for(var s=0;s<n.length;s++){var d=n[s];if(0===d.refs){for(var a=0;a<d.parts.length;a++)d.parts[a]();delete l[d.id]}}}};var g=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t){e.exports=function(e,t){for(var n=[],o={},r=0;r<t.length;r++){var s=t[r],i=s[0],d=s[1],a=s[2],u=s[3],l={id:e+":"+r,css:d,media:a,sourceMap:u};o[i]?o[i].parts.push(l):n.push(o[i]={id:i,parts:[l]})}return n}},function(e,t){e.exports=function(e,t,n,o,r){var s,i=e=e||{},d=typeof e.default;"object"!==d&&"function"!==d||(s=e,i=e.default);var a="function"==typeof i?i.options:i;t&&(a.render=t.render,a.staticRenderFns=t.staticRenderFns),o&&(a._scopeId=o);var u;if(r?(u=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},a._ssrRegister=u):n&&(u=n),u){var l=a.functional,c=l?a.render:a.beforeCreate;l?a.render=function(e,t){return u.call(t),c(e,t)}:a.beforeCreate=c?[].concat(c,u):[u]}return{esModule:s,exports:i,options:a}}},function(e,t,n){"use strict";t.a={name:"uk-dnd",props:{x:{type:[String,Number],default:0,validator:function(e){return!isNaN(e)}},y:{type:[String,Number],default:0,validator:function(e){return!isNaN(e)}},width:{type:[String,Number],default:"auto",validator:function(e){return"auto"===e||!isNaN(e)&&parseFloat(e)>0||/^\d+(\.\d+)?vw|%|cm|mm|in|px$/.test(e)&&parseFloat(e)>0}},height:{type:[String,Number],default:"auto",validator:function(e){return"auto"===e||!isNaN(e)&&parseFloat(e)>0||/^\d+(\.\d+)?vh|%|cm|mm|in|px$/.test(e)&&parseFloat(e)>0}},target:{type:String,default:null,validator:function(e){return/^(#|\.)/.test(e)&&e.length>1}}},data:function(){return{id:"dnd-"+Date.now(),left:parseInt(this.x),top:parseInt(this.y),w:this.width,h:this.height,zIndex:1,$clonedNode:null}},computed:{dndZone:function(){if(this.target&&this.target.length>1){if(/^#/.test(this.target)){var e=document.getElementById(this.target.substring(1));return"auto"!=e.style.overflow&&"scroll"!=e.style.overflow&&(e.style.overflow="auto"),e}if(/^\./.test(this.target)){var t=document.getElementsByClassName(this.target.substring(1));if(t.length)return"auto"!=t[0].style.overflow&&"scroll"!=t[0].style.overflow&&(t[0].style.overflow="auto"),t[0]}}return null},style:function(){return{top:this.top+"px",left:this.left+"px",width:isNaN(this.w)?this.w:this.w+"px",height:isNaN(this.h)?this.h:this.h+"px",zIndex:this.zIndex}}},mounted:function(){var e=window.getComputedStyle(this.$el,null);this.w=parseFloat(e.getPropertyValue("width")),this.h=parseFloat(e.getPropertyValue("height"))},methods:{dragstart:function(e){if(document.documentElement.addEventListener("mousemove",this.drag,!0),document.documentElement.addEventListener("mouseup",this.dragend,!0),document.documentElement.addEventListener("mouseleave",this.dragend,!1),this.dndZone&&this.dndZone!=this.$el.parentNode){document.documentElement.style.cursor="grabbing";var t=this.$el.parentNode;this.$clonedNode=this.$el.cloneNode(!0),this.$clonedNode.style.opacity=.6,this.$clonedNode.style.zIndex=1e3,this.$clonedNode.style.cursor="grabbing",t.appendChild(this.$clonedNode)}else document.documentElement.style.cursor="move",this.zIndex+=1},drag:function(e){if(this.$clonedNode)this.$clonedNode.style.top=parseInt(this.$clonedNode.style.top)+e.movementY+"px",this.$clonedNode.style.left=parseInt(this.$clonedNode.style.left)+e.movementX+"px";else{var t=this.left+e.movementX,n=this.top+e.movementY;(!this.dndZone||t>=0)&&(this.left=t),(!this.dndZone||n>=0)&&(this.top=n),this.$emit("drag",e,t,n,this.w,this.h)}},dragend:function(e){if(document.documentElement.removeEventListener("mousemove",this.drag,!0),document.documentElement.removeEventListener("mouseup",this.dragend,!0),document.documentElement.removeEventListener("mouseleave",this.dragend,!1),document.documentElement.style.cursor="auto",this.$clonedNode){this.$clonedNode.parentNode.removeChild(this.$clonedNode);var t=parseInt(this.$clonedNode.style.left),n=parseInt(this.$clonedNode.style.top),o=this.$el.parentNode.getBoundingClientRect(),r=this.dndZone.getBoundingClientRect(),s=t+(o.x-r.x)+this.dndZone.scrollLeft,i=n+(o.y-r.y)+this.dndZone.scrollTop;s>=0&&i>=0&&this.$emit("drop-to-target",s,i,this.w,this.h,this.$slots.default),this.$clonedNode=null}else this.zIndex-=1}},beforeDestroy:function(){document.documentElement.removeEventListener("mousemove",this.drag,!0),document.documentElement.removeEventListener("mouseup",this.dragend,!0),document.documentElement.removeEventListener("mouseleave",this.dragend,!1)}}},function(e,t,n){"use strict";var o=function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{staticClass:"uk-draggable",style:e.style,attrs:{id:e.id},on:{mousedown:function(t){t.stopPropagation(),t.preventDefault(),e.dragstart(t)}}},[e._t("default")],2)},r=[];o._withStripped=!0;var s={render:o,staticRenderFns:r};t.a=s}])});