UNPKG

eslink-ui-plus

Version:

vue3 component library, css framework

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