@gx-design-vue/pro-utils 0.2.0-beta.8 → 0.2.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base64/index.d.ts +20 -0
- package/dist/cloneDeep/cloneDeepWith.d.ts +43 -0
- package/dist/cloneDeep/index.d.ts +47 -0
- package/dist/getValueFromObjectByKey/index.d.ts +3 -0
- package/dist/index.d.ts +18 -9
- package/dist/isImg/index.d.ts +2 -0
- package/dist/isNil/index.d.ts +1 -0
- package/dist/isUrl/index.d.ts +6 -0
- package/dist/merge/index.d.ts +45 -2
- package/dist/merge/mergeWith.d.ts +49 -0
- package/dist/merge/useDeepMege.d.ts +43 -0
- package/dist/nanoid/index.d.ts +6 -0
- package/dist/omitUndefined/index.d.ts +2 -5
- package/dist/omitUndefinedAndEmptyArr/index.d.ts +1 -0
- package/dist/pro-utils.js +1134 -0
- package/dist/pro-utils.umd.cjs +13 -0
- package/dist/slots/index.d.ts +67 -8
- package/dist/typings/index.d.ts +17 -16
- package/dist/utils/config.d.ts +1 -2
- package/dist/utils/getSymbols.d.ts +1 -0
- package/dist/utils/getTag.d.ts +8 -0
- package/dist/utils/index.d.ts +145 -22
- package/dist/utils/isNotNil.d.ts +1 -0
- package/dist/utils/isPlainObject.d.ts +43 -0
- package/dist/utils/isPrimitive.d.ts +29 -0
- package/dist/utils/isTypedArray.d.ts +27 -0
- package/dist/utils/isUnsafeProperty.d.ts +11 -0
- package/dist/utils/isValid.d.ts +2 -0
- package/dist/utils/raf.d.ts +5 -0
- package/dist/utils/tags.d.ts +26 -0
- package/dist/utils/validate.d.ts +11 -8
- package/package.json +26 -49
- package/dist/pro-utils.mjs +0 -562
- package/dist/pro-utils.umd.js +0 -1
- package/dist/scroll/raf.d.ts +0 -9
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Gx Design Pro
|
|
3
|
+
* Version: 0.2.0-beta.80
|
|
4
|
+
* Author: gx12358
|
|
5
|
+
* Copyright (C) 2024 gx12358
|
|
6
|
+
* License: MIT License
|
|
7
|
+
* Description: Gx Design Pro Utils
|
|
8
|
+
* Date Created: 2025-11-27
|
|
9
|
+
* Homepage:
|
|
10
|
+
* Contact: gx12358@gmail.com
|
|
11
|
+
*/
|
|
12
|
+
(function(s,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.GPorUtils={},s.vue))})(this,(function(s,d){"use strict";class de{constructor(){this._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}_utf8_encode(t){t=t.replace(/\r\n/g,`
|
|
13
|
+
`);let r="";for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);i<128?r+=String.fromCharCode(i):i>127&&i<2048?(r+=String.fromCharCode(i>>6|192),r+=String.fromCharCode(i&63|128)):(r+=String.fromCharCode(i>>12|224),r+=String.fromCharCode(i>>6&63|128),r+=String.fromCharCode(i&63|128))}return r}_utf8_decode(t){let r="",n=0,i=0,c=0,o=0;for(;n<t.length;)i=t.charCodeAt(n),i<128?(r+=String.fromCharCode(i),n++):i>191&&i<224?(c=t.charCodeAt(n+1),r+=String.fromCharCode((i&31)<<6|c&63),n+=2):(c=t.charCodeAt(n+1),o=t.charCodeAt(n+2),r+=String.fromCharCode((i&15)<<12|(c&63)<<6|o&63),n+=3);return r}encode(t){let r="",n,i,c,o,f,u,a,l=0;for(t=this._utf8_encode(t);l<t.length;)n=t.charCodeAt(l++),i=t.charCodeAt(l++),c=t.charCodeAt(l++),o=n>>2,f=(n&3)<<4|i>>4,u=(i&15)<<2|c>>6,a=c&63,Number.isNaN(i)?u=a=64:Number.isNaN(c)&&(a=64),r=r+this._keyStr.charAt(o)+this._keyStr.charAt(f)+this._keyStr.charAt(u)+this._keyStr.charAt(a);return r}decode(t){let r="",n,i,c,o,f,u,a,l=0;for(t=t.replace(/[^A-Z0-9+/=]/gi,"");l<t.length;)o=this._keyStr.indexOf(t.charAt(l++)),f=this._keyStr.indexOf(t.charAt(l++)),u=this._keyStr.indexOf(t.charAt(l++)),a=this._keyStr.indexOf(t.charAt(l++)),n=o<<2|f>>4,i=(f&15)<<4|u>>2,c=(u&3)<<6|a,r=r+String.fromCharCode(n),u!==64&&(r=r+String.fromCharCode(i)),a!==64&&(r=r+String.fromCharCode(c));return r=this._utf8_decode(r),r}}function v(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function I(e){return typeof e=="boolean"}function p(e){return typeof e=="number"}function g(e){return typeof Array.isArray>"u"?Object.prototype.toString.call(e)==="[object Array]":Array.isArray(e)}function w(e){return e!==null&&v(e,"Object")}function W(e){return typeof e=="string"||e instanceof String}function ge(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Function]"}function ye(e){if(typeof e!="string")return!1;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null}catch{return!1}}function he(){const e=navigator.userAgent||navigator.vendor;return!!(/iPhone/.test(e)||/Android/.test(e)&&/Mobile/.test(e)||/Windows Phone/.test(e)||/Mobile/.test(e)&&!V())}function V(){const e=navigator.userAgent||navigator.vendor;return!!(/iPad/.test(e)||/Macintosh/.test(e)&&"ontouchend"in document||/Android/.test(e)&&!/Mobile/.test(e))}function z(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n){if(W(n))t.push(n);else if(g(n))for(let i=0;i<n.length;i++){const c=z(n[i]);c&&t.push(c)}else if(w(n))for(const i in n)n[i]&&t.push(i)}}return t.filter(r=>r).join(" ")}function me(e,t){if(typeof t!="string"&&!Array.isArray(t))return;const r=Array.isArray(t)?t:t.split(":");let n=e;for(let i=0;i<r.length;i++)if(n&&Object.prototype.hasOwnProperty.call(n,r[i]))n=n[r[i]];else return;return n}const O=typeof window>"u";function pe(e){return e.replace(/[-_](.)/g,(t,r)=>r.toUpperCase())}const F=function(e,t){if(O||!e||!t)return"";t=pe(t),t==="float"&&(t="cssFloat");try{const r=e.style[t];if(r)return r;const n=document?.defaultView?.getComputedStyle(e,"");return n?n[t]:""}catch{return e.style[t]}},q=(e,t)=>O?void 0:(t==null?F(e,"overflow"):t?F(e,"overflow-y"):F(e,"overflow-x")).match(/(scroll|auto|overlay)/),we=(e,t)=>{if(O)return;let r=e;for(;r;){if([window,document,document.documentElement].includes(r))return window;if(q(r,t))return r;r=r.parentNode}return r},Ae=(e,t)=>{if(O||!e||!t)return!1;const r=e.getBoundingClientRect();let n;return[window,document,document.documentElement,null,void 0].includes(t)?n={top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}:n=t.getBoundingClientRect(),r.top<n.bottom&&r.bottom>n.top&&r.right>n.left&&r.left<n.right};function P(e){return e!=null&&e===e.window}function H(e,t){if(typeof window>"u")return 0;const r=t?"scrollTop":"scrollLeft";let n=0;return P(e)?n=e[t?"pageYOffset":"pageXOffset"]:e instanceof Document?n=e.documentElement[r]:e&&(n=e[r]),e&&!P(e)&&typeof n!="number"&&(n=(e.ownerDocument||e).documentElement?.[r]),n}function x(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function Se(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}function J(e){return e==null||typeof e!="object"&&typeof e!="function"}function Z(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}const be="[object RegExp]",Oe="[object String]",je="[object Number]",Ue="[object Boolean]",Ie="[object Arguments]",Re="[object Symbol]",Be="[object Date]",Ne="[object Map]",De="[object Set]",Ee="[object Array]",Fe="[object ArrayBuffer]",Pe="[object Object]",Le="[object DataView]",Me="[object Uint8Array]",_e="[object Uint8ClampedArray]",$e="[object Uint16Array]",ve="[object Uint32Array]",We="[object Int8Array]",Ve="[object Int16Array]",ze="[object Int32Array]",qe="[object Float32Array]",He="[object Float64Array]";function xe(e,t){return A(e,void 0,e,new Map,t)}function A(e,t,r,n=new Map,i=void 0){const c=i?.(e,t,r,n);if(c!==void 0)return c;if(J(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){const o=Array.from({length:e.length});n.set(e,o);for(let f=0;f<e.length;f++)o[f]=A(e[f],f,r,n,i);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){const o=new Map;n.set(e,o);for(const[f,u]of e)o.set(f,A(u,f,r,n,i));return o}if(e instanceof Set){const o=new Set;n.set(e,o);for(const f of e)o.add(A(f,void 0,r,n,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(Z(e)){const o=new(Object.getPrototypeOf(e)).constructor(e.length);n.set(e,o);for(let f=0;f<e.length;f++)o[f]=A(e[f],f,r,n,i);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return n.set(e,o),y(o,e,r,n,i),o}if(typeof File<"u"&&e instanceof File){const o=new File([e],e.name,{type:e.type});return n.set(e,o),y(o,e,r,n,i),o}if(typeof Blob<"u"&&e instanceof Blob){const o=new Blob([e],{type:e.type});return n.set(e,o),y(o,e,r,n,i),o}if(e instanceof Error){const o=new e.constructor;return n.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,y(o,e,r,n,i),o}if(typeof e=="boolean"){const o=!!e.valueOf();return n.set(e,o),y(o,e,r,n,i),o}if(typeof e=="number"){const o=Number(e.valueOf());return n.set(e,o),y(o,e,r,n,i),o}if(typeof e=="string"){const o=String(e.valueOf());return n.set(e,o),y(o,e,r,n,i),o}if(typeof e=="object"&&Je(e)){const o=Object.create(Object.getPrototypeOf(e));return n.set(e,o),y(o,e,r,n,i),o}return e}function y(e,t,r=e,n,i){const c=[...Object.keys(t),...x(t)];for(let o=0;o<c.length;o++){const f=c[o],u=Object.getOwnPropertyDescriptor(e,f);(u==null||u.writable)&&(e[f]=A(t[f],f,r,n,i))}}function Je(e){switch(Se(e)){case Ie:case Ee:case Fe:case Le:case Ue:case Be:case qe:case He:case We:case Ve:case ze:case Ne:case je:case Pe:case be:case De:case Oe:case Re:case Me:case _e:case $e:case ve:return!0;default:return!1}}function S(e){return A(e,void 0,e,new Map,void 0)}const j={videoAllowType:["mp4","webm","ogg"],audioAllowType:["mp3","ogg","wav","aac","m4a","webm"],imageType:["jpeg","jpg","png","gif","bmp","tiff","tif","webp","heic","heif","svg","ico","raw","cr2","nef","arw","dng","psd","eps"],videoType:["mp4","avi","mov","wmv","mkv","flv","webm","mpeg","mpg","3gp","ogv","mxf","vob","rm","rmvb","ts","mts","m2ts","divx","xvid"],audioType:["mp3","wav","aac","flac","ogg","wma","m4a","alac","opus","amr","aiff","au","pcm","ape"]},X=e=>e!=null&&e!=="";let G=e=>setTimeout(e,16),Y=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(G=e=>window.requestAnimationFrame(e),Y=e=>window.cancelAnimationFrame(e));let K=0;const L=new Map;function Q(e){L.delete(e)}function R(e,t=1){K+=1;const r=K;function n(i){if(i===0)Q(r),e();else{const c=G(()=>{n(i-1)});L.set(r,c)}}return n(t),r}R.cancel=e=>{const t=L.get(e);return Q(t),Y(t)};function Ze(e){return e!=null}function b(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(e)==="[object Object]":!1}const Xe=({suffixCls:e,customizePrefixCls:t,isPor:r,className:n})=>{const i=n||(r?"gx-pro":"gx");return t||(e?`${i}-${e}`:i)},Ge=(e,t)=>e?g(e)?e.join("-"):e.toString():`${t||0}`;function Ye(e,{align:t,showIndex:r}){const n=S(e);if(r&&e.length&&e.every(i=>i.dataIndex!=="sortIndex")){const i=e[0];n.unshift({title:"序号",align:t,fixed:i.fixed,width:60,uuid:C().uuid(15),dataIndex:"sortIndex",key:"sortIndex"})}else n.filter(i=>i.dataIndex!=="sortIndex");return n}function Ke(e,...t){return typeof e=="function"?e(...t):e}function Qe(e){return JSON.parse(JSON.stringify(e))}function ke(e,t){if(w(e)){const{pageSize:r=10,total:n=0}=e;let{current:i=1}=e;return n-t<=r*(i-1)&&(i=i-1),i===0?1:i}return 1}function Te(e=[],t,r="children"){function n(i,c){return c.map((o,f)=>{const u=`${i}-${f+1}`;return o[r]&&(o[r]=n(u,o[r])),o.sortIndex=u,o})}return S(e).map((i,c)=>{const o=w(t)&&t.current||1,f=w(t)&&t.pageSize||10,u=`${(o-1)*f+(c+1)}`;return i[r]&&(i[r]=n(`${u}`,i[r])),i.sortIndex=u,i})}function Ce(e,t){return g(e)?e?.filter((r,n)=>{if(p(t))return n<=t-1;if(g(t)&&t.length===2){const i=t[0]-1,c=t[1]?t[1]-1:e.length-1;return n<=c&&n>=i}else if(g(t)&&t.length===1){const i=t[0]-1,c=e.length-1;return n<=c&&n>=i}return!0}):[]}function k(e,t,r,n=0){const i=p(n)&&(n===0||n===1)?n:0,c=e[r],o=t[r];let f=0;return c<o?f=i===0?-1:0:c>o&&(f=i===0?0:-1),f}function T(e,t,r,n=0){const i=p(n)&&(n===0||n===1)?n:0,c=new Date(e[r]),o=new Date(t[r]);let f=0;return c<o?f=i===0?-1:0:c>o&&(f=i===0?0:-1),f}function et(e,t,r=0){return e.sort((n,i)=>k(n,i,t,r))}function tt(e,t,r=0){return e.sort((n,i)=>T(n,i,t,r))}function nt(e){let t=S(e);const r=new Set(t);return t=Array.from(r),t}function rt(e,t){const r=["null","undefined"];let n=!0;return e===0?n=!0:r.includes(e)?n=!1:e||(n=!1),n?{value:e,success:n}:{value:t===""?t:t||"-",success:n}}function it(e){let t="";if(e>-1){const r=Math.floor(e/3600),n=Math.floor(e/60)%60,i=Number.parseInt(String(e%60));r<10?t="0"+r+":":t=r+":",n<10&&(t+="0"),t+=n+":",i<10&&(t+="0"),t+=i}return t.split(":")[0]==="00"?`${t.split(":")[1]}:${t.split(":")[2]}`:t}function C(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");return{uuid(t,r){const n=e,i=[],c=r||n.length;let o,f;if(t)for(o=0;o<t;o+=1)i[o]=n[Number.parseInt(String(Math.random()*c))];else for(i[8]="-",i[13]="-",i[18]="-",i[23]="-",i[14]="4",o=0;o<36;o+=1)i[o]||(f=Math.random()*16,i[o]=n[o===19?f&&3||8:f]);return i.join("")},uuidFast(){const t=e,r=Array.from({length:36});let n=0,i,c;for(c=0;c<36;c+=1)c===8||c===13||c===18||c===23?r[c]="-":c===14?r[c]="4":(n<=2&&(n=33554432+Math.random()*16777216||0),i=n&&15,n=n>4,r[c]=t[c===19?i&&3||8:i]);return r.join("")},uuidString(){return this.uuidFast().replace(new RegExp("-","g"),"")},uuidCompact(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=Math.random()*16||0;return(t==="x"?r:r&&3||8).toString(16)})}}}function ee(e,t){if(!Array.isArray(e)||e.length===0)return 0;const r=t||"children";return Math.max(...e.map(n=>{const i=n[r];return 1+(i?ee(i,r):0)}))}function te(e,t="children"){let r=[];return e.forEach(n=>{r.push(n),g(n[t])&&n[t].length>0&&(r=r.concat(te(n[t],t)))}),r}function ot(e,t){if(!e||!g(e)||e?.length===0)return[];const{id:r="id",parentId:n="parentId",children:i="children",emptyChildren:c=!0}=t||{},o=t?.rootId??0,f=S(e);return f.map(u=>(!c&&u[i]&&u[i]?.length===0&&delete u[i],u)).filter(u=>{const a=f.filter(l=>u[r]===l[n]);return a.length>0?u[i]=a:c&&(u[i]=[]),o===!1?!0:u[n]===o})}function ne(e,t){return e.map(r=>{const n={...r};return n.children&&(n.children=ne(n.children,t)),t(n)||n.children&&n.children.length>0?n:null}).filter(Boolean)}function ct(e,t,r){const{value:n,children:i}=r||{value:"value",children:"children"};let c=[];function o(f,u){if(f[n]===t)return c=[...u,f[n]],!0;if(f[i]){for(const a of f[i])if(o(a,[...u,f[n]]))return!0}return!1}for(const f of e)if(o(f,[]))break;return c}function ft(e){return e&&g(e)?e[e.length-1]:null}function re(e,t,r){const n=r?.value||"id",i=r?.children||"children";for(const c of e){if(c[n]===t)return c;const o=c[i];if(o){const f=re(o,t,r);if(f)return f}}}function st(e){return URL.createObjectURL(e)}function ut(e){return new Promise((t,r)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>t(n.result),n.onerror=i=>r(i)})}function at(e){const t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=atob(t[1]);let i=n.length;const c=new Uint8Array(i);for(;i--;)c[i]=n.charCodeAt(i);return new Blob([c],{type:r})}function lt(e,t){const r=e.split(","),n=r[0].match(/:(.*?);/)[1],i=atob(r[1]);let c=i.length;const o=new Uint8Array(c);for(;c--;)o[c]=i.charCodeAt(c);return new File([o],t,{type:n})}function dt(e,t,r){return new window.File([e],t,{type:r})}function ie(e){if(!e||typeof e!="string")return"";const t=e.indexOf("?");return t>0?`${e.substring(0,t)}`:e}function B(e){if(!e||typeof e!="string")return"";const t=ie(e),r=t.lastIndexOf(".");return r>0&&`${t?.substring?.(r)?.split("?")?.[0]}`?.split(".")?.[1]||""}function U(e,t){if(t)return t;if(!e||e==="data:")return"4";let r="4";return N(e)?e.includes("data:image/")?r="png":e.includes("data:video/")?r="mp4":e.includes("data:audio/")&&(r="mp3"):e instanceof Blob?(e=String(e),e.includes("image")?r="png":e.includes("video")?r="mp4":e.includes("audio")&&(r="mp3")):r=B(e).toLowerCase(),j.imageType.includes(r)?"1":j.videoType.includes(r)?"3":j.audioType.includes(r)?"2":"4"}function oe(e){const{url:t="",fileType:r="1"}=e||{};let n="",i={play:!1,height:0,size:0,width:0,duration:0};function c(){i={play:!1,height:0,size:0,width:0,duration:0}}return t instanceof File?n=URL.createObjectURL(t):N(t)?n=t:t instanceof Blob?n=URL.createObjectURL(t):(t.includes("https")||t.includes("http"))&&(n=t),new Promise(o=>{let f;if(r==="4"){o(i);return}r==="1"?(f=document.createElement("img"),f.src=n):r==="2"?(f=document.createElement("audio"),f.src=n):r==="3"&&(f=document.createElement("video"),f.src=n),r==="1"?f.onload=function(){c(),i.play=!0,i.width=f.width||0,i.height=f.height||0,o(i),f=null}:f.oncanplay=function(){c(),i.play=!0,i.width=f?.videoWidth||0,i.height=f?.videoHeight||0,i.duration=f?.duration||0,o(i),f=null},f.onerror=function(){c(),o(i),f=null}})}async function gt(e){const{url:t="",currentTime:r,videoSuffix:n="",videoAllowPlay:i=!1}=e;let c="",o=n,f="1",u;return t instanceof File?(c=URL.createObjectURL(t),o=B(t.name),f=U(t.name)):t instanceof Blob?(c=URL.createObjectURL(t),f=U(t)):N(t)?(c=t,f=U(t)):(t.includes("https")||t.includes("http"))&&(c=t,o=B(t),f=U(t)),(o?j.videoAllowType.includes(o.toLowerCase()):!1)?i?M(c,r):(u=await oe({url:c,fileType:f}),u.play?M(c,r):new Promise(l=>{l("")})):new Promise(l=>{l("")})}async function M(e,t=0){return new Promise(r=>{let n=document.createElement("video");n&&(n.controls=!0,n.muted=!0,n.setAttribute("src",e),n.setAttribute("muted",String(!0)),n.setAttribute("crossorigin","anonymous"),n.setAttribute("autoplay",String(!0)),n.addEventListener("loadeddata",async()=>{let i;for(n?.addEventListener("seeked",async()=>{i&&i()});t<(n?.duration||0);){n&&(n.currentTime=t),await new Promise(m=>i=m);const c=document.createElement("canvas"),o=.8,f=c.getContext("2d"),u=n?.videoWidth||0*o,a=n?.videoHeight||0*o,l=0;c.width=n?.videoWidth||0*o,c.height=n?.videoHeight||0*o,n&&f.drawImage(n,0,0,u+l,a+l),n=null,r(u===0||a===0?"":c.toDataURL("image/png",1))}}))})}function N(e=""){return!!(e&&["data:image/","data:video/","data:audio/"].find(r=>e.includes(r)))}function yt(e){return typeof e=="string"&&/^data:(?:image|video|audio)\/[A-Za-z]+;base64,[A-Za-z0-9+/=]+$/.test(e)}function ht(e,t,r,n=!1){e&&t&&r&&e.addEventListener(t,r,n)}function mt(e,t,r,n=!1){e&&t&&r&&e.removeEventListener(t,r,n)}function pt(){return/windows|win32/i.test(navigator.userAgent)}function wt(e){return I(e)?e:!!e}function _(e,t){const r=`^\\d+(?:\\.\\d{0,${e}})?`,n=new RegExp(r),i=t.toString().match(n);if(i){const c=i[0];if(c.includes(".")){const[o,f]=c.split(".");if(/^0*$/.test(f))return o}return c}return t.toString()}function At(e,t){const{toChinese:r=!1,fixed:n=2,min:i=1e4}=t||{},c=p(i)?i:1e4,o=p(n)?n:2,f=r?e<c?"":e<1e8?"万":"亿":e<c?"":e<1e8?"w":"亿";if(!p(e))return{str:`${e}`,number:`${e}`};if(e<c)return{str:`${e}`,number:`${e}`};if(o===0){const a=(e/(e<1e8?1e4:1e8)).toFixed(1).split(".")[0];return{str:`${a}${f}`,number:a,unit:f}}let u;return e<1e8?(u=_(o,e/1e4),{str:u+f,number:u,unit:f}):(u=_(o,e/1e8),{str:u+f,number:u,unit:f})}function St(e,t){let r=0;const n=I(t.removeAfter)?t.removeAfter:!0,i=t.id||"hiddenElement",c={opacity:0,visibility:"hidden",position:"fixed",zIndex:-1,top:0,left:0};let o=document.querySelector(`#${i}`);if(!o){const u=document.createElement("div");u.id=i,document.body.appendChild(u),o=document.querySelector(`#${i}`)}Object.assign(o.style,c);const f=document.createElement(t.createName||"span");return f.innerHTML=e,(t.cssObject||w(t.cssObject))&&Object.assign(f.style,t.cssObject),o.append(f),r=f.getBoundingClientRect()[t.type||"width"],n&&o.removeChild(f),r}function bt(e){e=p(e)&&!Number.isNaN(e)?e:0;const t=["零","一","二","三","四","五","六","七","八","九"],r=["","十","百","千","万"];e=Number.parseInt(`${e}`);const n=o=>{const f=o.toString().split("").reverse();let u="";for(let a=0;a<f.length;a++)u=(a===0&&f[a]==="0"||a>0&&f[a]==="0"&&f[a-1]==="0"?"":(e<20&&a>0?"":t[f[a]])+(f[a]==="0"?r[0]:r[a]))+u;return u},i=Math.floor(e/1e4);let c=e%1e4;return c.toString().length<4&&(c="0"+c),i?n(i)+"万"+n(c):n(e)}function Ot(e,t){Object.keys(e).forEach(r=>{t(r,e[r])})}function jt(e,t,r,n){const i=r-t;return e/=n/2,e<1?i/2*e*e*e+t:i/2*((e-=2)*e*e+2)+t}function Ut(e,t={}){const{getContainer:r=()=>window,callback:n,duration:i=450}=t,c=r(),o=H(c,!0),f=Date.now(),u=()=>{const l=Date.now()-f,m=jt(l>i?i:l,o,e,i);P(c)?c.scrollTo(window.pageXOffset,m):c instanceof HTMLDocument||c.constructor.name==="HTMLDocument"?c.documentElement.scrollTop=m:c.scrollTop=m,l<i?R(u):typeof n=="function"&&n()};c&&R(u)}function It(e){let t;const r=i=>()=>{t=null,e(...i)},n=(...i)=>{t==null&&(t=requestAnimationFrame(r(i)))};return n.cancel=()=>cancelAnimationFrame(t),n}const Rt=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Bt=()=>process.env.NODE_ENV==="TEST"?!0:typeof window<"u"&&typeof window.document<"u"&&typeof window.matchMedia<"u"&&!Rt;function D(e,t,r,n){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;let i,c,o;if(Array.isArray(e)){if(i=e.length,i!=t.length)return!1;for(c=i;c--!==0;)if(!D(e[c],t[c],r,n))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(c of e.entries())if(!t.has(c[0]))return!1;for(c of e.entries())if(!D(c[1],t.get(c[0]),r,n))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(c of e.entries())if(!t.has(c[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(i=e.length,i!=t.length)return!1;for(c=i;c--!==0;)if(e[c]!==t[c])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&e.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&e.toString)return e.toString()===t.toString();if(o=Object.keys(e),i=o.length,i!==Object.keys(t).length)return!1;for(c=i;c--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[c]))return!1;for(c=i;c--!==0;){const f=o[c];if(!r?.includes(f)&&!(f==="_owner"&&e.$$typeof)&&!D(e[f],t[f],r,n))return n&&console.log(f),!1}return!0}return e!==e&&t!==t}function Nt(e){return/\w.(?:png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(e)}const ce=e=>e==null,Dt=e=>{if(!e||!e.startsWith("http"))return!1;try{return!!new URL(e)}catch(t){return console.error("isUrl error",t),!1}};function Et(e){return e==="__proto__"}function h(e,t,r){const n=Object.keys(t);for(let i=0;i<n.length;i++){const c=n[i];if(Et(c))continue;const o=t[c],f=e[c],u=r(f,o,c,e,t);u!==void 0?e[c]=u:b(o)?b(f)?e[c]=h(f,o,r):e[c]=h({},o,r):ce(o)&&(e[c]=o)}return e}const Ft=(...e)=>{const t={},r=e.length;let n,i=0;for(;i<r;i+=1)for(n in e[i])Object.prototype.hasOwnProperty.call(e[i],n)&&(typeof t[n]=="object"&&typeof e[i][n]=="object"&&t[n]!==void 0&&t[n]!==null&&!Array.isArray(t[n])&&!Array.isArray(e[i][n])?t[n]={...t[n],...e[i][n]}:t[n]=e[i][n]);return t};function Pt(e,t){return h(S(e),t,function r(n,i){if(b(i))return b(n)?h(S(n),i,r):h({},i,r)})}function Lt(e,t){return h(e,t,function r(n,i){if(b(i))return b(n)?h(n,i,r):h({},i,r)})}let fe=0;const se=(e=21)=>{if(typeof window>"u"||!window.crypto)return(fe+=1).toFixed(0);let t="";const r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){const n=63&r[e];t+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return t},Mt=()=>typeof window>"u"?se():window.crypto&&window.crypto.randomUUID&&typeof crypto.randomUUID=="function"?crypto.randomUUID():se(),_t=e=>{if(e&&e!==!0)return e},$t=e=>{const t={};if(Object.keys(e||{}).forEach(r=>{e[r]!==void 0&&(t[r]=e[r])}),!(Object.keys(t).length<1))return t},vt=e=>{const t={};return Object.keys(e||{}).forEach(r=>{Array.isArray(e[r])&&e[r]?.length===0||e[r]!==void 0&&(t[r]=e[r])}),t};function Wt(e){if(!(typeof e!="string"&&!Array.isArray(e)))return Array.isArray(e)?e[e.length-1]:e.split(":")?.slice(-1)[0]}function ue(e){return e&&(e.type===d.Comment||e.type===d.Fragment&&e.children.length===0||e.type===Text&&e.children.trim()==="")}function Vt(e,t){return E(typeof e[t]=="function"?e[t]?.():[])}function E(e=[],t=!0){const r=Array.isArray(e)?e:[e],n=[];return r.forEach(i=>{Array.isArray(i)?n.push(...E(i,t)):i?.type===d.Fragment||i?.type==="template"?n.push(...E(i.children,t)):i&&d.isVNode(i)?t&&!ue(i)?n.push(i):t||n.push(i):X(i)&&n.push(i)}),n}function $({vnode:e,defaultVNode:t},...r){return e===!1?null:typeof e=="function"?e?.(...r):e||t}function ae(e,...t){const{slots:r,key:n="default",render:i,props:c,defaultChildren:o}=e;let f;const u=c[n],a=r?.[n],l=typeof o=="function"?o?.():o;return u===!1?f=!1:u===!0?f=a??l:w(u)&&i?d.isVNode(u)?f=u:f=a:f=u||a,f===!1?!1:i?$({vnode:f,defaultVNode:l},...t):f}function le(e,...t){const{slots:r,key:n="default",props:i,defaultChildren:c}=e;let o;const f=i[n],u=r?.[n]?.(...t),a=typeof c=="function"?c?.():c;return f===!1?o=!1:f===!0?o=u??a:w(f)?d.isVNode(f)?o=f:o=u:o=f||u,o===!1?!1:$({vnode:o,defaultVNode:a},...t)}function zt(e,...t){const{slots:r,props:n,keys:i,render:c,defaultVNodes:o}=e,f={};return i.forEach((u,a)=>{const l=o?o[a]:null,m=c?le({slots:r,props:n,key:u,defaultChildren:l},...t):ae({slots:r,props:n,key:u,render:!1,defaultChildren:l},...t);(I(m)||m)&&(f[u]=m)}),f}s.Base64=de,s.arrayRepeat=nt,s.arraySlice=Ce,s.blobToDataURL=dt,s.checkFileType=U,s.classNames=z,s.cloneDeep=S,s.cloneDeepWith=xe,s.cloneDeepWithImpl=A,s.compareArray=k,s.compareArraySort=et,s.compareArrayTimeSort=tt,s.compareTime=T,s.convertValueBoolean=wt,s.copyProperties=y,s.dataURLtoBlob=at,s.dataURLtoFile=lt,s.deepCopy=Qe,s.deepMerge=Pt,s.fileTypes=j,s.filterEmpty=E,s.filterTree=ne,s.findSourceByTree=re,s.findValueAndAncestors=ct,s.forInObject=Ot,s.formatDuration=it,s.formatNumber=_,s.genColumnKey=Ge,s.generateVideoPicture=M,s.getArrayLast=ft,s.getBase64=ut,s.getBlobUrl=st,s.getFileSuffix=B,s.getKeys=Wt,s.getLevelData=te,s.getMaxFloor=ee,s.getMediaInfos=oe,s.getPrefixCls=Xe,s.getRandomNumber=C,s.getScroll=H,s.getScrollContainer=we,s.getSlot=ae,s.getSlotVNode=le,s.getSlotsChildren=Vt,s.getSlotsProps=zt,s.getSortIndex=Te,s.getSymbols=x,s.getTextWidth=St,s.getValueFromObjectByKey=me,s.getVideoCoverPicture=gt,s.getVideoFileUrl=ie,s.handleCurrentPage=ke,s.handleEmptyField=rt,s.handleShowIndex=Ye,s.is=v,s.isArray=g,s.isBase64=N,s.isBoolean=I,s.isBrowser=Bt,s.isDataURLBase64=yt,s.isDeepEqualReact=D,s.isEmptyElement=ue,s.isFunction=ge,s.isImg=Nt,s.isInContainer=Ae,s.isJSONStr=ye,s.isMobile=he,s.isNil=ce,s.isNotNil=Ze,s.isNumber=p,s.isObject=w,s.isPlainObject=b,s.isPrimitive=J,s.isScroll=q,s.isServer=O,s.isString=W,s.isTablet=V,s.isTypedArray=Z,s.isUrl=Dt,s.isValid=X,s.isWindowsOs=pt,s.merge=Ft,s.mergeWith=h,s.nanoid=Mt,s.off=mt,s.omitBoolean=_t,s.omitUndefined=$t,s.omitUndefinedAndEmptyArr=vt,s.on=ht,s.raf=R,s.runFunction=Ke,s.scrollTo=Ut,s.slotRender=$,s.throttleByAnimationFrame=It,s.toChinesNum=bt,s.toConvertNumberShow=At,s.treeData=ot,s.useDeepMerge=Lt,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/slots/index.d.ts
CHANGED
|
@@ -1,9 +1,68 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
2
|
import type { CustomRender, WithFalse } from '../typings';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export declare function
|
|
9
|
-
export
|
|
3
|
+
export type SlotsPropsResult<S extends object, K extends keyof S, R extends boolean, D = any> = {
|
|
4
|
+
[P in K]: R extends true ? D extends undefined ? WithFalse<CustomRender> : CustomRender : D extends undefined ? (S[P] | false) : CustomRender;
|
|
5
|
+
};
|
|
6
|
+
export type RenderResult<S extends object, K extends keyof S, R extends boolean, D = any> = R extends true ? D extends undefined ? WithFalse<CustomRender> : CustomRender : D extends undefined ? (S[K] | false) : CustomRender;
|
|
7
|
+
export declare function getKeys(keys: string | string[]): string | undefined;
|
|
8
|
+
export declare function isEmptyElement(c: any): any;
|
|
9
|
+
export declare function getSlotsChildren<T extends object = Record<string, any>>(slots: T, key: keyof T): VNode[];
|
|
10
|
+
export declare function filterEmpty(vnode?: any, isEmpty?: boolean): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>[];
|
|
13
|
+
export declare function slotRender({ vnode, defaultVNode }: {
|
|
14
|
+
vnode: any;
|
|
15
|
+
defaultVNode?: any;
|
|
16
|
+
}, ...arg: any): any;
|
|
17
|
+
/**
|
|
18
|
+
* @Author gx12358
|
|
19
|
+
* @DateTime 2024/2/2
|
|
20
|
+
* @lastTime 2024/2/2
|
|
21
|
+
* @description Function () => WithFalse<CustomRender> | S[K]
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSlot<S extends object, K extends keyof S = keyof S, R extends boolean = false>(options: {
|
|
24
|
+
slots: S;
|
|
25
|
+
props: Record<string, any>;
|
|
26
|
+
key: K;
|
|
27
|
+
render?: R;
|
|
28
|
+
defaultChildren?: undefined;
|
|
29
|
+
}, ...arg: any): RenderResult<S, K, R, undefined>;
|
|
30
|
+
export declare function getSlot<S extends object, K extends keyof S = keyof S, R extends boolean = false>(options: {
|
|
31
|
+
slots: S;
|
|
32
|
+
props: Record<string, any>;
|
|
33
|
+
key: K;
|
|
34
|
+
render?: R;
|
|
35
|
+
defaultChildren: any;
|
|
36
|
+
}, ...arg: any): RenderResult<S, K, R>;
|
|
37
|
+
/**
|
|
38
|
+
* @Author gx12358
|
|
39
|
+
* @DateTime 2024/2/2
|
|
40
|
+
* @lastTime 2024/2/2
|
|
41
|
+
* @description VNode
|
|
42
|
+
*/
|
|
43
|
+
export declare function getSlotVNode<S extends object, K extends keyof S = keyof S>(options: {
|
|
44
|
+
slots: S;
|
|
45
|
+
props: Record<string, any>;
|
|
46
|
+
key: K;
|
|
47
|
+
defaultChildren?: any;
|
|
48
|
+
}, ...arg: any): WithFalse<CustomRender>;
|
|
49
|
+
/**
|
|
50
|
+
* @Author gx12358
|
|
51
|
+
* @DateTime 2024/10/13
|
|
52
|
+
* @lastTime 2024/10/13
|
|
53
|
+
* @description 获取names的slots或者props的VNode
|
|
54
|
+
*/
|
|
55
|
+
export declare function getSlotsProps<S extends object, K extends keyof S = keyof S, R extends boolean = false>(options: {
|
|
56
|
+
slots: S;
|
|
57
|
+
props: Record<string, any>;
|
|
58
|
+
keys: K[];
|
|
59
|
+
render?: R;
|
|
60
|
+
defaultVNodes?: undefined;
|
|
61
|
+
}, ...arg: any): SlotsPropsResult<S, K, R, undefined>;
|
|
62
|
+
export declare function getSlotsProps<S extends object, K extends keyof S = keyof S, R extends boolean = false>(options: {
|
|
63
|
+
slots: S;
|
|
64
|
+
props: Record<string, any>;
|
|
65
|
+
keys: K[];
|
|
66
|
+
render?: R;
|
|
67
|
+
defaultVNodes?: any;
|
|
68
|
+
}, ...arg: any): SlotsPropsResult<S, K, R>;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Slot, VNode, VNodeChild } from 'vue';
|
|
2
|
-
export type
|
|
2
|
+
export type DeepPartial<T> = T extends object ? {
|
|
3
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
4
|
+
} : T;
|
|
5
|
+
export interface Fn<T = any, R = T> {
|
|
6
|
+
(...arg: T[]): R;
|
|
7
|
+
}
|
|
3
8
|
export type Nullable<T> = T | null;
|
|
4
9
|
export type WithFalse<T> = T | false;
|
|
5
10
|
export type RecordType = Record<string, any>;
|
|
11
|
+
export type DefaultToT<T, R> = R extends undefined ? T : R;
|
|
6
12
|
export type VueNode = VNodeChild | JSX.Element;
|
|
7
|
-
export type CustomRender = Slot | VNodeChild | VNode | ((...props: any[]) =>
|
|
13
|
+
export type CustomRender = Slot | VNodeChild | VNode | ((...props: any[]) => VNode) | ((...props: any[]) => VNode[]) | VNode[] | JSX.Element | string | null | undefined;
|
|
8
14
|
export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
9
15
|
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
10
16
|
export type AlignType = 'left' | 'center' | 'right';
|
|
@@ -13,18 +19,13 @@ export type BasicTablePageConfig = {
|
|
|
13
19
|
pageSize: number;
|
|
14
20
|
total?: number;
|
|
15
21
|
} | boolean;
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export type MaterialInfo = {
|
|
26
|
-
play?: boolean;
|
|
27
|
-
width?: number;
|
|
28
|
-
height?: number;
|
|
29
|
-
duration?: number;
|
|
22
|
+
export interface MaterialOptions {
|
|
23
|
+
play: boolean;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
duration: number;
|
|
27
|
+
size?: number | string;
|
|
28
|
+
}
|
|
29
|
+
export type OmitUndefined<T> = {
|
|
30
|
+
[P in keyof T]: NonNullable<T[P]>;
|
|
30
31
|
};
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSymbols(object: any): symbol[];
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
import type { AlignType, BasicTablePageConfig, MaterialOptions, RecordType } from '../typings';
|
|
3
|
+
import isValid from './isValid';
|
|
4
|
+
import raf from './raf';
|
|
5
|
+
export * from './config';
|
|
6
|
+
export * from './getSymbols';
|
|
7
|
+
export * from './isNotNil';
|
|
8
|
+
export * from './isPlainObject';
|
|
9
|
+
export * from './isPrimitive';
|
|
10
|
+
export * from './isTypedArray';
|
|
11
|
+
export * from './validate';
|
|
12
|
+
export { isValid, raf };
|
|
2
13
|
export interface PrefixCls {
|
|
3
14
|
suffixCls?: string;
|
|
4
15
|
customizePrefixCls?: string;
|
|
@@ -13,11 +24,17 @@ export declare const getPrefixCls: ({ suffixCls, customizePrefixCls, isPor, clas
|
|
|
13
24
|
* @param dataIndex 在对象中的数据
|
|
14
25
|
* @param index 序列号,理论上唯一
|
|
15
26
|
*/
|
|
16
|
-
export declare const genColumnKey: (key
|
|
17
|
-
|
|
27
|
+
export declare const genColumnKey: (key: string[] | number | string | undefined, index?: number) => string;
|
|
28
|
+
/**
|
|
29
|
+
* @Author gx12358
|
|
30
|
+
* @DateTime 2025/2/5
|
|
31
|
+
* @lastTime 2025/2/5
|
|
32
|
+
* @description 这里是结合ant的数据结构给到的分页数据
|
|
33
|
+
*/
|
|
34
|
+
export declare function handleShowIndex<T extends object>(columns: T[], { align, showIndex }: {
|
|
18
35
|
align: AlignType;
|
|
19
36
|
showIndex: boolean;
|
|
20
|
-
}):
|
|
37
|
+
}): T[];
|
|
21
38
|
/**
|
|
22
39
|
* @Author gx12358
|
|
23
40
|
* @DateTime 2021/11/3
|
|
@@ -31,7 +48,7 @@ export declare function runFunction<T extends any[]>(valueEnum: any, ...rest: T)
|
|
|
31
48
|
* @lastTime 2022/10/11
|
|
32
49
|
* @description 简单深拷贝下
|
|
33
50
|
*/
|
|
34
|
-
export declare function deepCopy(data:
|
|
51
|
+
export declare function deepCopy<T = RecordType>(data: any): T;
|
|
35
52
|
/**
|
|
36
53
|
* @Author gx12358
|
|
37
54
|
* @DateTime 2021/1/28
|
|
@@ -45,30 +62,54 @@ export declare function handleCurrentPage(pageConfig: BasicTablePageConfig, curr
|
|
|
45
62
|
* @lastTime 2020/7/24
|
|
46
63
|
* @description 数组(树形)添加序号
|
|
47
64
|
*/
|
|
48
|
-
export declare function getSortIndex<T =
|
|
65
|
+
export declare function getSortIndex<T = RecordType>(data: T[] | undefined, pageConfig: BasicTablePageConfig, childrenKey?: keyof T): any[];
|
|
66
|
+
export declare function arraySlice<T = RecordType>(data: T[], range: number | number[]): T[];
|
|
49
67
|
/**
|
|
50
68
|
* @Author gaoxiang
|
|
51
69
|
* @DateTime 2019/11/29
|
|
52
70
|
* @lastTime 2019/11/29
|
|
71
|
+
* @description 这里是给到数组的sort的方法
|
|
53
72
|
* @description 排序 sort 0 从小到大 1 从大到小
|
|
54
73
|
*/
|
|
55
|
-
export declare function compareArray(obj1:
|
|
74
|
+
export declare function compareArray<T = RecordType>(obj1: T, obj2: T, key: keyof T, sort?: 0 | 1): number;
|
|
75
|
+
/**
|
|
76
|
+
* @Author gx12358
|
|
77
|
+
* @DateTime 2023/10/17
|
|
78
|
+
* @lastTime 2023/10/17
|
|
79
|
+
* @description 这里是给到数组的sort的方法
|
|
80
|
+
* @description type 0 从小到大 1 从大到小
|
|
81
|
+
*/
|
|
82
|
+
export declare function compareTime<T = RecordType>(obj1: T, obj2: T, key: keyof T, sort?: 0 | 1): number;
|
|
83
|
+
/**
|
|
84
|
+
* @Author gx12358
|
|
85
|
+
* @DateTime 2024/10/27
|
|
86
|
+
* @lastTime 2024/10/27
|
|
87
|
+
* @description type 0 从小到大 1 从大到小
|
|
88
|
+
*/
|
|
89
|
+
export declare function compareArraySort<T = RecordType>(dataSource: T[], key: keyof T, sort?: 0 | 1): T[];
|
|
90
|
+
/**
|
|
91
|
+
* @Author gx12358
|
|
92
|
+
* @DateTime 2024/10/27
|
|
93
|
+
* @lastTime 2024/10/27
|
|
94
|
+
* @description 比较时间 type 0 从小到大 1 从大到小
|
|
95
|
+
*/
|
|
96
|
+
export declare function compareArrayTimeSort<T = RecordType>(dataSource: T[], key: keyof T, sort?: 0 | 1): T[];
|
|
56
97
|
/**
|
|
57
98
|
* @Author gaoxiang
|
|
58
99
|
* @DateTime 2019/12/11
|
|
59
100
|
* @lastTime 2019/12/11
|
|
60
101
|
* @description 数组去重
|
|
61
102
|
*/
|
|
62
|
-
export declare function arrayRepeat<T =
|
|
103
|
+
export declare function arrayRepeat<T = RecordType>(data: T[]): T[];
|
|
63
104
|
/**
|
|
64
105
|
* @Author gaoxiang
|
|
65
106
|
* @DateTime 2020/8/26
|
|
66
107
|
* @lastTime 2020/8/26
|
|
67
|
-
* @description
|
|
108
|
+
* @description 处理字段为空
|
|
68
109
|
*/
|
|
69
|
-
export declare function
|
|
70
|
-
value: any;
|
|
110
|
+
export declare function handleEmptyField(str: any, customize: any): {
|
|
71
111
|
success: boolean;
|
|
112
|
+
value: any;
|
|
72
113
|
};
|
|
73
114
|
/**
|
|
74
115
|
* @Author gaoxiang
|
|
@@ -76,7 +117,7 @@ export declare function hanndleField(str: any, customize: any): {
|
|
|
76
117
|
* @lastTime 2020/8/7
|
|
77
118
|
* @description 时长格式转换
|
|
78
119
|
*/
|
|
79
|
-
export declare function
|
|
120
|
+
export declare function formatDuration(time: number): string;
|
|
80
121
|
/**
|
|
81
122
|
* @Author gaoxiang
|
|
82
123
|
* @DateTime 2019/11/29
|
|
@@ -95,14 +136,14 @@ export declare function getRandomNumber(): {
|
|
|
95
136
|
* @lastTime 2022/10/11
|
|
96
137
|
* @description 获取树形结构最深的层级数
|
|
97
138
|
*/
|
|
98
|
-
export declare function getMaxFloor(
|
|
139
|
+
export declare function getMaxFloor<T>(data: T[], childrenKey?: keyof T): number;
|
|
99
140
|
/**
|
|
100
141
|
* @Author gaoxiang
|
|
101
142
|
* @DateTime 2020/8/10
|
|
102
143
|
* @lastTime 2020/8/10
|
|
103
144
|
* @description 树形转平级
|
|
104
145
|
*/
|
|
105
|
-
export declare function getLevelData(data:
|
|
146
|
+
export declare function getLevelData<T extends RecordType = RecordType>(data: T[], filed?: keyof T): T[];
|
|
106
147
|
/**
|
|
107
148
|
* 构造树型结构数据
|
|
108
149
|
* @param {*} source 数据源
|
|
@@ -111,7 +152,41 @@ export declare function getLevelData(data: any[], filed?: string): any[];
|
|
|
111
152
|
* @param {*} children 孩子节点字段 默认 'children'
|
|
112
153
|
* @param {*} rootId 根Id 默认 0
|
|
113
154
|
*/
|
|
114
|
-
export declare function treeData(source:
|
|
155
|
+
export declare function treeData<T extends RecordType = RecordType>(source: T[], options?: {
|
|
156
|
+
id?: keyof T;
|
|
157
|
+
parentId?: keyof T;
|
|
158
|
+
children?: keyof T;
|
|
159
|
+
rootId?: number | false;
|
|
160
|
+
emptyChildren?: boolean;
|
|
161
|
+
}): T[];
|
|
162
|
+
/**
|
|
163
|
+
* @Author gx12358
|
|
164
|
+
* @DateTime 2024/12/21
|
|
165
|
+
* @lastTime 2024/12/21
|
|
166
|
+
* @description 树形数组 按照条件 过滤
|
|
167
|
+
*/
|
|
168
|
+
export declare function filterTree<T = any>(tree: T[], predicate: (val: T) => boolean): any[];
|
|
169
|
+
/**
|
|
170
|
+
* @Author gx12358
|
|
171
|
+
* @DateTime 2024/12/21
|
|
172
|
+
* @lastTime 2024/12/21
|
|
173
|
+
* @description 给定指定的value值,找到其所有的祖先节点
|
|
174
|
+
*/
|
|
175
|
+
export declare function findValueAndAncestors<T = any>(tree: T[], targetValue: any, fieldNames?: {
|
|
176
|
+
value: 'value';
|
|
177
|
+
children: 'children';
|
|
178
|
+
}): any[];
|
|
179
|
+
export declare function getArrayLast<T = any>(data: any): T;
|
|
180
|
+
/**
|
|
181
|
+
* @Author gx12358
|
|
182
|
+
* @DateTime 2024/12/6
|
|
183
|
+
* @lastTime 2024/12/6
|
|
184
|
+
* @description 树形数组递归查找指定对象
|
|
185
|
+
*/
|
|
186
|
+
export declare function findSourceByTree<T>(tree: T[], value: any, options?: {
|
|
187
|
+
value: keyof T;
|
|
188
|
+
children: keyof T;
|
|
189
|
+
}): T | undefined;
|
|
115
190
|
/**
|
|
116
191
|
* @Author gx12358
|
|
117
192
|
* @DateTime 2021/11/5
|
|
@@ -132,14 +207,14 @@ export declare function getBase64(file: File): Promise<string | ArrayBuffer | nu
|
|
|
132
207
|
* @lastTime 2021/1/21
|
|
133
208
|
* @description base转blob对象
|
|
134
209
|
*/
|
|
135
|
-
export declare function dataURLtoBlob(
|
|
210
|
+
export declare function dataURLtoBlob(url: any): Blob;
|
|
136
211
|
/**
|
|
137
212
|
* @Author gaoxiang
|
|
138
213
|
* @DateTime 2020/10/26
|
|
139
214
|
* @lastTime 2020/10/26
|
|
140
215
|
* @description base64码转file文件
|
|
141
216
|
*/
|
|
142
|
-
export declare function dataURLtoFile(
|
|
217
|
+
export declare function dataURLtoFile(url: string, filename: string): File;
|
|
143
218
|
/**
|
|
144
219
|
* @Author gaoxiang
|
|
145
220
|
* @DateTime 2020/10/26
|
|
@@ -153,14 +228,14 @@ export declare function blobToDataURL(blob: Blob, fileName: string, fileType: st
|
|
|
153
228
|
* @lastTime 2020/11/13
|
|
154
229
|
* @description 截取视频时间戳
|
|
155
230
|
*/
|
|
156
|
-
export declare function getVideoFileUrl(url
|
|
231
|
+
export declare function getVideoFileUrl(url: string): string;
|
|
157
232
|
/**
|
|
158
233
|
* @Author gaoxiang
|
|
159
234
|
* @DateTime 2020/11/13
|
|
160
235
|
* @lastTime 2020/11/13
|
|
161
236
|
* @description 获取文件后缀名
|
|
162
237
|
*/
|
|
163
|
-
export declare function getFileSuffix(url
|
|
238
|
+
export declare function getFileSuffix(url: string): string;
|
|
164
239
|
/**
|
|
165
240
|
* @Author gaoxiang
|
|
166
241
|
* @DateTime 2020/10/5
|
|
@@ -177,7 +252,7 @@ export declare function checkFileType(url: any, type?: '1' | '2' | '3' | '4'): "
|
|
|
177
252
|
export declare function getMediaInfos(mediaInfo: {
|
|
178
253
|
url: any;
|
|
179
254
|
fileType?: string;
|
|
180
|
-
}): Promise<
|
|
255
|
+
}): Promise<MaterialOptions>;
|
|
181
256
|
/**
|
|
182
257
|
* @Author gaoxiang
|
|
183
258
|
* @DateTime 2020/11/13
|
|
@@ -188,7 +263,7 @@ export declare function getVideoCoverPicture(videoInfo: {
|
|
|
188
263
|
url: any;
|
|
189
264
|
currentTime?: number;
|
|
190
265
|
videoSuffix?: string;
|
|
191
|
-
|
|
266
|
+
videoAllowPlay?: boolean;
|
|
192
267
|
}): Promise<string>;
|
|
193
268
|
/**
|
|
194
269
|
* @Author gx12358
|
|
@@ -196,7 +271,7 @@ export declare function getVideoCoverPicture(videoInfo: {
|
|
|
196
271
|
* @lastTime 2022/8/4
|
|
197
272
|
* @description 直接获取视频地址
|
|
198
273
|
*/
|
|
199
|
-
export declare function
|
|
274
|
+
export declare function generateVideoPicture(videoUrl: string, currentTime?: number): Promise<string>;
|
|
200
275
|
/**
|
|
201
276
|
* @Author gx12358
|
|
202
277
|
* @DateTime 2022/8/4
|
|
@@ -204,5 +279,53 @@ export declare function generateVidoePicture(videoUrl: string, currentTime?: num
|
|
|
204
279
|
* @description 判断是否是base64码
|
|
205
280
|
*/
|
|
206
281
|
export declare function isBase64(str?: string): boolean;
|
|
282
|
+
export declare function isDataURLBase64(str: string): boolean;
|
|
207
283
|
export declare function on(element: HTMLElement | Document | Window | null, event: string, handler: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
|
208
284
|
export declare function off(element: HTMLElement | Document | Window | null, event: string, handler: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
|
285
|
+
/**
|
|
286
|
+
* 检查当前运行环境是否为Windows OS。
|
|
287
|
+
*
|
|
288
|
+
* 这个函数通过检查navigator.userAgent字符串来判断当前运行环境。
|
|
289
|
+
* 如果userAgent字符串中包含"windows"或"win32"(不区分大小写),则认为当前环境是Windows OS。
|
|
290
|
+
*
|
|
291
|
+
* @returns {boolean} 如果当前环境是Windows OS,返回true,否则返回false。
|
|
292
|
+
*/
|
|
293
|
+
export declare function isWindowsOs(): boolean;
|
|
294
|
+
export declare function convertValueBoolean(value: any): boolean;
|
|
295
|
+
export declare function formatNumber(fixedNum: number, value: number): string;
|
|
296
|
+
/**
|
|
297
|
+
* @Author gx12358
|
|
298
|
+
* @DateTime 2022/6/20
|
|
299
|
+
* @lastTime 2022/6/20
|
|
300
|
+
* @description 转换数字
|
|
301
|
+
*/
|
|
302
|
+
export declare function toConvertNumberShow(number: number, options?: {
|
|
303
|
+
toChinese?: boolean;
|
|
304
|
+
fixed?: number;
|
|
305
|
+
min?: number;
|
|
306
|
+
}): {
|
|
307
|
+
str: string;
|
|
308
|
+
number: string;
|
|
309
|
+
unit?: string;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* @Author gx12358
|
|
313
|
+
* @DateTime 2022/9/13
|
|
314
|
+
* @lastTime 2022/9/13
|
|
315
|
+
* @description 获取字符宽度或高度
|
|
316
|
+
*/
|
|
317
|
+
export declare function getTextWidth(str: string, options: {
|
|
318
|
+
id?: string;
|
|
319
|
+
type?: 'width' | 'height';
|
|
320
|
+
createName?: string;
|
|
321
|
+
removeAfter?: boolean;
|
|
322
|
+
cssObject?: CSSProperties;
|
|
323
|
+
}): number;
|
|
324
|
+
/**
|
|
325
|
+
* @Author gx12358
|
|
326
|
+
* @DateTime 2022/8/4
|
|
327
|
+
* @lastTime 2022/8/4
|
|
328
|
+
* @description 数字转中文
|
|
329
|
+
*/
|
|
330
|
+
export declare function toChinesNum(num: number): string;
|
|
331
|
+
export declare function forInObject<T extends object>(obj: T, callback: (key: keyof T, value: T[keyof T]) => void): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isNotNil<T>(x: T | null | undefined): x is T;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a given value is a plain object.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} value - The value to check.
|
|
5
|
+
* @returns {value is Record<PropertyKey, any>} - True if the value is a plain object, otherwise false.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // ✅👇 True
|
|
10
|
+
*
|
|
11
|
+
* isPlainObject({ }); // ✅
|
|
12
|
+
* isPlainObject({ key: 'value' }); // ✅
|
|
13
|
+
* isPlainObject({ key: new Date() }); // ✅
|
|
14
|
+
* isPlainObject(new Object()); // ✅
|
|
15
|
+
* isPlainObject(Object.create(null)); // ✅
|
|
16
|
+
* isPlainObject({ nested: { key: true} }); // ✅
|
|
17
|
+
* isPlainObject(new Proxy({}, {})); // ✅
|
|
18
|
+
* isPlainObject({ [Symbol('tag')]: 'A' }); // ✅
|
|
19
|
+
*
|
|
20
|
+
* // ✅👇 (cross-realms, node context, workers, ...)
|
|
21
|
+
* const runInNewContext = await import('node:vm').then(
|
|
22
|
+
* (mod) => mod.runInNewContext
|
|
23
|
+
* );
|
|
24
|
+
* isPlainObject(runInNewContext('({})')); // ✅
|
|
25
|
+
*
|
|
26
|
+
* // ❌👇 False
|
|
27
|
+
*
|
|
28
|
+
* class Test { };
|
|
29
|
+
* isPlainObject(new Test()) // ❌
|
|
30
|
+
* isPlainObject(10); // ❌
|
|
31
|
+
* isPlainObject(null); // ❌
|
|
32
|
+
* isPlainObject('hello'); // ❌
|
|
33
|
+
* isPlainObject([]); // ❌
|
|
34
|
+
* isPlainObject(new Date()); // ❌
|
|
35
|
+
* isPlainObject(new Uint8Array([1])); // ❌
|
|
36
|
+
* isPlainObject(Buffer.from('ABC')); // ❌
|
|
37
|
+
* isPlainObject(Promise.resolve({})); // ❌
|
|
38
|
+
* isPlainObject(Object.create({})); // ❌
|
|
39
|
+
* isPlainObject(new (class Cls {})); // ❌
|
|
40
|
+
* isPlainObject(globalThis); // ❌,
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function isPlainObject(value: unknown): value is Record<PropertyKey, any>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a value is a JavaScript primitive.
|
|
3
|
+
* JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} value The value to check.
|
|
6
|
+
* @returns {value is
|
|
7
|
+
* null
|
|
8
|
+
* | undefined
|
|
9
|
+
* | string
|
|
10
|
+
* | number
|
|
11
|
+
* | boolean
|
|
12
|
+
* | symbol
|
|
13
|
+
* | bigint} Returns true if `value` is a primitive, false otherwise.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* isPrimitive(null); // true
|
|
17
|
+
* isPrimitive(undefined); // true
|
|
18
|
+
* isPrimitive('123'); // true
|
|
19
|
+
* isPrimitive(false); // true
|
|
20
|
+
* isPrimitive(true); // true
|
|
21
|
+
* isPrimitive(Symbol('a')); // true
|
|
22
|
+
* isPrimitive(123n); // true
|
|
23
|
+
* isPrimitive({}); // false
|
|
24
|
+
* isPrimitive(new Date()); // false
|
|
25
|
+
* isPrimitive(new Map()); // false
|
|
26
|
+
* isPrimitive(new Set()); // false
|
|
27
|
+
* isPrimitive([1, 2, 3]); // false
|
|
28
|
+
*/
|
|
29
|
+
export declare function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a TypedArray.
|
|
3
|
+
* @param {unknown} x The value to check.
|
|
4
|
+
* @returns {x is
|
|
5
|
+
* Uint8Array
|
|
6
|
+
* | Uint8ClampedArray
|
|
7
|
+
* | Uint16Array
|
|
8
|
+
* | Uint32Array
|
|
9
|
+
* | BigUint64Array
|
|
10
|
+
* | Int8Array
|
|
11
|
+
* | Int16Array
|
|
12
|
+
* | Int32Array
|
|
13
|
+
* | BigInt64Array
|
|
14
|
+
* | Float32Array
|
|
15
|
+
* | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const arr = new Uint8Array([1, 2, 3]);
|
|
19
|
+
* isTypedArray(arr); // true
|
|
20
|
+
*
|
|
21
|
+
* const regularArray = [1, 2, 3];
|
|
22
|
+
* isTypedArray(regularArray); // false
|
|
23
|
+
*
|
|
24
|
+
* const buffer = new ArrayBuffer(16);
|
|
25
|
+
* isTypedArray(buffer); // false
|
|
26
|
+
*/
|
|
27
|
+
export declare function isTypedArray(x: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a property key is unsafe to modify directly.
|
|
3
|
+
*
|
|
4
|
+
* This function is used in functions like `merge` to prevent prototype pollution attacks
|
|
5
|
+
* by identifying property keys that could modify the object's prototype chain or constructor.
|
|
6
|
+
*
|
|
7
|
+
* @param key - The property key to check
|
|
8
|
+
* @returns `true` if the property is unsafe to modify directly, `false` otherwise
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function isUnsafeProperty(key: PropertyKey): key is "__proto__";
|