@gx-design-vue/pro-utils 0.1.4 → 0.2.0-alpha.1
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/LICENSE +21 -0
- package/README.md +73 -2
- package/dist/array/index.d.ts +5 -0
- package/dist/array/index.js +6 -0
- package/dist/array/slice.d.ts +11 -0
- package/dist/array/slice.js +29 -0
- package/dist/array/sort.d.ts +41 -0
- package/dist/array/sort.js +65 -0
- package/dist/array/tree.d.ts +83 -0
- package/dist/array/tree.js +157 -0
- package/dist/array/unique.d.ts +12 -0
- package/dist/array/unique.js +14 -0
- package/dist/base64/index.d.ts +26 -0
- package/dist/base64/index.js +106 -0
- package/dist/class/index.d.ts +2 -0
- package/dist/class/index.js +3 -0
- package/dist/class/prefix.d.ts +25 -0
- package/dist/class/prefix.js +15 -0
- package/dist/clone/cloneDeep.d.ts +30 -0
- package/dist/clone/cloneDeep.js +35 -0
- package/dist/clone/cloneDeepWith.d.ts +14 -0
- package/dist/clone/cloneDeepWith.js +150 -0
- package/dist/clone/getTag.d.ts +10 -0
- package/dist/clone/getTag.js +13 -0
- package/dist/clone/index.d.ts +3 -0
- package/dist/clone/index.js +4 -0
- package/dist/clone/symbols.d.ts +10 -0
- package/dist/clone/symbols.js +13 -0
- package/dist/clone/tags.d.ts +47 -0
- package/dist/clone/tags.js +48 -0
- package/dist/dom/event.d.ts +21 -0
- package/dist/dom/event.js +26 -0
- package/dist/dom/index.d.ts +5 -0
- package/dist/dom/index.js +6 -0
- package/dist/dom/measure.d.ts +19 -0
- package/dist/dom/measure.js +42 -0
- package/dist/dom/raf.d.ts +14 -0
- package/dist/dom/raf.js +44 -0
- package/dist/dom/scroll.d.ts +20 -0
- package/dist/dom/scroll.js +97 -0
- package/dist/file/config.d.ts +13 -0
- package/dist/file/config.js +81 -0
- package/dist/file/convert.d.ts +41 -0
- package/dist/file/convert.js +69 -0
- package/dist/file/index.d.ts +5 -0
- package/dist/file/index.js +6 -0
- package/dist/file/media.d.ts +35 -0
- package/dist/file/media.js +161 -0
- package/dist/file/type.d.ts +25 -0
- package/dist/file/type.js +58 -0
- package/dist/function/copy.d.ts +12 -0
- package/dist/function/copy.js +13 -0
- package/dist/function/getValue.d.ts +12 -0
- package/dist/function/getValue.js +19 -0
- package/dist/function/index.d.ts +5 -0
- package/dist/function/index.js +6 -0
- package/dist/function/object.d.ts +24 -0
- package/dist/function/object.js +33 -0
- package/dist/function/run.d.ts +11 -0
- package/dist/function/run.js +15 -0
- package/dist/index.d.ts +59 -26
- package/dist/index.js +61 -0
- package/dist/is/base64.d.ts +17 -0
- package/dist/is/base64.js +27 -0
- package/dist/is/browser.d.ts +9 -0
- package/dist/is/browser.js +14 -0
- package/dist/is/deepEqual.d.ts +13 -0
- package/dist/is/deepEqual.js +62 -0
- package/dist/is/device.d.ts +21 -0
- package/dist/is/device.js +37 -0
- package/dist/is/equal.d.ts +12 -0
- package/dist/is/equal.js +34 -0
- package/dist/is/img.d.ts +10 -0
- package/dist/is/img.js +13 -0
- package/dist/is/index.d.ts +16 -0
- package/dist/is/index.js +17 -0
- package/dist/is/nil.d.ts +17 -0
- package/dist/is/nil.js +22 -0
- package/dist/is/plainObject.d.ts +17 -0
- package/dist/is/plainObject.js +30 -0
- package/dist/is/primitive.d.ts +10 -0
- package/dist/is/primitive.js +13 -0
- package/dist/is/server.d.ts +9 -0
- package/dist/is/server.js +10 -0
- package/dist/is/type.d.ts +60 -0
- package/dist/is/type.js +84 -0
- package/dist/is/typedArray.d.ts +30 -0
- package/dist/is/typedArray.js +33 -0
- package/dist/is/unsafeProperty.d.ts +10 -0
- package/dist/is/unsafeProperty.js +18 -0
- package/dist/is/url.d.ts +10 -0
- package/dist/is/url.js +20 -0
- package/dist/is/valid.d.ts +17 -0
- package/dist/is/valid.js +23 -0
- package/dist/merge/index.d.ts +19 -5
- package/dist/merge/index.js +42 -0
- package/dist/merge/mergeWith.d.ts +12 -0
- package/dist/merge/mergeWith.js +31 -0
- package/dist/merge/useDeepMege.d.ts +46 -0
- package/dist/merge/useDeepMege.js +56 -0
- package/dist/number/chinese.d.ts +10 -0
- package/dist/number/chinese.js +46 -0
- package/dist/number/format.d.ts +27 -0
- package/dist/number/format.js +72 -0
- package/dist/number/index.d.ts +3 -0
- package/dist/number/index.js +4 -0
- package/dist/object/classNames.d.ts +10 -0
- package/dist/object/classNames.js +30 -0
- package/dist/object/index.d.ts +5 -0
- package/dist/object/index.js +6 -0
- package/dist/object/omitBoolean.d.ts +10 -0
- package/dist/object/omitBoolean.js +13 -0
- package/dist/object/omitUndefined.d.ts +12 -0
- package/dist/object/omitUndefined.js +18 -0
- package/dist/object/omitUndefinedAndEmptyArr.d.ts +10 -0
- package/dist/object/omitUndefinedAndEmptyArr.js +19 -0
- package/dist/pro-utils.esm.js +948 -0
- package/dist/pro-utils.js +1 -0
- package/dist/string/duration.d.ts +10 -0
- package/dist/string/duration.js +25 -0
- package/dist/string/empty.d.ts +14 -0
- package/dist/string/empty.js +26 -0
- package/dist/string/index.d.ts +5 -0
- package/dist/string/index.js +6 -0
- package/dist/string/nanoid.d.ts +9 -0
- package/dist/string/nanoid.js +32 -0
- package/dist/string/uuid.d.ts +34 -0
- package/dist/string/uuid.js +57 -0
- package/dist/table/column.d.ts +27 -0
- package/dist/table/column.js +42 -0
- package/dist/table/index.d.ts +3 -0
- package/dist/table/index.js +4 -0
- package/dist/table/page.d.ts +13 -0
- package/dist/table/page.js +23 -0
- package/dist/typing.d.ts +262 -0
- package/dist/typing.js +1 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +3 -0
- package/dist/vue/slots.d.ts +56 -0
- package/dist/vue/slots.js +89 -0
- package/package.json +45 -64
- package/dist/classNames/index.d.ts +0 -2
- package/dist/components/FieldLabel/index.d.ts +0 -77
- package/dist/components/FieldLabel/index.less +0 -107
- package/dist/components/LabelIconTip/index.d.ts +0 -20
- package/dist/components/LabelIconTip/index.less +0 -38
- package/dist/design/ant-design-theme.less +0 -4
- package/dist/design/ant-design-vue.less +0 -1
- package/dist/design/config.less +0 -2
- package/dist/isBrowser/index.d.ts +0 -1
- package/dist/isDeepEqualReact/index.d.ts +0 -1
- package/dist/isServer.d.ts +0 -2
- package/dist/omitBoolean/index.d.ts +0 -6
- package/dist/omitUndefined/index.d.ts +0 -5
- package/dist/pro-utils.es.js +0 -1044
- package/dist/pro-utils.umd.js +0 -1
- package/dist/proUtils.less +0 -4
- package/dist/scroll/easings.d.ts +0 -1
- package/dist/scroll/getScroll.d.ts +0 -2
- package/dist/scroll/index.d.ts +0 -4
- package/dist/scroll/raf.d.ts +0 -9
- package/dist/scroll/scrollTo.d.ts +0 -10
- package/dist/scroll/throttleByAnimationFrame.d.ts +0 -5
- package/dist/slots/index.d.ts +0 -9
- package/dist/style/index.less +0 -2
- package/dist/style.css +0 -1
- package/dist/style.less +0 -3
- package/dist/typings/index.d.ts +0 -30
- package/dist/utils/config.d.ts +0 -8
- package/dist/utils/index.d.ts +0 -208
- package/dist/utils/validate.d.ts +0 -25
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ProUtils={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e=``){return!!(e&&[`data:image/`,`data:video/`,`data:audio/`].find(t=>e.includes(t)))}function r(e){return typeof e==`string`&&/^data:(?:image|video|audio)\/[A-Za-z]+;base64,[A-Za-z0-9+/=]+$/.test(e)}var i=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;function a(){return process.env.NODE_ENV===`TEST`?!0:typeof window<`u`&&window.document!==void 0&&window.matchMedia!==void 0&&!i}function o(e,t,n,r){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(e.constructor!==t.constructor)return!1;let i,a;if(Array.isArray(e)){if(i=e.length,i!=t.length)return!1;for(a=i;a--!==0;)if(!o(e[a],t[a],n,r))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(a of e.entries())if(!t.has(a[0]))return!1;for(a of e.entries())if(!o(a[1],t.get(a[0]),n,r))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(a of e.entries())if(!t.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(i=e.length,i!=t.length)return!1;for(a=i;a--!==0;)if(e[a]!==t[a])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();let s=Object.keys(e);if(i=s.length,i!==Object.keys(t).length)return!1;for(a=i;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[a]))return!1;for(a=i;a--!==0;){let i=s[a];if(!n?.includes(i)&&!(i===`_owner`&&e.$$typeof)&&!o(e[i],t[i],n,r))return r&&console.log(i),!1}return!0}return e!==e&&t!==t}function s(){let e=navigator.userAgent||navigator.vendor;return!!(/iPhone/.test(e)||/Android/.test(e)&&/Mobile/.test(e)||/Windows Phone/.test(e)||/Mobile/.test(e)&&!c())}function c(){let e=navigator.userAgent||navigator.vendor;return!!(/iPad/.test(e)||/Macintosh/.test(e)&&`ontouchend`in document||/Android/.test(e)&&!/Mobile/.test(e))}function l(){return/windows|win32/i.test(navigator.userAgent)}function u(e,t,n=!1){let r=new Set;function i(e,t,a=1){if(r.has(e))return!1;if(e===t)return!0;if(n&&a>1)return!1;r.add(e);let o=a+1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n],o))return!1;return!0}if(e&&t&&typeof e==`object`&&typeof t==`object`){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>i(e[n],t[n],o)):!1}return!1}return i(e,t)}function d(e){return/\w.(?:png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(e)}function ee(e){return e==null}function te(e){return e!=null}function f(e){return Object.getOwnPropertySymbols(e)}function ne(e,t){Object.keys(e).forEach(n=>{t(n,e[n])})}function re(e){return Object.keys(e)}function p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function m(e){return typeof e==`boolean`}function h(e){return typeof e==`number`}function g(e){return Array.isArray===void 0?Object.prototype.toString.call(e)===`[object Array]`:Array.isArray(e)}function _(e){return e!==null&&p(e,`Object`)}function v(e){return typeof e==`string`}function ie(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function ae(e){if(typeof e!=`string`)return!1;try{let t=JSON.parse(e);return typeof t==`object`&&!!t}catch{return!1}}function y(e){if(!_(e))return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=Object.prototype.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)}function oe(e){return _(e)?f(e).length>0:!1}function b(e){return e===null||typeof e!=`object`&&typeof e!=`function`}let x=typeof window>`u`;function S(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function C(e){return typeof e==`symbol`?!1:[`__proto__`,`constructor`,`prototype`].includes(e)}function se(e){if(!e||!e.startsWith(`http`))return!1;try{return!!new URL(e)}catch(e){return console.error(`isUrl error`,e),!1}}function ce(e){return e!=null&&e!==``}function le(e){return typeof e==`boolean`?e:!!e}function ue(e,t){return g(e)?e?.filter((n,r)=>{if(h(t))return r<=t-1;if(g(t)&&t.length===2){let n=t,i=n[0]-1;return r<=(n[1]?n[1]-1:e.length-1)&&r>=i}else if(g(t)&&t.length===1){let n=t[0]-1;return r<=e.length-1&&r>=n}return!0}):[]}function w(e,t,n,r=0){let i=h(r)&&(r===0||r===1)?r:0,a=e[n],o=t[n],s=0;return a<o?s=i===0?-1:0:a>o&&(s=i===0?0:-1),s}function T(e,t,n,r=0){let i=h(r)&&(r===0||r===1)?r:0,a=new Date(e[n]),o=new Date(t[n]),s=0;return a<o?s=i===0?-1:0:a>o&&(s=i===0?0:-1),s}function de(e,t,n=0){return e.sort((e,r)=>w(e,r,t,n))}function fe(e,t,n=0){return e.sort((e,r)=>T(e,r,t,n))}function E(e,t){if(!Array.isArray(e)||e.length===0)return 0;let n=t||`children`;return Math.max(...e.map(e=>{let t=e[n];return 1+(t?E(t,n):0)}))}function D(e,t=`children`){let n=[];return e.forEach(e=>{n.push(e),g(e[t])&&e[t].length>0&&(n=n.concat(D(e[t],t)))}),n}function pe(e,t){if(!e||!g(e)||e?.length===0)return[];let{id:n=`id`,parentId:r=`parentId`,children:i=`children`,emptyChildren:a=!0}=t||{},o=t?.rootId??0,s=structuredClone(e);return s.map(e=>(!a&&e[i]&&e[i]?.length===0&&delete e[i],e)).filter(e=>{let t=s.filter(t=>e[n]===t[r]);return t.length>0?e[i]=t:a&&(e[i]=[]),o===!1?!0:e[r]===o})}function O(e,t){return e.map(e=>{let n={...e};return n.children&&=O(n.children,t),t(n)||n.children&&n.children.length>0?n:null}).filter(Boolean)}function me(e,t,n){let{value:r,children:i}=n||{value:`value`,children:`children`},a=[];function o(e,n){if(e[r]===t)return a=[...n,e[r]],!0;if(e[i]){for(let t of e[i])if(o(t,[...n,e[r]]))return!0}return!1}for(let t of e)if(o(t,[]))break;return a}function k(e,t,n){let r=n?.value||`id`,i=n?.children||`children`;for(let a of e){if(a[r]===t)return a;let e=a[i];if(e){let r=k(e,t,n);if(r)return r}}}function he(e){return e&&g(e)?e[e.length-1]:null}function ge(e=[],t,n=`children`){function r(e,t){return t.map((t,i)=>{let a=`${e}-${i+1}`;return t[n]&&(t[n]=r(a,t[n])),t.sortIndex=a,t})}return structuredClone(e).map((e,i)=>{let a=_(t)&&t.current||1,o=_(t)&&t.pageSize||10,s=`${a?(a-1)*o+(i+1):i+1}`;return e[n]&&(e[n]=r(`${s}`,e[n])),e.sortIndex=s,e})}function _e(e){let t=new Set(e);return Array.from(t)}function ve({suffixCls:e,customizePrefixCls:t,isPor:n,className:r}){let i=r||(n?`gx-pro`:`gx`);return t||(e?`${i}-${e}`:i)}function ye(e){return Object.prototype.toString.call(e)}function be(e){return Object.getOwnPropertySymbols(e)}function xe(e,t){return A(e,void 0,e,new Map,t)}function A(e,t,n,r=new Map,i=void 0){let a=i?.(e,t,n,r);if(a!==void 0)return a;if(b(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array.from({length:e.length});r.set(e,t);for(let a=0;a<e.length;a++)t[a]=A(e[a],a,n,r,i);return Object.prototype.hasOwnProperty.call(e,`index`)&&(t.index=e.index),Object.prototype.hasOwnProperty.call(e,`input`)&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;r.set(e,t);for(let[a,o]of e)t.set(a,A(o,a,n,r,i));return t}if(e instanceof Set){let t=new Set;r.set(e,t);for(let a of e)t.add(A(a,void 0,n,r,i));return t}if(typeof Buffer<`u`&&Buffer.isBuffer(e))return e.subarray();if(S(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=A(e[a],a,n,r,i);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return r.set(e,t),j(t,e,n,r,i),t}if(typeof File<`u`&&e instanceof File){let t=new File([e],e.name,{type:e.type});return r.set(e,t),j(t,e,n,r,i),t}if(typeof Blob<`u`&&e instanceof Blob){let t=new Blob([e],{type:e.type});return r.set(e,t),j(t,e,n,r,i),t}if(e instanceof Error){let t=new e.constructor;return r.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,j(t,e,n,r,i),t}if(typeof e==`boolean`){let t=!!e.valueOf();return r.set(e,t),j(t,e,n,r,i),t}if(typeof e==`number`){let t=Number(e.valueOf());return r.set(e,t),j(t,e,n,r,i),t}if(typeof e==`string`){let t=String(e.valueOf());return r.set(e,t),j(t,e,n,r,i),t}if(typeof e==`object`&&Se(e)){let t=Object.create(Object.getPrototypeOf(e));return r.set(e,t),j(t,e,n,r,i),t}return e}function j(e,t,n=e,r,i){let a=[...Object.keys(t),...be(t)];for(let o=0;o<a.length;o++){let s=a[o],c=Object.getOwnPropertyDescriptor(e,s);(c==null||c.writable)&&(e[s]=A(t[s],s,n,r,i))}}function Se(e){switch(ye(e)){case`[object Arguments]`:case`[object Array]`:case`[object ArrayBuffer]`:case`[object DataView]`:case`[object Boolean]`:case`[object Date]`:case`[object Float32Array]`:case`[object Float64Array]`:case`[object Int8Array]`:case`[object Int16Array]`:case`[object Int32Array]`:case`[object Map]`:case`[object Number]`:case`[object Object]`:case`[object RegExp]`:case`[object Set]`:case`[object String]`:case`[object Symbol]`:case`[object Uint8Array]`:case`[object Uint8ClampedArray]`:case`[object Uint16Array]`:case`[object Uint32Array]`:return!0;default:return!1}}function M(e){return A(e,void 0,e,new Map,void 0)}function Ce(e,t,n,r=!1){e&&t&&n&&e.addEventListener(t,n,r)}function we(e,t,n,r=!1){e&&t&&n&&e.removeEventListener(t,n,r)}function Te(e,t){let n=0,r=m(t.removeAfter)?t.removeAfter:!0,i=t.id||`hiddenElement`,a={opacity:0,visibility:`hidden`,position:`fixed`,zIndex:-1,top:0,left:0},o=document.querySelector(`#${i}`);if(!o){let e=document.createElement(`div`);e.id=i,document.body.appendChild(e),o=document.querySelector(`#${i}`)}Object.assign(o.style,a);let s=document.createElement(t.createName||`span`);return s.innerHTML=e,(t.cssObject||_(t.cssObject))&&Object.assign(s.style,t.cssObject),o.append(s),n=s.getBoundingClientRect()[t.type||`width`],r&&o.removeChild(s),n}var N=e=>setTimeout(e,16),P=e=>clearTimeout(e);typeof window<`u`&&`requestAnimationFrame`in window&&(N=e=>window.requestAnimationFrame(e),P=e=>window.cancelAnimationFrame(e));var F=0,I=new Map;function L(e){I.delete(e)}function R(e,t=1){F+=1;let n=F;function r(t){if(t===0)L(n),e();else{let e=N(()=>{r(t-1)});I.set(n,e)}}return r(t),n}R.cancel=e=>{let t=I.get(e);return L(t),P(t)};function z(e,t,n,r){let i=n-t;return e/=r/2,e<1?i/2*e*e*e+t:i/2*((e-=2)*e*e+2)+t}function Ee(e){return e.replace(/[-_](.)/g,(e,t)=>t.toUpperCase())}function B(e,t){if(x||!e||!t)return``;t=Ee(t),t===`float`&&(t=`cssFloat`);try{let n=e.style[t];if(n)return n;let r=document?.defaultView?.getComputedStyle(e,``);return r?r[t]:``}catch{return e.style[t]}}function V(e,t){if(!x)return(t==null?B(e,`overflow`):t?B(e,`overflow-y`):B(e,`overflow-x`)).match(/(scroll|auto|overlay)/)}function De(e,t){if(x)return;let n=e;for(;n;){if([window,document,document.documentElement].includes(n))return window;if(V(n,t))return n;n=n.parentNode}return n}function Oe(e,t){if(x||!e||!t)return!1;let n=e.getBoundingClientRect(),r;return r=[window,document,document.documentElement,null,void 0].includes(t)?{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}:t.getBoundingClientRect(),n.top<r.bottom&&n.bottom>r.top&&n.right>r.left&&n.left<r.right}function H(e){return e!=null&&e===e.window}function U(e,t){if(typeof window>`u`)return 0;let n=t?`scrollTop`:`scrollLeft`,r=0;return H(e)?r=e[t?`pageYOffset`:`pageXOffset`]:e instanceof Document?r=e.documentElement[n]:e&&(r=e[n]),e&&!H(e)&&typeof r!=`number`&&(r=(e.ownerDocument||e).documentElement?.[n]),r}function ke(e,t={}){let{getContainer:n=()=>window,callback:r,duration:i=450}=t,a=n(),o=U(a,!0),s=Date.now(),c=()=>{let t=Date.now()-s,n=z(t>i?i:t,o,e,i);H(a)?a.scrollTo(window.pageXOffset,n):a instanceof HTMLDocument||a.constructor.name===`HTMLDocument`?a.documentElement.scrollTop=n:a.scrollTop=n,t<i?R(c):typeof r==`function`&&r()};a&&R(c)}let W={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`]};function Ae(e){return URL.createObjectURL(e)}function je(e){return new Promise((t,n)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result),r.onerror=e=>n(e)})}function Me(e){let t=e.split(`,`),n=t[0].match(/:(.*?);/)[1],r=atob(t[1]),i=r.length,a=new Uint8Array(i);for(;i--;)a[i]=r.charCodeAt(i);return new Blob([a],{type:n})}function Ne(e,t){let n=e.split(`,`),r=n[0].match(/:(.*?);/)[1],i=atob(n[1]),a=i.length,o=new Uint8Array(a);for(;a--;)o[a]=i.charCodeAt(a);return new File([o],t,{type:r})}function Pe(e,t,n){return new window.File([e],t,{type:n})}function G(e){if(!e||typeof e!=`string`)return``;let t=K(e),n=t.lastIndexOf(`.`);return n>0&&`${t?.substring?.(n)?.split(`?`)?.[0]}`?.split(`.`)?.[1]||``}function K(e){if(!e||typeof e!=`string`)return``;let t=e.indexOf(`?`);return t>0?`${e.substring(0,t)}`:e}function q(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=G(e).toLowerCase(),W.imageType.includes(r)?`1`:W.videoType.includes(r)?`3`:W.audioType.includes(r)?`2`:`4`}function J(e){let{url:t=``,fileType:r=`1`}=e||{},i=``,a={play:!1,height:0,size:0,width:0,duration:0};function o(){a={play:!1,height:0,size:0,width:0,duration:0}}return t instanceof File?i=URL.createObjectURL(t):n(t)?i=t:t instanceof Blob?i=URL.createObjectURL(t):(t.includes(`https`)||t.includes(`http`))&&(i=t),new Promise(e=>{let t;if(r===`4`){e(a);return}r===`1`?(t=document.createElement(`img`),t.src=i):r===`2`?(t=document.createElement(`audio`),t.src=i):r===`3`&&(t=document.createElement(`video`),t.src=i),r===`1`?t.onload=function(){o(),a.play=!0,a.width=t.width||0,a.height=t.height||0,e(a),t=null}:t.oncanplay=function(){o(),a.play=!0,a.width=t?.videoWidth||0,a.height=t?.videoHeight||0,a.duration=t?.duration||0,e(a),t=null},t.onerror=function(){o(),e(a),t=null}})}async function Fe(e){let{url:t=``,currentTime:r,videoSuffix:i=``,videoAllowPlay:a=!1}=e,o=``,s=i,c=`1`,l;return t instanceof File?(o=URL.createObjectURL(t),s=G(t.name),c=q(t.name)):t instanceof Blob?(o=URL.createObjectURL(t),c=q(t)):n(t)?(o=t,c=q(t)):(t.includes(`https`)||t.includes(`http`))&&(o=t,s=G(t),c=q(t)),s&&W.videoAllowType.includes(s.toLowerCase())?a?Y(o,r):(l=await J({url:o,fileType:c}),l.play?Y(o,r):new Promise(e=>{e(``)})):new Promise(e=>{e(``)})}async function Y(e,t=0){return new Promise(n=>{let r=document.createElement(`video`);r&&(r.controls=!0,r.muted=!0,r.setAttribute(`src`,e),r.setAttribute(`muted`,`true`),r.setAttribute(`crossorigin`,`anonymous`),r.setAttribute(`autoplay`,`true`),r.addEventListener(`loadeddata`,async()=>{let e;for(r?.addEventListener(`seeked`,async()=>{e&&e()});t<(r?.duration||0);){r&&(r.currentTime=t),await new Promise(t=>e=t);let i=document.createElement(`canvas`),a=.8,o=i.getContext(`2d`),s=r?.videoWidth||0*a,c=r?.videoHeight||0*a;i.width=r?.videoWidth||0*a,i.height=r?.videoHeight||0*a,r&&o.drawImage(r,0,0,s+0,c+0),r=null,n(s===0||c===0?``:i.toDataURL(`image/png`,1))}}))})}function Ie(e){return JSON.parse(JSON.stringify(e))}function Le(e,t){if(typeof t!=`string`&&!Array.isArray(t))return;let n=Array.isArray(t)?t:t.split(`:`),r=e;for(let e=0;e<n.length;e++)if(r&&Object.prototype.hasOwnProperty.call(r,n[e]))r=r[n[e]];else return;return r}function Re(e,...t){return typeof e==`function`?e(...t):e}function X(e,t,n){let r=Object.keys(t);for(let i=0;i<r.length;i++){let a=r[i];if(C(a))continue;let o=t[a],s=e[a],c=n(s,o,a,e,t);c===void 0?y(o)?y(s)?e[a]=X(s,o,n):e[a]=X({},o,n):e[a]=o:e[a]=c}return e}function ze(e,t){return X(e,t,function e(t,n){if(y(n))return y(t)?X(t,n,e):X({},n,e)})}function Be(...e){let t={},n=e.length,r,i=0;for(;i<n;i+=1)for(r in e[i])Object.prototype.hasOwnProperty.call(e[i],r)&&(typeof t[r]==`object`&&typeof e[i][r]==`object`&&t[r]!==void 0&&t[r]!==null&&!Array.isArray(t[r])&&!Array.isArray(e[i][r])?t[r]={...t[r],...e[i][r]}:t[r]=e[i][r]);return t}function Ve(e,t){return X(M(e),t,function e(t,n){if(y(n))return y(t)?X(M(t),n,e):X({},n,e)})}function He(e){e=h(e)&&!Number.isNaN(e)?e:0;let t=[`零`,`一`,`二`,`三`,`四`,`五`,`六`,`七`,`八`,`九`],n=[``,`十`,`百`,`千`,`万`];e=Number.parseInt(`${e}`);let r=r=>{let i=r.toString().split(``).reverse(),a=``;for(let r=0;r<i.length;r++)a=(r===0&&i[r]===`0`||r>0&&i[r]===`0`&&i[r-1]===`0`?``:(e<20&&r>0?``:t[i[r]])+(i[r]===`0`?n[0]:n[r]))+a;return a},i=Math.floor(e/1e4),a=e%1e4;return a.toString().length<4&&(a=`0${a}`),i?`${r(i)}万${r(a)}`:r(e)}function Z(e,t){let n=`^\\d+(?:\\.\\d{0,${e}})?`,r=new RegExp(n),i=t.toString().match(r);if(i){let e=i[0];if(e.includes(`.`)){let[t,n]=e.split(`.`);if(/^0*$/.test(n))return t}return e}return t.toString()}function Ue(e,t){let{toChinese:n=!1,fixed:r=2,min:i=1e4}=t||{},a=h(i)?i:1e4,o=h(r)?r:2,s=n?e<a?``:e<1e8?`万`:`亿`:e<a?``:e<1e8?`w`:`亿`;if(!h(e)||e<a)return{str:`${e}`,number:`${e}`};if(o===0){let t=(e/(e<1e8?1e4:1e8)).toFixed(1).split(`.`)[0];return{str:`${t}${s}`,number:t,unit:s}}let c;return e<1e8?(c=Z(o,e/1e4),{str:c+s,number:c,unit:s}):(c=Z(o,e/1e8),{str:c+s,number:c,unit:s})}function We(...e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r){if(v(r))t.push(r);else if(g(r))for(let e=0;e<r.length;e++){let n=We(r[e]);n&&t.push(n)}else if(_(r))for(let e in r)r[e]&&t.push(e)}}return t.filter(e=>e).join(` `)}function Ge(e){if(e&&e!==!0)return e}function Ke(e){let t={};if(Object.keys(e||{}).forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),!(Object.keys(t).length<1))return t}function qe(e){let t={};return Object.keys(e||{}).forEach(n=>{Array.isArray(e[n])&&e[n]?.length===0||e[n]!==void 0&&(t[n]=e[n])}),t}function Je(e){let t=``;if(e>-1){let n=Math.floor(e/3600),r=Math.floor(e/60)%60,i=Number.parseInt(String(e%60));t=n<10?`0${n}:`:`${n}:`,r<10&&(t+=`0`),t+=`${r}:`,i<10&&(t+=`0`),t+=i}return t.split(`:`)[0]===`00`?`${t.split(`:`)[1]}:${t.split(`:`)[2]}`:t}function Ye(e,t){let n=[`null`,`undefined`],r=!0;return e===0?r=!0:n.includes(e)?r=!1:e||(r=!1),r?{value:e,success:r}:{value:t===``?t:t||`-`,success:r}}var Xe=0;function Ze(e=21){if(typeof window>`u`||!window.crypto)return(Xe+=1).toFixed(0);let t=``,n=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let r=63&n[e];t+=r<36?r.toString(36):r<62?(r-26).toString(36).toUpperCase():r<63?`_`:`-`}return t}function Qe(){return typeof window>`u`?Ze():window.crypto&&window.crypto.randomUUID&&typeof crypto.randomUUID==`function`?crypto.randomUUID():Ze()}function $e(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``);return{uuid(t,n){let r=e,i=[],a=n||r.length,o,s;if(t)for(o=0;o<t;o+=1)i[o]=r[Number.parseInt(String(Math.random()*a))];else for(i[8]=`-`,i[13]=`-`,i[18]=`-`,i[23]=`-`,i[14]=`4`,o=0;o<36;o+=1)i[o]||(s=Math.random()*16,i[o]=r[o===19?s&&3||8:s]);return i.join(``)},uuidFast(){let t=e,n=Array.from({length:36}),r=0,i,a;for(a=0;a<36;a+=1)a===8||a===13||a===18||a===23?n[a]=`-`:a===14?n[a]=`4`:(r<=2&&(r=33554432+Math.random()*16777216||0),i=r&&15,r=r>4,n[a]=t[a===19?i&&3||8:i]);return n.join(``)},uuidString(){return this.uuidFast().replace(/-/g,``)},uuidCompact(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16||0;return(e===`x`?t:t&&3||8).toString(16)})}}}function et(e,t){return e?g(e)?e.join(`-`):e.toString():`${t||0}`}function tt(e,{align:t,showIndex:n}){let r=structuredClone(e);if(n&&e.length&&e.every(e=>e.dataIndex!==`sortIndex`)){let n=e[0];r.unshift({title:`序号`,align:t,fixed:n.fixed,width:60,uuid:$e().uuid(15),dataIndex:`sortIndex`,key:`sortIndex`})}else r.filter(e=>e.dataIndex!==`sortIndex`);return r}function nt(e,t){if(_(e)){let{pageSize:n=10,total:r=0}=e,{current:i=1}=e;return r-t<=n*(i-1)&&--i,i===0?1:i}return 1}function rt(e){if(!(typeof e!=`string`&&!Array.isArray(e)))return Array.isArray(e)?e[e.length-1]:e.split(`:`)?.slice(-1)[0]}function it(e){return e&&(e.type===t.Comment||e.type===t.Fragment&&e.children.length===0||e.type===Text&&e.children.trim()===``)}function at(e,t){return Q(typeof e[t]==`function`?e[t]?.():[])}function Q(e=[],n=!0){let r=Array.isArray(e)?e:[e],i=[];return r.forEach(e=>{Array.isArray(e)?i.push(...Q(e,n)):e?.type===t.Fragment||e?.type===`template`?i.push(...Q(e.children,n)):e&&(0,t.isVNode)(e)?n&&!it(e)?i.push(e):n||i.push(e):ce(e)&&i.push(e)}),i}function $({vnode:e,defaultVNode:t},...n){return e===!1?null:typeof e==`function`?e?.(...n):e||t}function ot(e,...n){let{slots:r,key:i=`default`,render:a,props:o,defaultChildren:s}=e,c,l=o[i],u=r?.[i],d=typeof s==`function`?s?.():s;return c=l===!1?!1:l===!0?u??d:_(l)&&a?(0,t.isVNode)(l)?l:u:l||u,c===!1?!1:a?$({vnode:c,defaultVNode:d},...n):c}function st(e,...n){let{slots:r,key:i=`default`,props:a,defaultChildren:o}=e,s,c=a[i],l=r?.[i]?.(...n),u=typeof o==`function`?o?.():o;return s=c===!1?!1:c===!0?l??u:_(c)?(0,t.isVNode)(c)?c:l:c||l,s===!1?!1:$({vnode:s,defaultVNode:u},...n)}function ct(e,...t){let{slots:n,props:r,keys:i,render:a,defaultVNodes:o}=e,s={};return i.forEach((e,i)=>{let c=o?o[i]:null,l=a?st({slots:n,props:r,key:e,defaultChildren:c},...t):ot({slots:n,props:r,key:e,render:!1,defaultChildren:c},...t);(m(l)||l)&&(s[e]=l)}),s}e.arraySlice=ue,e.arrayUnique=_e,e.blobToDataURL=Pe,e.checkFileType=q,e.classNames=We,e.cloneDeep=M,e.cloneDeepWith=xe,e.cloneDeepWithImpl=A,e.compareArray=w,e.compareArraySort=de,e.compareArrayTimeSort=fe,e.compareTime=T,e.convertValueBoolean=le,e.copyProperties=j,e.dataURLtoBlob=Me,e.dataURLtoFile=Ne,e.deepCopy=Ie,e.deepMerge=Ve,e.easeInOutCubic=z,e.fileTypes=W,e.filterEmpty=Q,e.filterTree=O,e.findSourceByTree=k,e.findValueAndAncestors=me,e.forInObject=ne,e.formatDuration=Je,e.formatNumber=Z,e.genColumnKey=et,e.generateVideoPicture=Y,e.getArrayLast=he,e.getBase64=je,e.getBlobUrl=Ae,e.getFileSuffix=G,e.getKeys=rt,e.getLevelData=D,e.getMaxFloor=E,e.getMediaInfos=J,e.getPrefixCls=ve,e.getRandomNumber=$e,e.getScroll=U,e.getScrollContainer=De,e.getSlot=ot,e.getSlotVNode=st,e.getSlotsChildren=at,e.getSlotsProps=ct,e.getSortIndex=ge,e.getSymbols=f,e.getTextWidth=Te,e.getValueFromObjectByKey=Le,e.getVideoCoverPicture=Fe,e.getVideoFileUrl=K,e.handleCurrentPage=nt,e.handleEmptyField=Ye,e.handleShowIndex=tt,e.is=p,e.isArray=g,e.isBase64=n,e.isBoolean=m,e.isBrowser=a,e.isDataURLBase64=r,e.isDeepEqualReact=o,e.isEmptyElement=it,e.isEqual=u,e.isFunction=ie,e.isImg=d,e.isInContainer=Oe,e.isJSONStr=ae,e.isMobile=s,e.isNil=ee,e.isNotNil=te,e.isNumber=h,e.isObject=_,e.isObjectWithSymbols=oe,e.isPlainObject=y,e.isPrimitive=b,e.isScroll=V,e.isServer=x,e.isString=v,e.isTablet=c,e.isTypedArray=S,e.isUnsafeProperty=C,e.isUrl=se,e.isValid=ce,e.isWindow=H,e.isWindowsOs=l,e.keysOf=re,e.merge=Be,e.mergeWith=X,e.nanoid=Qe,e.off=we,e.omitBoolean=Ge,e.omitUndefined=Ke,e.omitUndefinedAndEmptyArr=qe,e.on=Ce,e.raf=R,e.runFunction=Re,e.scrollTo=ke,e.slotRender=$,e.toChinesNum=He,e.toConvertNumberShow=Ue,e.treeData=pe,e.useDeepMerge=ze});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/string/duration.ts
|
|
2
|
+
/**
|
|
3
|
+
* 时长格式转换(秒转 HH:MM:SS)
|
|
4
|
+
*
|
|
5
|
+
* @param time - 秒数
|
|
6
|
+
* @returns 格式化后的时长字符串
|
|
7
|
+
*/
|
|
8
|
+
function formatDuration(time) {
|
|
9
|
+
let newTime = "";
|
|
10
|
+
if (time > -1) {
|
|
11
|
+
const hour = Math.floor(time / 3600);
|
|
12
|
+
const min = Math.floor(time / 60) % 60;
|
|
13
|
+
const sec = Number.parseInt(String(time % 60));
|
|
14
|
+
if (hour < 10) newTime = `0${hour}:`;
|
|
15
|
+
else newTime = `${hour}:`;
|
|
16
|
+
if (min < 10) newTime += "0";
|
|
17
|
+
newTime += `${min}:`;
|
|
18
|
+
if (sec < 10) newTime += "0";
|
|
19
|
+
newTime += sec;
|
|
20
|
+
}
|
|
21
|
+
return newTime.split(":")[0] === "00" ? `${newTime.split(":")[1]}:${newTime.split(":")[2]}` : newTime;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { formatDuration };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/string/empty.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 处理字段为空的情况
|
|
4
|
+
*
|
|
5
|
+
* @param str - 要处理的值
|
|
6
|
+
* @param customize - 自定义空值显示
|
|
7
|
+
* @returns 处理结果
|
|
8
|
+
*/
|
|
9
|
+
declare function handleEmptyField(str: any, customize: any): {
|
|
10
|
+
success: boolean;
|
|
11
|
+
value: any;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { handleEmptyField };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/string/empty.ts
|
|
2
|
+
/**
|
|
3
|
+
* 处理字段为空的情况
|
|
4
|
+
*
|
|
5
|
+
* @param str - 要处理的值
|
|
6
|
+
* @param customize - 自定义空值显示
|
|
7
|
+
* @returns 处理结果
|
|
8
|
+
*/
|
|
9
|
+
function handleEmptyField(str, customize) {
|
|
10
|
+
const stringNull = ["null", "undefined"];
|
|
11
|
+
let success = true;
|
|
12
|
+
if (str === 0) success = true;
|
|
13
|
+
else if (stringNull.includes(str)) success = false;
|
|
14
|
+
else if (!str) success = false;
|
|
15
|
+
if (success) return {
|
|
16
|
+
value: str,
|
|
17
|
+
success
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
value: customize === "" ? customize : customize || "-",
|
|
21
|
+
success
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { handleEmptyField };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/string/nanoid.ts
|
|
2
|
+
let index = 0;
|
|
3
|
+
/**
|
|
4
|
+
* 生成 nanoid
|
|
5
|
+
*
|
|
6
|
+
* @param t - 长度
|
|
7
|
+
* @returns nanoid 字符串
|
|
8
|
+
*/
|
|
9
|
+
function genNanoid(t = 21) {
|
|
10
|
+
if (typeof window === "undefined") return (index += 1).toFixed(0);
|
|
11
|
+
if (!window.crypto) return (index += 1).toFixed(0);
|
|
12
|
+
let e = "";
|
|
13
|
+
const r = crypto.getRandomValues(new Uint8Array(t));
|
|
14
|
+
for (; t--;) {
|
|
15
|
+
const n = 63 & r[t];
|
|
16
|
+
e += n < 36 ? n.toString(36) : n < 62 ? (n - 26).toString(36).toUpperCase() : n < 63 ? "_" : "-";
|
|
17
|
+
}
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 生成 uuid,如果不支持 randomUUID,就用 genNanoid
|
|
22
|
+
*
|
|
23
|
+
* @returns uuid 字符串
|
|
24
|
+
*/
|
|
25
|
+
function nanoid() {
|
|
26
|
+
if (typeof window === "undefined") return genNanoid();
|
|
27
|
+
if (window.crypto && window.crypto.randomUUID && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
28
|
+
return genNanoid();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { nanoid };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/string/uuid.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 随机 UUID 生成器
|
|
4
|
+
*/
|
|
5
|
+
declare function getRandomNumber(): {
|
|
6
|
+
/**
|
|
7
|
+
* 生成指定长度的 UUID
|
|
8
|
+
*
|
|
9
|
+
* @param len - 长度
|
|
10
|
+
* @param rad - 基数
|
|
11
|
+
* @returns UUID 字符串
|
|
12
|
+
*/
|
|
13
|
+
uuid(len?: number, rad?: number): any;
|
|
14
|
+
/**
|
|
15
|
+
* 快速生成 UUID
|
|
16
|
+
*
|
|
17
|
+
* @returns UUID 字符串
|
|
18
|
+
*/
|
|
19
|
+
uuidFast(): string;
|
|
20
|
+
/**
|
|
21
|
+
* 生成无横线的 UUID
|
|
22
|
+
*
|
|
23
|
+
* @returns UUID 字符串
|
|
24
|
+
*/
|
|
25
|
+
uuidString(): string;
|
|
26
|
+
/**
|
|
27
|
+
* 生成紧凑格式 UUID
|
|
28
|
+
*
|
|
29
|
+
* @returns UUID 字符串
|
|
30
|
+
*/
|
|
31
|
+
uuidCompact(): string;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getRandomNumber };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/string/uuid.ts
|
|
2
|
+
/**
|
|
3
|
+
* 随机 UUID 生成器
|
|
4
|
+
*/
|
|
5
|
+
function getRandomNumber() {
|
|
6
|
+
const CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
|
|
7
|
+
return {
|
|
8
|
+
uuid(len, rad) {
|
|
9
|
+
const chars = CHARS;
|
|
10
|
+
const uuid = [];
|
|
11
|
+
const radix = rad || chars.length;
|
|
12
|
+
let i;
|
|
13
|
+
let r;
|
|
14
|
+
if (len) for (i = 0; i < len; i += 1) uuid[i] = chars[Number.parseInt(String(Math.random() * radix))];
|
|
15
|
+
else {
|
|
16
|
+
uuid[8] = "-";
|
|
17
|
+
uuid[13] = "-";
|
|
18
|
+
uuid[18] = "-";
|
|
19
|
+
uuid[23] = "-";
|
|
20
|
+
uuid[14] = "4";
|
|
21
|
+
for (i = 0; i < 36; i += 1) if (!uuid[i]) {
|
|
22
|
+
r = Math.random() * 16;
|
|
23
|
+
uuid[i] = chars[i === 19 ? r && 3 || 8 : r];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return uuid.join("");
|
|
27
|
+
},
|
|
28
|
+
uuidFast() {
|
|
29
|
+
const chars = CHARS;
|
|
30
|
+
const uuid = Array.from({ length: 36 });
|
|
31
|
+
let rnd = 0;
|
|
32
|
+
let r;
|
|
33
|
+
let i;
|
|
34
|
+
for (i = 0; i < 36; i += 1) if (i === 8 || i === 13 || i === 18 || i === 23) uuid[i] = "-";
|
|
35
|
+
else if (i === 14) uuid[i] = "4";
|
|
36
|
+
else {
|
|
37
|
+
if (rnd <= 2) rnd = 33554432 + Math.random() * 16777216 || 0;
|
|
38
|
+
r = rnd && 15;
|
|
39
|
+
rnd = rnd > 4;
|
|
40
|
+
uuid[i] = chars[i === 19 ? r && 3 || 8 : r];
|
|
41
|
+
}
|
|
42
|
+
return uuid.join("");
|
|
43
|
+
},
|
|
44
|
+
uuidString() {
|
|
45
|
+
return this.uuidFast().replace(/-/g, "");
|
|
46
|
+
},
|
|
47
|
+
uuidCompact() {
|
|
48
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
49
|
+
const r = Math.random() * 16 || 0;
|
|
50
|
+
return (c === "x" ? r : r && 3 || 8).toString(16);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { getRandomNumber };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AlignType } from "../typing.js";
|
|
2
|
+
|
|
3
|
+
//#region src/table/column.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 根据 key 和 dataIndex 生成唯一 id
|
|
6
|
+
*
|
|
7
|
+
* @param key - 用户设置的 key
|
|
8
|
+
* @param index - 序列号
|
|
9
|
+
* @returns 唯一 key
|
|
10
|
+
*/
|
|
11
|
+
declare function genColumnKey(key: string[] | number | string | undefined, index?: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* 处理表格序号列
|
|
14
|
+
*
|
|
15
|
+
* @param columns - 列配置
|
|
16
|
+
* @param options - 配置选项
|
|
17
|
+
* @returns 处理后的列
|
|
18
|
+
*/
|
|
19
|
+
declare function handleShowIndex<T extends object>(columns: T[], {
|
|
20
|
+
align,
|
|
21
|
+
showIndex
|
|
22
|
+
}: {
|
|
23
|
+
align: AlignType;
|
|
24
|
+
showIndex: boolean;
|
|
25
|
+
}): T[];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { genColumnKey, handleShowIndex };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isArray } from "../is/type.js";
|
|
2
|
+
import "../is/index.js";
|
|
3
|
+
import { getRandomNumber } from "../string/uuid.js";
|
|
4
|
+
|
|
5
|
+
//#region src/table/column.ts
|
|
6
|
+
/**
|
|
7
|
+
* 根据 key 和 dataIndex 生成唯一 id
|
|
8
|
+
*
|
|
9
|
+
* @param key - 用户设置的 key
|
|
10
|
+
* @param index - 序列号
|
|
11
|
+
* @returns 唯一 key
|
|
12
|
+
*/
|
|
13
|
+
function genColumnKey(key, index) {
|
|
14
|
+
if (key) return isArray(key) ? key.join("-") : key.toString();
|
|
15
|
+
return `${index || 0}`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 处理表格序号列
|
|
19
|
+
*
|
|
20
|
+
* @param columns - 列配置
|
|
21
|
+
* @param options - 配置选项
|
|
22
|
+
* @returns 处理后的列
|
|
23
|
+
*/
|
|
24
|
+
function handleShowIndex(columns, { align, showIndex }) {
|
|
25
|
+
const columnsList = structuredClone(columns);
|
|
26
|
+
if (showIndex && columns.length && columns.every((column) => column.dataIndex !== "sortIndex")) {
|
|
27
|
+
const firstColumnsItem = columns[0];
|
|
28
|
+
columnsList.unshift({
|
|
29
|
+
title: "序号",
|
|
30
|
+
align,
|
|
31
|
+
fixed: firstColumnsItem.fixed,
|
|
32
|
+
width: 60,
|
|
33
|
+
uuid: getRandomNumber().uuid(15),
|
|
34
|
+
dataIndex: "sortIndex",
|
|
35
|
+
key: "sortIndex"
|
|
36
|
+
});
|
|
37
|
+
} else columnsList.filter((item) => item.dataIndex !== "sortIndex");
|
|
38
|
+
return columnsList;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { genColumnKey, handleShowIndex };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BasicTablePageConfig } from "../typing.js";
|
|
2
|
+
|
|
3
|
+
//#region src/table/page.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 处理删除后的当前页码
|
|
6
|
+
*
|
|
7
|
+
* @param pageConfig - 分页配置
|
|
8
|
+
* @param currentPage - 当前页数据条数
|
|
9
|
+
* @returns 处理后的页码
|
|
10
|
+
*/
|
|
11
|
+
declare function handleCurrentPage(pageConfig: BasicTablePageConfig, currentPage: number): number;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { handleCurrentPage };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isObject } from "../is/type.js";
|
|
2
|
+
import "../is/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/table/page.ts
|
|
5
|
+
/**
|
|
6
|
+
* 处理删除后的当前页码
|
|
7
|
+
*
|
|
8
|
+
* @param pageConfig - 分页配置
|
|
9
|
+
* @param currentPage - 当前页数据条数
|
|
10
|
+
* @returns 处理后的页码
|
|
11
|
+
*/
|
|
12
|
+
function handleCurrentPage(pageConfig, currentPage) {
|
|
13
|
+
if (isObject(pageConfig)) {
|
|
14
|
+
const { pageSize = 10, total = 0 } = pageConfig;
|
|
15
|
+
let { current = 1 } = pageConfig;
|
|
16
|
+
if (total - currentPage <= pageSize * (current - 1)) current = current - 1;
|
|
17
|
+
return current === 0 ? 1 : current;
|
|
18
|
+
}
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { handleCurrentPage };
|
package/dist/typing.d.ts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { CSSProperties, Slot, VNode, VNodeChild } from "vue";
|
|
2
|
+
import { JSX } from "vue/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/typing.d.ts
|
|
5
|
+
interface EmptyEmit {}
|
|
6
|
+
/**
|
|
7
|
+
* 深度部分类型,递归地将所有属性变为可选。
|
|
8
|
+
*
|
|
9
|
+
* @template T - 要处理的类型
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* interface User {
|
|
14
|
+
* name: string
|
|
15
|
+
* address: {
|
|
16
|
+
* city: string
|
|
17
|
+
* zip: number
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* type PartialUser = DeepPartial<User>
|
|
21
|
+
* // { name?: string; address?: { city?: string; zip?: number } }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
25
|
+
/**
|
|
26
|
+
* 带递归深度限制的深度部分类型,防止无限类型实例化。
|
|
27
|
+
*
|
|
28
|
+
* @template T - 要处理的类型
|
|
29
|
+
* @template Depth - 最大递归深度(默认:5)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* interface DeepObject {
|
|
34
|
+
* a: { b: { c: { d: { e: { f: string } } } } }
|
|
35
|
+
* }
|
|
36
|
+
* type Limited = LimitDeepPartial<DeepObject, 3>
|
|
37
|
+
* // 只递归 3 层
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
type LimitDeepPartial<T, Depth extends number = 5> = Depth extends 0 ? Partial<T> : T extends object ? { [P in keyof T]?: LimitDeepPartial<T[P], Prev[Depth]> } : T;
|
|
41
|
+
/**
|
|
42
|
+
* 内部类型辅助工具,用于递减数字字面量。
|
|
43
|
+
* 被 {@link LimitDeepPartial} 用于追踪递归深度。
|
|
44
|
+
*/
|
|
45
|
+
type Prev = [0, 0, 1, 2, 3, 4, 5];
|
|
46
|
+
/**
|
|
47
|
+
* 通用函数接口,支持自定义参数和返回类型。
|
|
48
|
+
*
|
|
49
|
+
* @template T - 函数参数的类型
|
|
50
|
+
* @template R - 函数的返回类型
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const sum: Fn<number, number> = (...args) => args.reduce((a, b) => a + b, 0)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
interface Fn<T = any, R = T> {
|
|
58
|
+
(...arg: T[]): R;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 将类型变为可空类型,添加 `null` 到可能的值中。
|
|
62
|
+
*
|
|
63
|
+
* @template T - 基础类型
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* type MaybeString = Nullable<string> // string | null
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
type Nullable<T> = T | null;
|
|
71
|
+
/**
|
|
72
|
+
* 为类型添加 `false` 作为可能的值。
|
|
73
|
+
* 常用于条件渲染模式。
|
|
74
|
+
*
|
|
75
|
+
* @template T - 基础类型
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* type ConditionalRender = WithFalse<JSX.Element> // JSX.Element | false
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
type WithFalse<T> = T | false;
|
|
83
|
+
/**
|
|
84
|
+
* 通用记录类型,字符串键和任意值。
|
|
85
|
+
* 请谨慎使用;尽可能使用更具体的类型。
|
|
86
|
+
*/
|
|
87
|
+
type RecordType = Record<string, any>;
|
|
88
|
+
/**
|
|
89
|
+
* 条件类型,返回基础类型或默认类型。
|
|
90
|
+
*
|
|
91
|
+
* @template T - 基础类型
|
|
92
|
+
* @template R - 要检查的类型(默认为 undefined)
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* type Result = WithIfDefault<string, undefined> // string
|
|
97
|
+
* type Result2 = WithIfDefault<string, number> // string
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
type WithIfDefault<T, R = undefined> = R extends undefined ? T : R;
|
|
101
|
+
/**
|
|
102
|
+
* 有条件地扩展类型,添加额外属性。
|
|
103
|
+
*
|
|
104
|
+
* @template T - 基础类型
|
|
105
|
+
* @template R - 扩展类型(默认为 undefined)
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* interface Base { name: string }
|
|
110
|
+
* interface Extra { age: number }
|
|
111
|
+
* type Extended = ExtendIfDefined<Base, Extra> // Base & Extra
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
type ExtendIfDefined<T, R = undefined> = R extends undefined ? T : T & R;
|
|
115
|
+
/**
|
|
116
|
+
* 将指定键设为必填,其余保持可选。
|
|
117
|
+
*
|
|
118
|
+
* @template T - 基础类型
|
|
119
|
+
* @template Keys - 要设为必填的键
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* interface User {
|
|
124
|
+
* name?: string
|
|
125
|
+
* email?: string
|
|
126
|
+
* age?: number
|
|
127
|
+
* }
|
|
128
|
+
* type RequiredUser = WithRequired<User, 'name' | 'email'>
|
|
129
|
+
* // { name: string; email: string; age?: number }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
type WithRequired<T, Keys extends keyof T> = Required<Pick<T, Keys>> & Partial<Omit<T, Keys>>;
|
|
133
|
+
/**
|
|
134
|
+
* 联合类型,表示所有可能的 Vue 节点类型。
|
|
135
|
+
* 包含 VNodeChild 和 JSX.Element 以提供更广泛的兼容性。
|
|
136
|
+
*/
|
|
137
|
+
type VueNode = VNodeChild | JSX.Element;
|
|
138
|
+
/**
|
|
139
|
+
* 综合渲染函数类型,用于自定义内容渲染。
|
|
140
|
+
* 支持插槽、虚拟节点、渲染函数和原始值。
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const render: CustomRender = (props) => h('div', props.title)
|
|
145
|
+
* const render2: CustomRender = h('span', 'Hello')
|
|
146
|
+
* const render3: CustomRender = '纯文本'
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
type CustomRender = Slot | VNodeChild | VNode | ((...props: any[]) => VNode) | ((...props: any[]) => VNode[]) | VNode[] | JSX.Element | string | null | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* 响应式断点名称,遵循 Ant Design 的断点系统。
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://ant.design/components/grid/#Col}
|
|
154
|
+
*/
|
|
155
|
+
type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
156
|
+
/**
|
|
157
|
+
* 组件通用的尺寸变体。
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* const size: SizeType = 'large'
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* 文本对齐选项。
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const align: AlignType = 'center'
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
type AlignType = 'left' | 'center' | 'right';
|
|
174
|
+
/**
|
|
175
|
+
* 表格组件的分页配置。
|
|
176
|
+
* 可以是包含分页属性的配置对象,或 `false` 来隐藏分页。
|
|
177
|
+
*
|
|
178
|
+
* @template T - 额外的自定义分页属性
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const config: BasicTablePageConfig = {
|
|
183
|
+
* current: 1,
|
|
184
|
+
* pageSize: 10,
|
|
185
|
+
* total: 100
|
|
186
|
+
* }
|
|
187
|
+
* const hidden: BasicTablePageConfig = false
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
type BasicTablePageConfig<T = object> = {
|
|
191
|
+
current: number;
|
|
192
|
+
pageSize: number;
|
|
193
|
+
total?: number;
|
|
194
|
+
} & T | boolean;
|
|
195
|
+
/**
|
|
196
|
+
* 媒体元素配置选项。
|
|
197
|
+
* 用于视频/音频播放器配置。
|
|
198
|
+
*
|
|
199
|
+
* @template T - 额外的自定义媒体属性
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const media: MediaOptions = {
|
|
204
|
+
* play: true,
|
|
205
|
+
* width: 1920,
|
|
206
|
+
* height: 1080,
|
|
207
|
+
* duration: 120,
|
|
208
|
+
* size: '1080p'
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
type MediaOptions<T = object> = {
|
|
213
|
+
/** 媒体是否自动播放 */play: boolean; /** 媒体宽度(像素) */
|
|
214
|
+
width: number; /** 媒体高度(像素) */
|
|
215
|
+
height: number; /** 媒体时长(秒) */
|
|
216
|
+
duration: number; /** 可选的尺寸描述(如 '1080p'、'4K') */
|
|
217
|
+
size?: number | string;
|
|
218
|
+
} & T;
|
|
219
|
+
/**
|
|
220
|
+
* 从类型的所有属性中移除 `undefined` 和 `null`。
|
|
221
|
+
*
|
|
222
|
+
* @template T - 要处理的类型
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* interface MaybeNull {
|
|
227
|
+
* name: string | null
|
|
228
|
+
* age: number | undefined
|
|
229
|
+
* }
|
|
230
|
+
* type Definite = OmitUndefined<MaybeNull>
|
|
231
|
+
* // { name: string; age: number }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
type OmitUndefined<T> = { [P in keyof T]: NonNullable<T[P]> };
|
|
235
|
+
/**
|
|
236
|
+
* 语义化类名映射类型。
|
|
237
|
+
* 用于组件样式定制。
|
|
238
|
+
*
|
|
239
|
+
* @template Name - 有效的语义名称联合类型
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* type ButtonClassNames = SemanticClassNames<'root' | 'icon' | 'text'>
|
|
244
|
+
* // Partial<Record<'root' | 'icon' | 'text', string>>
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
type SemanticClassNames<Name extends string> = Partial<Record<Name, string>>;
|
|
248
|
+
/**
|
|
249
|
+
* 语义化样式映射类型。
|
|
250
|
+
* 用于组件各部分的行内样式定制。
|
|
251
|
+
*
|
|
252
|
+
* @template Name - 有效的语义名称联合类型
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* type ButtonStyles = SemanticStyles<'root' | 'icon'>
|
|
257
|
+
* // Partial<Record<'root' | 'icon', CSSProperties>>
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
type SemanticStyles<Name extends string> = Partial<Record<Name, CSSProperties>>;
|
|
261
|
+
//#endregion
|
|
262
|
+
export { AlignType, BasicTablePageConfig, Breakpoint, CustomRender, DeepPartial, EmptyEmit, ExtendIfDefined, Fn, LimitDeepPartial, MediaOptions, Nullable, OmitUndefined, RecordType, SemanticClassNames, SemanticStyles, SizeType, VueNode, WithFalse, WithIfDefault, WithRequired };
|
package/dist/typing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { RenderResult, SlotsPropsResult, filterEmpty, getKeys, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, isEmptyElement, slotRender } from "./slots.js";
|
|
2
|
+
export { RenderResult, SlotsPropsResult, filterEmpty, getKeys, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, isEmptyElement, slotRender };
|