UNPKG

dm-vue3-ui

Version:

This Components Library will help get you started developing in Vue 3.

2 lines (1 loc) 4.65 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("dayjs");const n="undefined"!=typeof window?window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame:()=>{},i="undefined"!=typeof window?window.cancelAnimationFrame:()=>{};function o(e,t=0,n=!1){const i="undefined"!=typeof window?window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame:()=>{};let o=null;const r={id:i((function s(l){o||(o=l),l-o>=t?(e(),n&&(o=null,r.id=i(s))):r.id=i(s)}))};return r}function r(e){const t="undefined"!=typeof window?window.cancelAnimationFrame:()=>{};e&&e.id&&t(e.id)}const s="di-alert-search-template";function l(e,t){if("undefined"!=typeof window&&(null==window?void 0:window.localStorage))try{if(void 0===t)return(t=localStorage.getItem(e))&&function(e){try{return JSON.parse(e)}catch(t){return e}}(t);localStorage.setItem(e,JSON.stringify(t))}catch(n){}}exports.add=function(e,t){const n=String(e).split(".")[1],i=String(t).split(".")[1],o=Math.max((null==n?void 0:n.length)||0,(null==i?void 0:i.length)||0),r=e.toFixed(o),s=t.toFixed(o);return(+r.replace(".","")+ +s.replace(".",""))/Math.pow(10,o)},exports.addTemplate=(e,t)=>{const n=l(s)&&JSON.parse(l(s))||{},i=n[e]||[],o=i.findIndex((e=>e.name===t.name));-1===o||i.splice(o,1),i.push(t),n[e]=i,l(s,JSON.stringify(n))},exports.cancelAnimationFrame=i,exports.cancelRaf=r,exports.dateFormat=function(e=Date.now(),t="YYYY-MM-DD HH:mm:ss"){let n;function i(e){return e<10?"0"+e:String(e)}n="number"==typeof e||"string"==typeof e?new Date(e):e;let o=t;if(o.includes("SSS")){const e=n.getMilliseconds();o=o.replace("SSS","0".repeat(3-String(e).length)+e)}if(o.includes("YY")){const e=n.getFullYear();o=o.includes("YYYY")?o.replace("YYYY",String(e)):o.replace("YY",String(e).slice(2,4))}if(o.includes("M")){const e=n.getMonth()+1;o=o.includes("MM")?o.replace("MM",i(e)):o.replace("M",String(e))}if(o.includes("D")){const e=n.getDate();o=o.includes("DD")?o.replace("DD",i(e)):o.replace("D",String(e))}if(o.includes("H")){const e=n.getHours();o=o.includes("HH")?o.replace("HH",i(e)):o.replace("H",String(e))}if(o.includes("m")){const e=n.getMinutes();o=o.includes("mm")?o.replace("mm",i(e)):o.replace("m",String(e))}if(o.includes("s")){const e=n.getSeconds();o=o.includes("ss")?o.replace("ss",i(e)):o.replace("s",String(e))}return o},exports.debounce=function(e,t=300){let n=null;return function(){n&&r(n),n=o(e,t)}},exports.deleteTemplate1=(e,t)=>{const n=l(s)&&JSON.parse(l(s))||{},i=n[e]||[],o=i.findIndex((e=>e.name===t));-1===o||i.splice(o,1),n[e]=i,l(s,JSON.stringify(n))},exports.downloadFile=function(e,t){let n="";if(t)n=t;else{const t=e.split("?")[0].split("/");n=t[t.length-1]}const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="blob",i.onload=function(){if(200===i.status){const e=i.response,t=document.createElement("a"),o=document.querySelector("body");t.href="undefined"!=typeof window?window.URL.createObjectURL(e):"",t.download=n,t.style.display="none",null==o||o.appendChild(t),t.click(),null==o||o.removeChild(t),"undefined"!=typeof window&&window.URL.revokeObjectURL(t.href)}},i.send()},exports.getTemplatesByModuleKey=e=>(l(s)&&JSON.parse(l(s))||{})[e]||[],exports.moneyFormat=function(e,t=2,n=","){function i(e){const t=e.length;return t<=3?e:i(e.slice(0,t-3))+n+e.slice(t-3,t)}const o=String(e);if(isFinite(parseFloat(o))){if(0===parseFloat(o))return parseFloat(o).toFixed(t);{let e="";const n=o.indexOf(".");if(-1===n)e=0===t?i(o):i(o)+"."+"0".repeat(t);else{const r=String((Math.round(parseFloat(o)*Math.pow(10,t))/Math.pow(10,t)).toFixed(t)),s=r.slice(n,n+t+1);e=i(r.slice(0,n))+s}return e}}return"--"},exports.rafTimeout=o,exports.removeStore=function(e){if("undefined"!=typeof window)try{localStorage.removeItem(e)}catch(t){}},exports.requestAnimationFrame=n,exports.store=l,exports.throttle=function(e,t=300){let n=!0;return function(){return n&&(n=!1,o((()=>{e(),n=!0}),t)),!1}},exports.useSlotsExist=function(t="default"){const n=e.useSlots(),i=e=>{var t;const i=null==(t=n[e])?void 0:t.call(n);if(i&&(null==i?void 0:i.length)){return i.some((e=>(e=>"string"==typeof e.children?"v-if"!==e.children&&""!==e.children.trim():null!==e.children?Boolean(e.children):"img"===e.type||"string"!=typeof e.type||void 0)(e)))}return!1};if(Array.isArray(t)){const n=e.reactive({});return t.forEach((t=>{const o=e.computed((()=>i(t)));n[t]=o})),n}return e.computed((()=>i(t)))},exports.validateRangeDateValue=e=>!(!Array.isArray(e)||2!==e.length)&&e.every((e=>e&&t(e).isValid()));