@gx-design-vue/pro-utils 0.2.0-beta.42 → 0.2.0-beta.43
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/pro-utils.js +482 -378
- package/dist/pro-utils.umd.cjs +2 -2
- package/dist/typings/index.d.ts +5 -5
- package/dist/utils/index.d.ts +75 -15
- package/dist/utils/validate.d.ts +8 -5
- package/package.json +1 -1
package/dist/pro-utils.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(c=typeof globalThis<"u"?globalThis:c||self,s(c.PorUtils={},c.vue))})(this,function(c,s){"use strict";const w=typeof window>"u";/**
|
|
2
2
|
* @vue/shared v3.5.11
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
|
-
**/process.env.NODE_ENV!=="production"&&Object.freeze({}),process.env.NODE_ENV!=="production"&&Object.freeze([]);const Z=e=>{const n=Object.create(null);return r=>n[r]||(n[r]=e(r))},k=/-(\w)/g,K=Z(e=>e.replace(k,(n,r)=>r?r.toUpperCase():"")),O=function(e,n){var r;if(w||!e||!n)return"";n=K(n),n==="float"&&(n="cssFloat");try{const t=e.style[n];if(t)return t;const i=(r=document==null?void 0:document.defaultView)==null?void 0:r.getComputedStyle(e,"");return i?i[n]:""}catch{return e.style[n]}},C=(e,n)=>w?void 0:(n==null?O(e,"overflow"):n?O(e,"overflow-y"):O(e,"overflow-x")).match(/(scroll|auto|overlay)/),ee=(e,n)=>{if(w)return;let r=e;for(;r;){if([window,document,document.documentElement].includes(r))return window;if(C(r,n))return r;r=r.parentNode}return r},ne=(e,n)=>{if(w||!e||!n)return!1;const r=e.getBoundingClientRect();let t;return[window,document,document.documentElement,null,void 0].includes(n)?t={top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}:t=n.getBoundingClientRect(),r.top<t.bottom&&r.bottom>t.top&&r.right>t.left&&r.left<t.right};function te(e){return/\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(e)}const re=e=>e==null,ie=e=>{if(!e||!e.startsWith("http"))return!1;try{return!!new URL(e)}catch{return!1}},oe=(...e)=>{const n={},r=e.length;let t,i=0;for(;i<r;i+=1)for(t in e[i])e[i].hasOwnProperty(t)&&(typeof n[t]=="object"&&typeof e[i][t]=="object"&&n[t]!==void 0&&n[t]!==null&&!Array.isArray(n[t])&&!Array.isArray(e[i][t])?n[t]={...n[t],...e[i][t]}:n[t]=e[i][t]);return n};let N=0;const P=(e=21)=>{if(typeof window>"u"||!window.crypto)return(N+=1).toFixed(0);let n="";const r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){const t=63&r[e];n+=t<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t<63?"_":"-"}return n},ue=()=>typeof window>"u"?P():window.crypto&&window.crypto.randomUUID&&typeof crypto.randomUUID=="function"?crypto.randomUUID():P();function U(e,n){if(typeof n!="string"&&!Array.isArray(n))return;const r=Array.isArray(n)?n:n.split(":");let t=e;for(let i=0;i<r.length;i++)if(t&&t.hasOwnProperty(r[i]))t=t[r[i]];else return;return t}const ce=Object.prototype.toString;function R(e,n){return ce.call(e)===`[object ${n}]`}function b(e){return R(e,"Boolean")}function fe(e){return typeof e=="number"}function E(e){return typeof Array.isArray>"u"?Object.prototype.toString.call(e)==="[object Array]":Array.isArray(e)}function g(e){return e!==null&&R(e,"Object")}function V(e){return typeof e=="string"||e instanceof String}function ae(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Function]"}function x(...e){const n=[];for(let r=0;r<e.length;r++){const t=e[r];if(t){if(V(t))n.push(t);else if(E(t))for(let i=0;i<t.length;i++){const o=x(t[i]);o&&n.push(o)}else if(g(t))for(const i in t)t[i]&&n.push(i)}}return n.filter(r=>r).join(" ")}let M=e=>setTimeout(e,16),$=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(M=e=>window.requestAnimationFrame(e),$=e=>window.cancelAnimationFrame(e));let z=0;const F=new Map;function W(e){F.delete(e)}function T(e,n=1){z+=1;const r=z;function t(i){if(i===0)W(r),e();else{const o=M(()=>{t(i-1)});F.set(r,o)}}return t(n),r}T.cancel=e=>{const n=F.get(e);return W(n),$(n)};function I(e){return e!=null&&e===e.window}function q(e,n){var i;if(typeof window>"u")return 0;const r=n?"scrollTop":"scrollLeft";let t=0;return I(e)?t=e[n?"pageYOffset":"pageXOffset"]:e instanceof Document?t=e.documentElement[r]:e&&(t=e[r]),e&&!I(e)&&typeof t!="number"&&(t=(i=(e.ownerDocument||e).documentElement)==null?void 0:i[r]),t}function le(e,n,r,t){const i=r-n;return e/=t/2,e<1?i/2*e*e*e+n:i/2*((e-=2)*e*e+2)+n}function se(e,n={}){const{getContainer:r=()=>window,callback:t,duration:i=450}=n,o=r(),c=q(o,!0),f=Date.now(),a=()=>{const d=Date.now()-f,m=le(d>i?i:d,c,e,i);I(o)?o.scrollTo(window.pageXOffset,m):o instanceof HTMLDocument||o.constructor.name==="HTMLDocument"?o.documentElement.scrollTop=m:o.scrollTop=m,d<i?T(a):typeof t=="function"&&t()};T(a)}function de(e){let n;const r=i=>()=>{n=null,e(...i)},t=(...i)=>{n==null&&(n=requestAnimationFrame(r(i)))};return t.cancel=()=>cancelAnimationFrame(n),t}const y={videoAllowType:["mp4","webm","ogg"],audioAllowType:["mp3"],imageType:["bmp","png","gif","jpg","jpeg","psd","tif"],videoType:["mp4","swf","rmvb","avi","flv","mpg","rm","mov","asf","3gp","mkv","ts","f4v","webm","m4v","3g2","m3u8"],audioType:["mp3","mpeg","aac","wav","wma","mp2","flac","midi","ra","ape","aac","cda"]};function h(e,n,r,t){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;let i,o,c;if(Array.isArray(e)){if(i=e.length,i!=n.length)return!1;for(o=i;o--!==0;)if(!h(e[o],n[o],r,t))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;for(o of e.entries())if(!h(o[1],n.get(o[0]),r,t))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(i=e.length,i!=n.length)return!1;for(o=i;o--!==0;)if(e[o]!==n[o])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf&&e.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString&&e.toString)return e.toString()===n.toString();if(c=Object.keys(e),i=c.length,i!==Object.keys(n).length)return!1;for(o=i;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,c[o]))return!1;for(o=i;o--!==0;){const f=c[o];if(!(r!=null&&r.includes(f))&&!(f==="_owner"&&e.$$typeof)&&!h(e[f],n[f],r,t))return t&&console.log(f),!1}return!0}return e!==e&&n!==n}const ge=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,me=()=>process.env.NODE_ENV==="TEST"?!0:typeof window<"u"&&typeof window.document<"u"&&typeof window.matchMedia<"u"&&!ge,we=e=>{if(e&&e!==!0)return e},ye=e=>{const n={};if(Object.keys(e||{}).forEach(r=>{e[r]!==void 0&&(n[r]=e[r])}),!(Object.keys(n).length<1))return n},pe=e=>{const n={};return Object.keys(e||{}).forEach(r=>{var t;Array.isArray(e[r])&&((t=e[r])==null?void 0:t.length)===0||e[r]!==void 0&&(n[r]=e[r])}),n};function j(e){var n;if(!(typeof e!="string"&&!Array.isArray(e)))return Array.isArray(e)?e[e.length-1]:(n=e.split(":"))==null?void 0:n.slice(-1)[0]}function H(e){return e&&(e.type===l.Comment||e.type===l.Fragment&&e.children.length===0||e.type===Text&&e.children.trim()==="")}function he(e,n){var r;return B((r=e[n])==null?void 0:r.call(e))}function B(e=[]){const n=[];return e.forEach(r=>{Array.isArray(r)?n.push(...r):(r==null?void 0:r.type)===l.Fragment?n.push(...B(r.children)):n.push(r)}),n.filter(r=>!H(r))}function D(e,...n){return typeof e=="function"?e==null?void 0:e(...n):e}function _(e,n,r="default",t){const i=j(r);if(i){let o;const c=U(n,r);return c===!1?o=!1:c===!0?o=e==null?void 0:e[i]:g(c)&&t?l.isVNode(c)?o=c:o=e==null?void 0:e[i]:o=c||(e==null?void 0:e[i]),t?l.isVNode(o)?o:D(o):o}}function J(e,n,r="default",t){var o,c,f;const i=j(r);if(i){let a;const s=U(n,r);return s===!1?a=!1:s===!0?a=(o=e==null?void 0:e[i])==null?void 0:o.call(e,t):g(s)?l.isVNode(s)?a=s:a=(c=e==null?void 0:e[i])==null?void 0:c.call(e,t):a=s||((f=e==null?void 0:e[i])==null?void 0:f.call(e,t)),l.isVNode(a)?a:D(a,t)}}function Se(e,n,r,t){const i={};return e.forEach(o=>{const c=j(o);if(c){const f=t!=null&&t.render?J(n,r,o,t==null?void 0:t.params):_(n,r,o);(b(f)||f)&&(i[c]=f)}}),i}const ve=({suffixCls:e,customizePrefixCls:n,isPor:r,className:t})=>{const i=t||(r?"gx-pro":"gx");return n||(e?`${i}-${e}`:i)},Ae=(e,n)=>e?Array.isArray(e)?e.join("-"):e.toString():`${n}`;function Oe(e,{align:n,showIndex:r}){const t=S(e);if(r&&e.length&&e.every(i=>i.dataIndex!=="sortIndex")){const i=e[0];t.unshift({title:"序号",align:n,fixed:i.fixed,width:60,uuid:X().uuid(15),dataIndex:"sortIndex",key:"sortIndex"})}else t.filter(i=>i.dataIndex!=="sortIndex");return t}function Ue(e,...n){return typeof e=="function"?e(...n):e}function S(e){return JSON.parse(JSON.stringify(e))}function Re(e,n){if(g(e)){const{pageSize:r=10,total:t=0}=e;let{current:i=1}=e;return t-n<=r*(i-1)&&(i=i-1),i===0?1:i}return 1}function be(e=[],n,r="children"){function t(i,o){return o.map((c,f)=>{const a=`${i}-${f+1}`;return c[r]&&(c[r]=t(a,c[r])),c.sortIndex=a,c})}return S(e).map((i,o)=>{let c=o;const f=g(n)&&n.current||1,a=g(n)&&n.pageSize||10;return c=f?(f-1)*a+(o+1):o+1,i[r]&&(i[r]=t(`${c}`,i[r])),i.sortIndex=c,i})}function Ee(e,n,r,t){const i=e[r],o=n[r];let c=0;return i<o?c=t===0?-1:0:i>o&&(c=t===0?0:-1),c}function Fe(e){let n=S(e);const r=new Set(n);return n=Array.from(r),n}function Te(e,n){const r=["null","undefined"];let t=!0;return e===0?t=!0:r.includes(e)?t=!1:e||(t=!1),t?{value:e,success:t}:{value:n===""?n:n||"-",success:t}}function Ie(e){let n="";if(e>-1){const r=Math.floor(e/3600),t=Math.floor(e/60)%60,i=Number.parseInt(String(e%60));r<10?n="0"+r+":":n=r+":",t<10&&(n+="0"),n+=t+":",i<10&&(n+="0"),n+=i}return n.split(":")[0]==="00"?`${n.split(":")[1]}:${n.split(":")[2]}`:n}function X(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");return{uuid(n,r){const t=e,i=[],o=r||t.length;let c,f;if(n)for(c=0;c<n;c+=1)i[c]=t[Number.parseInt(String(Math.random()*o))];else for(i[8]="-",i[13]="-",i[18]="-",i[23]="-",i[14]="4",c=0;c<36;c+=1)i[c]||(f=Math.random()*16,i[c]=t[c===19?f&&3||8:f]);return i.join("")},uuidFast(){const n=e,r=Array.from({length:36});let t=0,i,o;for(o=0;o<36;o+=1)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216||0),i=t&&15,t=t>4,r[o]=n[o===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,n=>{const r=Math.random()*16||0;return(n==="x"?r:r&&3||8).toString(16)})}}}function je(e=[]){let n=0;function r(t=[],i){t.forEach(o=>{o.floor=i,i>n&&(n=i),o.children&&o.children.length>0&&r(o.children,i+1)})}return r(e,1),n}function Y(e,n="children"){let r=[];return e.forEach(t=>{r.push(t),E(t[n])&&t[n].length>0&&(r=r.concat(Y(t[n])))}),r}function Be(e,n,r,t,i){n=n||"id",r=r||"parentId",t=t||"children",i=i||0;const o=JSON.parse(JSON.stringify(e));return o.filter(c=>{const f=o.filter(a=>c[n]===a[r||"parentId"]);return f.length>0?c[t||"children"]=f:delete c[t||"children"],c[r||"parentId"]===i})}function De(e){return URL.createObjectURL(e)}function Le(e){return new Promise((n,r)=>{const t=new FileReader;t.readAsDataURL(e),t.onload=()=>n(t.result),t.onerror=i=>r(i)})}function Ce(e){const n=e.split(","),r=n[0].match(/:(.*?);/)[1],t=atob(n[1]);let i=t.length;const o=new Uint8Array(i);for(;i--;)o[i]=t.charCodeAt(i);return new Blob([o],{type:r})}function Ne(e,n){const r=e.split(","),t=r[0].match(/:(.*?);/)[1],i=atob(r[1]);let o=i.length;const c=new Uint8Array(o);for(;o--;)c[o]=i.charCodeAt(o);return new File([c],n,{type:t})}function Pe(e,n,r){return new window.File([e],n,{type:r})}function G(e=""){const n=e.indexOf("?");return n>0?`${e.substring(0,n)}`:e}function v(e=""){e=G(e);const n=e.lastIndexOf(".");return n>0?`${e.substring(n).split("?")[0]}`.split(".")[1]:""}function p(e,n){if(n)return n;if(!e||e==="data:")return"4";let r="4";return A(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=v(e).toLowerCase(),y.imageType.includes(r)?"1":y.videoType.includes(r)?"3":y.audioType.includes(r)?"2":"4"}function Q(e){const{url:n="",fileType:r="1"}=e;let t="";return n instanceof File?t=URL.createObjectURL(n):A(n)?t=n:n instanceof Blob?t=URL.createObjectURL(n):(n.includes("https")||n.includes("http"))&&(t=n),new Promise(i=>{let o;r==="1"?(o=document.createElement("img"),o.src=t):r==="2"?(o=document.createElement("audio"),o.src=t):r==="3"&&(o=document.createElement("video"),o.src=t),r==="1"?o.onload=function(){i({play:!0,width:o.width||0,height:o.height||0}),o=null}:o.oncanplay=function(){i({play:!0,duration:o.duration,width:(o==null?void 0:o.videoWidth)||0,height:(o==null?void 0:o.videoHeight)||0}),o=null},o.onerror=function(){i({play:!1}),o=null}})}async function Ve(e){const{url:n="",currentTime:r,videoSuffix:t="",vidoeAllowPlay:i=!1}=e;let o="",c=t,f="1",a;return n instanceof File?(o=URL.createObjectURL(n),c=v(n.name),f=p(n.name)):n instanceof Blob?(o=URL.createObjectURL(n),f=p(n)):A(n)?(o=n,f=p(n)):(n.includes("https")||n.includes("http"))&&(o=n,c=v(n),f=p(n)),(c?y.videoAllowType.includes(c.toLowerCase()):!1)?i?L(o,r):(a=await Q({url:o,fileType:f}),a.play?L(o,r):new Promise(d=>{d("")})):new Promise(d=>{d("")})}async function L(e,n=0){return new Promise(r=>{let t=document.createElement("video");t.controls=!0,t.muted=!0,t.setAttribute("src",e),t.setAttribute("muted",String(!0)),t.setAttribute("crossorigin","anonymous"),t.setAttribute("autoplay",String(!0)),t&&t.addEventListener("loadeddata",async function(){let i;t==null||t.addEventListener("seeked",async function(){i&&i()});const o=(t==null?void 0:t.duration)||0;for(;n<o;){t&&(t.currentTime=n),await new Promise(We=>i=We);const c=document.createElement("canvas"),f=.8,a=c.getContext("2d"),s=(t==null?void 0:t.videoWidth)||0*f,d=(t==null?void 0:t.videoHeight)||0*f,m=0;c.width=(t==null?void 0:t.videoWidth)||0*f,c.height=(t==null?void 0:t.videoHeight)||0*f,a.drawImage(t,0,0,s+m,d+m),t=null,r(s===0||d===0?"":c.toDataURL("image/png",1))}})})}function A(e=""){return!!(e&&["data:image/","data:video/","data:audio/"].find(r=>e.includes(r)))}function xe(e,n,r,t=!1){e&&n&&r&&e.addEventListener(n,r,t)}function Me(e,n,r,t=!1){e&&n&&r&&e.removeEventListener(n,r,t)}function $e(){return/windows|win32/i.test(navigator.userAgent)}function ze(e){return b(e)?e:!!e}u.arrayRepeat=Fe,u.blobToDataURL=Pe,u.checkFileType=p,u.classNames=x,u.compareArray=Ee,u.convertValueBoolean=ze,u.dataURLtoBlob=Ce,u.dataURLtoFile=Ne,u.deepCopy=S,u.filterEmpty=B,u.formatDuraton=Ie,u.genColumnKey=Ae,u.generateVidoePicture=L,u.getBase64=Le,u.getBlobUrl=De,u.getFileSuffix=v,u.getLevelData=Y,u.getMaxFloor=je,u.getMediaInfos=Q,u.getPrefixCls=ve,u.getRandomNumber=X,u.getScroll=q,u.getScrollContainer=ee,u.getSlot=_,u.getSlotVNode=J,u.getSlotsChildren=he,u.getSlotsProps=Se,u.getSortIndex=be,u.getValueFromObjectByKey=U,u.getVideoCoverPicture=Ve,u.getVideoFileUrl=G,u.globalConfig=y,u.handleCurrentPage=Re,u.handleShowIndex=Oe,u.hanndleField=Te,u.is=R,u.isArray=E,u.isBase64=A,u.isBoolean=b,u.isBrowser=me,u.isDeepEqualReact=h,u.isEmptyElement=H,u.isFunction=ae,u.isImg=te,u.isInContainer=ne,u.isNil=re,u.isNumber=fe,u.isObject=g,u.isScroll=C,u.isServer=w,u.isString=V,u.isUrl=ie,u.isWindowsOs=$e,u.merge=oe,u.nanoid=ue,u.off=Me,u.omitBoolean=we,u.omitUndefined=ye,u.omitUndefinedAndEmptyArr=pe,u.on=xe,u.runFunction=Ue,u.scrollTo=se,u.slotRender=D,u.throttleByAnimationFrame=de,u.treeData=Be,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
5
|
+
**/process.env.NODE_ENV!=="production"&&Object.freeze({}),process.env.NODE_ENV!=="production"&&Object.freeze([]);const ne=e=>{const t=Object.create(null);return r=>t[r]||(t[r]=e(r))},re=/-(\w)/g,ie=ne(e=>e.replace(re,(t,r)=>r?r.toUpperCase():"")),R=function(e,t){var r;if(w||!e||!t)return"";t=ie(t),t==="float"&&(t="cssFloat");try{const n=e.style[t];if(n)return n;const i=(r=document==null?void 0:document.defaultView)==null?void 0:r.getComputedStyle(e,"");return i?i[t]:""}catch{return e.style[t]}},N=(e,t)=>w?void 0:(t==null?R(e,"overflow"):t?R(e,"overflow-y"):R(e,"overflow-x")).match(/(scroll|auto|overlay)/),oe=(e,t)=>{if(w)return;let r=e;for(;r;){if([window,document,document.documentElement].includes(r))return window;if(N(r,t))return r;r=r.parentNode}return r},ue=(e,t)=>{if(w||!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 ce(e){return/\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(e)}const fe=e=>e==null,ae=e=>{if(!e||!e.startsWith("http"))return!1;try{return!!new URL(e)}catch{return!1}},le=(...e)=>{const t={},r=e.length;let n,i=0;for(;i<r;i+=1)for(n in e[i])e[i].hasOwnProperty(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};let P=0;const M=(e=21)=>{if(typeof window>"u"||!window.crypto)return(P+=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},se=()=>typeof window>"u"?M():window.crypto&&window.crypto.randomUUID&&typeof crypto.randomUUID=="function"?crypto.randomUUID():M();function T(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&&n.hasOwnProperty(r[i]))n=n[r[i]];else return;return n}function V(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function E(e){return typeof e=="boolean"}function m(e){return typeof e=="number"}function y(e){return typeof Array.isArray>"u"?Object.prototype.toString.call(e)==="[object Array]":Array.isArray(e)}function g(e){return e!==null&&V(e,"Object")}function $(e){return typeof e=="string"||e instanceof String}function de(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Function]"}function ge(e){if(typeof e!="string")return!1;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null}catch{return!1}}function me(){const e=navigator.userAgent||navigator.vendor;return!!(/iPhone/.test(e)||/Android/.test(e)&&/Mobile/.test(e)||/Windows Phone/.test(e)||/Mobile/.test(e)&&!x())}function x(){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($(n))t.push(n);else if(y(n))for(let i=0;i<n.length;i++){const o=z(n[i]);o&&t.push(o)}else if(g(n))for(const i in n)n[i]&&t.push(i)}}return t.filter(r=>r).join(" ")}let W=e=>setTimeout(e,16),q=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(W=e=>window.requestAnimationFrame(e),q=e=>window.cancelAnimationFrame(e));let H=0;const U=new Map;function _(e){U.delete(e)}function j(e,t=1){H+=1;const r=H;function n(i){if(i===0)_(r),e();else{const o=W(()=>{n(i-1)});U.set(r,o)}}return n(t),r}j.cancel=e=>{const t=U.get(e);return _(t),q(t)};function F(e){return e!=null&&e===e.window}function J(e,t){var i;if(typeof window>"u")return 0;const r=t?"scrollTop":"scrollLeft";let n=0;return F(e)?n=e[t?"pageYOffset":"pageXOffset"]:e instanceof Document?n=e.documentElement[r]:e&&(n=e[r]),e&&!F(e)&&typeof n!="number"&&(n=(i=(e.ownerDocument||e).documentElement)==null?void 0:i[r]),n}function ye(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 we(e,t={}){const{getContainer:r=()=>window,callback:n,duration:i=450}=t,o=r(),u=J(o,!0),f=Date.now(),a=()=>{const d=Date.now()-f,v=ye(d>i?i:d,u,e,i);F(o)?o.scrollTo(window.pageXOffset,v):o instanceof HTMLDocument||o.constructor.name==="HTMLDocument"?o.documentElement.scrollTop=v:o.scrollTop=v,d<i?j(a):typeof n=="function"&&n()};o&&j(a)}function he(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 h={videoAllowType:["mp4","webm","ogg"],audioAllowType:["mp3"],imageType:["bmp","png","gif","jpg","jpeg","psd","tif"],videoType:["mp4","swf","rmvb","avi","flv","mpg","rm","mov","asf","3gp","mkv","ts","f4v","webm","m4v","3g2","m3u8"],audioType:["mp3","mpeg","aac","wav","wma","mp2","flac","midi","ra","ape","aac","cda"]};function A(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,o,u;if(Array.isArray(e)){if(i=e.length,i!=t.length)return!1;for(o=i;o--!==0;)if(!A(e[o],t[o],r,n))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;for(o of e.entries())if(!A(o[1],t.get(o[0]),r,n))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(i=e.length,i!=t.length)return!1;for(o=i;o--!==0;)if(e[o]!==t[o])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(u=Object.keys(e),i=u.length,i!==Object.keys(t).length)return!1;for(o=i;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,u[o]))return!1;for(o=i;o--!==0;){const f=u[o];if(!(r!=null&&r.includes(f))&&!(f==="_owner"&&e.$$typeof)&&!A(e[f],t[f],r,n))return n&&console.log(f),!1}return!0}return e!==e&&t!==t}const pe=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Se=()=>process.env.NODE_ENV==="TEST"?!0:typeof window<"u"&&typeof window.document<"u"&&typeof window.matchMedia<"u"&&!pe,ve=e=>{if(e&&e!==!0)return e},Ae=e=>{const t={};if(Object.keys(e||{}).forEach(r=>{e[r]!==void 0&&(t[r]=e[r])}),!(Object.keys(t).length<1))return t},Oe=e=>{const t={};return Object.keys(e||{}).forEach(r=>{var n;Array.isArray(e[r])&&((n=e[r])==null?void 0:n.length)===0||e[r]!==void 0&&(t[r]=e[r])}),t};function C(e){var t;if(!(typeof e!="string"&&!Array.isArray(e)))return Array.isArray(e)?e[e.length-1]:(t=e.split(":"))==null?void 0:t.slice(-1)[0]}function X(e){return e&&(e.type===s.Comment||e.type===s.Fragment&&e.children.length===0||e.type===Text&&e.children.trim()==="")}function be(e,t){var r;return D((r=e[t])==null?void 0:r.call(e))}function D(e=[]){const t=[];return e.forEach(r=>{Array.isArray(r)?t.push(...r):(r==null?void 0:r.type)===s.Fragment?t.push(...D(r.children)):t.push(r)}),t.filter(r=>!X(r))}function L(e,...t){return typeof e=="function"?e==null?void 0:e(...t):e}function Z(e,t,r="default",n){const i=C(r);if(i){let o;const u=T(t,r);return u===!1?o=!1:u===!0?o=e==null?void 0:e[i]:g(u)&&n?s.isVNode(u)?o=u:o=e==null?void 0:e[i]:o=u||(e==null?void 0:e[i]),n?s.isVNode(o)?o:L(o):o}}function Y(e,t,r="default",n){var o,u,f;const i=C(r);if(i){let a;const l=T(t,r);return l===!1?a=!1:l===!0?a=(o=e==null?void 0:e[i])==null?void 0:o.call(e,n):g(l)?s.isVNode(l)?a=l:a=(u=e==null?void 0:e[i])==null?void 0:u.call(e,n):a=l||((f=e==null?void 0:e[i])==null?void 0:f.call(e,n)),s.isVNode(a)?a:L(a,n)}}function Re(e,t,r,n){const i={};return e.forEach(o=>{const u=C(o);if(u){const f=n!=null&&n.render?Y(t,r,o,n==null?void 0:n.params):Z(t,r,o);(E(f)||f)&&(i[u]=f)}}),i}const Te=({suffixCls:e,customizePrefixCls:t,isPor:r,className:n})=>{const i=n||(r?"gx-pro":"gx");return t||(e?`${i}-${e}`:i)},Ee=(e,t)=>e?y(e)?e.join("-"):e.toString():`${t||0}`;function Ue(e,{align:t,showIndex:r}){const n=p(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:k().uuid(15),dataIndex:"sortIndex",key:"sortIndex"})}else n.filter(i=>i.dataIndex!=="sortIndex");return n}function je(e,...t){return typeof e=="function"?e(...t):e}function p(e){return JSON.parse(JSON.stringify(e))}function Fe(e,t){if(g(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 Ce(e=[],t,r="children"){function n(i,o){return o.map((u,f)=>{const a=`${i}-${f+1}`;return u[r]&&(u[r]=n(a,u[r])),u.sortIndex=a,u})}return p(e).map((i,o)=>{const u=g(t)&&t.current||1,f=g(t)&&t.pageSize||10,a=`${u?(u-1)*f+(o+1):o+1}`;return i[r]&&(i[r]=n(`${a}`,i[r])),i.sortIndex=a,i})}function De(e,t){return y(e)?e==null?void 0:e.filter((r,n)=>{if(m(t))return n<=t-1;if(y(t)&&t.length===2){const i=t[0]-1,o=t[1]?t[1]-1:e.length-1;return n<=o&&n>=i}else if(y(t)&&t.length===1){const i=t[0]-1,o=e.length-1;return n<=o&&n>=i}return!0}):[]}function G(e,t,r,n=0){const i=m(n)&&(n===0||n===1)?n:0,o=e[r],u=t[r];let f=0;return o<u?f=i===0?-1:0:o>u&&(f=i===0?0:-1),f}function Q(e,t,r,n=0){const i=m(n)&&(n===0||n===1)?n:0,o=new Date(e[r]),u=new Date(t[r]);let f=0;return o<u?f=i===0?-1:0:o>u&&(f=i===0?0:-1),f}function Le(e,t,r=0){return e.sort((n,i)=>G(n,i,t,r))}function Be(e,t,r=0){return e.sort((n,i)=>Q(n,i,t,r))}function Ie(e){let t=p(e);const r=new Set(t);return t=Array.from(r),t}function Ne(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 Pe(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 k(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");return{uuid(t,r){const n=e,i=[],o=r||n.length;let u,f;if(t)for(u=0;u<t;u+=1)i[u]=n[Number.parseInt(String(Math.random()*o))];else for(i[8]="-",i[13]="-",i[18]="-",i[23]="-",i[14]="4",u=0;u<36;u+=1)i[u]||(f=Math.random()*16,i[u]=n[u===19?f&&3||8:f]);return i.join("")},uuidFast(){const t=e,r=Array.from({length:36});let n=0,i,o;for(o=0;o<36;o+=1)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(n<=2&&(n=33554432+Math.random()*16777216||0),i=n&&15,n=n>4,r[o]=t[o===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 Me(e=[],t="children"){let r=0;function n(i=[],o){i.forEach(u=>{u.floor=o,o>r&&(r=o),u[t]&&u[t].length>0&&n(u[t],o+1)})}return n(e,1),r}function K(e,t="children"){let r=[];return e.forEach(n=>{r.push(n),y(n[t])&&n[t].length>0&&(r=r.concat(K(n[t])))}),r}function Ve(e,t,r,n,i){t=t||"id",r=r||"parentId",n=n||"children",i=i||0;const o=p(e);return o.filter(u=>{const f=o.filter(a=>u[t]===a[r]);return f.length>0?u[n]=f:u[n]=[],u[r]===i})}function $e(e){return URL.createObjectURL(e)}function xe(e){return new Promise((t,r)=>{const n=new FileReader;n.readAsDataURL(e),n.onload=()=>t(n.result),n.onerror=i=>r(i)})}function ze(e){const t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=atob(t[1]);let i=n.length;const o=new Uint8Array(i);for(;i--;)o[i]=n.charCodeAt(i);return new Blob([o],{type:r})}function We(e,t){const r=e.split(","),n=r[0].match(/:(.*?);/)[1],i=atob(r[1]);let o=i.length;const u=new Uint8Array(o);for(;o--;)u[o]=i.charCodeAt(o);return new File([u],t,{type:n})}function qe(e,t,r){return new window.File([e],t,{type:r})}function ee(e){if(!e||typeof e!="string")return"";const t=e.indexOf("?");return t>0?`${e.substring(0,t)}`:e}function O(e){var n,i,o,u,f;if(!e||typeof e!="string")return"";const t=ee(e),r=t.lastIndexOf(".");return r>0&&((f=(u=`${(o=(i=(n=t==null?void 0:t.substring)==null?void 0:n.call(t,r))==null?void 0:i.split("?"))==null?void 0:o[0]}`)==null?void 0:u.split("."))==null?void 0:f[1])||""}function S(e,t){if(t)return t;if(!e||e==="data:")return"4";let r="4";return b(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=O(e).toLowerCase(),h.imageType.includes(r)?"1":h.videoType.includes(r)?"3":h.audioType.includes(r)?"2":"4"}function te(e){const{url:t="",fileType:r="1"}=e||{};let n="",i={play:!1,height:0,size:0,width:0,duration:0};function o(){i={play:!1,height:0,size:0,width:0,duration:0}}return t instanceof File?n=URL.createObjectURL(t):b(t)?n=t:t instanceof Blob?n=URL.createObjectURL(t):(t.includes("https")||t.includes("http"))&&(n=t),new Promise(u=>{let f;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(){o(),i.play=!0,i.width=f.width||0,i.height=f.height||0,u(i),f=null}:f.oncanplay=function(){o(),i.play=!0,i.width=(f==null?void 0:f.videoWidth)||0,i.height=(f==null?void 0:f.videoHeight)||0,i.duration=(f==null?void 0:f.duration)||0,u(i),f=null},f.onerror=function(){o(),u(i),f=null}})}async function He(e){const{url:t="",currentTime:r,videoSuffix:n="",vidoeAllowPlay:i=!1}=e;let o="",u=n,f="1",a;return t instanceof File?(o=URL.createObjectURL(t),u=O(t.name),f=S(t.name)):t instanceof Blob?(o=URL.createObjectURL(t),f=S(t)):b(t)?(o=t,f=S(t)):(t.includes("https")||t.includes("http"))&&(o=t,u=O(t),f=S(t)),(u?h.videoAllowType.includes(u.toLowerCase()):!1)?i?B(o,r):(a=await te({url:o,fileType:f}),a.play?B(o,r):new Promise(d=>{d("")})):new Promise(d=>{d("")})}async function B(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 function(){let i;for(n==null||n.addEventListener("seeked",async function(){i&&i()});t<((n==null?void 0:n.duration)||0);){n&&(n.currentTime=t),await new Promise(v=>i=v);const o=document.createElement("canvas"),u=.8,f=o.getContext("2d"),a=(n==null?void 0:n.videoWidth)||0*u,l=(n==null?void 0:n.videoHeight)||0*u,d=0;o.width=(n==null?void 0:n.videoWidth)||0*u,o.height=(n==null?void 0:n.videoHeight)||0*u,n&&f.drawImage(n,0,0,a+d,l+d),n=null,r(a===0||l===0?"":o.toDataURL("image/png",1))}}))})}function b(e=""){return!!(e&&["data:image/","data:video/","data:audio/"].find(r=>e.includes(r)))}function _e(e){return typeof e=="string"&&/^data:(image|video|audio)\/[A-Za-z]+;base64,[A-Za-z0-9+/=]+$/.test(e)}function Je(e,t,r,n=!1){e&&t&&r&&e.addEventListener(t,r,n)}function Xe(e,t,r,n=!1){e&&t&&r&&e.removeEventListener(t,r,n)}function Ze(){return/windows|win32/i.test(navigator.userAgent)}function Ye(e){return E(e)?e:!!e}function I(e,t){const r=`^\\d+(?:\\.\\d{0,${e}})?`,n=new RegExp(r),i=t.toString().match(n);if(i){const o=i[0];if(o.includes(".")){const[u,f]=o.split(".");if(/^0*$/.test(f))return u}return o}return t.toString()}function Ge(e,t){const{toChinese:r=!1,fixed:n=2,min:i=1e4}=t||{},o=m(i)?i:1e4,u=m(n)?n:2,f=r?e<o?"":e<1e8?"万":"亿":e<o?"":e<1e8?"w":"亿";if(!m(e))return{str:`${e}`,number:`${e}`};if(e<o)return{str:`${e}`,number:`${e}`};if(u===0){const l=(e/(e<1e8?1e4:1e8)).toFixed(1).split(".")[0];return{str:`${l}${f}`,number:l,unit:f}}let a;return e<1e8?(a=I(u,e/1e4),{str:a+f,number:a,unit:f}):(a=I(u,e/1e8),{str:a+f,number:a,unit:f})}function Qe(e,t){let r=0;const n=document.querySelector(t.root||"hiddenElement");if(!n)return 0;const i=document.createElement(t.createName||"span");return i.innerHTML=e,(t.cssObject||g(t.cssObject))&&Object.keys(t.cssObject).forEach(o=>{var u,f;(u=t.cssObject)!=null&&u[o]&&(i.style[o]=(f=t.cssObject)==null?void 0:f[o])}),n.append(i),r=i.getBoundingClientRect()[t.type||"width"],n.removeChild(i),r}c.arrayRepeat=Ie,c.arraySlice=De,c.blobToDataURL=qe,c.checkFileType=S,c.classNames=z,c.compareArray=G,c.compareArraySort=Le,c.compareArrayTimeSort=Be,c.compareToMaxTime=Q,c.convertValueBoolean=Ye,c.dataURLtoBlob=ze,c.dataURLtoFile=We,c.deepCopy=p,c.filterEmpty=D,c.formatDuraton=Pe,c.formatNumber=I,c.genColumnKey=Ee,c.generateVidoePicture=B,c.getBase64=xe,c.getBlobUrl=$e,c.getFileSuffix=O,c.getLevelData=K,c.getMaxFloor=Me,c.getMediaInfos=te,c.getPrefixCls=Te,c.getRandomNumber=k,c.getScroll=J,c.getScrollContainer=oe,c.getSlot=Z,c.getSlotVNode=Y,c.getSlotsChildren=be,c.getSlotsProps=Re,c.getSortIndex=Ce,c.getTextWidth=Qe,c.getValueFromObjectByKey=T,c.getVideoCoverPicture=He,c.getVideoFileUrl=ee,c.globalConfig=h,c.handleCurrentPage=Fe,c.handleShowIndex=Ue,c.hanndleEmptyField=Ne,c.is=V,c.isArray=y,c.isBase64=b,c.isBoolean=E,c.isBrowser=Se,c.isDataURLBase64=_e,c.isDeepEqualReact=A,c.isEmptyElement=X,c.isFunction=de,c.isImg=ce,c.isInContainer=ue,c.isJSONStr=ge,c.isMobile=me,c.isNil=fe,c.isNumber=m,c.isObject=g,c.isScroll=N,c.isServer=w,c.isString=$,c.isTablet=x,c.isUrl=ae,c.isWindowsOs=Ze,c.merge=le,c.nanoid=se,c.off=Xe,c.omitBoolean=ve,c.omitUndefined=Ae,c.omitUndefinedAndEmptyArr=Oe,c.on=Je,c.runFunction=je,c.scrollTo=we,c.slotRender=L,c.throttleByAnimationFrame=he,c.toConvertNumberShow=Ge,c.treeData=Ve,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -24,11 +24,11 @@ export interface DefaultProColumn {
|
|
|
24
24
|
}
|
|
25
25
|
export type ProColumn<T = undefined> = T extends undefined ? DefaultProColumn : DefaultProColumn & T;
|
|
26
26
|
export interface MaterialOptions {
|
|
27
|
-
play
|
|
28
|
-
width
|
|
29
|
-
height
|
|
30
|
-
duration
|
|
31
|
-
size?: string;
|
|
27
|
+
play: boolean;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
duration: number;
|
|
31
|
+
size?: number | string;
|
|
32
32
|
}
|
|
33
33
|
export type OmitUndefined<T> = {
|
|
34
34
|
[P in keyof T]: NonNullable<T[P]>;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { AlignType, BasicTablePageConfig, MaterialOptions, ProColumn } from '../typings';
|
|
1
|
+
import type { AlignType, BasicTablePageConfig, MaterialOptions, ProColumn, RecordType } from '../typings';
|
|
2
2
|
export interface PrefixCls {
|
|
3
3
|
suffixCls?: string;
|
|
4
4
|
customizePrefixCls?: string;
|
|
5
5
|
isPor?: boolean;
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
|
+
export type TreeRecordType<T extends RecordType = RecordType> = T & {
|
|
9
|
+
id?: number;
|
|
10
|
+
parentId?: number;
|
|
11
|
+
floor?: number;
|
|
12
|
+
sortIndex?: string;
|
|
13
|
+
children?: T[];
|
|
14
|
+
};
|
|
8
15
|
export declare const getPrefixCls: ({ suffixCls, customizePrefixCls, isPor, className }: PrefixCls) => string;
|
|
9
16
|
/**
|
|
10
17
|
* 根据 key 和 dataIndex 生成唯一 id
|
|
@@ -13,8 +20,8 @@ export declare const getPrefixCls: ({ suffixCls, customizePrefixCls, isPor, clas
|
|
|
13
20
|
* @param dataIndex 在对象中的数据
|
|
14
21
|
* @param index 序列号,理论上唯一
|
|
15
22
|
*/
|
|
16
|
-
export declare const genColumnKey: (key
|
|
17
|
-
export declare function handleShowIndex<T
|
|
23
|
+
export declare const genColumnKey: (key: string[] | number | string, index?: number) => string;
|
|
24
|
+
export declare function handleShowIndex<T extends ProColumn>(columns: T[], { align, showIndex }: {
|
|
18
25
|
align: AlignType;
|
|
19
26
|
showIndex: boolean;
|
|
20
27
|
}): T[];
|
|
@@ -31,7 +38,7 @@ export declare function runFunction<T extends any[]>(valueEnum: any, ...rest: T)
|
|
|
31
38
|
* @lastTime 2022/10/11
|
|
32
39
|
* @description 简单深拷贝下
|
|
33
40
|
*/
|
|
34
|
-
export declare function deepCopy<T =
|
|
41
|
+
export declare function deepCopy<T = RecordType>(data: any): T;
|
|
35
42
|
/**
|
|
36
43
|
* @Author gx12358
|
|
37
44
|
* @DateTime 2021/1/28
|
|
@@ -45,30 +52,54 @@ export declare function handleCurrentPage(pageConfig: BasicTablePageConfig, curr
|
|
|
45
52
|
* @lastTime 2020/7/24
|
|
46
53
|
* @description 数组(树形)添加序号
|
|
47
54
|
*/
|
|
48
|
-
export declare function getSortIndex<T
|
|
55
|
+
export declare function getSortIndex<T extends TreeRecordType>(data: T[] | undefined, pageConfig: BasicTablePageConfig, childrenKey?: keyof T): T[];
|
|
56
|
+
export declare function arraySlice<T = RecordType>(data: T[], range: number | number[]): T[];
|
|
49
57
|
/**
|
|
50
58
|
* @Author gaoxiang
|
|
51
59
|
* @DateTime 2019/11/29
|
|
52
60
|
* @lastTime 2019/11/29
|
|
61
|
+
* @description 这里是给到数组的sort的方法
|
|
53
62
|
* @description 排序 sort 0 从小到大 1 从大到小
|
|
54
63
|
*/
|
|
55
|
-
export declare function compareArray(obj1:
|
|
64
|
+
export declare function compareArray<T = RecordType>(obj1: T, obj2: T, key: keyof T, sort?: 0 | 1): number;
|
|
65
|
+
/**
|
|
66
|
+
* @Author gx12358
|
|
67
|
+
* @DateTime 2023/10/17
|
|
68
|
+
* @lastTime 2023/10/17
|
|
69
|
+
* @description 这里是给到数组的sort的方法
|
|
70
|
+
* @description type 0 从小到大 1 从大到小
|
|
71
|
+
*/
|
|
72
|
+
export declare function compareToMaxTime<T = RecordType>(obj1: T, obj2: T, key: keyof T, sort?: 0 | 1): number;
|
|
73
|
+
/**
|
|
74
|
+
* @Author gx12358
|
|
75
|
+
* @DateTime 2024/10/27
|
|
76
|
+
* @lastTime 2024/10/27
|
|
77
|
+
* @description type 0 从小到大 1 从大到小
|
|
78
|
+
*/
|
|
79
|
+
export declare function compareArraySort<T = RecordType>(dataSource: T[], key: keyof T, sort?: 0 | 1): T[];
|
|
80
|
+
/**
|
|
81
|
+
* @Author gx12358
|
|
82
|
+
* @DateTime 2024/10/27
|
|
83
|
+
* @lastTime 2024/10/27
|
|
84
|
+
* @description 比较时间 type 0 从小到大 1 从大到小
|
|
85
|
+
*/
|
|
86
|
+
export declare function compareArrayTimeSort<T = RecordType>(dataSource: T[], key: keyof T, sort?: 0 | 1): T[];
|
|
56
87
|
/**
|
|
57
88
|
* @Author gaoxiang
|
|
58
89
|
* @DateTime 2019/12/11
|
|
59
90
|
* @lastTime 2019/12/11
|
|
60
91
|
* @description 数组去重
|
|
61
92
|
*/
|
|
62
|
-
export declare function arrayRepeat<T =
|
|
93
|
+
export declare function arrayRepeat<T = RecordType>(data: T[]): T[];
|
|
63
94
|
/**
|
|
64
95
|
* @Author gaoxiang
|
|
65
96
|
* @DateTime 2020/8/26
|
|
66
97
|
* @lastTime 2020/8/26
|
|
67
|
-
* @description
|
|
98
|
+
* @description 处理字段为空
|
|
68
99
|
*/
|
|
69
|
-
export declare function
|
|
70
|
-
value: any;
|
|
100
|
+
export declare function hanndleEmptyField(str: any, customize: any): {
|
|
71
101
|
success: boolean;
|
|
102
|
+
value: any;
|
|
72
103
|
};
|
|
73
104
|
/**
|
|
74
105
|
* @Author gaoxiang
|
|
@@ -95,14 +126,14 @@ export declare function getRandomNumber(): {
|
|
|
95
126
|
* @lastTime 2022/10/11
|
|
96
127
|
* @description 获取树形结构最深的层级数
|
|
97
128
|
*/
|
|
98
|
-
export declare function getMaxFloor(treeData?:
|
|
129
|
+
export declare function getMaxFloor<T extends TreeRecordType>(treeData?: T[], key?: keyof T): number;
|
|
99
130
|
/**
|
|
100
131
|
* @Author gaoxiang
|
|
101
132
|
* @DateTime 2020/8/10
|
|
102
133
|
* @lastTime 2020/8/10
|
|
103
134
|
* @description 树形转平级
|
|
104
135
|
*/
|
|
105
|
-
export declare function getLevelData<T
|
|
136
|
+
export declare function getLevelData<T extends TreeRecordType>(data: T[], filed?: keyof T): T[];
|
|
106
137
|
/**
|
|
107
138
|
* 构造树型结构数据
|
|
108
139
|
* @param {*} source 数据源
|
|
@@ -111,7 +142,7 @@ export declare function getLevelData<T = any>(data: T[], filed?: keyof T): any[]
|
|
|
111
142
|
* @param {*} children 孩子节点字段 默认 'children'
|
|
112
143
|
* @param {*} rootId 根Id 默认 0
|
|
113
144
|
*/
|
|
114
|
-
export declare function treeData(source:
|
|
145
|
+
export declare function treeData<T extends TreeRecordType>(source: T[], id: keyof T, parentId?: keyof T, children?: keyof T, rootId?: number): T[];
|
|
115
146
|
/**
|
|
116
147
|
* @Author gx12358
|
|
117
148
|
* @DateTime 2021/11/5
|
|
@@ -153,14 +184,14 @@ export declare function blobToDataURL(blob: Blob, fileName: string, fileType: st
|
|
|
153
184
|
* @lastTime 2020/11/13
|
|
154
185
|
* @description 截取视频时间戳
|
|
155
186
|
*/
|
|
156
|
-
export declare function getVideoFileUrl(url
|
|
187
|
+
export declare function getVideoFileUrl(url: string): string;
|
|
157
188
|
/**
|
|
158
189
|
* @Author gaoxiang
|
|
159
190
|
* @DateTime 2020/11/13
|
|
160
191
|
* @lastTime 2020/11/13
|
|
161
192
|
* @description 获取文件后缀名
|
|
162
193
|
*/
|
|
163
|
-
export declare function getFileSuffix(url
|
|
194
|
+
export declare function getFileSuffix(url: string): string;
|
|
164
195
|
/**
|
|
165
196
|
* @Author gaoxiang
|
|
166
197
|
* @DateTime 2020/10/5
|
|
@@ -204,6 +235,7 @@ export declare function generateVidoePicture(videoUrl: string, currentTime?: num
|
|
|
204
235
|
* @description 判断是否是base64码
|
|
205
236
|
*/
|
|
206
237
|
export declare function isBase64(str?: string): boolean;
|
|
238
|
+
export declare function isDataURLBase64(str: string): boolean;
|
|
207
239
|
export declare function on(element: HTMLElement | Document | Window | null, event: string, handler: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
|
208
240
|
export declare function off(element: HTMLElement | Document | Window | null, event: string, handler: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
|
209
241
|
/**
|
|
@@ -216,3 +248,31 @@ export declare function off(element: HTMLElement | Document | Window | null, eve
|
|
|
216
248
|
*/
|
|
217
249
|
export declare function isWindowsOs(): boolean;
|
|
218
250
|
export declare function convertValueBoolean(value: any): boolean;
|
|
251
|
+
export declare function formatNumber(fixedNum: number, value: number): string;
|
|
252
|
+
/**
|
|
253
|
+
* @Author gx12358
|
|
254
|
+
* @DateTime 2022/6/20
|
|
255
|
+
* @lastTime 2022/6/20
|
|
256
|
+
* @description 转换数字
|
|
257
|
+
*/
|
|
258
|
+
export declare function toConvertNumberShow(number: number, options?: {
|
|
259
|
+
toChinese?: boolean;
|
|
260
|
+
fixed?: number;
|
|
261
|
+
min?: number;
|
|
262
|
+
}): {
|
|
263
|
+
str: string;
|
|
264
|
+
number: string;
|
|
265
|
+
unit?: string;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* @Author gx12358
|
|
269
|
+
* @DateTime 2022/9/13
|
|
270
|
+
* @lastTime 2022/9/13
|
|
271
|
+
* @description 获取字符宽度
|
|
272
|
+
*/
|
|
273
|
+
export declare function getTextWidth(str: string, options: {
|
|
274
|
+
cssObject?: CSSStyleDeclaration;
|
|
275
|
+
type?: 'width' | 'height';
|
|
276
|
+
root?: string;
|
|
277
|
+
createName?: string;
|
|
278
|
+
}): number;
|
package/dist/utils/validate.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export declare function isNumber(val: unknown): val is number;
|
|
|
4
4
|
/**
|
|
5
5
|
* @author gx12358 gx12358@gmail.com
|
|
6
6
|
* @description 判断是否是数组
|
|
7
|
-
* @param
|
|
8
|
-
* @returns {
|
|
7
|
+
* @param val
|
|
8
|
+
* @returns {val is any[]|boolean}
|
|
9
9
|
*/
|
|
10
|
-
export declare function isArray(
|
|
10
|
+
export declare function isArray(val: any): val is Array<any>;
|
|
11
11
|
/**
|
|
12
12
|
* @Author gaoxiang
|
|
13
13
|
* @DateTime 2019/11/29
|
|
@@ -21,5 +21,8 @@ export declare function isObject(val: any): val is Record<any, any>;
|
|
|
21
21
|
* @param value
|
|
22
22
|
* @returns {boolean}
|
|
23
23
|
*/
|
|
24
|
-
export declare function isString(value: unknown): value is string
|
|
25
|
-
export declare function isFunction(func:
|
|
24
|
+
export declare function isString(value: unknown): value is string;
|
|
25
|
+
export declare function isFunction(func: unknown): func is (...args: any[]) => any;
|
|
26
|
+
export declare function isJSONStr(str: any): boolean;
|
|
27
|
+
export declare function isMobile(): boolean;
|
|
28
|
+
export declare function isTablet(): boolean;
|