UNPKG

eslink-ui-plus

Version:

vue3 component library, css framework

7 lines (6 loc) 19 kB
import{ref as N,onMounted as ce,onBeforeUnmount as fe}from"vue";const O={labelKey:"label",valueKey:"value",disabledKey:"disabled",childrenKey:"children"},de={type:Object,default:()=>O},pe={type:Object,default:()=>[]},he={type:Boolean,default:!1};var ye=Object.defineProperty,H=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,K=(e,n,t)=>n in e?ye(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,V=(e,n)=>{for(var t in n||(n={}))ge.call(n,t)&&K(e,t,n[t]);if(H)for(var t of H(n))me.call(n,t)&&K(e,t,n[t]);return e};const P=e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase(),C=e=>P(e)==="object",ve=e=>P(e)==="array",be=e=>P(e)==="set",we=e=>typeof e=="string",$e=(e,n)=>{if(e.size!==n.size)return!1;for(const t of e)if(!n.has(t))return!1;return!0},j=(e={},n={})=>{for(const t in e)e.hasOwnProperty(t)&&(C(n[t])&&C(e[t])?j(e[t],n[t]):n[t]=e[t]);return n},Ee=(e,n)=>{const t={};return Object.keys(e).forEach(o=>{const s=`\${${o}}`;n.includes(s)?n=n.replace(`\${${o}}`,e[o]):t[o]=e[o]}),{otherParams:t,url:n}},_e=(e,n)=>{const t=new FormData;return Object.keys(e).forEach(o=>{const s=`\${${o}}`;n.includes(s)?n=n.replace(`\${${o}}`,e[o]):t.append(o,e[o])}),{otherParams:t,url:n}},B=(e=[],n=O,t=null,o={},s={})=>{const{valueKey:c,labelKey:a,childrenKey:r}=n;return e.length?(e.forEach(i=>{var f;const h=i[c],b=i[a];i.parent=t,i.path=t?[...t.path,h]:[h],i.labelPath=t?[...t.labelPath,b]:[b],i.leaf=!((f=i==null?void 0:i[r])==null?void 0:f.length),i.leafLabel=i.labelPath.join("/"),i[`_${a}`]=i[a],i[r]=(i==null?void 0:i[r])?B(i[r],n,i,o,s).source:[],o[h]=i.path,s[h]=i}),{source:e,pathMap:o,valueMap:s}):{source:e,pathMap:o,valueMap:s}},Te=e=>V(V({},O),e),Se=e=>e.toString().includes("px")?e:e+"px",De=e=>j(e,O),ke=(e=null)=>{const n=N(e);return[n,s=>{n.value=s},()=>n.value]},Oe=e=>{const n=N(!1),t=a=>{e.value.$el.contains(a.target)||s()},o=a=>{n.value=!n.value,a.cancelBubble=!0};ce(()=>{window.addEventListener("click",t,!1),e.value.$el.addEventListener("click",o)}),fe(()=>{window.removeEventListener("click",t),e.value.$el.removeEventListener("click",o)});const s=()=>{n.value=!1};return{panelShow:n,closePanel:s,openPanel:()=>{n.value=!0}}};var Le=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I={exports:{}};/*! * clipboard.js v2.0.8 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */(function(e,n){(function(o,s){e.exports=s()})(Le,function(){return function(){var t={134:function(c,a,r){r.d(a,{default:function(){return se}});var i=r(279),f=r.n(i),h=r(370),b=r.n(h),v=r(817),_=r.n(v);function g(d){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?g=function(l){return typeof l}:g=function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},g(d)}function w(d,u){if(!(d instanceof u))throw new TypeError("Cannot call a class as a function")}function m(d,u){for(var l=0;l<u.length;l++){var p=u[l];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(d,p.key,p)}}function T(d,u,l){return u&&m(d.prototype,u),l&&m(d,l),d}var X=function(){function d(u){w(this,d),this.resolveOptions(u),this.initSelection()}return T(d,[{key:"resolveOptions",value:function(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=l.action,this.container=l.container,this.emitter=l.emitter,this.target=l.target,this.text=l.text,this.trigger=l.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var l=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[l?"right":"left"]="-9999px";var p=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(p,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var l=this,p=this.createFakeElement();this.fakeHandlerCallback=function(){return l.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(p),this.selectedText=_()(p),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=_()(this.target),this.copyText()}},{key:"copyText",value:function(){var l;try{l=document.execCommand(this.action)}catch(p){l=!1}this.handleResult(l)}},{key:"handleResult",value:function(l){this.emitter.emit(l?"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 l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"copy";if(this._action=l,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(l){if(l!==void 0)if(l&&g(l)==="object"&&l.nodeType===1){if(this.action==="copy"&&l.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(this.action==="cut"&&(l.hasAttribute("readonly")||l.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);this._target=l}else throw new Error('Invalid "target" value, use a valid Element')},get:function(){return this._target}}]),d}(),Z=X;function D(d){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?D=function(l){return typeof l}:D=function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},D(d)}function ee(d,u){if(!(d instanceof u))throw new TypeError("Cannot call a class as a function")}function Y(d,u){for(var l=0;l<u.length;l++){var p=u[l];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(d,p.key,p)}}function te(d,u,l){return u&&Y(d.prototype,u),l&&Y(d,l),d}function ne(d,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function");d.prototype=Object.create(u&&u.prototype,{constructor:{value:d,writable:!0,configurable:!0}}),u&&x(d,u)}function x(d,u){return x=Object.setPrototypeOf||function(p,y){return p.__proto__=y,p},x(d,u)}function re(d){var u=ae();return function(){var p=L(d),y;if(u){var E=L(this).constructor;y=Reflect.construct(p,arguments,E)}else y=p.apply(this,arguments);return oe(this,y)}}function oe(d,u){return u&&(D(u)==="object"||typeof u=="function")?u:ie(d)}function ie(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}function ae(){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(d){return!1}}function L(d){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},L(d)}function A(d,u){var l="data-clipboard-".concat(d);if(!!u.hasAttribute(l))return u.getAttribute(l)}var le=function(d){ne(l,d);var u=re(l);function l(p,y){var E;return ee(this,l),E=u.call(this),E.resolveOptions(y),E.listenClick(p),E}return te(l,[{key:"resolveOptions",value:function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof y.action=="function"?y.action:this.defaultAction,this.target=typeof y.target=="function"?y.target:this.defaultTarget,this.text=typeof y.text=="function"?y.text:this.defaultText,this.container=D(y.container)==="object"?y.container:document.body}},{key:"listenClick",value:function(y){var E=this;this.listener=b()(y,"click",function(k){return E.onClick(k)})}},{key:"onClick",value:function(y){var E=y.delegateTarget||y.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new Z({action:this.action(E),target:this.target(E),text:this.text(E),container:this.container,trigger:E,emitter:this})}},{key:"defaultAction",value:function(y){return A("action",y)}},{key:"defaultTarget",value:function(y){var E=A("target",y);if(E)return document.querySelector(E)}},{key:"defaultText",value:function(y){return A("text",y)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],E=typeof y=="string"?[y]:y,k=!!document.queryCommandSupported;return E.forEach(function(ue){k=k&&!!document.queryCommandSupported(ue)}),k}}]),l}(f()),se=le},828:function(c){var a=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}function i(f,h){for(;f&&f.nodeType!==a;){if(typeof f.matches=="function"&&f.matches(h))return f;f=f.parentNode}}c.exports=i},438:function(c,a,r){var i=r(828);function f(v,_,g,w,m){var T=b.apply(this,arguments);return v.addEventListener(g,T,m),{destroy:function(){v.removeEventListener(g,T,m)}}}function h(v,_,g,w,m){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(T){return f(T,_,g,w,m)}))}function b(v,_,g,w){return function(m){m.delegateTarget=i(m.target,_),m.delegateTarget&&w.call(v,m)}}c.exports=h},879:function(c,a){a.node=function(r){return r!==void 0&&r instanceof HTMLElement&&r.nodeType===1},a.nodeList=function(r){var i=Object.prototype.toString.call(r);return r!==void 0&&(i==="[object NodeList]"||i==="[object HTMLCollection]")&&"length"in r&&(r.length===0||a.node(r[0]))},a.string=function(r){return typeof r=="string"||r instanceof String},a.fn=function(r){var i=Object.prototype.toString.call(r);return i==="[object Function]"}},370:function(c,a,r){var i=r(879),f=r(438);function h(g,w,m){if(!g&&!w&&!m)throw new Error("Missing required arguments");if(!i.string(w))throw new TypeError("Second argument must be a String");if(!i.fn(m))throw new TypeError("Third argument must be a Function");if(i.node(g))return b(g,w,m);if(i.nodeList(g))return v(g,w,m);if(i.string(g))return _(g,w,m);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function b(g,w,m){return g.addEventListener(w,m),{destroy:function(){g.removeEventListener(w,m)}}}function v(g,w,m){return Array.prototype.forEach.call(g,function(T){T.addEventListener(w,m)}),{destroy:function(){Array.prototype.forEach.call(g,function(T){T.removeEventListener(w,m)})}}}function _(g,w,m){return f(document.body,g,w,m)}c.exports=h},817:function(c){function a(r){var i;if(r.nodeName==="SELECT")r.focus(),i=r.value;else if(r.nodeName==="INPUT"||r.nodeName==="TEXTAREA"){var f=r.hasAttribute("readonly");f||r.setAttribute("readonly",""),r.select(),r.setSelectionRange(0,r.value.length),f||r.removeAttribute("readonly"),i=r.value}else{r.hasAttribute("contenteditable")&&r.focus();var h=window.getSelection(),b=document.createRange();b.selectNodeContents(r),h.removeAllRanges(),h.addRange(b),i=h.toString()}return i}c.exports=a},279:function(c){function a(){}a.prototype={on:function(r,i,f){var h=this.e||(this.e={});return(h[r]||(h[r]=[])).push({fn:i,ctx:f}),this},once:function(r,i,f){var h=this;function b(){h.off(r,b),i.apply(f,arguments)}return b._=i,this.on(r,b,f)},emit:function(r){var i=[].slice.call(arguments,1),f=((this.e||(this.e={}))[r]||[]).slice(),h=0,b=f.length;for(h;h<b;h++)f[h].fn.apply(f[h].ctx,i);return this},off:function(r,i){var f=this.e||(this.e={}),h=f[r],b=[];if(h&&i)for(var v=0,_=h.length;v<_;v++)h[v].fn!==i&&h[v].fn._!==i&&b.push(h[v]);return b.length?f[r]=b:delete f[r],this}},c.exports=a,c.exports.TinyEmitter=a}},o={};function s(c){if(o[c])return o[c].exports;var a=o[c]={exports:{}};return t[c](a,a.exports,s),a.exports}return function(){s.n=function(c){var a=c&&c.__esModule?function(){return c.default}:function(){return c};return s.d(a,{a}),a}}(),function(){s.d=function(c,a){for(var r in a)s.o(a,r)&&!s.o(c,r)&&Object.defineProperty(c,r,{enumerable:!0,get:a[r]})}}(),function(){s.o=function(c,a){return Object.prototype.hasOwnProperty.call(c,a)}}(),s(134)}().default})})(I);var xe=Pe(I.exports);const Ae=(e,n,t)=>{var o;let s=null;const c=document.querySelector(".copy-virtual-btn");c?s=c:(s=document.createElement("button"),s.setAttribute("class","copy-virtual-btn"),s.setAttribute("style","display: none"),(o=document.body)==null||o.appendChild(s));const a=new xe(".copy-virtual-btn");s.setAttribute("data-clipboard-text",e),a.on("success",function(r){typeof n=="function"&&n(r),a.destroy()}),a.on("error",function(r){typeof t=="function"&&t(r),a.destroy()}),s.click()};var Ce=Object.defineProperty,je=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,Fe=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,z=(e,n,t)=>n in e?Ce(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Ye=(e,n)=>{for(var t in n||(n={}))Fe.call(n,t)&&z(e,t,n[t]);if(q)for(var t of q(n))Re.call(n,t)&&z(e,t,n[t]);return e},Ne=(e,n)=>je(e,Me(n));const $=e=>e<10?`0${e}`:e,M=(e,n,t=!0)=>{const o=[],s={31:[1,3,5,7,8,10,12],30:[4,6,9,11],28:[2]},c=Object.values(s).findIndex(f=>f.includes(n)),r=Object.keys(s)[c];let i=1;for(;i<=+r;){const f=t?`${e}-${$(n)}-${$(i)}`:`${$(i)}\u65E5`;o.push({label:f,value:`${e}-${$(n)}-${$(i)}`}),i++}return o},F=e=>{const n=e?new Date(e):new Date,t=n.getFullYear(),o=n.getMonth()+1,s=n.getDate(),c=n.getDay(),a=+new Date(`${t}-${$(o)}-${$(s)}`),r=3600*1e3*24;let i,f;c===1?(i=a,f=i+6*r):c>0?(i=a-(c-1)*r,f=i+6*r):(i=a-(7-1)*r,f=i+6*r);const h=new Date(i).toLocaleDateString().split("/").map(v=>$(v)).join("-"),b=new Date(f).toLocaleDateString().split("/").map(v=>$(v)).join("-");return{timeString:{startTime:h,endTime:b},timeStamp:{startTime:+new Date(i),endTime:+new Date(f)}}},U=e=>{const n=e?new Date(e):new Date,t=n.getFullYear(),o=n.getMonth()+1,s=new Date(t,o,0).getDate();return{timeString:{startTime:`${t}-${$(o)}-01`,endTime:`${t}-${$(o)}-${s}`},timeStamp:{startTime:+new Date(`${t}-${$(o)}-01`),endTime:+new Date(`${t}-${$(o)}-${s}`)}}},Q=e=>{const t=(e?new Date(e):new Date).getFullYear();return{timeString:{startTime:`${t}-01-01`,endTime:`${t}-12-31`},timeStamp:{startTime:+new Date(`${t}-01-01`),endTime:+new Date(`${t}-12-31`)}}},He=e=>{const n=e?new Date(e):new Date,t=n.getFullYear(),o=n.getMonth()+1,s=o>6?7:1,c=o>6?12:6,a=o>6?31:30;return{timeString:{startTime:`${t}-${$(s)}-01`,endTime:`${t}-${$(c)}-${a}`},timeStamp:{startTime:+new Date(`${t}-${$(s)}-01`),endTime:+new Date(`${t}-${$(c)}-${a}`)}}},W=e=>{const n=e?new Date(e):new Date,t=n.getFullYear(),o=n.getMonth()+1;let s=null;[[1,2,3],[4,5,6],[7,8,9],[10,11,12]].forEach((r,i)=>{r.includes(o)&&(s=i+1)});const a=Ke(s);return{timeString:{startTime:`${t}-${a[0]}`,endTime:`${t}-${a[1]}`},timeStamp:{startTime:+new Date(`${t}-${a[0]}`),endTime:+new Date(`${t}-${a[1]}`)}}},Ke=e=>({1:["01-01","03-31"],2:["04-01","06-30"],3:["07-01","09-30"],4:["10-01","12-31"]})[e],S=(e=5)=>{const n=[],t=new Date().getFullYear();if(e===void 0)return[];for(e--;e;)n.push(t-e),e--;return n.push(t),n},R=(e=new Date().getFullYear(),n=!0)=>{const t=[];let o=1;for(;o<=12;){const s=n?`${o}\u6708`:o,c=U(`${e}-${o}-01`).timeString;t.push({label:s,value:`${c.startTime}~${c.endTime}`,month:o}),o++}return t},G=(e=new Date().getFullYear(),n=!0)=>{const t=[];let o=1;const s={1:`${e}-01-01`,2:`${e}-04-01`,3:`${e}-07-01`,4:`${e}-10-01`};for(;o<=4;){const c=n?`\u7B2C${o}\u5B63\u5EA6`:o,a=W(s[o]).timeString;t.push({label:c,value:`${a.startTime}~${a.endTime}`}),o++}return t},J=(e=new Date().getFullYear(),n=!0)=>{const t=3600*1e3*24,o=[],s=new Date(`${e}-01-01`),c=+new Date(`${e}-12-31`);let a=F(s),r=1;for(;a.timeStamp.startTime<=c;){const i=n?`\u7B2C${r}\u5468 (${a.timeString.startTime} ~ ${a.timeString.endTime})`:`\u7B2C${r}\u5468`;o.push({label:i,value:`${a.timeString.startTime}~${a.timeString.endTime}`}),r++,a=F(a.timeStamp.endTime+t)}return o},Ve=(e=5)=>S(e).map(t=>({label:`${t}\u5E74`,value:`${t}\u5E74`,children:J(t).map(o=>({complateLabel:`${t}\u5E74 ${o.label}`,label:o.label,value:o.value}))})),Be=(e=5)=>S(e).map(t=>({label:`${t}\u5E74`,value:`${t}\u5E74`,children:R(t).map(o=>({complateLabel:`${t}\u5E74 ${o.label}`,label:o.label,value:o.value}))})),Ie=(e=5)=>S(e).map(t=>({label:`${t}\u5E74`,value:`${t}\u5E74`,children:G(t).map(o=>({complateLabel:`${t}\u5E74 ${o.label}`,label:o.label,value:o.value}))})),qe=(e=5)=>S(e).map(t=>({label:`${t}\u5E74`,value:`${t}\u5E74`,children:R(t).map(o=>({label:o.label,value:o.value,children:M(t,o.month,!1).map(s=>({complateLabel:`${t}\u5E74 ${o.label} ${s.label}`,label:s.label,value:s.value}))}))})),ze=(e=5)=>S(e).map(t=>{const o=Q(`${t}-01-01`).timeString;return{complateLabel:`${t}\u5E74`,label:`${t}\u5E74`,value:`${o.startTime}~${o.endTime}`}}),Ue=e=>{const n=[];let t=1;const o={0:"\u65E5",1:"\u4E00",2:"\u4E8C",3:"\u4E09",4:"\u56DB",5:"\u4E94",6:"\u516D"};for(;t<=12;){const s=M(e,t);n.push({title:`${e}-${$(t)}`,list:s.map(c=>{const r=new Date(c.value).getDay(),i=new Date(c.value).getDate();return Ne(Ye({},c),{week:r,weekDesc:o[r],day:i})})}),t++}return n};export{$ as addZero,Ae as copyTool,$e as equalSet,Se as getCssUnit,M as getDayListByMonth,He as getHalfYear,Te as getKeyConfig,U as getMonth,R as getMonthList,W as getQuarter,G as getQuarterList,F as getWeek,J as getWeekList,Q as getYear,Ue as getYearCanlandar,qe as getYearDayList,ze as getYearLabelList,S as getYearList,Be as getYearMonthList,Ie as getYearQuarterList,Ve as getYearWeekList,O as initKeyConfig,B as initSource,ve as isArray,C as isObject,be as isSet,we as isString,de as keyConfigProp,j as merge,he as multipleProp,pe as sourceProp,_e as toRestFullFormDataResult,Ee as toRestFullResult,P as typeOf,De as useConfigKey,ke as useRefValue,Oe as useTogglePanle};