UNPKG

eslink-ui-plus

Version:

vue3 component library, css framework

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