@persagy2/meri-design
Version:
fork from meri-design and extend it.
7 lines • 28.2 kB
JavaScript
/*!
* @@persagy2/meri-design v1.4.9-extend.2
* (c) 2019-2020 xiongshuang
* Released under the MIT License.
* 2022-12-07 10:32:51
*/
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),o=i.n(n),r=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,r.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),p=o().extend(l),d=null,u=function(t){var e=t.propsData;if(e.content){var i=t.tag,n=t.countTag,o=document.body;return(d=(d=new p({propsData:e})).$mount()).tag=i,d.countTag=n,d.dom=o,o.appendChild(d.$el),d}};u.remove=a.Z,u.resetPosition=function(t){if(t.content){var e=window,i=e.innerWidth,n=e.pageXOffset,o=t.tag,a=t.countTag,s=t.dom,l=o.getBoundingClientRect(),p=l.left,d=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("、"),o=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,o.appendChild(a);var l=a.getBoundingClientRect(),p=l.width,d=l.height;return(0,r.Z)()?a.removeNode(!0):a.remove(),{width:p,height:d,scrollWidth:(0,c.Z)()}}(t),v=g.width,m=g.height,x=g.scrollWidth,y=function(t,e,i){var n,o=e.clientHeight,r=window.pageYOffset,a=t.getBoundingClientRect(),s=a.top,l=a.height,c=!0,p=s-8;return p>=i?(n=p-i+r,c=!1):n=o-(s+l+8)>=i?s+l+8+r:o-i+r,{Y:n,P:c}}(o,s,m),w=y.Y,b=y.P;t.position=b,t.$el.style.top="".concat(w,"px");var S,C=t.$el.lastChild,T=0;if(v===i)n>0&&(T=0),S=h+f/2-6;else{if(0===p)T=0;else{var k=h+f/2,D=v/2;T=k<D?0:v<=d?v<=i-p?k-D:i-v:k>=D?i-k<=D?i-v-x:k-D:0}S=h-T+f/2-6}t.$el.style.left="".concat(T+n,"px"),C.style.left="".concat(S,"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 o=e-i;return o<6?6:o}},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,o,r,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),r&&(c._scopeId="data-v-"+r),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__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},c._ssrRegister=l):o&&(l=s?function(){o.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:o),l)if(c.functional){c._injectStyles=l;var p=c.render;c.render=function(t,e){return l.call(e),p(t,e)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,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 o=i[t];if(void 0!==o)return o.exports;var r=i[t]={exports:{}};return e[t](r,r.exports,n),r.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 o={};return function(){n.r(o),n.d(o,{default:function(){return P}});var t=n(1900),e=(0,t.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,i=(0,t.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,r=(0,t.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,a=function(t){var e=t.target,i=e.clientWidth,n=e.scrollWidth;e.title=n>i?e.innerText:""},s=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,o=Math.ceil(n);return e.removeChild(i),o>98?98:o},l=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""},c=n(4597),p=n(7488),d={name:"DropTrigger",components:{TriangleIcon:e,DeleteIcon:i,CloseIcon:r},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=s(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 o=this.multiple,r=this.type;o&&n.length<=4&&this.popoverTip&&(p.default.remove(this.popoverTip),this.popoverTip=null),this.$nextTick((function(){"tag"===r&&(i.errorTop=i.$el.clientHeight+6)}))}},deep:!0}},mounted:function(){var t=this.caption,e=this.type;t&&(this.captionWidth=s(t)),"tag"===e&&(this.scrollbarWidth=(0,c.Z)())},methods:{TextEllipsis:a,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,o=this.selectedData;if("tag"!==e&&!i&&!n){var r=l(o);r&&(this.popoverTip?this.timerPopover?this.clearTimer():this.timerEnter=setTimeout((function(){t.popoverTip.content=r,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:r}}).$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)}}},u=(0,t.Z)(d,(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),h=u.exports,f=function(t,e,i){var n=t.x,o=t.y,r=e.getBoundingClientRect(),a=r.width,s=r.height,l=r.left,c=r.top;(n<l||n>l+a||o<c||o>c+s)&&i()},g=function(t,e,i){var n=t.split(""),o=e.split("");return n.map((function(t){return o.includes(t)?'<span class="'.concat(i,'">').concat(t,"</span>"):t})).join("")},v=n(2205),m=n.n(v),x=function(t,e,i,n,o){var r,a,s=e.clientHeight,l=e.clientWidth,c=window,p=c.pageYOffset,d=c.pageXOffset,u=t.getBoundingClientRect(),h=u.top,f=u.left,g=u.height,v=u.width,m=!0;s-(h+g+8)>=i?r=h+g+8+p:h-8>=i?(r=h-i-8+p,m=!1):r=s-i+p;var x=l-f-v,y=x+v;return a=l<=n?d:f>0?y>=n?f+d:f+v>=n?f+v-n+d+(x>0?0:x):(l-n)/2+d:d,o&&y>=n&&(a=a-n+v),{X:a,Y:r,P:m}},y=n(5171),w={name:"Checkbox",props:{checked:{type:String,default:"uncheck"},disabled:{type:Boolean,default:!1},stopPropagation:{type:Boolean,default:!1}},methods:{TextEllipsis:a,handleChange:function(t){var e,i=this.disabled,n=this.checked;if(this.stopPropagation&&t.stopPropagation(),!i){var o=this.$el.dataset,r="";r="checked"===n?"uncheck":"checked",null!==(e=this._events)&&void 0!==e&&e.change?this.$emit("change",r,o):this.$emit("update:checked",r)}}}},b=(0,t.Z)(w,(function(){var t=this,e=t._self._c;return e("div",{class:["p-checkbox",t.disabled&&"p-checkbox-disabled"],on:{click:t.handleChange}},[e("i",{class:["p-checkbox-box","p-checkbox-"+t.checked]}),t._v(" "),Object.keys(t.$slots).length?e("span",{staticClass:"p-checkbox-text",on:{mouseenter:t.TextEllipsis}},[t._t("default")],2):t._e()])}),[],!1,null,null,null).exports,S=n(3114),C=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,i=document.createElement("div");i.style.display="inline-block",i.style.position="absolute",i.style.height="0",i.style.fontSize="14px",i.innerText=e,document.body.appendChild(i);var n=i.getBoundingClientRect(),o=n.width,r=Math.ceil(o);return(0,S.Z)()?i.removeNode(!0):i.remove(),r<=t?0:r-t},T={name:"SelectCheckbox",components:{Checkbox:b},props:{data:{type:Array,default:function(){return[]}},childDisable:{type:Boolean,default:!1},width:{type:[String,Number],default:280},textIndent:{type:Boolean,default:!0},stopPropagation:{type:Boolean,default:!1}},data:function(){return{scrollBar:0}},computed:{selectData:{get:function(){var t=this,e=this.data,i=this.textIndent;return JSON.stringify(e).length<4?[]:e.map((function(e){return i&&(e.excess=-t.getTextWidth(e.name)),e}))},set:function(t){return t}}},mounted:function(){this.scrollBar=(0,c.Z)()},methods:{textEllipsis:function(t,e){var i=e.excess,n=e.name;this.textIndent?i&&(t.target.title=n.replace(/<\/?.+?\/?>/g,"")):a(t)},removeOption:function(t){this.selectData=this.selectData.map((function(e){return e.id===t&&(e.checked="uncheck"),e}))},optionClick:function(t,e){var i={},n={};this.selectData=this.selectData.map((function(o){return o.id!==t||o.disabled||(o.checked=e,e.startsWith("c")?i=o:n=o),o})),this.$emit("change",i,n)},change:function(t,e){var i=e.id;this.optionClick(i,t)},getTextWidth:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=/<\/?.+?\/?>/g,i=this.width,n=i-49;return C(n,t.replace(e,""))}}},k=T,D=(0,t.Z)(k,(function(){var t=this,e=t._self._c;return e("div",{directives:[{name:"show",rawName:"v-show",value:t.data&&t.data.length,expression:"data&&data.length"}],staticClass:"p-select-checkbox"},t._l(t.selectData,(function(i,n){return e("div",{key:i.id,staticClass:"p-select-checkbox-item",class:{"p-select-checkbox-disabled":i.disabled}},[e("Checkbox",{key:"".concat(i.id,"-").concat(n),attrs:{checked:i.checked,disabled:i.disabled,stopPropagation:t.stopPropagation,"data-id":i.id},on:{change:t.change}},[e("span",{staticClass:"p-select-checkbox-text",class:{"p-select-checkbox-text-ellipsis-start":i.excess},style:t.textIndent&&{textIndent:"".concat(i.excess-(i.excess&&t.scrollBar),"px")},domProps:{innerHTML:t._s(i.name)},on:{mouseenter:function(e){return t.textEllipsis(e,i)}}})])],1)})),0)}),[],!1,null,null,null).exports;D.install=function(t){return t.component(D.name,D)};var _=D,B={name:"DropBox",props:{width:{type:[String,Number],default:""},alignRight:{type:Boolean,default:!0},multiple:{type:Boolean,default:!1},selectedId:{type:[Number,String,Array]},data:{type:Array,default:function(){return[]}},maxCount:{type:[String,Number],default:5}},data:function(){return{position:!0,dropShow:!1,confirmDisable:!0,selectedData:[],selectedDataHistory:[]}},computed:{dropData:{get:function(){return this.data},set:function(t){return t}}},watch:{dropShow:function(t,e){var i=this;if(t!==e){var n=this.confirmDisable,o=this.selectedDataHistory;t||n||setTimeout((function(){i.selectedData=JSON.parse(JSON.stringify(o)),i.confirmDisable=!0;var t=o.map((function(t){return t.id}));i.dropData=i.data.map((function(e){return t.includes(e.id)?e.checked="checked":e.checked="uncheck",e}))}),300)}}},mounted:function(){var t=this.multiple,e=this.data,i=this.selectedId,n=void 0===i?[]:i,o=t?e.filter((function(t){return n.includes(t.id)})):e.find((function(t){return t.id===n}));o&&(this.selectedData=o,this.selectedDataHistory=JSON.parse(JSON.stringify(o)))},methods:{optionHandle:function(t){if(!t.disabled){var e=JSON.parse(JSON.stringify(t));e.name=e.name.replace(/<[^<>]+>/g,""),this.$emit("change",e)}},change:function(t,e){var i=this.selectedData,n=this.selectedDataHistory,o=[];JSON.stringify(t).length>4?(i.push(t),o=i):o=i.filter((function(t){return t.id!==e.id})),this.selectedData=o;var r=o.map((function(t){return t.id})).sort().join(""),a=n.map((function(t){return t.id})).sort().join("");this.confirmDisable=r||a?r===a:!r||!a},cancel:function(){this.$emit("cancel")},confirm:function(){var t=this.confirmDisable,e=this.selectedData;t||(this.selectedDataHistory=JSON.parse(JSON.stringify(e)),this.confirmDisable=!0,this.$emit("change",e))}},render:function(t){var e=this.width,i=this.position,n=this.dropShow,o=this.maxCount,r=this.selectedId,s=this.multiple,l=this.dropData,c=this.confirmDisable,p=this.change,d=this.optionHandle,u=this.cancel,h=this.confirm;return t("transition",{attrs:{name:i?"selectDownUpExtend":"selectDownUpExtendTop"}},[t("div",{directives:[{name:"show",value:n}],class:["m-drop-box","m-drop-box-shadow-".concat(i?"bottom":"top")],style:{width:"".concat(e,"px")}},[t("div",{class:["m-drop-box-content","m-drop-box-content-".concat(o<=5?"normal":"max")]},[l&&l.length?s?t(_,{attrs:{textIndent:!1,data:l,stopPropagation:!0},on:{change:p}}):l.map((function(e,i){return t("div",{key:"".concat(e.id,"-").concat(i),class:["m-drop-option",e.id===r&&"m-drop-option-selected",e.disabled?"m-drop-option-disabled":"m-drop-option-normal"],on:{click:function(){return d(e)}}},[t("section",{class:"m-drop-option-text",on:{mouseenter:a},domProps:{innerHTML:e.name}})])})):t("div",{class:"m-drop-option-none"},["没有找到任何内容"])]),s&&t("div",{class:["m-drop-handle",l.length>o&&"m-drop-handle-shadow"]},[t("span",{class:"m-drop-btn m-drop-btn-cancel",on:{click:u}},["取消"]),t("span",{class:["m-drop-btn",c?"m-drop-btn-disabled":"m-drop-btn-confirm"],on:{click:h}},["确定"])])])])}},$=m().extend(B),H=null,O=function(t){var e=t.tag,i=t.propsData,n=document.body;return(H=(H=new $({propsData:i})).$mount()).tag=e,H.dom=n,n.appendChild(H.$el),H};O.remove=y.Z,O.resetPosition=function(t){var e,i=t.data,n=void 0===i?[]:i,o=t.width,r=t.alignRight,a=void 0!==r&&r,s=38*n.length+16;e=s<208?s:208;var l=x(t.tag,t.dom,e,o,a),c=l.X,p=l.Y,d=l.P;t.position=d,t.$el.style.top="".concat(p,"px"),t.$el.style.left="".concat(c,"px"),t.dropShow=!0};var E=O,N={name:"MSelect",props:{width:{type:[String,Number],default:"120"},dropWidth:{type:[String,Number],default:"120"},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},value:{type:[Number,String,Array]},data:{type:Array,default:function(){return[]}},maxCount:{type:[String,Number],default:5},errorText:{type:String,default:""},errorShow:{type:Boolean,default:!1}},data:function(){return{activeClose:!0,dropShow:!1,dropData:[],selectedData:[],searchData:[]}},watch:{value:{handler:function(t,e){var i,n,o=this.multiple,r=this.data;if(o){if(String(t)===String(e))return;i=r.filter((function(e){return t.includes(e.id)})),n=r.map((function(e){return t.includes(e.id)?e.checked="checked":e.checked="uncheck",e})),this.dropData=n}else{if(t===e)return;i=r.find((function(e){return e.id===t}))||{}}this.selectedData=i,this.dropBox&&(this.dropBox.selectedId=t,o&&(this.dropBox.data=n))},deep:!0,immediate:!0},data:{handler:function(t,e){var i=this.multiple,n=this.value,o=JSON.stringify(t),r=JSON.parse(o);i&&r.forEach((function(t){n.includes(t.id)?t.checked="checked":t.checked="uncheck"})),this.dropData=r,this.dropBox&&(this.dropBox.data=r)},deep:!0,immediate:!0}},methods:{openDropHandle:function(t){var e=this,i=this.disabled,n=this.dropShow;if(!i)if("triangle"===t&&n)this.changeDropShow(!1);else if(this.dropBox)this.changeDropShow(!0);else{var o=this.$refs.dropTrigger,r=this.width,a=this.dropWidth,s=this.multiple,l=this.alignRight,c=this.dropData,p=this.value,d=this.maxCount;this.dropBox=E({tag:o.$el,propsData:{width:a<r?r:a,multiple:s,alignRight:l,data:c,selectedId:p,maxCount:d}}).$on("change",(function(t){if(e.selectedData=t,t instanceof Array){var i=t.map((function(t){return t.id}));e.$emit("input",i),e.$emit("change",i,t)}else e.$emit("input",t.id),e.$emit("change",t.id,t);e.changeDropShow(!1)})).$on("cancel",(function(){e.$emit("cancel"),e.changeDropShow(!1)})),this.dropBox.$nextTick((function(){e.changeDropShow(!0),window.addEventListener("click",e.clickOutSide,!1),e.$once("hook:beforeDestroy",(function(){window.removeEventListener("click",e.clickOutSide)}))})),this.$once("hook:beforeDestroy",(function(){e.dropBox&&E.remove(e.dropBox)}))}},changeDropShow:function(t){this.dropShow=t,t?E.resetPosition(this.dropBox):this.dropBox.dropShow=!1},triggerEnter:function(){this.disabled||(this.activeClose=!1)},triggerLeave:function(){this.activeClose=!0},getInputText:function(t){if(t){var e=this.dropData;if(!e||!e.length)return;var i=JSON.parse(JSON.stringify(e)).filter((function(e){return!e.disabled&&(i=e.name,n=t,o=i.split(""),r=n.split(""),o.filter((function(t){return r.includes(t)})).join(""))?(e.name=g(e.name,t,"m-drop-option-text-highlight"),e):null;var i,n,o,r}));this.searchData=i,this.dropBox&&(this.dropBox.data=i)}else this.searchData=[],this.dropBox.data=this.dropData},delHandle:function(){this.selectedData=[],this.$emit("input",""),this.$emit("change","",{}),this.dropBox&&(this.dropBox.selectedData=[],this.dropBox.selectedDataHistory=[])},clickOutSide:function(t){var e=this,i=this.activeClose,n=this.dropShow,o=this.dropBox.$el;i&&n&&f(t,o,(function(){e.dropBox&&e.changeDropShow(!1)}))}},render:function(t){var e=this.openDropHandle,i=this.triggerEnter,n=this.triggerLeave,o=this.caption,r=this.width,a=this.placeholder,s=this.disabled,l=this.clearHide,c=this.openSearch,p=this.multiple,d=this.dropShow,u=this.errorText,f=this.errorShow,g=this.selectedData,v=this.getInputText,m=this.delHandle;return t("div",{class:"m-select",on:{mouseenter:i,mouseleave:n}},[t(h,{ref:"dropTrigger",attrs:{caption:o,width:r,placeholder:a,disabled:s,clearHide:l,openSearch:c,multiple:p,dropShow:d,errorText:u,errorShow:f,selectedData:g},on:{getInputText:v,click:e,delHandle:m}})])},install:function(t){return t.component(N.name,N)}},P=N}(),o}()},"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("MSelect",["vue"],e):"object"==typeof exports?exports.MSelect=e(require("vue")):t.MSelect=e(t.Vue);