shu-c-view
Version:
rollup 打包vue组件库框架
7 lines (6 loc) • 14 kB
JavaScript
/*!
* shu-c-view v1.2.37
* (c) 2022-09-22
* @license MIT
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/isEmpty"),t=require("lodash/difference");function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var n=r(e),a=r(t),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var i=function(e,t){for(var r=-1,n=null==e?0:e.length,a=Array(n);++r<n;)a[r]=t(e[r],r,e);return a};var s=function(e,t,r,n){for(var a=e.length,o=r+(n?1:-1);n?o--:++o<a;)if(t(e[o],o,e))return o;return-1},c=function(e){return e!=e},l=function(e,t,r){for(var n=r-1,a=e.length;++n<a;)if(e[n]===t)return n;return-1};var u=function(e,t,r){return t==t?l(e,t,r):s(e,c,r)};var h=function(e){return function(t){return e(t)}};var f=i,d=u,p=function(e,t,r,n){for(var a=r-1,o=e.length;++a<o;)if(n(e[a],t))return a;return-1},v=h,_=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t},b=Array.prototype.splice;var g=function(e,t,r,n){var a=n?p:d,o=-1,i=t.length,s=e;for(e===t&&(t=_(t)),r&&(s=f(e,v(r)));++o<i;)for(var c=0,l=t[o],u=r?r(l):l;(c=a(s,u,c,n))>-1;)s!==e&&b.call(s,c,1),b.call(e,c,1);return e};var y=function(e,t){return e&&e.length&&t&&t.length?g(e,t):e},m="object"==typeof o&&o&&o.Object===Object&&o,w="object"==typeof self&&self&&self.Object===Object&&self,k=m||w||Function("return this")(),x=k.Symbol,S=x,C=Object.prototype,P=C.hasOwnProperty,j=C.toString,O=S?S.toStringTag:void 0;var E=function(e){var t=P.call(e,O),r=e[O];try{e[O]=void 0;var n=!0}catch(e){}var a=j.call(e);return n&&(t?e[O]=r:delete e[O]),a},G=Object.prototype.toString;var $=E,N=function(e){return G.call(e)},D=x?x.toStringTag:void 0;var T=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},z=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":D&&D in Object(e)?$(e):N(e)},A=T;var I,F=function(e){if(!A(e))return!1;var t=z(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},R=k["__core-js_shared__"],U=(I=/[^.]+$/.exec(R&&R.keys&&R.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"";var V=function(e){return!!U&&U in e},q=Function.prototype.toString;var B=F,L=V,M=T,X=function(e){if(null!=e){try{return q.call(e)}catch(e){}try{return e+""}catch(e){}}return""},H=/^\[object .+?Constructor\]$/,J=Function.prototype,K=Object.prototype,Q=J.toString,W=K.hasOwnProperty,Y=RegExp("^"+Q.call(W).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Z=function(e){return!(!M(e)||L(e))&&(B(e)?Y:H).test(X(e))},ee=function(e,t){return null==e?void 0:e[t]};var te=function(e,t){var r=ee(e,t);return Z(r)?r:void 0},re=te(Object,"create"),ne=re;var ae=function(){this.__data__=ne?ne(null):{},this.size=0};var oe=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ie=re,se=Object.prototype.hasOwnProperty;var ce=function(e){var t=this.__data__;if(ie){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return se.call(t,e)?t[e]:void 0},le=re,ue=Object.prototype.hasOwnProperty;var he=re;var fe=ae,de=oe,pe=ce,ve=function(e){var t=this.__data__;return le?void 0!==t[e]:ue.call(t,e)},_e=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=he&&void 0===t?"__lodash_hash_undefined__":t,this};function be(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}be.prototype.clear=fe,be.prototype.delete=de,be.prototype.get=pe,be.prototype.has=ve,be.prototype.set=_e;var ge=be;var ye=function(){this.__data__=[],this.size=0};var me=function(e,t){return e===t||e!=e&&t!=t};var we=function(e,t){for(var r=e.length;r--;)if(me(e[r][0],t))return r;return-1},ke=we,xe=Array.prototype.splice;var Se=we;var Ce=we;var Pe=we;var je=ye,Oe=function(e){var t=this.__data__,r=ke(t,e);return!(r<0)&&(r==t.length-1?t.pop():xe.call(t,r,1),--this.size,!0)},Ee=function(e){var t=this.__data__,r=Se(t,e);return r<0?void 0:t[r][1]},Ge=function(e){return Ce(this.__data__,e)>-1},$e=function(e,t){var r=this.__data__,n=Pe(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function Ne(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ne.prototype.clear=je,Ne.prototype.delete=Oe,Ne.prototype.get=Ee,Ne.prototype.has=Ge,Ne.prototype.set=$e;var De=Ne,Te=te(k,"Map"),ze=ge,Ae=De,Ie=Te;var Fe=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Re=function(e,t){var r=e.__data__;return Fe(t)?r["string"==typeof t?"string":"hash"]:r.map},Ue=Re;var Ve=Re;var qe=Re;var Be=Re;var Le=function(){this.size=0,this.__data__={hash:new ze,map:new(Ie||Ae),string:new ze}},Me=function(e){var t=Ue(this,e).delete(e);return this.size-=t?1:0,t},Xe=function(e){return Ve(this,e).get(e)},He=function(e){return qe(this,e).has(e)},Je=function(e,t){var r=Be(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function Ke(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ke.prototype.clear=Le,Ke.prototype.delete=Me,Ke.prototype.get=Xe,Ke.prototype.has=He,Ke.prototype.set=Je;var Qe=Ke,We=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Ye=function(e){return this.__data__.has(e)};function Ze(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Qe;++t<r;)this.add(e[t])}Ze.prototype.add=Ze.prototype.push=We,Ze.prototype.has=Ye;var et=u;var tt=Ze,rt=function(e,t){return!!(null==e?0:e.length)&&et(e,t,0)>-1},nt=function(e,t,r){for(var n=-1,a=null==e?0:e.length;++n<a;)if(r(t,e[n]))return!0;return!1},at=i,ot=h,it=function(e,t){return e.has(t)},st=Math.min;var ct=function(e,t,r){for(var n=r?nt:rt,a=e[0].length,o=e.length,i=o,s=Array(o),c=1/0,l=[];i--;){var u=e[i];i&&t&&(u=at(u,ot(t))),c=st(u.length,c),s[i]=!r&&(t||a>=120&&u.length>=120)?new tt(i&&u):void 0}u=e[0];var h=-1,f=s[0];e:for(;++h<a&&l.length<c;){var d=u[h],p=t?t(d):d;if(d=r||0!==d?d:0,!(f?it(f,p):n(l,p,r))){for(i=o;--i;){var v=s[i];if(!(v?it(v,p):n(e[i],p,r)))continue e}f&&f.push(p),l.push(d)}}return l};var lt=function(e){return e};var ut=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)},ht=Math.max;var ft=function(e,t,r){return t=ht(void 0===t?e.length-1:t,0),function(){for(var n=arguments,a=-1,o=ht(n.length-t,0),i=Array(o);++a<o;)i[a]=n[t+a];a=-1;for(var s=Array(t+1);++a<t;)s[a]=n[a];return s[t]=r(i),ut(e,this,s)}};var dt=function(e){return function(){return e}},pt=te,vt=function(){try{var e=pt(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),_t=dt,bt=vt,gt=bt?function(e,t){return bt(e,"toString",{configurable:!0,enumerable:!1,value:_t(t),writable:!0})}:lt,yt=Date.now;var mt=function(e){var t=0,r=0;return function(){var n=yt(),a=16-(n-r);if(r=n,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(gt),wt=lt,kt=ft,xt=mt;var St=F,Ct=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var Pt=function(e){return null!=e&&Ct(e.length)&&!St(e)},jt=function(e){return null!=e&&"object"==typeof e};var Ot=function(e){return jt(e)&&Pt(e)};var Et=i,Gt=ct,$t=function(e){return Ot(e)?e:[]},Nt=function(e,t){return xt(kt(e,t,wt),e+"")}((function(e){var t=Et(e,$t);return t.length&&t[0]===e[0]?Gt(t):[]})),Dt=document.addEventListener?function(e,t,r){e&&t&&r&&e.addEventListener(t,r,!1)}:function(e,t,r){e&&t&&r&&e.attachEvent("on"+t,r)},Tt=document.removeEventListener?function(e,t,r){e&&t&&e.removeEventListener(t,r,!1)}:function(e,t,r){e&&t&&e.detachEvent("on"+t,r)};function zt(e,t,r,n,a,o,i,s,c,l){"boolean"!=typeof i&&(c=s,s=i,i=!1);const u="function"==typeof r?r.options:r;let h;if(e&&e.render&&(u.render=e.render,u.staticRenderFns=e.staticRenderFns,u._compiled=!0,a&&(u.functional=!0)),n&&(u._scopeId=n),o?(h=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,c(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},u._ssrRegister=h):t&&(h=i?function(e){t.call(this,l(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,s(e))}),h)if(u.functional){const e=u.render;u.render=function(t,r){return h.call(r),e(t,r)}}else{const e=u.beforeCreate;u.beforeCreate=e?[].concat(e,h):[h]}return r}const At={name:"BaseSelectCollapseCheckbox",props:{value:{type:[Array]},allData:{type:Object,required:!0},selectTitle:{type:Array,required:!0},width:{type:String,default:"200px"},defaulProps:{type:Object,default:function(){return{children:"children",label:"areaCode",value:"areaName"}}},isCascader:{type:Boolean,default:!1},disableSameName:{type:Boolean,default:!1}},data(){return{that:this,showSelect:!1,checkboxGroup:[],activeNames:["1"],formatData:[]}},mounted(){Dt(document,"click",this.showSelectDomEvent)},watch:{allData:{handler:function(e){n(e)||this.formatterData(e)},deep:!0,immediate:!0},checkboxGroup:{handler:function(e,t){if(!this.isCascader)return!1;this.handleCheckEvent(e,t),this.handleUncheckedEvent(e,t)},deep:!0}},filters:{filterTitle(e,t){if(!n(t.selectTitle))return t.selectTitle.filter((t=>t.key===e))[0].name}},computed:{isShow:()=>function(e,t){let r=!1;return t&&(r=!0),t&&e.length>0&&(r=!1),r},getSatus:()=>function(e){if(!this.disableSameName)return;let t=!1;const r=e[this.defaulProps.value];return n(this.checkboxGroup)?void 0:(this.checkboxGroup.map((n=>{const a=n[this.defaulProps.value];t=a===r&&n!==e})),t)}},methods:{handleCheckEvent(e,t){if(e.length>t.length){const r=a(e,t)[0];if(r.children)for(const t of r.children)-1===e.findIndex((e=>e===t))&&e.push(t);else{Nt(this.checkboxGroup,r.parent.children).length===r.parent.children.length&&e.push(r.parent)}}},handleUncheckedEvent(e,t){if(e.length<t.length){const r=a(t,e)[0];r.children?y(e,r.children):y(e,[r.parent])}},getIndeterminateStatus(e){return Nt(this.checkboxGroup,e.children).length>0&&-1===this.checkboxGroup.findIndex((t=>t===e))},showSelectDomEvent(e){this.$el.contains(e.target)||(this.showSelect=!1)},formatterData(e){this.formatData=Object.keys(e).map((t=>{e[t].map((e=>{e.length>0&&e[this.defaulProps.children]&&0===e[this.defaulProps.children].length&&delete e[this.defaulProps.children]}));var r={key:t,currentItem:e[t]};return r.currentItem.forEach((e=>{e.children.forEach((t=>{t.parent=e}))})),r}))},getCheckValue(e){const t=[];for(let e=0;e<this.checkboxGroup.length;e++)t.push(this.checkboxGroup[e][this.defaulProps.label]);this.$emit("input",t)},handleClose(e,t){const r=this.checkboxGroup.findIndex((e=>e===t));-1!==r&&(this.checkboxGroup.splice(r,1),this.getCheckValue()),e.stopPropagation()},reset(){this.checkboxGroup=[],this.$emit("input",this.checkboxGroup)}},beforeDestroy(){Tt(document,"click",this.showSelectDomEvent)}};var It=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"base-select-collapse-checkbox"},[r("div",{staticClass:"select-area",style:{width:e.width},on:{click:function(t){t.stopPropagation(),e.showSelect=!e.showSelect}}},[e.checkboxGroup&&e.checkboxGroup.length>0?r("div",{staticClass:"select-group"},[r("el-tag",{staticClass:"select-area-li",attrs:{closable:"","disable-transitions":!1},on:{close:function(t){return e.handleClose(t,e.checkboxGroup[0])}}},[r("span",[e._v(e._s(e.checkboxGroup[0][e.defaulProps.value]))])]),e._v(" "),e.checkboxGroup.length>1?r("el-tag",{staticClass:"select-area-li",attrs:{closable:!1,"disable-transitions":""}},[r("span",{staticClass:"el-select__tags-text"},[e._v("+ "+e._s(e.checkboxGroup.length-1))])]):e._e()],1):e._e(),e._v(" "),r("div",{staticClass:"select-area-arrow"},[r("i",{directives:[{name:"show",rawName:"v-show",value:!e.showSelect,expression:"!showSelect"}],staticClass:"el-icon-arrow-down"}),e._v(" "),r("i",{directives:[{name:"show",rawName:"v-show",value:e.showSelect,expression:"showSelect"}],staticClass:"el-icon-arrow-up"})])]),e._v(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:e.showSelect,expression:"showSelect"}],ref:"selectOptions",staticClass:"selectOptions",style:{width:e.width}},[e.formatData&&e.formatData.length>0?r("el-checkbox-group",e._b({on:{change:e.getCheckValue},model:{value:e.checkboxGroup,callback:function(t){e.checkboxGroup=t},expression:"checkboxGroup"}},"el-checkbox-group",e.$attrs,!1),[r("el-collapse",{attrs:{accordion:""},model:{value:e.activeNames,callback:function(t){e.activeNames=t},expression:"activeNames"}},e._l(e.formatData,(function(t,n){return r("el-collapse-item",{key:n},[r("template",{slot:"title"},[r("span",{staticClass:"pl-20"},[e._v(e._s(e._f("filterTitle")(t.key,e.that)))])]),e._v(" "),e._l(t.currentItem,(function(t,n){return r("div",{key:n},[r("div",{directives:[{name:"show",rawName:"v-show",value:t[e.defaulProps.children].length>0,expression:"child[defaulProps.children].length > 0"}],class:["mb-12","weight-600","mt-12"]},[e.isCascader?r("el-checkbox",{attrs:{indeterminate:e.getIndeterminateStatus(t),disabled:e.getSatus(t),label:t}},[e._v(e._s(t[e.defaulProps.value]))]):r("span",[e._v(e._s(t[e.defaulProps.value]))])],1),e._v(" "),r("el-checkbox",{directives:[{name:"show",rawName:"v-show",value:e.isShow(t[e.defaulProps.children],t[e.defaulProps.label]),expression:"\n isShow(child[defaulProps.children], child[defaulProps.label])\n "}],attrs:{disabled:e.getSatus(t),label:t}},[e._v(e._s(t[e.defaulProps.value]))]),e._v(" "),e._l(t[e.defaulProps.children],(function(t,n){return r("el-checkbox",{key:n,attrs:{disabled:e.getSatus(t),label:t}},[e._v(e._s(t[e.defaulProps.value]))])}))],2)}))],2)})),1)],1):r("div",{staticClass:"empty-data"},[e._v("暂无数据")])],1)])};It._withStripped=!0;const Ft=zt({render:It,staticRenderFns:[]},undefined,At,undefined,false,undefined,!1,void 0,void 0,void 0);exports.BaseSelectCollapseCheckbox=Ft;