UNPKG

eslink-ui-plus

Version:

vue3 component library, css framework

9 lines (8 loc) 13.1 kB
(function(h,w){typeof exports=="object"&&typeof module!="undefined"?module.exports=w(require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["vue","element-plus"],w):(h=typeof globalThis!="undefined"?globalThis:h||self,h["es-form-select"]=w(h.Vue,h.ElementPlus))})(this,function(h,w){"use strict";const R={labelKey:"label",valueKey:"value",disabledKey:"disabled",childrenKey:"children"},M={type:Object,default:()=>R};var H=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},B={exports:{}};/*! * clipboard.js v2.0.8 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */(function(d,b){(function(k,y){d.exports=y()})(H,function(){return function(){var g={134:function(c,a,e){e.d(a,{default:function(){return ne}});var i=e(279),l=e.n(i),u=e(370),E=e.n(u),v=e(817),S=e.n(v);function f(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?f=function(t){return typeof t}:f=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(r)}function m(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function p(r,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(r,o.key,o)}}function T(r,n,t){return n&&p(r.prototype,n),t&&p(r,t),r}var Y=function(){function r(n){m(this,r),this.resolveOptions(n),this.initSelection()}return T(r,[{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 o=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(o,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var t=this,o=this.createFakeElement();this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(o),this.selectedText=S()(o),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=S()(this.target),this.copyText()}},{key:"copyText",value:function(){var t;try{t=document.execCommand(this.action)}catch(o){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&&f(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}}]),r}(),q=Y;function O(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(t){return typeof t}:O=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(r)}function G(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function K(r,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(r,o.key,o)}}function X(r,n,t){return n&&K(r.prototype,n),t&&K(r,t),r}function J(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),n&&P(r,n)}function P(r,n){return P=Object.setPrototypeOf||function(o,s){return o.__proto__=s,o},P(r,n)}function Q(r){var n=ee();return function(){var o=A(r),s;if(n){var _=A(this).constructor;s=Reflect.construct(o,arguments,_)}else s=o.apply(this,arguments);return W(this,s)}}function W(r,n){return n&&(O(n)==="object"||typeof n=="function")?n:Z(r)}function Z(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function ee(){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(r){return!1}}function A(r){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},A(r)}function L(r,n){var t="data-clipboard-".concat(r);if(!!n.hasAttribute(t))return n.getAttribute(t)}var te=function(r){J(t,r);var n=Q(t);function t(o,s){var _;return G(this,t),_=n.call(this),_.resolveOptions(s),_.listenClick(o),_}return X(t,[{key:"resolveOptions",value:function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof s.action=="function"?s.action:this.defaultAction,this.target=typeof s.target=="function"?s.target:this.defaultTarget,this.text=typeof s.text=="function"?s.text:this.defaultText,this.container=O(s.container)==="object"?s.container:document.body}},{key:"listenClick",value:function(s){var _=this;this.listener=E()(s,"click",function(C){return _.onClick(C)})}},{key:"onClick",value:function(s){var _=s.delegateTarget||s.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new q({action:this.action(_),target:this.target(_),text:this.text(_),container:this.container,trigger:_,emitter:this})}},{key:"defaultAction",value:function(s){return L("action",s)}},{key:"defaultTarget",value:function(s){var _=L("target",s);if(_)return document.querySelector(_)}},{key:"defaultText",value:function(s){return L("text",s)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],_=typeof s=="string"?[s]:s,C=!!document.queryCommandSupported;return _.forEach(function(re){C=C&&!!document.queryCommandSupported(re)}),C}}]),t}(l()),ne=te},828:function(c){var a=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 i(l,u){for(;l&&l.nodeType!==a;){if(typeof l.matches=="function"&&l.matches(u))return l;l=l.parentNode}}c.exports=i},438:function(c,a,e){var i=e(828);function l(v,S,f,m,p){var T=E.apply(this,arguments);return v.addEventListener(f,T,p),{destroy:function(){v.removeEventListener(f,T,p)}}}function u(v,S,f,m,p){return typeof v.addEventListener=="function"?l.apply(null,arguments):typeof f=="function"?l.bind(null,document).apply(null,arguments):(typeof v=="string"&&(v=document.querySelectorAll(v)),Array.prototype.map.call(v,function(T){return l(T,S,f,m,p)}))}function E(v,S,f,m){return function(p){p.delegateTarget=i(p.target,S),p.delegateTarget&&m.call(v,p)}}c.exports=u},879:function(c,a){a.node=function(e){return e!==void 0&&e instanceof HTMLElement&&e.nodeType===1},a.nodeList=function(e){var i=Object.prototype.toString.call(e);return e!==void 0&&(i==="[object NodeList]"||i==="[object HTMLCollection]")&&"length"in e&&(e.length===0||a.node(e[0]))},a.string=function(e){return typeof e=="string"||e instanceof String},a.fn=function(e){var i=Object.prototype.toString.call(e);return i==="[object Function]"}},370:function(c,a,e){var i=e(879),l=e(438);function u(f,m,p){if(!f&&!m&&!p)throw new Error("Missing required arguments");if(!i.string(m))throw new TypeError("Second argument must be a String");if(!i.fn(p))throw new TypeError("Third argument must be a Function");if(i.node(f))return E(f,m,p);if(i.nodeList(f))return v(f,m,p);if(i.string(f))return S(f,m,p);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function E(f,m,p){return f.addEventListener(m,p),{destroy:function(){f.removeEventListener(m,p)}}}function v(f,m,p){return Array.prototype.forEach.call(f,function(T){T.addEventListener(m,p)}),{destroy:function(){Array.prototype.forEach.call(f,function(T){T.removeEventListener(m,p)})}}}function S(f,m,p){return l(document.body,f,m,p)}c.exports=u},817:function(c){function a(e){var i;if(e.nodeName==="SELECT")e.focus(),i=e.value;else if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){var l=e.hasAttribute("readonly");l||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),l||e.removeAttribute("readonly"),i=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var u=window.getSelection(),E=document.createRange();E.selectNodeContents(e),u.removeAllRanges(),u.addRange(E),i=u.toString()}return i}c.exports=a},279:function(c){function a(){}a.prototype={on:function(e,i,l){var u=this.e||(this.e={});return(u[e]||(u[e]=[])).push({fn:i,ctx:l}),this},once:function(e,i,l){var u=this;function E(){u.off(e,E),i.apply(l,arguments)}return E._=i,this.on(e,E,l)},emit:function(e){var i=[].slice.call(arguments,1),l=((this.e||(this.e={}))[e]||[]).slice(),u=0,E=l.length;for(u;u<E;u++)l[u].fn.apply(l[u].ctx,i);return this},off:function(e,i){var l=this.e||(this.e={}),u=l[e],E=[];if(u&&i)for(var v=0,S=u.length;v<S;v++)u[v].fn!==i&&u[v].fn._!==i&&E.push(u[v]);return E.length?l[e]=E:delete l[e],this}},c.exports=a,c.exports.TinyEmitter=a}},k={};function y(c){if(k[c])return k[c].exports;var a=k[c]={exports:{}};return g[c](a,a.exports,y),a.exports}return function(){y.n=function(c){var a=c&&c.__esModule?function(){return c.default}:function(){return c};return y.d(a,{a}),a}}(),function(){y.d=function(c,a){for(var e in a)y.o(a,e)&&!y.o(c,e)&&Object.defineProperty(c,e,{enumerable:!0,get:a[e]})}}(),function(){y.o=function(c,a){return Object.prototype.hasOwnProperty.call(c,a)}}(),y(134)}().default})})(B);var I=Object.defineProperty,j=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,N=(d,b,g)=>b in d?I(d,b,{enumerable:!0,configurable:!0,writable:!0,value:g}):d[b]=g,F=(d,b)=>{for(var g in b||(b={}))$.call(b,g)&&N(d,g,b[g]);if(j)for(var g of j(b))D.call(b,g)&&N(d,g,b[g]);return d},x=h.defineComponent({props:{keyConfig:M,source:{type:Array,default:()=>[]}},components:{ElSelect:w.ElSelect,ElOption:w.ElOption},setup(d,b){var g;const{valueKey:k,labelKey:y,disabledKey:c}=F(F({},R),(g=d==null?void 0:d.keyConfig)!=null?g:{});return{valueKey:k,labelKey:y,disabledKey:c}}});function z(d,b,g,k,y,c){const a=h.resolveComponent("el-option"),e=h.resolveComponent("el-select");return h.openBlock(),h.createBlock(e,h.mergeProps(d.$attrs,{class:"es-form-select"}),{default:h.withCtx(()=>[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(d.source,i=>(h.openBlock(),h.createBlock(a,{key:i[d.valueKey],label:i[d.labelKey],value:i[d.valueKey],disabled:i[d.disabledKey]},{default:h.withCtx(()=>[h.renderSlot(d.$slots,"default")]),_:2},1032,["label","value","disabled"]))),128))]),_:3},16)}function U(d,b){b===void 0&&(b={});var g=b.insertAt;if(!(!d||typeof document=="undefined")){var k=document.head||document.getElementsByTagName("head")[0],y=document.createElement("style");y.type="text/css",g==="top"&&k.firstChild?k.insertBefore(y,k.firstChild):k.appendChild(y),y.styleSheet?y.styleSheet.cssText=d:y.appendChild(document.createTextNode(d))}}var V=`.es-form-select[data-v-72f0de86] { display: inline-block; }`;return U(V),x.render=z,x.__scopeId="data-v-72f0de86",x.__file="components/form-select/index.vue",x.install=d=>{d.component("es-form-select",x)},x});