UNPKG

vue-smooth-dnd

Version:
2 lines (1 loc) 2.92 kB
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("smooth-dnd")):"function"==typeof define&&define.amd?define(["exports","smooth-dnd"],n):n(t.VueSmoothDnd={},t.SmoothDnD)}(this,function(t,n){"use strict";var e=function(t){return"[object Array]"===Object.prototype.toString.call(t)};function r(t,n){var r=t.$props.tag;if(r){if("string"==typeof r){var o={value:r};return n&&(o.props={class:n}),o}if("object"==typeof r){var a={value:r.value||"div",props:r.props||{}};return n&&(a.props.class?e(a.props.class)?a.props.class.push(n):a.props.class=[n,a.props.class]:a.props.class=n),a}}return{value:"div"}}function o(t){return!t||("string"==typeof t||"object"==typeof t&&("string"==typeof t.value||"function"==typeof t.value||"object"==typeof t.value))}n.smoothDnD.dropHandler=n.dropHandlers.reactDropHandler().handler,n.smoothDnD.wrapChild=!1;var a={"drag-start":"onDragStart","drag-end":"onDragEnd",drop:"onDrop","drag-enter":"onDragEnter","drag-leave":"onDragLeave","drop-ready":"onDropReady"};var i=function(t){return function(t,n){return Object.keys(t).reduce(function(e,r){var o=r,i=t[o];return void 0!==i&&("function"==typeof i?a[o]?e[a[o]]=function(t){n.$emit(o,t)}:e[o]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return i.apply(void 0,t)}:e[o]=i),e},{})}(Object.assign({},t.$props,t.$listeners),t)},s={name:"Container",mounted:function(){this.containerElement=this.$refs.container||this.$el,this.container=n.smoothDnD(this.containerElement,i(this))},updated:function(){if(this.$refs.container!==this.containerElement&&this.$el!==this.containerElement)return this.container&&this.container.dispose(),this.containerElement=this.$refs.container||this.$el,void(this.container=n.smoothDnD(this.containerElement,i(this)));this.container.setOptions(i(this))},destroyed:function(){this.container&&this.container.dispose()},props:{behaviour:String,groupName:String,orientation:String,dragHandleSelector:String,nonDragAreaSelector:String,dragBeginDelay:Number,animationDuration:Number,autoScrollEnabled:{type:Boolean,default:!0},lockAxis:String,dragClass:String,dropClass:String,removeOnDropOut:{type:Boolean,default:!1},"drag-start":Function,"drag-end":Function,drop:Function,getChildPayload:Function,shouldAnimateDrop:Function,shouldAcceptDrop:Function,"drag-enter":Function,"drag-leave":Function,tag:{validator:o,default:"div"},getGhostParent:Function,"drop-ready":Function,dropPlaceholder:[Object,Boolean]},render:function(t){var n=r(this);return t(n.value,Object.assign({},{ref:"container"},n.props),this.$slots.default)}},c={name:"Draggable",props:{tag:{validator:o,default:"div"}},render:function(t){return function(t,e){var o=r(e,n.constants.wrapperClass);return t(o.value,Object.assign({},o.props),e.$slots.default)}(t,this)}};Object.keys(n).forEach(function(e){t[e]=n[e]}),t.Container=s,t.Draggable=c,Object.defineProperty(t,"__esModule",{value:!0})});