eslink-ui-plus
Version:
vue3 component library, css framework
75 lines (74 loc) • 18.3 kB
JavaScript
(function(i,x){typeof exports=="object"&&typeof module!="undefined"?module.exports=x(require("vue"),require("element-plus"),require("lodash-es")):typeof define=="function"&&define.amd?define(["vue","element-plus","lodash-es"],x):(i=typeof globalThis!="undefined"?globalThis:i||self,i["es-select-display"]=x(i.Vue,i.ElementPlus,i._))})(this,function(i,x,$){"use strict";const j={labelKey:"label",valueKey:"value",disabledKey:"disabled",childrenKey:"children"},K={type:Object,default:()=>j},U={type:Object,default:()=>[]};var Y=Object.defineProperty,M=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,I=(e,l,d)=>l in e?Y(e,l,{enumerable:!0,configurable:!0,writable:!0,value:d}):e[l]=d,H=(e,l)=>{for(var d in l||(l={}))q.call(l,d)&&I(e,d,l[d]);if(M)for(var d of M(l))G.call(l,d)&&I(e,d,l[d]);return e};const X=e=>H(H({},j),e),z=e=>e.toString().includes("px")?e:e+"px";var J=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Q={exports:{}};/*!
* clipboard.js v2.0.8
* https://clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
*/(function(e,l){(function(k,m){e.exports=m()})(J,function(){return function(){var d={134:function(y,u,t){t.d(u,{default:function(){return _e}});var c=t(279),f=t.n(c),h=t(370),_=t.n(h),v=t(817),w=t.n(v);function g(a){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?g=function(n){return typeof n}:g=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},g(a)}function b(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function o(a,r){for(var n=0;n<r.length;n++){var s=r[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(a,s.key,s)}}function S(a,r,n){return r&&o(a.prototype,r),n&&o(a,n),a}var ue=function(){function a(r){b(this,a),this.resolveOptions(r),this.initSelection()}return S(a,[{key:"resolveOptions",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=n.action,this.container=n.container,this.emitter=n.emitter,this.target=n.target,this.text=n.text,this.trigger=n.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var n=document.documentElement.getAttribute("dir")==="rtl";this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var s=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(s,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var n=this,s=this.createFakeElement();this.fakeHandlerCallback=function(){return n.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(s),this.selectedText=w()(s),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=w()(this.target),this.copyText()}},{key:"copyText",value:function(){var n;try{n=document.execCommand(this.action)}catch(s){n=!1}this.handleResult(n)}},{key:"handleResult",value:function(n){this.emitter.emit(n?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"copy";if(this._action=n,this._action!=="copy"&&this._action!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(n){if(n!==void 0)if(n&&g(n)==="object"&&n.nodeType===1){if(this.action==="copy"&&n.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(this.action==="cut"&&(n.hasAttribute("readonly")||n.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);this._target=n}else throw new Error('Invalid "target" value, use a valid Element')},get:function(){return this._target}}]),a}(),fe=ue;function O(a){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(n){return typeof n}:O=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},O(a)}function de(a,r){if(!(a instanceof r))throw new TypeError("Cannot call a class as a function")}function F(a,r){for(var n=0;n<r.length;n++){var s=r[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(a,s.key,s)}}function pe(a,r,n){return r&&F(a.prototype,r),n&&F(a,n),a}function ye(a,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(r&&r.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),r&&V(a,r)}function V(a,r){return V=Object.setPrototypeOf||function(s,p){return s.__proto__=p,s},V(a,r)}function he(a){var r=ve();return function(){var s=A(a),p;if(r){var E=A(this).constructor;p=Reflect.construct(s,arguments,E)}else p=s.apply(this,arguments);return ge(this,p)}}function ge(a,r){return r&&(O(r)==="object"||typeof r=="function")?r:me(a)}function me(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function ve(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function A(a){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},A(a)}function N(a,r){var n="data-clipboard-".concat(a);if(!!r.hasAttribute(n))return r.getAttribute(n)}var be=function(a){ye(n,a);var r=he(n);function n(s,p){var E;return de(this,n),E=r.call(this),E.resolveOptions(p),E.listenClick(s),E}return pe(n,[{key:"resolveOptions",value:function(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof p.action=="function"?p.action:this.defaultAction,this.target=typeof p.target=="function"?p.target:this.defaultTarget,this.text=typeof p.text=="function"?p.text:this.defaultText,this.container=O(p.container)==="object"?p.container:document.body}},{key:"listenClick",value:function(p){var E=this;this.listener=_()(p,"click",function(C){return E.onClick(C)})}},{key:"onClick",value:function(p){var E=p.delegateTarget||p.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new fe({action:this.action(E),target:this.target(E),text:this.text(E),container:this.container,trigger:E,emitter:this})}},{key:"defaultAction",value:function(p){return N("action",p)}},{key:"defaultTarget",value:function(p){var E=N("target",p);if(E)return document.querySelector(E)}},{key:"defaultText",value:function(p){return N("text",p)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],E=typeof p=="string"?[p]:p,C=!!document.queryCommandSupported;return E.forEach(function(ke){C=C&&!!document.queryCommandSupported(ke)}),C}}]),n}(f()),_e=be},828:function(y){var u=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var t=Element.prototype;t.matches=t.matchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector}function c(f,h){for(;f&&f.nodeType!==u;){if(typeof f.matches=="function"&&f.matches(h))return f;f=f.parentNode}}y.exports=c},438:function(y,u,t){var c=t(828);function f(v,w,g,b,o){var S=_.apply(this,arguments);return v.addEventListener(g,S,o),{destroy:function(){v.removeEventListener(g,S,o)}}}function h(v,w,g,b,o){return typeof v.addEventListener=="function"?f.apply(null,arguments):typeof g=="function"?f.bind(null,document).apply(null,arguments):(typeof v=="string"&&(v=document.querySelectorAll(v)),Array.prototype.map.call(v,function(S){return f(S,w,g,b,o)}))}function _(v,w,g,b){return function(o){o.delegateTarget=c(o.target,w),o.delegateTarget&&b.call(v,o)}}y.exports=h},879:function(y,u){u.node=function(t){return t!==void 0&&t instanceof HTMLElement&&t.nodeType===1},u.nodeList=function(t){var c=Object.prototype.toString.call(t);return t!==void 0&&(c==="[object NodeList]"||c==="[object HTMLCollection]")&&"length"in t&&(t.length===0||u.node(t[0]))},u.string=function(t){return typeof t=="string"||t instanceof String},u.fn=function(t){var c=Object.prototype.toString.call(t);return c==="[object Function]"}},370:function(y,u,t){var c=t(879),f=t(438);function h(g,b,o){if(!g&&!b&&!o)throw new Error("Missing required arguments");if(!c.string(b))throw new TypeError("Second argument must be a String");if(!c.fn(o))throw new TypeError("Third argument must be a Function");if(c.node(g))return _(g,b,o);if(c.nodeList(g))return v(g,b,o);if(c.string(g))return w(g,b,o);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function _(g,b,o){return g.addEventListener(b,o),{destroy:function(){g.removeEventListener(b,o)}}}function v(g,b,o){return Array.prototype.forEach.call(g,function(S){S.addEventListener(b,o)}),{destroy:function(){Array.prototype.forEach.call(g,function(S){S.removeEventListener(b,o)})}}}function w(g,b,o){return f(document.body,g,b,o)}y.exports=h},817:function(y){function u(t){var c;if(t.nodeName==="SELECT")t.focus(),c=t.value;else if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){var f=t.hasAttribute("readonly");f||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),f||t.removeAttribute("readonly"),c=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var h=window.getSelection(),_=document.createRange();_.selectNodeContents(t),h.removeAllRanges(),h.addRange(_),c=h.toString()}return c}y.exports=u},279:function(y){function u(){}u.prototype={on:function(t,c,f){var h=this.e||(this.e={});return(h[t]||(h[t]=[])).push({fn:c,ctx:f}),this},once:function(t,c,f){var h=this;function _(){h.off(t,_),c.apply(f,arguments)}return _._=c,this.on(t,_,f)},emit:function(t){var c=[].slice.call(arguments,1),f=((this.e||(this.e={}))[t]||[]).slice(),h=0,_=f.length;for(h;h<_;h++)f[h].fn.apply(f[h].ctx,c);return this},off:function(t,c){var f=this.e||(this.e={}),h=f[t],_=[];if(h&&c)for(var v=0,w=h.length;v<w;v++)h[v].fn!==c&&h[v].fn._!==c&&_.push(h[v]);return _.length?f[t]=_:delete f[t],this}},y.exports=u,y.exports.TinyEmitter=u}},k={};function m(y){if(k[y])return k[y].exports;var u=k[y]={exports:{}};return d[y](u,u.exports,m),u.exports}return function(){m.n=function(y){var u=y&&y.__esModule?function(){return y.default}:function(){return y};return m.d(u,{a:u}),u}}(),function(){m.d=function(y,u){for(var t in u)m.o(u,t)&&!m.o(y,t)&&Object.defineProperty(y,t,{enumerable:!0,get:u[t]})}}(),function(){m.o=function(y,u){return Object.prototype.hasOwnProperty.call(y,u)}}(),m(134)}().default})})(Q);var W=Object.defineProperty,Z=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,D=(e,l,d)=>l in e?W(e,l,{enumerable:!0,configurable:!0,writable:!0,value:d}):e[l]=d,P=(e,l)=>{for(var d in l||(l={}))te.call(l,d)&&D(e,d,l[d]);if(B)for(var d of B(l))ne.call(l,d)&&D(e,d,l[d]);return e},re=(e,l)=>Z(e,ee(l));const T=i.defineComponent({components:{ElScrollbar:x.ElScrollbar},props:{modelValue:U,keyConfig:K,height:[String,Number],maxHeight:[String,Number],styles:Object,type:{type:String,default:"align"},placeholder:{type:String,default:"\u8BF7\u9009\u62E9"},iconStyle:{type:Object,default:()=>({})},size:{type:String,default:"common"},withDelete:{type:Boolean,default:!0},clearable:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(e,{slots:l,emit:d}){const k=i.ref([]);i.watch(()=>e.modelValue,o=>{k.value=$.cloneDeep(o)},{deep:!0,immediate:!0});const m=i.computed(()=>{var o;return!((o=k==null?void 0:k.value)==null?void 0:o.length)}),y=()=>{e.readonly||(k.value=[],d("update:modelValue",[]),d("change",[]))},u=i.computed(()=>{var o;const S={};return e.height!==void 0&&(S.height=z(e.height)),e.maxHeight!==void 0&&(S.maxHeight=z(e.maxHeight)),P(P({},(o=e.styles)!=null?o:{}),S)}),t=i.computed(()=>!!l.item),c=i.computed(()=>({align:"inline-block",vertical:"block"})[e.type]),f=i.computed(()=>({align:"4px",vertical:e.size==="mini"?"3px":"10px"})[e.type]),h=i.computed(()=>({align:"12px",vertical:"14px"})[e.type]),_=i.computed(()=>({align:"20px",vertical:"28px"})[e.type]),v=i.computed(()=>m.value?"none":"block"),w=i.computed(()=>e.clearable?m.value?"block":"none":"block"),g=i.computed(()=>{var o,S;return(S=(o=e==null?void 0:e.iconStyle)==null?void 0:o.className)!=null?S:"es-icon-close-line"}),b=o=>{e.readonly||(k.value.splice(o,1),d("update:modelValue",k.value))};return re(P({customStyle:u},X(P({valueKey:"value",labelKey:"label"},e.keyConfig))),{noSource:m,hasCustomItemRender:t,alignType:c,paddingValue:f,fontSizeValue:h,itemHeightValue:_,list:k,clearIconDisplay:v,toggleIconDisplay:w,clearModelValue:y,iconClassName:g,deleteItem:b})}}),L=()=>{i.useCssVars(e=>({"2526f022-itemHeightValue":e.itemHeightValue,"2526f022-fontSizeValue":e.fontSizeValue,"2526f022-alignType":e.alignType,"2526f022-clearIconDisplay":e.clearIconDisplay,"2526f022-toggleIconDisplay":e.toggleIconDisplay,"2526f022-paddingValue":e.paddingValue}))},R=T.setup;T.setup=R?(e,l)=>(L(),R(e,l)):L,i.pushScopeId("data-v-2526f022");const ie={key:0,class:"es-select-display__placeholder"},oe=["onClick"],ae=i.createElementVNode("span",{class:"right-icon toggle el-icon-arrow-up"},null,-1);i.popScopeId();function le(e,l,d,k,m,y){const u=i.resolveComponent("el-scrollbar");return i.openBlock(),i.createBlock(u,i.mergeProps({class:"es-select-display"},e.$attrs,{"wrap-class":"es-select-display__wrapper",height:e.height,"max-height":e.maxHeight,style:e.customStyle}),{default:i.withCtx(()=>[e.noSource?(i.openBlock(),i.createElementBlock("span",ie,i.toDisplayString(e.placeholder),1)):(i.openBlock(!0),i.createElementBlock(i.Fragment,{key:1},i.renderList(e.list,(t,c)=>(i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["es-select-display__item",{align:e.type==="align"}]),key:t[e.valueKey]},[e.hasCustomItemRender?i.renderSlot(e.$slots,"item",{key:0,item:t}):(i.openBlock(),i.createElementBlock("span",{key:1,class:i.normalizeClass(["es-select-display__item__label",{align:e.type==="align"}])},i.toDisplayString(t[e.labelKey]),3)),e.withDelete?(i.openBlock(),i.createElementBlock("span",{key:2,class:i.normalizeClass(["clear",e.iconClassName]),style:i.normalizeStyle(e.iconStyle),onClick:i.withModifiers(f=>e.deleteItem(c),["stop"])},null,14,oe)):i.createCommentVNode("v-if",!0)],2))),128)),e.clearable?(i.openBlock(),i.createElementBlock("span",{key:2,class:"right-icon clear el-icon-circle-close",onClick:l[0]||(l[0]=i.withModifiers((...t)=>e.clearModelValue&&e.clearModelValue(...t),["stop"]))})):i.createCommentVNode("v-if",!0),ae]),_:3},16,["height","max-height","style"])}function se(e,l){l===void 0&&(l={});var d=l.insertAt;if(!(!e||typeof document=="undefined")){var k=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css",d==="top"&&k.firstChild?k.insertBefore(m,k.firstChild):k.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}var ce=`.es-select-display[data-v-2526f022] {
width: 100%;
height: unset;
cursor: pointer;
position: relative;
background: #ffffff;
}
.es-select-display__placeholder[data-v-2526f022] {
font-size: 12px;
color: #c0c4cc;
display: inline-block;
height: 18px;
line-height: 18px;
margin-left: 10px;
}
.es-select-display__item[data-v-2526f022] {
height: var(--2526f022-itemHeightValue);
line-height: var(--2526f022-itemHeightValue);
font-size: var(--2526f022-fontSizeValue);
display: var(--2526f022-alignType);
}
.es-select-display__item.align[data-v-2526f022] {
background: #eaf1ff;
border-radius: 2px;
margin-left: 4px;
margin-bottom: 4px;
}
.es-select-display__item__label[data-v-2526f022] {
vertical-align: middle;
}
.es-select-display__item__label.align[data-v-2526f022] {
margin-left: 6px;
color: #282934;
}
.es-select-display__item .clear[data-v-2526f022] {
text-align: right;
margin-right: 6px;
margin-left: 6px;
font-size: 12px;
color: #abbff7;
z-index: 1;
vertical-align: middle;
}
.es-select-display .right-icon[data-v-2526f022] {
position: absolute;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
right: 13px;
top: 50%;
color: #c0c4cc;
margin-top: -6px;
font-size: 12px;
}
.es-select-display .right-icon.clear[data-v-2526f022] {
display: none;
z-index: 1;
}
.es-select-display:hover .right-icon.clear[data-v-2526f022] {
display: var(--2526f022-clearIconDisplay);
}
.es-select-display:hover .right-icon.toggle[data-v-2526f022] {
display: var(--2526f022-toggleIconDisplay);
}
[data-v-2526f022] .es-select-display__wrapper {
border: 1px solid #dcdfe6;
border-radius: 4px;
padding: var(--2526f022-paddingValue) 30px var(--2526f022-paddingValue) 15px;
min-height: 28px;
}`;return se(ce),T.render=le,T.__scopeId="data-v-2526f022",T.__file="components/select-display/index.vue",T.install=e=>{e.component("es-select-display",T)},T});