UNPKG

@persagy2/meri-design

Version:

fork from meri-design and extend it.

7 lines 26.1 kB
/*! * @@persagy2/meri-design v1.4.9-extend.2 * (c) 2019-2020 xiongshuang * Released under the MIT License. * 2022-12-07 10:31:52 */ var t,e;t=this,e=function(t){return function(){"use strict";var e={7488:function(t,e,i){i.d(e,{default:function(){return h}});var n=i(2205),r=i.n(n),o=i(3114),a=i(5171),s={name:"PopoverTip",props:{parent:{type:Object,default:function(){return{}}},show:{type:Boolean,default:!1},content:{type:String,default:""},position:{type:Boolean,default:!0},split:{type:Boolean,default:!0}},computed:{contentArr:function(){var t=this;return this.content.split("、").map((function(e,i){return{id:"content-".concat(i),text:e,scroll:e.length>32?t.getScrollWidth(e):0}}))}},methods:{getScrollWidth:function(t){var e=document.createElement("div");e.innerText=t,e.style.position="absolute",e.style.left="0",e.style.bottom="0",e.style.zIndex="-100",e.style.display="inline-block",e.style.height="0",e.style.opacity="0",e.style.overflow="hidden",e.style.whiteSpace="nowrap",e.style.fontSize="14px",document.body.appendChild(e);var i=e.scrollWidth;return(0,o.Z)()?e.removeNode(!0):e.remove(),i>452?i-452:0},popoverTipHandle:function(t){this.$emit("tipHandle",t)},contentEnter:function(){this.split||(this.show=!1)}}},l=(0,i(1900).Z)(s,(function(){var t=this,e=t._self._c;return e("transition",{attrs:{name:t.position?"selectDownUpExtend":"selectDownUpExtendTop"}},[e("div",{directives:[{name:"show",rawName:"v-show",value:t.show,expression:"show"}],class:["p-popover-tip",t.split?"p-popover-tip-split":"p-popover-tip-words",t.position?"p-popover-tip-bottom":"p-popover-tip-top"],on:{wheel:function(t){t.stopPropagation()},mouseenter:function(e){return t.popoverTipHandle("enter")},mouseleave:function(e){return t.popoverTipHandle("leave")}}},[e("section",{staticClass:"p-popover-tip-content",on:{mouseenter:t.contentEnter}},[t.split?t._l(t.contentArr,(function(i){return e("article",{key:i.id,class:["p-popover-tip-content-item",i.scroll&&"p-popover-tip-content-item-before"]},[e("span",{staticClass:"p-popover-tip-item-text",style:i.scroll&&{transform:"translateX(".concat(-i.scroll,"px)")}},[t._v(t._s(i.text))])])})):[e("article",{staticClass:"p-popover-tip-content-words"},[t._v(t._s(t.content))])]],2),t._v(" "),e("section",{staticClass:"p-popover-tip-triangle"})])])}),[],!1,null,null,null).exports,c=i(4597),d=r().extend(l),p=null,u=function(t){var e=t.propsData;if(e.content){var i=t.tag,n=t.countTag,r=document.body;return(p=(p=new d({propsData:e})).$mount()).tag=i,p.countTag=n,p.dom=r,r.appendChild(p.$el),p}};u.remove=a.Z,u.resetPosition=function(t){if(t.content){var e=window,i=e.innerWidth,n=e.pageXOffset,r=t.tag,a=t.countTag,s=t.dom,l=r.getBoundingClientRect(),d=l.left,p=l.width,u=a.getBoundingClientRect(),h=u.left,f=u.width;if(!(i<=h+f/2||i<=f||h<0)){var g=function(t){var e=t.content,i=t.split,n=e.split("、"),r=document.body,a=document.createElement("div");a.className="p-popover-tip",a.style.left="0",a.style.bottom="0",a.style.opacity="0",a.style.zIndex="-100";var s='<section class="p-popover-tip-content">';i?n.forEach((function(t){s+='<article class="p-popover-tip-content-item"><span class="p-popover-tip-item-text">'.concat(t,"</span></article>")})):s+='<article class="p-popover-tip-content-words">'.concat(e,"</article>"),s+="</section>",a.innerHTML=s,r.appendChild(a);var l=a.getBoundingClientRect(),d=l.width,p=l.height;return(0,o.Z)()?a.removeNode(!0):a.remove(),{width:d,height:p,scrollWidth:(0,c.Z)()}}(t),v=g.width,m=g.height,y=g.scrollWidth,x=function(t,e,i){var n,r=e.clientHeight,o=window.pageYOffset,a=t.getBoundingClientRect(),s=a.top,l=a.height,c=!0,d=s-8;return d>=i?(n=d-i+o,c=!1):n=r-(s+l+8)>=i?s+l+8+o:r-i+o,{Y:n,P:c}}(r,s,m),w=x.Y,S=x.P;t.position=S,t.$el.style.top="".concat(w,"px");var C,T=t.$el.lastChild,b=0;if(v===i)n>0&&(b=0),C=h+f/2-6;else{if(0===d)b=0;else{var _=h+f/2,B=v/2;b=_<B?0:v<=p?v<=i-d?_-B:i-v:_>=B?i-_<=B?i-v-y:_-B:0}C=h-b+f/2-6}t.$el.style.left="".concat(b+n,"px"),T.style.left="".concat(C,"px"),t.show=!0}}};var h=u},4597:function(t,e,i){var n=i(3114);e.Z=function(){var t=document.createElement("div");t.style.cssText="position:absolute;top:-1000px;width:100px;height:100px;overflow:hidden;opacity:0;";var e=document.body.appendChild(t).clientWidth;t.style.overflowY="scroll";var i=t.clientWidth;(0,n.Z)()?t.removeNode(!0):t.remove();var r=e-i;return r<6?6:r}},3114:function(t,e){e.Z=function(){return!!window.ActiveXObject||"ActiveXObject"in window}},5171:function(t,e){e.Z=function(t){if(t&&!t._isDestroyed){t.$destroy();var e=t.$el;e&&e.parentNode.removeChild(e)}}},1900:function(t,e,i){function n(t,e,i,n,r,o,a,s){var l,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=i,c._compiled=!0),n&&(c.functional=!0),o&&(c._scopeId="data-v-"+o),a?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},c._ssrRegister=l):r&&(l=s?function(){r.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:r),l)if(c.functional){c._injectStyles=l;var d=c.render;c.render=function(t,e){return l.call(e),d(t,e)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,l):[l]}return{exports:t,options:c}}i.d(e,{Z:function(){return n}})},2205:function(e){e.exports=t}},i={};function n(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return function(){n.r(r),n.d(r,{default:function(){return H}});var t=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0,i=function t(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;return i.map((function(i){return i.checked=i.checked||"uncheck",i.disabled=!!i.disabled,i.floor=n,n>e&&(e=n),i.children&&i.children.length>0&&(i.children=t(i.children,n+1)),i}))},n=i(t,0);return{max:e+1,data:n}},e=n(1900),i=(0,e.Z)({},(function(){var t=this._self._c;return t("svg",{attrs:{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},[t("path",{staticClass:"svg-fill-grey-500",attrs:{d:"\r\n M8.3904344,6.48804301\r\n L11.350122,10.1876525\r\n C11.5226268,10.4032834 11.4876661,10.7179296 11.2720351,10.8904344\r\n C11.1833786,10.9613596 11.0732233,11 10.9596876,11\r\n L5.04031242,11\r\n C4.76417005,11 4.54031242,10.7761424 4.54031242,10.5\r\n C4.54031242,10.3864643 4.5789528,10.276309 4.64987802,10.1876525\r\n L7.6095656,6.48804301\r\n C7.78207037,6.27241204 8.09671656,6.23745135 8.31234752,6.40995612\r\n C8.34117988,6.43302201 8.36736852,6.45921065 8.3904344,6.48804301\r\n Z",transform:"translate(0, -0.5)"}})])}),[],!1,null,null,null).exports,o=(0,e.Z)({},(function(){var t=this._self._c;return t("svg",{attrs:{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},[t("g",{attrs:{stroke:"none","stroke-width":"1","fill-rule":"evenodd"}},[t("path",{staticClass:"svg-fill-grey-500",attrs:{d:"M8,1 C4.134375,1 1,4.134375 1,8 C1,11.865625 4.134375,15 8,15 C11.865625,15 15,11.865625 15,8 C15,4.134375 11.865625,1 8,1 Z M10.784375,9.6375 C11.040625,9.89375 11.040625,10.309375 10.784375,10.565625 C10.528125,10.821875 10.1125,10.821875 9.85625,10.565625 L8,8.709375 L6.14375,10.565625 C5.8875,10.821875 5.471875,10.821875 5.215625,10.565625 C4.959375,10.309375 4.959375,9.89375 5.215625,9.6375 L7.071875,7.78125 L5.215625,5.925 C4.959375,5.66875 4.959375,5.253125 5.215625,4.996875 C5.471875,4.740625 5.8875,4.740625 6.14375,4.996875 L8,6.853125 L9.85625,4.996875 C10.1125,4.740625 10.528125,4.740625 10.784375,4.996875 C11.040625,5.253125 11.040625,5.66875 10.784375,5.925 L8.928125,7.78125 L10.784375,9.6375 L10.784375,9.6375 Z"}})])])}),[],!1,null,null,null).exports,a=(0,e.Z)({},(function(){var t=this._self._c;return t("svg",{attrs:{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},[t("g",{attrs:{transform:"translate(8.000000, -9.000000)"}},[t("path",{staticClass:"svg-fill-grey-500",attrs:{transform:"rotate(45.000000)",d:"M11.3849873,11.346892 L11.3849873,3.72784442 L12.9087968,3.72784442 L12.9087968,11.346892 L20.5278444,11.346892 L20.5278444,12.8707016 L12.9087968,12.8707016 L12.9087968,20.4897492 L11.3849873,20.4897492 L11.3849873,12.8707016 L3.76593965,12.8707016 L3.76593965,11.346892 L11.3849873,11.346892 Z"}})])])}),[],!1,null,null,null).exports,s=function(t){var e=t.target,i=e.clientWidth,n=e.scrollWidth;e.title=n>i?e.innerText:""},l=function(t){var e=document.body,i=document.createElement("div");i.className="p-drop-trigger-caption",i.innerText=t,i.style.position="absolute",i.style.zIndex="-1",i.style.left="0",i.style.bottom="0",i.style.height="0px",e.appendChild(i);var n=i.getBoundingClientRect().width,r=Math.ceil(n);return e.removeChild(i),r>98?98:r},c=function(t){if(t instanceof Array&&JSON.stringify(t).length>4){var e=[];return t.forEach((function(t){e.push(t.name)})),e.toString().replace(/,/g,"、")}return""},d=n(4597),p=n(7488),u={name:"DropTrigger",components:{TriangleIcon:i,DeleteIcon:o,CloseIcon:a},props:{width:{type:[String,Number],default:""},type:{type:String,default:"normal"},placeholder:{type:String,default:"请选择"},caption:{type:String,default:""},disabled:{type:Boolean,default:!1},clearHide:{type:Boolean,default:!1},openSearch:{type:Boolean,default:!0},dropSearch:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},selectedData:{type:[Array,Object],default:function(){return{}}},dropShow:{type:Boolean,default:!1},errorText:{type:String,default:""},errorShow:{type:Boolean,default:!1}},data:function(){return{inputText:"",readonlyActive:!0,inputShow:!1,inputStatus:null,captionWidth:0,scrollbarWidth:6,errorTop:0}},computed:{hasColon:function(){var t=this.caption;return t.includes(":")||t.includes(":")},hasSelected:function(){var t=this.multiple,e=this.selectedData,i=JSON.stringify(e).length;return t?i>4:i>2},tabMaxWidth:function(){var t=this.width,e=void 0===t?120:t,i=this.scrollbarWidth;return e-(void 0===i?6:i)-64}},watch:{inputText:function(t,e){var i=this;t!==e&&(this.timerInputText&&clearTimeout(this.timerInputText),this.timerInputText=setTimeout((function(){i.$emit("getInputText",t)}),500))},caption:function(t,e){t!==e&&"tag"!==this.type&&t&&(this.captionWidth=l(t))},dropShow:function(t,e){var i=this;t!==e&&"tag"!==this.type&&(t&&this.popoverTip&&this.clearPopoverTip(),setTimeout((function(){i.inputShow=t,t||(i.inputStatus=null,i.inputText="")}),300))},selectedData:{handler:function(t,e){var i=this,n=JSON.stringify(t);if(n!==JSON.stringify(e)){var r=this.multiple,o=this.type;r&&n.length<=4&&this.popoverTip&&(p.default.remove(this.popoverTip),this.popoverTip=null),this.$nextTick((function(){"tag"===o&&(i.errorTop=i.$el.clientHeight+6)}))}},deep:!0}},mounted:function(){var t=this.caption,e=this.type;t&&(this.captionWidth=l(t)),"tag"===e&&(this.scrollbarWidth=(0,d.Z)())},methods:{TextEllipsis:s,inputHandle:function(t){var e=t.data,i=t.target.value;this.inputStatus=e||i},triangleHandle:function(){this.dropOpenClick("triangle")},delHandle:function(){this.inputStatus=null,this.$emit("delHandle")},focusHandle:function(){this.readonlyActive=!1},blurHandle:function(){this.readonlyActive=!0},dropOpenClick:function(t){this.clearPopoverTip(),this.$emit("click",t)},clearPopoverTip:function(){"tag"===this.type||this.disabled||(this.timerEnter&&clearTimeout(this.timerEnter),p.default.remove(this.popoverTip),this.popoverTip=null)},triggerEnter:function(){var t=this,e=this.type,i=this.disabled,n=this.dropShow,r=this.selectedData;if("tag"!==e&&!i&&!n){var o=c(r);o&&(this.popoverTip?this.timerPopover?this.clearTimer():this.timerEnter=setTimeout((function(){t.popoverTip.content=o,p.default.resetPosition(t.popoverTip),clearTimeout(t.timerEnter),t.timerEnter=null}),500):this.timerEnter=setTimeout((function(){var e=t.$el,i=t.$refs.countTag;t.popoverTip=(0,p.default)({tag:e,countTag:i,propsData:{content:o}}).$on("tipHandle",(function(e){"enter"===e?t.clearTimer():t.setTimer()})),t.popoverTip.$nextTick((function(){p.default.resetPosition(t.popoverTip)})),clearTimeout(t.timerEnter),t.timerEnter=null}),500))}},setTimer:function(){var t=this;this.timerPopover=setTimeout((function(){t.popoverTip.show=!1,t.clearTimer()}),500)},clearTimer:function(){clearTimeout(this.timerPopover),this.timerPopover=null},triggerLeave:function(){"tag"!==this.type&&(this.timerEnter?clearTimeout(this.timerEnter):this.popoverTip&&this.setTimer())},tagCloseHandle:function(t){t.disabled||this.$emit("clearItem",t)}}},h=(0,e.Z)(u,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"p-drop-trigger",class:["p-drop-trigger-".concat(t.type),t.disabled?"p-drop-trigger-disabled":"p-drop-trigger-active",t.errorShow&&"p-trigger-error"],style:{width:"".concat(t.width,"px")}},[e("div",{staticClass:"p-drop-trigger-main",class:["p-drop-trigger-main-".concat(t.type)],on:{click:t.dropOpenClick}},[t.caption?e("div",{staticClass:"p-drop-trigger-caption p-drop-trigger-text-overflow",style:{width:"".concat(t.captionWidth,"px")}},[t._v(t._s(t.caption)+"\n ")]):t._e(),t._v(" "),"normal"===t.type?e("section",{staticClass:"p-drop-trigger-label",class:{"p-drop-trigger-label-pl":t.caption&&!t.hasColon},style:t.captionWidth&&{width:"calc(100% - ".concat(t.captionWidth,"px)")}},[t.inputStatus?t._e():[t.hasSelected?e("span",{staticClass:"p-drop-trigger-selected",class:{"p-drop-trigger-selected-focus":!t.readonlyActive}},[t.multiple?e("span",{staticClass:"p-drop-trigger-selected-m",on:{mouseenter:t.triggerEnter,mouseleave:t.triggerLeave}},[t._v("已选择"),e("span",{ref:"countTag",staticClass:"p-drop-trigger-selected-m-c"},[t._v(t._s(t.selectedData.length))]),t._v("项")]):e("span",{staticClass:"p-drop-trigger-selected-s",on:{mouseenter:t.TextEllipsis}},[t._v(t._s(t.selectedData.name))])]):e("span",{staticClass:"p-drop-trigger-placeholder p-drop-trigger-text-overflow"},[t._v(t._s(t.placeholder))])],t._v(" "),t.openSearch&&!t.disabled&&!t.dropSearch&&t.inputShow?e("input",{directives:[{name:"model",rawName:"v-model",value:t.inputText,expression:"inputText"}],staticClass:"p-drop-trigger-input p-drop-trigger-text-overflow",class:{"p-drop-trigger-input-readonly":t.readonlyActive&&!t.dropShow,"p-drop-trigger-label-pl":t.caption&&!t.hasColon},attrs:{type:"text"},domProps:{value:t.inputText},on:{input:[function(e){e.target.composing||(t.inputText=e.target.value)},t.inputHandle],focus:t.focusHandle,blur:t.blurHandle}}):t._e()],2):[t.selectedData&&JSON.stringify(t.selectedData).length>4?e("div",{staticClass:"p-drop-trigger-main-tag-box",style:{width:"calc(100% - ".concat(t.captionWidth,"px)")}},[e("section",{staticClass:"p-drop-trigger-tag-list"},t._l(t.selectedData,(function(i,n){return e("article",{key:"".concat(i.id,"-").concat(n),staticClass:"p-drop-trigger-tag-list-item"},[e("span",{staticClass:"p-drop-trigger-tag-list-text p-drop-trigger-text-overflow",style:{maxWidth:"".concat(t.tabMaxWidth,"px")},on:{mouseenter:t.TextEllipsis}},[t._v(t._s(i.name))]),t._v(" "),e("i",{staticClass:"p-drop-trigger-tag-list-svg",class:[i.disabled?"p-drop-trigger-tag-list-svg-disabled":"p-drop-trigger-tag-list-svg-normal"],on:{click:function(e){return e.stopPropagation(),t.tagCloseHandle(i)}}},[e("CloseIcon")],1)])})),0)]):e("section",{staticClass:"p-drop-trigger-label",style:{width:"calc(100% - ".concat(t.captionWidth,"px)")}},[e("span",{staticClass:"p-drop-trigger-placeholder p-drop-trigger-text-overflow"},[t._v(t._s(t.placeholder))])])]],2),t._v(" "),e("div",{staticClass:"p-drop-trigger-icon",class:{"p-drop-trigger-icon-clear":!t.clearHide&&t.hasSelected&&!t.disabled}},[e("i",{staticClass:"p-drop-trigger-svg p-drop-trigger-tgl",class:{"p-drop-trigger-tgl-open":!t.dropShow},on:{click:function(e){return e.stopPropagation(),t.triangleHandle.apply(null,arguments)}}},[e("TriangleIcon")],1),t._v(" "),e("i",{staticClass:"p-drop-trigger-svg p-drop-trigger-del",on:{click:function(e){return e.stopPropagation(),t.delHandle.apply(null,arguments)}}},[e("DeleteIcon")],1)]),t._v(" "),t.errorShow?e("span",{staticClass:"p-trigger-error-text",style:t.errorTop&&{top:"".concat(t.errorTop,"px")}},[t._v(t._s(t.errorText))]):t._e()])}),[],!1,null,null,null),f=h.exports,g=n(2205),v=n.n(g),m=function(t,e,i,n,r){var o,a,s=e.clientHeight,l=e.clientWidth,c=window,d=c.pageYOffset,p=c.pageXOffset,u=t.getBoundingClientRect(),h=u.top,f=u.left,g=u.height,v=u.width,m=!0;s-(h+g+8)>=i?o=h+g+8+d:h-8>=i?(o=h-i-8+d,m=!1):o=s-i+d;var y=l-f-v,x=y+v;return a=l<=n?p:f>0?x>=n?f+p:f+v>=n?f+v-n+p+(y>0?0:y):(l-n)/2+p:p,r&&x>=n&&(a=a-n+v),{X:a,Y:o,P:m}},y=n(5171),x=(0,e.Z)({},(function(){var t=this._self._c;return t("svg",{attrs:{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},[t("g",{attrs:{transform:"translate(2.000000, 2.000000)","fill-rule":"nonzero"}},[t("path",{staticClass:"svg-fill-grey-500",attrs:{d:"M8.85127549,5.97990969 L2.91471326,10.5971422 C2.696738,10.766675 2.65746768,11.0808125 2.82700056,11.2987877 C2.99653344,11.516763 3.31067085,11.5560333 3.52864611,11.3865004 L9.9735924,6.37386614 C10.2312596,6.17346241 10.2309143,5.783911 9.97289228,5.58396435 L3.52794599,0.589640623 C3.30967055,0.420494413 2.99560324,0.460321528 2.82645703,0.678596974 C2.65731082,0.896872421 2.69713793,1.21093973 2.91541338,1.38008594 L8.85127549,5.97990969 Z"}})])])}),[],!1,null,null,null).exports,w={name:"UlCascade",props:{trigger:{type:String,default:"hover"},data:{type:Array,default:function(){return[]}},selectedId:{type:[String,Number],default:""},width:{type:[String,Number],default:300}},data:function(){return{}},watch:{},methods:{liClick:function(t){if(!t.disabled){var e=this.trigger,i=t.children;if("click"===e)i&&i.length?this.$emit("change",t,"hover"):this.$emit("change",t,"click");else{if(i&&i.length)return;this.$emit("change",t,"click")}}},liEnter:function(t){var e=this;this.timer&&clearTimeout(this.timer),t.disabled||(this.timer=setTimeout((function(){"click"!==e.trigger&&e.$emit("change",t,"hover")}),300))},ulLeave:function(){this.timer&&clearTimeout(this.timer)}},render:function(t){var e=this.width,i=this.data,n=this.selectedId,r=this.liClick,o=this.liEnter,a=this.ulLeave;return t("div",{class:"m-ul-cascade",style:{width:"".concat(e,"px")},on:{mouseleave:a}},[i.map((function(e){return t("div",{class:["m-li-cascade",n===e.id&&"m-li-cascade-active",e.disabled&&"m-li-cascade-disabled"],on:{click:function(){return r(e)},mouseenter:function(){return o(e)}}},[t("section",{class:"m-li-cascade-name",on:{mouseenter:s}},[e.name]),e.children&&e.children.length&&t("section",{class:"m-li-cascade-arrow"},[t(x)])])}))])}},S={name:"DropCascade",props:{trigger:{type:String,default:"hover"},data:{type:Array,default:function(){return[]}},selectedIds:{type:Array,default:function(){return[]}},width:{type:[String,Number],default:300}},data:function(){return{position:!0,dropShow:!1,activeBlur:!1}},watch:{dropShow:function(t){var e=this;t&&this.$nextTick((function(){e.$el.focus()}))}},methods:{change:function(t,e){this.$emit("change",t,e)},blur:function(){this.activeBlur&&this.$emit("close",!1)},enter:function(){this.activeBlur=!1},leave:function(){var t=this;this.activeBlur=!0,this.$nextTick((function(){t.$el.focus()}))}},render:function(t){var e=this.trigger,i=this.width,n=this.selectedIds,r=this.data,o=this.position,a=this.dropShow,s=this.change,l=this.blur,c=this.enter,d=this.leave;return t("transition",{attrs:{name:o?"selectDownUpExtend":"selectDownUpExtendTop"}},[t("div",{directives:[{name:"show",value:a}],class:["m-drop-cascade","m-drop-cascade-".concat(o?"bottom":"top")],attrs:{tabIndex:"-1"},on:{blur:l,mouseenter:c,mouseleave:d}},[r.map((function(r,o){return r.data&&r.data.length>0&&t(w,{attrs:{trigger:e,width:i,data:r.data,selectedId:n[o]},key:r.ul,on:{change:s}})}))])])}},C=function(t){var e=t.tag,i=t.propsData,n=document.body,r=new(v().extend(S))({propsData:i});return(r=r.$mount()).tag=e,r.dom=n,n.appendChild(r.$el),r};C.remove=y.Z,C.resetPosition=function(t){var e=t.width,i=t.alignRight,n=void 0!==i&&i,r=t.data.filter((function(t){return t.data&&t.data.length})).length*e,o=m(t.tag.$el,t.dom,192,r,n),a=o.X,s=o.Y,l=o.P;t.position=l,t.$el.style.top="".concat(s,"px"),t.$el.style.left="".concat(a,"px"),t.dropShow=!0};var T=C,b=function(t,e){var i;return(null===(i=e[t+1])||void 0===i?void 0:i.id)||""},_=function(t,e){var i;return(null===(i=e[t+1])||void 0===i?void 0:i.name)||""},B=function(t,e){var i;return(null===(i=e[t])||void 0===i?void 0:i.children)||[]},L=function(t,e,i){for(var n=[],r=function(t,e){var i=[{children:e}];return function e(n){n.forEach((function(n){t.includes(n.id)&&(i.push(n),n.children&&n.children.length&&e(n.children))}))}(e),i}(t,i),o=0;o<e;o++)n.push({ul:"ul".concat(o),id:b(o,r),name:_(o,r),data:B(o,r)});return n},$={name:"MCascade",props:{width:{type:[String,Number],default:"120"},dropWidth:{type:[String,Number],default:"300"},caption:{type:String,default:""},placeholder:{type:String,default:"请选择"},disabled:{type:Boolean,default:!1},clearHide:{type:Boolean,default:!1},openSearch:{type:Boolean,default:!0},alignRight:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},trigger:{type:String,default:"hover"},value:{type:Array,default:function(){return[]}},data:{type:Array,default:function(){return[]}},errorText:{type:String,default:""},errorShow:{type:Boolean,default:!1}},data:function(){return{dropShow:!1,dropData:[],selectedData:{},selectedIds:[],selectedIdsHis:[],floor:1,ulList:[],ulListHis:[]}},watch:{data:{handler:function(e){var i=t(JSON.parse(JSON.stringify(e))),n=i.max,r=i.data;this.floor=n,this.dropData=r,this.setUlList(r)},deep:!0,immediate:!0},value:{handler:function(t){this.selectedIds=t,this.selectedIdsHis=JSON.parse(JSON.stringify(t)),this.setUlList(this.dropData)},deep:!0,immediate:!0}},methods:{setUlList:function(t){if(t&&t.length){var e=this.value,i=this.floor,n=L(e,i,t),r=n.map((function(t){return t.name})).filter((function(t){return t}));r&&r.length?this.selectedData={name:r.join("/")}:this.selectedData={},this.ulList=n,this.ulListHis=JSON.parse(JSON.stringify(n))}},getInputText:function(){},openDropHandle:function(){var t=this,e=this.data;if(e&&e.length)if(this.dropShow)this.setCascadeBox(!1);else if(this.cascadeBox)setTimeout((function(){T.resetPosition(t.cascadeBox),t.setCascadeBox(!0)}),100);else{var i=this.multiple,n=this.trigger,r=this.dropShow,o=this.dropWidth,a=this.ulList,s=this.selectedIds,l=this.$refs.dropTrigger;this.cascadeBox=T({tag:l,propsData:{multiple:i,trigger:n,dropShow:r,width:o,data:a,selectedIds:s}}).$on("change",(function(e,i){var n=t.ulList,r=t.floor,o=t,a=e.id,s=e.name,l=e.floor,c=e.children,d=void 0===c?[]:c,p=[],u={setState:function(){n[l].id=a,n[l].name=s;var t=l+1;t!==r&&(n[t].data=d);for(var e=t+1;e<r;e++)n[e].name="",n[e].data=[];if(l>0)for(var i=0;i<=l;i++)p.push(n[i].id);else p.push(a);T.resetPosition(o.cascadeBox)},click:function(){this.setState(),o.$emit("change",p),o.ulListHis=JSON.parse(JSON.stringify(o.ulList)),o.selectedIdsHis=JSON.parse(JSON.stringify(p)),o.selectedData={name:o.ulList.filter((function(t){return p.includes(t.id)})).map((function(t){return t.name})).filter((function(t){return t})).join("/")},o.setCascadeBox(!1)},hover:function(){this.setState()}};t.ulList=n,u[i](),String(p)&&(t.selectedIds=p,t.cascadeBox.selectedIds=p),t.cascadeBox.data=t.ulList})).$on("close",(function(e){t.setCascadeBox(e),setTimeout((function(){t.ulList=JSON.parse(JSON.stringify(t.ulListHis)),t.selectedIds=JSON.parse(JSON.stringify(t.selectedIdsHis)),t.cascadeBox.data=t.ulList,t.cascadeBox.selectedIds=t.selectedIds;var e=t.ulList.filter((function(e){return t.selectedIds.includes(e.id)})).map((function(t){return t.name})).filter((function(t){return t}));e&&e.length?t.selectedData={name:e.join("/")}:t.selectedData={}}),300)})),this.cascadeBox.$nextTick((function(){T.resetPosition(t.cascadeBox),t.setCascadeBox(!0)}))}},setCascadeBox:function(t){this.dropShow=t,this.cascadeBox&&(this.cascadeBox.dropShow=t)},delHandle:function(){this.selectedData={},this.selectedIds=[],this.selectedIdsHis=[],this.ulList=this.ulList.map((function(t,e){return e>0?(t.id="",t.name="",t.data=[]):(t.id="",t.name=""),t})),this.ulListHis=JSON.parse(JSON.stringify(this.ulList)),this.cascadeBox&&(this.cascadeBox.selectedIds=[],this.cascadeBox.data=this.ulList,this.dropShow&&T.resetPosition(this.cascadeBox)),this.$emit("change",[])},enter:function(){this.cascadeBox&&this.dropShow&&(this.cascadeBox.activeBlur=!1)},leave:function(){this.cascadeBox&&this.dropShow&&(this.cascadeBox.activeBlur=!0)}},render:function(t){var e=this.caption,i=this.width,n=this.placeholder,r=this.disabled,o=this.clearHide,a=this.multiple,s=this.errorText,l=this.errorShow,c=this.dropShow,d=this.selectedData,p=this.getInputText,u=this.openDropHandle,h=this.delHandle;return t("div",{class:"m-cascade",on:{mouseenter:this.enter,mouseleave:this.leave}},[t(f,{ref:"dropTrigger",attrs:{caption:e,width:i,placeholder:n,disabled:r,clearHide:o,openSearch:!1,multiple:a,dropShow:c,errorText:s,errorShow:l,selectedData:d},on:{getInputText:p,click:u,delHandle:h}})])},install:function(t){return t.component($.name,$)}},H=$}(),r}()},"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("MCascade",["vue"],e):"object"==typeof exports?exports.MCascade=e(require("vue")):t.MCascade=e(t.Vue);