UNPKG

eslink-ui-plus

Version:

vue3 component library, css framework

29 lines (28 loc) 14.5 kB
import{ElMessage as ee}from"element-plus";import{defineComponent as te,useCssVars as ne,pushScopeId as oe,popScopeId as re,openBlock as w,createElementBlock as A,normalizeStyle as D,Fragment as F,renderList as ie,createElementVNode as M,createTextVNode as $,toDisplayString as N,renderSlot as R}from"vue";var ae=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function le(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var H={exports:{}};/*! * clipboard.js v2.0.8 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */(function(r,_){(function(m,f){r.exports=f()})(ae,function(){return function(){var S={134:function(a,n,e){e.d(n,{default:function(){return Q}});var s=e(279),u=e.n(s),d=e(370),b=e.n(d),h=e(817),k=e.n(h);function p(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?p=function(t){return typeof t}:p=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(i)}function v(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function y(i,o){for(var t=0;t<o.length;t++){var l=o[t];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(i,l.key,l)}}function E(i,o,t){return o&&y(i.prototype,o),t&&y(i,t),i}var z=function(){function i(o){v(this,i),this.resolveOptions(o),this.initSelection()}return E(i,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var t=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[t?"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 t=this,l=this.createFakeElement();this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(l),this.selectedText=k()(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=k()(this.target),this.copyText()}},{key:"copyText",value:function(){var t;try{t=document.execCommand(this.action)}catch(l){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"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 t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"copy";if(this._action=t,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(t){if(t!==void 0)if(t&&p(t)==="object"&&t.nodeType===1){if(this.action==="copy"&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(this.action==="cut"&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);this._target=t}else throw new Error('Invalid "target" value, use a valid Element')},get:function(){return this._target}}]),i}(),B=z;function C(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(t){return typeof t}:C=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C(i)}function U(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function P(i,o){for(var t=0;t<o.length;t++){var l=o[t];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(i,l.key,l)}}function Y(i,o,t){return o&&P(i.prototype,o),t&&P(i,t),i}function W(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(o&&o.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),o&&L(i,o)}function L(i,o){return L=Object.setPrototypeOf||function(l,c){return l.__proto__=c,l},L(i,o)}function G(i){var o=q();return function(){var l=O(i),c;if(o){var g=O(this).constructor;c=Reflect.construct(l,arguments,g)}else c=l.apply(this,arguments);return J(this,c)}}function J(i,o){return o&&(C(o)==="object"||typeof o=="function")?o:X(i)}function X(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function q(){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(i){return!1}}function O(i){return O=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},O(i)}function j(i,o){var t="data-clipboard-".concat(i);if(!!o.hasAttribute(t))return o.getAttribute(t)}var K=function(i){W(t,i);var o=G(t);function t(l,c){var g;return U(this,t),g=o.call(this),g.resolveOptions(c),g.listenClick(l),g}return Y(t,[{key:"resolveOptions",value:function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof c.action=="function"?c.action:this.defaultAction,this.target=typeof c.target=="function"?c.target:this.defaultTarget,this.text=typeof c.text=="function"?c.text:this.defaultText,this.container=C(c.container)==="object"?c.container:document.body}},{key:"listenClick",value:function(c){var g=this;this.listener=b()(c,"click",function(x){return g.onClick(x)})}},{key:"onClick",value:function(c){var g=c.delegateTarget||c.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new B({action:this.action(g),target:this.target(g),text:this.text(g),container:this.container,trigger:g,emitter:this})}},{key:"defaultAction",value:function(c){return j("action",c)}},{key:"defaultTarget",value:function(c){var g=j("target",c);if(g)return document.querySelector(g)}},{key:"defaultText",value:function(c){return j("text",c)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],g=typeof c=="string"?[c]:c,x=!!document.queryCommandSupported;return g.forEach(function(Z){x=x&&!!document.queryCommandSupported(Z)}),x}}]),t}(u()),Q=K},828:function(a){var n=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var e=Element.prototype;e.matches=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}function s(u,d){for(;u&&u.nodeType!==n;){if(typeof u.matches=="function"&&u.matches(d))return u;u=u.parentNode}}a.exports=s},438:function(a,n,e){var s=e(828);function u(h,k,p,v,y){var E=b.apply(this,arguments);return h.addEventListener(p,E,y),{destroy:function(){h.removeEventListener(p,E,y)}}}function d(h,k,p,v,y){return typeof h.addEventListener=="function"?u.apply(null,arguments):typeof p=="function"?u.bind(null,document).apply(null,arguments):(typeof h=="string"&&(h=document.querySelectorAll(h)),Array.prototype.map.call(h,function(E){return u(E,k,p,v,y)}))}function b(h,k,p,v){return function(y){y.delegateTarget=s(y.target,k),y.delegateTarget&&v.call(h,y)}}a.exports=d},879:function(a,n){n.node=function(e){return e!==void 0&&e instanceof HTMLElement&&e.nodeType===1},n.nodeList=function(e){var s=Object.prototype.toString.call(e);return e!==void 0&&(s==="[object NodeList]"||s==="[object HTMLCollection]")&&"length"in e&&(e.length===0||n.node(e[0]))},n.string=function(e){return typeof e=="string"||e instanceof String},n.fn=function(e){var s=Object.prototype.toString.call(e);return s==="[object Function]"}},370:function(a,n,e){var s=e(879),u=e(438);function d(p,v,y){if(!p&&!v&&!y)throw new Error("Missing required arguments");if(!s.string(v))throw new TypeError("Second argument must be a String");if(!s.fn(y))throw new TypeError("Third argument must be a Function");if(s.node(p))return b(p,v,y);if(s.nodeList(p))return h(p,v,y);if(s.string(p))return k(p,v,y);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function b(p,v,y){return p.addEventListener(v,y),{destroy:function(){p.removeEventListener(v,y)}}}function h(p,v,y){return Array.prototype.forEach.call(p,function(E){E.addEventListener(v,y)}),{destroy:function(){Array.prototype.forEach.call(p,function(E){E.removeEventListener(v,y)})}}}function k(p,v,y){return u(document.body,p,v,y)}a.exports=d},817:function(a){function n(e){var s;if(e.nodeName==="SELECT")e.focus(),s=e.value;else if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){var u=e.hasAttribute("readonly");u||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),u||e.removeAttribute("readonly"),s=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var d=window.getSelection(),b=document.createRange();b.selectNodeContents(e),d.removeAllRanges(),d.addRange(b),s=d.toString()}return s}a.exports=n},279:function(a){function n(){}n.prototype={on:function(e,s,u){var d=this.e||(this.e={});return(d[e]||(d[e]=[])).push({fn:s,ctx:u}),this},once:function(e,s,u){var d=this;function b(){d.off(e,b),s.apply(u,arguments)}return b._=s,this.on(e,b,u)},emit:function(e){var s=[].slice.call(arguments,1),u=((this.e||(this.e={}))[e]||[]).slice(),d=0,b=u.length;for(d;d<b;d++)u[d].fn.apply(u[d].ctx,s);return this},off:function(e,s){var u=this.e||(this.e={}),d=u[e],b=[];if(d&&s)for(var h=0,k=d.length;h<k;h++)d[h].fn!==s&&d[h].fn._!==s&&b.push(d[h]);return b.length?u[e]=b:delete u[e],this}},a.exports=n,a.exports.TinyEmitter=n}},m={};function f(a){if(m[a])return m[a].exports;var n=m[a]={exports:{}};return S[a](n,n.exports,f),n.exports}return function(){f.n=function(a){var n=a&&a.__esModule?function(){return a.default}:function(){return a};return f.d(n,{a:n}),n}}(),function(){f.d=function(a,n){for(var e in n)f.o(n,e)&&!f.o(a,e)&&Object.defineProperty(a,e,{enumerable:!0,get:n[e]})}}(),function(){f.o=function(a,n){return Object.prototype.hasOwnProperty.call(a,n)}}(),f(134)}().default})})(H);var se=le(H.exports);const ue=(r,_,S)=>{var m;let f=null;const a=document.querySelector(".copy-virtual-btn");a?f=a:(f=document.createElement("button"),f.setAttribute("class","copy-virtual-btn"),f.setAttribute("style","display: none"),(m=document.body)==null||m.appendChild(f));const n=new se(".copy-virtual-btn");f.setAttribute("data-clipboard-text",r),n.on("success",function(e){typeof _=="function"&&_(e),n.destroy()}),n.on("error",function(e){typeof S=="function"&&S(e),n.destroy()}),f.click()},T=te({props:{styles:{type:Object,default:()=>({})},labelWidth:{type:Number,default:56},config:{type:Array,default:()=>[]},source:{type:Object,default:()=>({})},align:{type:String,default:"right"}},setup(r,{slots:_}){return{slots:_,hasSlot:(a,n)=>{const e=`${n==null?void 0:n.key}-slot-${a}`;return!!_[e]},slotName:(a,n)=>`${n==null?void 0:n.key}-slot-${a}`,copyValue:a=>{ue(a,()=>{ee.success("\u590D\u5236\u6210\u529F")})}}}}),V=()=>{ne(r=>({"2f0e9b96-align":r.align}))},I=T.setup;T.setup=I?(r,_)=>(V(),I(r,_)):V,oe("data-v-2f0e9b96");const ce=["title"],fe=["title"],de=["onClick"],pe=["onClick"];re();function ye(r,_,S,m,f,a){return w(),A("div",{class:"es-info-list",style:D(r.styles)},[(w(!0),A(F,null,ie(r.config,n=>(w(),A("div",{class:"es-info-list__item",key:n.key},[M("span",{class:"es-info-list__item__label",style:D({width:`${r.labelWidth}px`}),title:n.label},[n.labelDisplay?(w(),A(F,{key:0},[$(N(n.labelDisplay(n,r.source)),1)],2112)):r.hasSlot("label",n)?R(r.$slots,r.slotName("label",n),{key:1,item:n,source:r.source}):(w(),A(F,{key:2},[$(N(n.label||""),1)],2112))],12,ce),M("span",{class:"es-info-list__item__value",title:r.source&&r.source[n.key]||""},[n.valueDisplay?(w(),A("span",{key:0,onClick:e=>{var s,u;return r.copyValue((u=(s=n==null?void 0:n.valueDisplay)==null?void 0:s.call(n,n,r.source))!=null?u:"")}},N(n.valueDisplay(n,r.source)),9,de)):r.hasSlot("value",n)?R(r.$slots,r.slotName("value",n),{key:1,item:n,source:r.source}):(w(),A("span",{key:2,onClick:e=>r.copyValue(r.source&&r.source[n.key]||"")},N(r.source&&r.source[n.key]||""),9,pe))],8,fe)]))),128)),R(r.$slots,"decoration")],4)}function he(r,_){_===void 0&&(_={});var S=_.insertAt;if(!(!r||typeof document=="undefined")){var m=document.head||document.getElementsByTagName("head")[0],f=document.createElement("style");f.type="text/css",S==="top"&&m.firstChild?m.insertBefore(f,m.firstChild):m.appendChild(f),f.styleSheet?f.styleSheet.cssText=r:f.appendChild(document.createTextNode(r))}}var ve=`.es-info-list[data-v-2f0e9b96] { display: inline-block; line-height: 21px; } .es-info-list__item[data-v-2f0e9b96] { display: flex; } .es-info-list__item__label[data-v-2f0e9b96], .es-info-list__item__value[data-v-2f0e9b96] { display: inline-block; } .es-info-list__item__label[data-v-2f0e9b96] { color: #7a7c90; text-align: var(--2f0e9b96-align); font-size: 14px; margin-right: 20px; } .es-info-list__item__value[data-v-2f0e9b96] { cursor: pointer; text-align: left; color: #282934; font-size: 14px; flex: 1; }`;he(ve),T.render=ye,T.__scopeId="data-v-2f0e9b96",T.__file="components/info-list/index.vue",T.install=r=>{r.component("es-info-list",T)};export{T as default};