UNPKG

eslink-ui-plus

Version:

vue3 component library, css framework

75 lines (74 loc) 17.9 kB
import{defineComponent as ae,ref as le,watch as se,computed as w,useCssVars as ce,pushScopeId as ue,popScopeId as fe,resolveComponent as de,openBlock as x,createBlock as pe,mergeProps as ye,withCtx as he,createElementBlock as O,toDisplayString as H,Fragment as ge,renderList as ve,normalizeClass as I,renderSlot as me,normalizeStyle as be,withModifiers as L,createCommentVNode as R,createElementVNode as _e}from"vue";import{ElScrollbar as ke}from"element-plus";import{cloneDeep as Se}from"lodash-es";const D={labelKey:"label",valueKey:"value",disabledKey:"disabled",childrenKey:"children"},Ee={type:Object,default:()=>D},we={type:Object,default:()=>[]};var Te=Object.defineProperty,z=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,F=(e,a,f)=>a in e?Te(e,a,{enumerable:!0,configurable:!0,writable:!0,value:f}):e[a]=f,$=(e,a)=>{for(var f in a||(a={}))xe.call(a,f)&&F(e,f,a[f]);if(z)for(var f of z(a))Oe.call(a,f)&&F(e,f,a[f]);return e};const Ce=e=>$($({},D),e),K=e=>e.toString().includes("px")?e:e+"px";var Pe=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Ae={exports:{}};/*! * clipboard.js v2.0.8 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */(function(e,a){(function(_,g){e.exports=g()})(Pe,function(){return function(){var f={134:function(p,c,t){t.d(c,{default:function(){return ie}});var s=t(279),u=t.n(s),y=t(370),b=t.n(y),v=t(817),E=t.n(v);function h(o){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?h=function(n){return typeof n}:h=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},h(o)}function m(o,r){if(!(o instanceof r))throw new TypeError("Cannot call a class as a function")}function i(o,r){for(var n=0;n<r.length;n++){var l=r[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}function S(o,r,n){return r&&i(o.prototype,r),n&&i(o,n),o}var X=function(){function o(r){m(this,o),this.resolveOptions(r),this.initSelection()}return S(o,[{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 l=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(l,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var n=this,l=this.createFakeElement();this.fakeHandlerCallback=function(){return n.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(l),this.selectedText=E()(l),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=E()(this.target),this.copyText()}},{key:"copyText",value:function(){var n;try{n=document.execCommand(this.action)}catch(l){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&&h(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}}]),o}(),J=X;function C(o){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(n){return typeof n}:C=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},C(o)}function Q(o,r){if(!(o instanceof r))throw new TypeError("Cannot call a class as a function")}function M(o,r){for(var n=0;n<r.length;n++){var l=r[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}function W(o,r,n){return r&&M(o.prototype,r),n&&M(o,n),o}function Z(o,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(r&&r.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),r&&N(o,r)}function N(o,r){return N=Object.setPrototypeOf||function(l,d){return l.__proto__=d,l},N(o,r)}function q(o){var r=ne();return function(){var l=A(o),d;if(r){var k=A(this).constructor;d=Reflect.construct(l,arguments,k)}else d=l.apply(this,arguments);return ee(this,d)}}function ee(o,r){return r&&(C(r)==="object"||typeof r=="function")?r:te(o)}function te(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function ne(){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(o){return!1}}function A(o){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},A(o)}function j(o,r){var n="data-clipboard-".concat(o);if(!!r.hasAttribute(n))return r.getAttribute(n)}var re=function(o){Z(n,o);var r=q(n);function n(l,d){var k;return Q(this,n),k=r.call(this),k.resolveOptions(d),k.listenClick(l),k}return W(n,[{key:"resolveOptions",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof d.action=="function"?d.action:this.defaultAction,this.target=typeof d.target=="function"?d.target:this.defaultTarget,this.text=typeof d.text=="function"?d.text:this.defaultText,this.container=C(d.container)==="object"?d.container:document.body}},{key:"listenClick",value:function(d){var k=this;this.listener=b()(d,"click",function(P){return k.onClick(P)})}},{key:"onClick",value:function(d){var k=d.delegateTarget||d.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new J({action:this.action(k),target:this.target(k),text:this.text(k),container:this.container,trigger:k,emitter:this})}},{key:"defaultAction",value:function(d){return j("action",d)}},{key:"defaultTarget",value:function(d){var k=j("target",d);if(k)return document.querySelector(k)}},{key:"defaultText",value:function(d){return j("text",d)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],k=typeof d=="string"?[d]:d,P=!!document.queryCommandSupported;return k.forEach(function(oe){P=P&&!!document.queryCommandSupported(oe)}),P}}]),n}(u()),ie=re},828:function(p){var c=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 s(u,y){for(;u&&u.nodeType!==c;){if(typeof u.matches=="function"&&u.matches(y))return u;u=u.parentNode}}p.exports=s},438:function(p,c,t){var s=t(828);function u(v,E,h,m,i){var S=b.apply(this,arguments);return v.addEventListener(h,S,i),{destroy:function(){v.removeEventListener(h,S,i)}}}function y(v,E,h,m,i){return typeof v.addEventListener=="function"?u.apply(null,arguments):typeof h=="function"?u.bind(null,document).apply(null,arguments):(typeof v=="string"&&(v=document.querySelectorAll(v)),Array.prototype.map.call(v,function(S){return u(S,E,h,m,i)}))}function b(v,E,h,m){return function(i){i.delegateTarget=s(i.target,E),i.delegateTarget&&m.call(v,i)}}p.exports=y},879:function(p,c){c.node=function(t){return t!==void 0&&t instanceof HTMLElement&&t.nodeType===1},c.nodeList=function(t){var s=Object.prototype.toString.call(t);return t!==void 0&&(s==="[object NodeList]"||s==="[object HTMLCollection]")&&"length"in t&&(t.length===0||c.node(t[0]))},c.string=function(t){return typeof t=="string"||t instanceof String},c.fn=function(t){var s=Object.prototype.toString.call(t);return s==="[object Function]"}},370:function(p,c,t){var s=t(879),u=t(438);function y(h,m,i){if(!h&&!m&&!i)throw new Error("Missing required arguments");if(!s.string(m))throw new TypeError("Second argument must be a String");if(!s.fn(i))throw new TypeError("Third argument must be a Function");if(s.node(h))return b(h,m,i);if(s.nodeList(h))return v(h,m,i);if(s.string(h))return E(h,m,i);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function b(h,m,i){return h.addEventListener(m,i),{destroy:function(){h.removeEventListener(m,i)}}}function v(h,m,i){return Array.prototype.forEach.call(h,function(S){S.addEventListener(m,i)}),{destroy:function(){Array.prototype.forEach.call(h,function(S){S.removeEventListener(m,i)})}}}function E(h,m,i){return u(document.body,h,m,i)}p.exports=y},817:function(p){function c(t){var s;if(t.nodeName==="SELECT")t.focus(),s=t.value;else if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){var u=t.hasAttribute("readonly");u||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),u||t.removeAttribute("readonly"),s=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var y=window.getSelection(),b=document.createRange();b.selectNodeContents(t),y.removeAllRanges(),y.addRange(b),s=y.toString()}return s}p.exports=c},279:function(p){function c(){}c.prototype={on:function(t,s,u){var y=this.e||(this.e={});return(y[t]||(y[t]=[])).push({fn:s,ctx:u}),this},once:function(t,s,u){var y=this;function b(){y.off(t,b),s.apply(u,arguments)}return b._=s,this.on(t,b,u)},emit:function(t){var s=[].slice.call(arguments,1),u=((this.e||(this.e={}))[t]||[]).slice(),y=0,b=u.length;for(y;y<b;y++)u[y].fn.apply(u[y].ctx,s);return this},off:function(t,s){var u=this.e||(this.e={}),y=u[t],b=[];if(y&&s)for(var v=0,E=y.length;v<E;v++)y[v].fn!==s&&y[v].fn._!==s&&b.push(y[v]);return b.length?u[t]=b:delete u[t],this}},p.exports=c,p.exports.TinyEmitter=c}},_={};function g(p){if(_[p])return _[p].exports;var c=_[p]={exports:{}};return f[p](c,c.exports,g),c.exports}return function(){g.n=function(p){var c=p&&p.__esModule?function(){return p.default}:function(){return p};return g.d(c,{a:c}),c}}(),function(){g.d=function(p,c){for(var t in c)g.o(c,t)&&!g.o(p,t)&&Object.defineProperty(p,t,{enumerable:!0,get:c[t]})}}(),function(){g.o=function(p,c){return Object.prototype.hasOwnProperty.call(p,c)}}(),g(134)}().default})})(Ae);var Ve=Object.defineProperty,Ne=Object.defineProperties,je=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,U=(e,a,f)=>a in e?Ve(e,a,{enumerable:!0,configurable:!0,writable:!0,value:f}):e[a]=f,V=(e,a)=>{for(var f in a||(a={}))Ie.call(a,f)&&U(e,f,a[f]);if(B)for(var f of B(a))Me.call(a,f)&&U(e,f,a[f]);return e},He=(e,a)=>Ne(e,je(a));const T=ae({components:{ElScrollbar:ke},props:{modelValue:we,keyConfig:Ee,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:a,emit:f}){const _=le([]);se(()=>e.modelValue,i=>{_.value=Se(i)},{deep:!0,immediate:!0});const g=w(()=>{var i;return!((i=_==null?void 0:_.value)==null?void 0:i.length)}),p=()=>{e.readonly||(_.value=[],f("update:modelValue",[]),f("change",[]))},c=w(()=>{var i;const S={};return e.height!==void 0&&(S.height=K(e.height)),e.maxHeight!==void 0&&(S.maxHeight=K(e.maxHeight)),V(V({},(i=e.styles)!=null?i:{}),S)}),t=w(()=>!!a.item),s=w(()=>({align:"inline-block",vertical:"block"})[e.type]),u=w(()=>({align:"4px",vertical:e.size==="mini"?"3px":"10px"})[e.type]),y=w(()=>({align:"12px",vertical:"14px"})[e.type]),b=w(()=>({align:"20px",vertical:"28px"})[e.type]),v=w(()=>g.value?"none":"block"),E=w(()=>e.clearable?g.value?"block":"none":"block"),h=w(()=>{var i,S;return(S=(i=e==null?void 0:e.iconStyle)==null?void 0:i.className)!=null?S:"es-icon-close-line"}),m=i=>{e.readonly||(_.value.splice(i,1),f("update:modelValue",_.value))};return He(V({customStyle:c},Ce(V({valueKey:"value",labelKey:"label"},e.keyConfig))),{noSource:g,hasCustomItemRender:t,alignType:s,paddingValue:u,fontSizeValue:y,itemHeightValue:b,list:_,clearIconDisplay:v,toggleIconDisplay:E,clearModelValue:p,iconClassName:h,deleteItem:m})}}),Y=()=>{ce(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}))},G=T.setup;T.setup=G?(e,a)=>(Y(),G(e,a)):Y,ue("data-v-2526f022");const Le={key:0,class:"es-select-display__placeholder"},Re=["onClick"],De=_e("span",{class:"right-icon toggle el-icon-arrow-up"},null,-1);fe();function ze(e,a,f,_,g,p){const c=de("el-scrollbar");return x(),pe(c,ye({class:"es-select-display"},e.$attrs,{"wrap-class":"es-select-display__wrapper",height:e.height,"max-height":e.maxHeight,style:e.customStyle}),{default:he(()=>[e.noSource?(x(),O("span",Le,H(e.placeholder),1)):(x(!0),O(ge,{key:1},ve(e.list,(t,s)=>(x(),O("div",{class:I(["es-select-display__item",{align:e.type==="align"}]),key:t[e.valueKey]},[e.hasCustomItemRender?me(e.$slots,"item",{key:0,item:t}):(x(),O("span",{key:1,class:I(["es-select-display__item__label",{align:e.type==="align"}])},H(t[e.labelKey]),3)),e.withDelete?(x(),O("span",{key:2,class:I(["clear",e.iconClassName]),style:be(e.iconStyle),onClick:L(u=>e.deleteItem(s),["stop"])},null,14,Re)):R("v-if",!0)],2))),128)),e.clearable?(x(),O("span",{key:2,class:"right-icon clear el-icon-circle-close",onClick:a[0]||(a[0]=L((...t)=>e.clearModelValue&&e.clearModelValue(...t),["stop"]))})):R("v-if",!0),De]),_:3},16,["height","max-height","style"])}function Fe(e,a){a===void 0&&(a={});var f=a.insertAt;if(!(!e||typeof document=="undefined")){var _=document.head||document.getElementsByTagName("head")[0],g=document.createElement("style");g.type="text/css",f==="top"&&_.firstChild?_.insertBefore(g,_.firstChild):_.appendChild(g),g.styleSheet?g.styleSheet.cssText=e:g.appendChild(document.createTextNode(e))}}var $e=`.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; }`;Fe($e),T.render=ze,T.__scopeId="data-v-2526f022",T.__file="components/select-display/index.vue",T.install=e=>{e.component("es-select-display",T)};export{T as default};