next-ui3 1.4.1 → 1.4.2
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/index.full.min.js +2 -2
- package/dist/index.full.min.mjs +10 -10
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/utils/index.min.js +1 -1
- package/dist/utils/index.min.mjs +1 -1
- package/es/components/_base/next.d.ts +1 -1
- package/es/version.d.ts +1 -1
- package/lib/components/_base/next.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/locale/zh-cn.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! Next UI v1.4.
|
|
1
|
+
/*! Next UI v1.4.2 */(function(e,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis!="undefined"?globalThis:e||self,e.NextUILocaleZhCn=n())})(this,function(){"use strict";var e={name:"zh-cn",nt:{input:{label:"\u786E\u8BA4"}}};return e});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! Next UI v1.4.
|
|
1
|
+
/*! Next UI v1.4.2 */var a={name:"zh-cn",nt:{input:{label:"\u786E\u8BA4"}}};export{a as default};
|
package/dist/utils/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Next UI utils v1.4.
|
|
1
|
+
/*! Next UI utils v1.4.2 */(function(c,M){typeof exports=="object"&&typeof module!="undefined"?M(exports,require("element-plus")):typeof define=="function"&&define.amd?define(["exports","element-plus"],M):(c=typeof globalThis!="undefined"?globalThis:c||self,M(c.NextUI={},c.ElementPlus))})(this,function(c,M){"use strict";const Z=(e,n)=>{try{if(e.install=t=>{for(const r of[e,...Object.values(n!=null?n:{})])r.name&&t.component(r.name,r)},n)for(const[t,r]of Object.entries(n))e[t]=r;return e}catch(t){}};function x(e){const n=typeof e;return e!=null&&(n==="object"||n==="function")}function A(e){return typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function B(e){if(typeof e=="boolean"||typeof e=="number")return!1;if(Array.isArray(e)){if(e.length===0)return!0}else if(e instanceof Object&&JSON.stringify(e)==="{}")return!0;return e==null||e==="null"||e==="undefined"||e===""}function Q(){return window.top!==window}function ee(e){return toString.call(e)==="[object Blob]"}function te(e){if(e.startsWith("data:image"))return!0;const n=e.lastIndexOf("."),t=n>=0?e.slice(n+1).toLowerCase():"";return["png","jpg","jpeg","gif","bmp","webp","svg"].includes(t)}function ne(e,n){for(;e;){if(e===n)return!0;e=Object.getPrototypeOf(e)}return!1}const k=(e,n)=>{const t=A(e),r=A(n);return t&&r?JSON.stringify(e)===JSON.stringify(n):!t&&!r?String(e)===String(n):!1},$=(e,n)=>{if(e=e||[],n=n||[],e.length!==n.length)return!1;for(const[t,r]of e.entries())if(!k(r,n[t]))return!1;return!0},re=(e,n)=>Array.isArray(e)&&Array.isArray(n)?$(e,n):k(e,n);function ie(e,n,t){const r={};let i;typeof t=="function"?i=t:t?i=d=>d[t]:i=d=>d,(e||[]).forEach(d=>{const h=i(d);r[h]={item:d,count:-1}}),(n||[]).forEach(d=>{const h=i(d);r[h]?r[h].count=0:r[h]={item:d,count:1}});const o=[],l=[];for(const d in r)Object.prototype.hasOwnProperty.call(r,d)&&(r[d].count===1?l.push(r[d].item):r[d].count===-1&&o.push(r[d].item));return{changed:o.length+l.length>0,removed:o.length>0,added:l.length>0,removedItems:o,addedItems:l}}const oe=(e,...n)=>{const t=[];return e.forEach(r=>{n.includes(r)||t.push(r)}),t},ae=e=>B(e)?[]:Array.isArray(e)?e:[e],ue=(e,n)=>{if(typeof n!="function"){const t=n;n=r=>String(r[t])}return(e||[]).reduce((t,r)=>{const i=n(r);return t[i]||(t[i]=[]),t[i].push(r),t},{})};function se(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}function H(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}function ce(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase()).replace(/_([a-z])/g,(n,t)=>t.toUpperCase())}const W=(e,n,...t)=>{const r={};return n=(n?[].concat(n):[]).concat(t),e&&n.forEach(i=>{Object.hasOwnProperty.call(e,i)&&(r[i]=e[i])}),r},le=(e,n,...t)=>{const r={};return n=(n?[].concat(n):[]).concat(t),e&&Object.keys(e).forEach(i=>{n.includes(i)||(r[i]=e[i])}),r},fe=(e,...n)=>{for(const t of n)Object.assign(e,W(t,Object.keys(e)));return e};function z(e,...n){A(e)||(e={});for(const t of n)if(A(t))for(const r in t)r==="__proto__"||e===t[r]||(A(t[r])?e[r]=z(e[r],t[r]):e[r]=t[r]);return e}const de=e=>{const n={};if(e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(B(e[t])||(n[t]=e[t]));return n};function he(e){const n=new WeakMap,t=r=>{if(typeof r=="object"&&r!==null){if(n.has(r))return n.get(r);const i=Array.isArray(r)?[]:{};n.set(r,i);for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&(i[o]=t(r[o]));return i}return r};return t(e)}function Y(e,n){try{return JSON.parse(e)}catch(t){return console.error("parse json error:",e),n}}function me(e,n,t){if(!e||!n)return;const r=n.split(".");let i;for(;(i=r.shift())!==void 0&&r.length!==0;)e[i]||(e[i]={}),e=e[i];i&&(e[i]=t)}function S(e,n){if(!e||!n)return;const t=n.split(".");for(const r of t){if(!e)return;e=e[r]}return e}const J=(e,n)=>{for(const t in e)Object.getOwnPropertyDescriptor(n,t)?A(e[t])&&J(e[t],n[t]):n[t]=e[t];return n},ge=(e,n)=>{var t;return(t=e[n])!=null?t:e[H(n)]};function pe(e,n){let{key:t,parentKey:r}=n||{};t=t||"id",r=r||"pid";const i=(e||[]).reduce((l,d)=>(l[S(d,t)]=d,l),{}),o=[];return(e||[]).forEach(l=>{const d=i[S(l,r)];d?(d.children||(d.children=[])).push(l):o.push(l)}),o}function V(e,n){const t=[];return(e||[]).forEach(r=>{let{children:i,...o}=r;i&&i.length>0&&(i=V(i,n),i.length>0&&(o.children=i)),n(o)&&t.push(o)}),t}function ye(e,n){const t=e?[...e]:[];for(;t.length>0;){const r=t.shift();if(n(r))return r;r.children&&r.children.length>0&&t.push(...r.children)}return null}function we(e,n){const t=(r,i)=>{for(const o of r){if(n(o))return[...i,o];if(o.children&&o.children.length>0){const l=t(o.children,[...i,o]);if(l)return l}}return null};return t(e||[],[])}function be(e,n){const t={children:e||[]},r=[t];let i,o=-1;for(;r.length>0;){i=r.shift();const{children:l}=i;if(l&&l.length>0){for(const[d,h]of l.entries())if(n(h)){o=d;break}if(o!==-1)break;r.push(...l)}}return{found:o!==-1,parent:i===t?null:i,index:o}}function Ee(e,n){const t=(e||[]).map(r=>({node:r,parent:null}));for(;t.length>0;){const r=t.shift(),{node:i,parent:o}=r;if(n(i,o)===!1)break;i.children&&i.children.length>0&&t.push(...i.children.map(d=>({node:d,parent:i})))}}function ve(e){const n=[];if(e&&e.length>0){n.push(...e);let t=0;for(;t<n.length;){const{children:r}=n[t];r&&r.length>0&&n.push(...r),t++}}return n}function Oe(e,n,t){t||(t=n);const r=i=>(i||[]).reduce((o,l)=>(l[t]=l[n]+(l.children?r(l.children):0),o+l[t]),0);r(e)}function Fe(e,n){if(!e)return"";const t=new Date(e);if(t.getTime()===0)return"";n=n||"yyyy-MM-dd";let r;const i={"Y+":t.getFullYear().toString(),"y+":t.getFullYear().toString(),"M+":(t.getMonth()+1).toString(),"D+":t.getDate().toString(),"d+":t.getDate().toString(),"h+":(t.getHours()%12||12).toString(),"H+":t.getHours().toString(),"m+":t.getMinutes().toString(),"s+":t.getSeconds().toString(),a:t.getHours()<12?"am":"pm",A:t.getHours()<12?"AM":"PM"};for(const o in i)r=new RegExp(`(${o})`).exec(n),r&&(n=n.replace(r[1],r[1].length===1?i[o]:i[o].padStart(r[1].length,"0")));return n}function Te(e,n){if(B(e))return"";let{minPrecision:t,maxPrecision:r,decimalPoint:i,thousandSeparator:o,grouping:l}=n||{};t=t!=null?t:0,r=r!=null?r:2,i=i||".",o=o!=null?o:",",l=l!=null?l:3;let[d,h]=`${e}`.split(".");return d=d.replace(new RegExp(`(?<!^-?)(?=(\\d{${l}})+$)`,"g"),o),h=(h||"").slice(0,r).padEnd(t,"0"),h&&(h=i+h),d+h}function Ie(e,n){if(n){const i=B(e[0])||e[0]===Number.NEGATIVE_INFINITY?"-\u221E":e[0],o=B(e[1])||e[1]===+Number.POSITIVE_INFINITY?"+\u221E":e[1];return`${i+(i==="-\u221E"?" < ":" \u2264 ")+n} < ${o}`}const t=B(e[0])||e[0]==="-\u221E"||e[0]==="-Infinity"?"-\u221E":e[0],r=B(e[1])||e[1]==="+\u221E"||e[1]==="Infinity"?"+\u221E":e[1];return`${t==="-\u221E"?"(":"["} ${t}, ${r} )`}function De(e){if(e=Number(e),Number.isNaN(e))return"";const n=["B","KB","MB","GB","TB","PB"];let t=0;for(;e>=1024&&t<n.length-1;)e/=1024,t++;return e=Math.round(e*100)/100,`${e} ${n[t]}`}function Pe(e){return Number.isNaN(Number(e))?e||"":`${Number(e)}px`}const _=e=>new Promise(n=>{setTimeout(n,e)}),Ae=(e,n)=>new Promise((t,r)=>{(async()=>{try{const o=Date.now(),l=await e(),d=Date.now()-o;d<n&&await _(n-d),t(l)}catch(o){r(o)}})()}),Be=()=>{const e=Date.now();return{delayTo:async t=>{const r=Date.now()-e;r<t&&await _(t-r)}}},Ce=(e,n,t)=>{let r,i=!1,o;const l=()=>{if(i||e()){r(void 0),clearTimeout(o);return}requestAnimationFrame(l)};return t&&(o=setTimeout(()=>{i=!0},t)),new Promise(d=>{r=d,n?setTimeout(l,n):requestAnimationFrame(l)})},Me=(e,n)=>Math.floor(e+Math.random()*(n-e));function Ue(e){return new Promise((n,t)=>{const r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=()=>{if(r.status===200){const i=new FileReader;i.readAsDataURL(r.response),i.onload=o=>{n(o.target.result)},i.onerror=o=>t(o)}else t(new Error("Failed to load file"))},r.onerror=()=>{t(new Error("Failed to load file"))},r.send()})}function Le(e){return new Promise((n,t)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=i=>{n(i.target.result)},r.onerror=i=>t(i)})}function ke(e){return URL.createObjectURL(e)}function Se(e){return new Promise((n,t)=>{const r=new FileReader;r.readAsArrayBuffer(e),r.onload=i=>{n(new Blob([i.target.result]))},r.onerror=i=>t(i)})}async function _e(e){if(!e)throw new Error("url is empty");return(await fetch(e)).blob()}async function Re(e){if(!e)throw new Error("url is empty");return new Promise((n,t)=>{const r=new Image;r.onload=()=>{const i=document.createElement("canvas");i.width=r.width,i.height=r.height;const o=i.getContext("2d");o==null||o.drawImage(r,0,0,r.width,r.height),i.toBlob(l=>{l?n(l):t(new Error("transform image to blob failed"))},"image/png")},r.onerror=t,r.src=e})}function je(e,n){if(!e)return"";if(typeof e=="string"&&(e=new URL(e)),n)for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.searchParams.append(t,n[t]);return e.toString()}function Ne(e){return e.replace(/[<>&]/g,n=>`&#${n.charCodeAt(0)};`)}function qe(e){const n=document.createElement("div");return n.innerHTML=e,n.textContent||n.innerText}async function*$e(e,n){const t=new TextDecoder("utf-8"),{original:r}=n||{};let i="";for(;;){const{value:o,done:l}=await e.read();if(l)return;i+=t.decode(o);const d=i.split(`
|
|
2
2
|
`);i=d.pop()||"";for(let h of d)if(h=h.trim(),!!h)if(r)yield h;else{if(h==="event: ping")continue;const I=h.match(/^(?:(\w*):)?(.*)$/);if(!I){console.error("[BufferedReader] parse line failed:",h);continue}const O=I[1],D=Y(I[2].trim());if(!D){console.error("[BufferedReader] parse json failed:",I[2].trim());continue}yield{event:O,data:D}}}}const He=e=>{let{url:n,filename:t}=e;if(t=t||"\u672A\u547D\u540D",n||e.blob&&(n=URL.createObjectURL(e.blob),setTimeout(()=>{URL.revokeObjectURL(n)},1e4)),!n)throw new Error("No URL provided");const r=document.createElement("a");r.href=n,r.download=t,r.click()};function We(e,n,t){let r,i,o,l,d,h,I=0,O=!1,D=!1,U=!0;if(typeof e!="function")throw new TypeError("Expected a function");n=+n||0,t&&A(t)&&(O=!!t.leading,D="maxWait"in t,o=D?Math.max(+t.maxWait||0,n):o,U="trailing"in t?!!t.trailing:U);function T(p){const v=r,F=i;return r=i=void 0,I=p,l=e.apply(F,v),l}function C(p,v){return setTimeout(p,v)}function a(p){clearTimeout(p)}function f(p){return I=p,d=C(g,n),O?T(p):l}function s(p){const v=p-h,F=p-I,P=n-v;return D?Math.min(P,o-F):P}function u(p){const v=p-h,F=p-I;return h===void 0||v>=n||v<0||D&&F>=o}function g(){const p=Date.now();if(u(p))return y(p);d=C(g,s(p))}function y(p){return d=void 0,U&&r?T(p):(r=i=void 0,l)}function E(){d!==void 0&&a(d),I=0,r=h=i=d=void 0}function m(){return d===void 0?l:y(Date.now())}function b(){return d!==void 0}function w(...p){const v=Date.now(),F=u(v);if(r=p,i=this,h=v,F){if(d===void 0)return f(h);if(D)return d=C(g,n),T(h)}return d===void 0&&(d=C(g,n)),l}return w.cancel=E,w.flush=m,w.pending=b,w}function ze(e){const{el:n,msg:t}=e||{},r=t===void 0?"\u8BF7\u5B8C\u5584\u8868\u5355\u5185\u5BB9":t;if(r&&M.ElMessage.error(r),!n)return;const i=n.querySelector(".is-error");i&&i.scrollIntoView({behavior:"smooth",inline:"nearest",block:"center"})}async function Ye(e,n={successText:"\u590D\u5236\u6210\u529F"}){const{successText:t}=n||{};try{if(navigator.clipboard){await navigator.clipboard.writeText(e),t&&M.ElMessage.success(t);return}}catch(i){}const r=document.createElement("textarea");document.body.appendChild(r),r.style.position="fixed",r.style.clip="rect(0 0 0 0)",r.style.top="10px",r.value=e,r.select(),document.execCommand("copy",!0),document.body.removeChild(r),t&&M.ElMessage.success(t)}function Je(e,...n){if(!e)return;const t=document.createElement("a");t.addEventListener("click",r=>{r.preventDefault(),window.open(e,...n)}),t.click()}function Ve(e){if(!e)return[];const n=[`${e.slice(0,2)}0000`,`${e.slice(0,4)}00`,e.slice(0,6),e.slice(0,9),e.slice(0,12)],t=0,r=n.indexOf(e)+1;return n.slice(t,r)}class R{constructor(n){this._enumItems={};var t;if(n)if(Array.isArray(n))for(const[r,i]of n.entries())this.add((t=i.key)!=null?t:`${r}`,i);else for(const r in n){const i=n[r];this.add(r,i)}}add(n,t){if(this[n])throw new Error(`\u679A\u4E3E\u9879 ${n} \u5DF2\u5B58\u5728`);const r=t.value;return this[n]=r,this._enumItems[r]={...t},this}keys(){return Object.keys(this).filter(n=>n!=="_enumItems")}*[Symbol.iterator](){for(const n of this.keys())yield this.getItem(this[n])}getItem(n){return this._enumItems[n]}getLabel(n){var t;return(t=this.getItem(n))==null?void 0:t.label}getProps(n){var t;return(t=this.getItem(n))==null?void 0:t.props}filter(n){const t=new R;for(const r of this.keys()){const i=this.getItem(this[r]);n(i,r)&&t.add(r,i)}return t}clone(){return this.filter(()=>!0)}set(n,t){const r=this.getItem(this[n]);return r&&Object.assign(r,t),this}remove(n){const t=this[n];return t!==void 0&&(delete this[n],delete this._enumItems[t]),this}forEach(n){for(const t of this.keys())n(this.getItem(this[t]),t)}}const Ge=(e,n)=>{if(!e||!n)return!1;if(n.includes(" "))throw new Error("className should not contain space.");return e.classList.contains(n)};function Ke(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var G={exports:{}},j={exports:{}},K;function Xe(){return K||(K=1,function(e,n){(function(t,r){e.exports=r()})(window,function(){return function(t){var r={};function i(o){if(r[o])return r[o].exports;var l=r[o]={i:o,l:!1,exports:{}};return t[o].call(l.exports,l,l.exports,i),l.l=!0,l.exports}return i.m=t,i.c=r,i.d=function(o,l,d){i.o(o,l)||Object.defineProperty(o,l,{enumerable:!0,get:d})},i.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},i.t=function(o,l){if(1&l&&(o=i(o)),8&l||4&l&&typeof o=="object"&&o&&o.__esModule)return o;var d=Object.create(null);if(i.r(d),Object.defineProperty(d,"default",{enumerable:!0,value:o}),2&l&&typeof o!="string")for(var h in o)i.d(d,h,function(I){return o[I]}.bind(null,h));return d},i.n=function(o){var l=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(l,"a",l),l},i.o=function(o,l){return Object.prototype.hasOwnProperty.call(o,l)},i.p="",i(i.s=0)}([function(t,r,i){i.r(r);var o=window,l=/^image\//,d=/\.\w+$/,h={},I={file:null,quality:.8,convertSize:2048e3,loose:!0,redressOrientation:!0},O=function(a){return typeof a=="function"},D=function(a){return l.test(a)};function U(a){a=Object.assign({},I,a),this.options=a,this.file=a.file,this.image=null,this.ParsedOrientationInfo=null,this.init()}var T=U.prototype;for(var C in r.default=U,T.init=function(){var a=this,f=this.file,s=this.options;f&&D(f.type)?(D(s.mimeType)||(s.mimeType=f.type),h.file2Image(f,function(u){O(a.beforeCompress)&&(a.image=u,f.width=u.naturalWidth,f.height=u.naturalHeight,a.beforeCompress(f)),f.type==="image/jpeg"&&s.redressOrientation?a.getParsedOrientationInfo(function(g){a.parsedOrientationInfo=g,a.rendCanvas()}):(a.parsedOrientationInfo={rotate:0,scaleX:1,scaleY:1},a.rendCanvas())},a.error)):a.error("\u8BF7\u4E0A\u4F20\u56FE\u7247\u6587\u4EF6!")},T.rendCanvas=function(){var a=this,f=this.options,s=this.image,u=this.getExpectedEdge(),g=u.dWidth,y=u.dHeight,E=u.width,m=u.height,b=h.image2Canvas(s,g,y,a.beforeDraw.bind(a),a.afterDraw.bind(a),E,m);h.canvas2Blob(b,function(w){w&&(w.width=b.width,w.height=b.height),a.success(w)},f.quality,f.mimeType)},T.beforeCompress=function(){O(this.options.beforeCompress)&&this.options.beforeCompress(this.file)},T.getExpectedEdge=function(){var a,f=this.image,s=this.parsedOrientationInfo.rotate,u=this.options,g=f.naturalWidth,y=f.naturalHeight,E=Math.abs(s)%180==90;E&&(a=y,y=g,g=a);var m=g/y,b=Math.max(u.maxWidth,0)||1/0,w=Math.max(u.maxHeight,0)||1/0,p=Math.max(u.minWidth,0)||0,v=Math.max(u.minHeight,0)||0,F=Math.max(u.width,0)||g,P=Math.max(u.height,0)||y;b<1/0&&w<1/0?w*m>b?w=b/m:b=w*m:b<1/0?w=b/m:w<1/0&&(b=w*m),p>0&&v>0?v*m>p?v=p/m:p=v*m:p>0?v=p/m:v>0&&(p=v*m),P*m>F?P=F/m:F=P*m;var N=F=Math.floor(Math.min(Math.max(F,p),b)),q=P=Math.floor(Math.min(Math.max(P,v),w));return E&&(a=q,q=N,N=a),{dWidth:N,dHeight:q,width:F,height:P}},T.getParsedOrientationInfo=function(a){var f=this;this.getOrientation(function(s){O(a)&&a(f.parseOrientation(s))})},T.getOrientation=function(a){var f=this;h.file2ArrayBuffer(this.file,function(s){O(a)&&a(f.resetAndGetOrientation(s))})},T.resetAndGetOrientation=function(a){var f,s=new DataView(a);try{var u,g,y;if(s.getUint8(0)===255&&s.getUint8(1)===216)for(var E=s.byteLength,m=2;m+1<E;){if(s.getUint8(m)===255&&s.getUint8(m+1)===225){g=m;break}m+=1}if(g){var b=g+4,w=g+10;if(h.getStringFromCharCode(s,b,4)==="Exif"){var p=s.getUint16(w);if(((u=p===18761)||p===19789)&&s.getUint16(w+2,u)===42){var v=s.getUint32(w+4,u);v>=8&&(y=w+v)}}}if(y){var F;for(E=s.getUint16(y,u),F=0;F<E;F+=1)if(m=y+12*F+2,s.getUint16(m,u)===274){m+=8,f=s.getUint16(m,u),s.setUint16(m,1,u);break}}}catch(P){console.error(P),f=1}return f},T.parseOrientation=function(a){var f=0,s=1,u=1;switch(a){case 2:s=-1;break;case 3:f=-180;break;case 4:u=-1;break;case 5:f=90,u=-1;break;case 6:f=90;break;case 7:f=90,s=-1;break;case 8:f=-90}return{rotate:f,scaleX:s,scaleY:u}},T.beforeDraw=function(a,f){var s=this.parsedOrientationInfo,u=s.rotate,g=s.scaleX,y=s.scaleY,E=this.file,m=this.options,b="transparent",w=f.width,p=f.height;switch(E.size>m.convertSize&&m.mimeType==="image/png"&&(b="#fff",m.mimeType="image/jpeg"),a.fillStyle=b,a.fillRect(0,0,w,p),O(m.beforeDraw)&&m.beforeDraw.call(this,a,f),a.save(),u){case 90:a.translate(w,0);break;case-90:a.translate(0,p);break;case-180:a.translate(w,p)}a.rotate(u*Math.PI/180),a.scale(g,y)},T.afterDraw=function(a,f){var s=this.options;O(s.afterDraw)&&s.afterDraw.call(this,a,f)},T.error=function(a){var f=this.options;if(!O(f.error))throw new Error(a);f.error.call(this,a)},T.success=function(a){var f,s,u=this.options,g=this.file,y=this.image,E=this.getExpectedEdge(),m=y.naturalHeight,b=y.naturalWidth;if(a&&a.size)if(!u.loose&&a.size>g.size&&!(E.width>b||E.height>m))console.warn("\u5F53\u524D\u8BBE\u7F6E\u7684\u662F\u975E\u5BBD\u677E\u6A21\u5F0F\uFF0C\u538B\u7F29\u7ED3\u679C\u5927\u4E8E\u6E90\u56FE\u7247\uFF0C\u8F93\u51FA\u6E90\u56FE\u7247"),a=g;else{var w=new Date;a.lastModified=w.getTime(),a.lastModifiedDate=w,a.name=g.name,a.name&&a.type!==g.type&&(a.name=a.name.replace(d,(f=a.type,(s=D(f)?f.substr(6):"")==="jpeg"&&(s="jpg"),"."+s)))}else console.warn("\u56FE\u7247\u538B\u7F29\u51FA\u4E86\u70B9\u610F\u5916\uFF0C\u8F93\u51FA\u6E90\u56FE\u7247"),a=g;O(u.success)&&u.success.call(this,a)},h.file2DataUrl=function(a,f,s){var u=new FileReader;u.onload=function(){f(u.result)},u.onerror=function(){O(s)&&s("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF01")},u.readAsDataURL(a)},h.file2ArrayBuffer=function(a,f,s){var u=new FileReader;u.onload=function(g){f(g.target.result)},u.onerror=function(){O(s)&&s("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF01")},u.readAsArrayBuffer(a)},h.getStringFromCharCode=function(a,f,s){var u,g="";for(s+=f,u=f;u<s;u+=1)g+=String.fromCharCode(a.getUint8(u));return g},h.file2Image=function(a,f,s){var u=new Image,g=o.URL||o.webkitURL;if(o.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(o.navigator.userAgent)&&(u.crossOrigin="anonymous"),u.alt=a.name,u.onerror=function(){O(s)&&s("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01")},g){var y=g.createObjectURL(a);u.onload=function(){f(u),g.revokeObjectURL(y)},u.src=y}else this.file2DataUrl(a,function(E){u.onload=function(){f(u)},u.src=E},s)},h.url2Image=function(a,f,s){var u=new Image;u.src=a,u.onload=function(){f(u)},u.onerror=function(){O(s)&&s("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01")}},h.image2Canvas=function(a,f,s,u,g,y,E){var m=document.createElement("canvas"),b=m.getContext("2d");return m.width=y||a.naturalWidth,m.height=E||a.naturalHeight,O(u)&&u(b,m),b.save(),b.drawImage(a,0,0,f,s),b.restore(),O(g)&&g(b,m),m},h.canvas2DataUrl=function(a,f,s){return a.toDataURL(s||"image/jpeg",f)},h.dataUrl2Image=function(a,f,s){var u=new Image;u.onload=function(){f(u)},u.error=function(){O(s)&&s("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01")},u.src=a},h.dataUrl2Blob=function(a,f){for(var s=a.split(",")[1],u=a.match(/^data:(.*?)(;base64)?,/)[1],g=atob(s),y=s.length,E=new Uint8Array(y),m=0;m<y;m++)E[m]=g.charCodeAt(m);return new Blob([E],{type:f||u})},h.blob2DataUrl=function(a,f,s){this.file2DataUrl(a,f,s)},h.blob2Image=function(a,f,s){this.file2Image(a,f,s)},h.canvas2Blob=function(a,f,s,u){var g=this;HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(y,E,m){var b=this.toDataURL(E,m);y(g.dataUrl2Blob(b))}}),a.toBlob(function(y){f(y)},u||"image/jpeg",s||.8)},h.upload=function(a,f,s){var u=new XMLHttpRequest,g=new FormData;g.append("file",f),u.onreadystatechange=function(){if(u.readyState!==4||u.status!==200)throw new Error(u);s&&s(u.responseText)},u.open("POST",a,!0),u.send(g)},h)h.hasOwnProperty(C)&&(U[C]=h[C])}]).default})}(j)),j.exports}(function(e){e.exports=Xe()})(G);var Ze=Ke(G.exports);const xe=e=>{if(!e.file)throw new Error("file is required");const n=e.file.size/1024;let t=e.quality;if(t===void 0){if(n<200)return e.file;n>200&&n<=512?t=.9:n>512&&n<=1024?t=.8:n>1024&&n<=2048?t=.85:n>2048&&n<=10240?t=.8:n>10240&&n<=20480&&(t=.75)}return new Promise((r,i)=>{var o;new Ze({...e,quality:t,convertSize:(o=e.convertSize)!=null?o:1024,success:l=>{r(l)},error:l=>{i(l)}})})},X=e=>e&&e.split("?")[0].split("/").pop()||"",Qe=e=>(e=X(e),e?(e.split(".").pop()||"").toLowerCase():""),et=(e,n,t)=>Math.min(Math.max(t,e),n),L=new Map,tt=(e,n=3)=>{if(!e)throw new Error("name is required");let t;return L.has(e)?t=L.get(e):(t={maxNum:n,currentNum:0,queue:[]},L.set(e,t)),{acquire:async()=>new Promise((d,h)=>{t.currentNum>=t.maxNum?t.queue.push({resolve:d,reject:h}):(t.currentNum++,d(!0))}),release:()=>{if(t.queue.length>0){const{resolve:d}=t.queue.shift();d(!0)}else t.currentNum--},destroy:async()=>{L.delete(e)},getMaxNum:()=>t.maxNum}};c.Enum=R,c.arrayDiff=ie,c.arrayEquals=$,c.assign=fe,c.buildTree=pe,c.buildUrl=je,c.clamp=et,c.combineByField=Oe,c.compressImage=xe,c.copyText=Ye,c.createLock=tt,c.createStreamIterator=$e,c.createTimer=Be,c.debounce=We,c.decodeHTMLEntities=qe,c.deepAssign=z,c.deepClone=he,c.delayWhen=Ce,c.downloadFile=He,c.encodeHTMLEntities=Ne,c.fileToBlob=Se,c.fileToDataURL=Le,c.fileToObjectURL=ke,c.filterTree=V,c.findNode=ye,c.findNodeWithPath=we,c.findParentAndIndex=be,c.flatTree=ve,c.formatBytes=De,c.formatDate=Fe,c.formatInterval=Ie,c.formatNumber=Te,c.formatPx=Pe,c.getFileExt=Qe,c.getFilename=X,c.getProp=ge,c.getProperty=S,c.getRandInt=Me,c.groupBy=ue,c.handleFormValidateError=ze,c.hasClass=Ge,c.isBlob=ee,c.isChildClassOf=ne,c.isEmpty=B,c.isEqual=re,c.isIframe=Q,c.isImage=te,c.isObject=x,c.isPlainObject=A,c.looseEqual=k,c.mergeDefaultOptions=J,c.omit=le,c.omitEmpty=de,c.openPage=Je,c.parseAreaCode=Ve,c.parseJson=Y,c.pick=W,c.runAtLeastTime=Ae,c.setProperty=me,c.sleep=_,c.toArray=ae,c.toCamelCase=ce,c.toKebabCase=H,c.toUnderscore=se,c.urlToBlob=_e,c.urlToDataURL=Ue,c.urlToPngBlob=Re,c.walkTree=Ee,c.withInstall=Z,c.without=oe,Object.defineProperty(c,"__esModule",{value:!0})});
|
package/dist/utils/index.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Next UI utils v1.4.
|
|
1
|
+
/*! Next UI utils v1.4.2 */import{ElMessage as U}from"element-plus";const X=(e,n)=>{try{if(e.install=t=>{for(const r of[e,...Object.values(n!=null?n:{})])r.name&&t.component(r.name,r)},n)for(const[t,r]of Object.entries(n))e[t]=r;return e}catch(t){}};function K(e){const n=typeof e;return e!=null&&(n==="object"||n==="function")}function A(e){return typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function P(e){if(typeof e=="boolean"||typeof e=="number")return!1;if(Array.isArray(e)){if(e.length===0)return!0}else if(e instanceof Object&&JSON.stringify(e)==="{}")return!0;return e==null||e==="null"||e==="undefined"||e===""}function Z(){return window.top!==window}function Q(e){return toString.call(e)==="[object Blob]"}function ee(e){if(e.startsWith("data:image"))return!0;const n=e.lastIndexOf("."),t=n>=0?e.slice(n+1).toLowerCase():"";return["png","jpg","jpeg","gif","bmp","webp","svg"].includes(t)}function te(e,n){for(;e;){if(e===n)return!0;e=Object.getPrototypeOf(e)}return!1}const k=(e,n)=>{const t=A(e),r=A(n);return t&&r?JSON.stringify(e)===JSON.stringify(n):!t&&!r?String(e)===String(n):!1},j=(e,n)=>{if(e=e||[],n=n||[],e.length!==n.length)return!1;for(const[t,r]of e.entries())if(!k(r,n[t]))return!1;return!0},ne=(e,n)=>Array.isArray(e)&&Array.isArray(n)?j(e,n):k(e,n);function re(e,n,t){const r={};let i;typeof t=="function"?i=t:t?i=f=>f[t]:i=f=>f,(e||[]).forEach(f=>{const d=i(f);r[d]={item:f,count:-1}}),(n||[]).forEach(f=>{const d=i(f);r[d]?r[d].count=0:r[d]={item:f,count:1}});const o=[],c=[];for(const f in r)Object.prototype.hasOwnProperty.call(r,f)&&(r[f].count===1?c.push(r[f].item):r[f].count===-1&&o.push(r[f].item));return{changed:o.length+c.length>0,removed:o.length>0,added:c.length>0,removedItems:o,addedItems:c}}const ie=(e,...n)=>{const t=[];return e.forEach(r=>{n.includes(r)||t.push(r)}),t},oe=e=>P(e)?[]:Array.isArray(e)?e:[e],se=(e,n)=>{if(typeof n!="function"){const t=n;n=r=>String(r[t])}return(e||[]).reduce((t,r)=>{const i=n(r);return t[i]||(t[i]=[]),t[i].push(r),t},{})};function ue(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}function $(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}function ae(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase()).replace(/_([a-z])/g,(n,t)=>t.toUpperCase())}const q=(e,n,...t)=>{const r={};return n=(n?[].concat(n):[]).concat(t),e&&n.forEach(i=>{Object.hasOwnProperty.call(e,i)&&(r[i]=e[i])}),r},ce=(e,n,...t)=>{const r={};return n=(n?[].concat(n):[]).concat(t),e&&Object.keys(e).forEach(i=>{n.includes(i)||(r[i]=e[i])}),r},le=(e,...n)=>{for(const t of n)Object.assign(e,q(t,Object.keys(e)));return e};function H(e,...n){A(e)||(e={});for(const t of n)if(A(t))for(const r in t)r==="__proto__"||e===t[r]||(A(t[r])?e[r]=H(e[r],t[r]):e[r]=t[r]);return e}const fe=e=>{const n={};if(e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(P(e[t])||(n[t]=e[t]));return n};function de(e){const n=new WeakMap,t=r=>{if(typeof r=="object"&&r!==null){if(n.has(r))return n.get(r);const i=Array.isArray(r)?[]:{};n.set(r,i);for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&(i[o]=t(r[o]));return i}return r};return t(e)}function W(e,n){try{return JSON.parse(e)}catch(t){return console.error("parse json error:",e),n}}function he(e,n,t){if(!e||!n)return;const r=n.split(".");let i;for(;(i=r.shift())!==void 0&&r.length!==0;)e[i]||(e[i]={}),e=e[i];i&&(e[i]=t)}function _(e,n){if(!e||!n)return;const t=n.split(".");for(const r of t){if(!e)return;e=e[r]}return e}const z=(e,n)=>{for(const t in e)Object.getOwnPropertyDescriptor(n,t)?A(e[t])&&z(e[t],n[t]):n[t]=e[t];return n},pe=(e,n)=>{var t;return(t=e[n])!=null?t:e[$(n)]};function ge(e,n){let{key:t,parentKey:r}=n||{};t=t||"id",r=r||"pid";const i=(e||[]).reduce((c,f)=>(c[_(f,t)]=f,c),{}),o=[];return(e||[]).forEach(c=>{const f=i[_(c,r)];f?(f.children||(f.children=[])).push(c):o.push(c)}),o}function Y(e,n){const t=[];return(e||[]).forEach(r=>{let{children:i,...o}=r;i&&i.length>0&&(i=Y(i,n),i.length>0&&(o.children=i)),n(o)&&t.push(o)}),t}function me(e,n){const t=e?[...e]:[];for(;t.length>0;){const r=t.shift();if(n(r))return r;r.children&&r.children.length>0&&t.push(...r.children)}return null}function we(e,n){const t=(r,i)=>{for(const o of r){if(n(o))return[...i,o];if(o.children&&o.children.length>0){const c=t(o.children,[...i,o]);if(c)return c}}return null};return t(e||[],[])}function ye(e,n){const t={children:e||[]},r=[t];let i,o=-1;for(;r.length>0;){i=r.shift();const{children:c}=i;if(c&&c.length>0){for(const[f,d]of c.entries())if(n(d)){o=f;break}if(o!==-1)break;r.push(...c)}}return{found:o!==-1,parent:i===t?null:i,index:o}}function be(e,n){const t=(e||[]).map(r=>({node:r,parent:null}));for(;t.length>0;){const r=t.shift(),{node:i,parent:o}=r;if(n(i,o)===!1)break;i.children&&i.children.length>0&&t.push(...i.children.map(f=>({node:f,parent:i})))}}function ve(e){const n=[];if(e&&e.length>0){n.push(...e);let t=0;for(;t<n.length;){const{children:r}=n[t];r&&r.length>0&&n.push(...r),t++}}return n}function Ee(e,n,t){t||(t=n);const r=i=>(i||[]).reduce((o,c)=>(c[t]=c[n]+(c.children?r(c.children):0),o+c[t]),0);r(e)}function Fe(e,n){if(!e)return"";const t=new Date(e);if(t.getTime()===0)return"";n=n||"yyyy-MM-dd";let r;const i={"Y+":t.getFullYear().toString(),"y+":t.getFullYear().toString(),"M+":(t.getMonth()+1).toString(),"D+":t.getDate().toString(),"d+":t.getDate().toString(),"h+":(t.getHours()%12||12).toString(),"H+":t.getHours().toString(),"m+":t.getMinutes().toString(),"s+":t.getSeconds().toString(),a:t.getHours()<12?"am":"pm",A:t.getHours()<12?"AM":"PM"};for(const o in i)r=new RegExp(`(${o})`).exec(n),r&&(n=n.replace(r[1],r[1].length===1?i[o]:i[o].padStart(r[1].length,"0")));return n}function Oe(e,n){if(P(e))return"";let{minPrecision:t,maxPrecision:r,decimalPoint:i,thousandSeparator:o,grouping:c}=n||{};t=t!=null?t:0,r=r!=null?r:2,i=i||".",o=o!=null?o:",",c=c!=null?c:3;let[f,d]=`${e}`.split(".");return f=f.replace(new RegExp(`(?<!^-?)(?=(\\d{${c}})+$)`,"g"),o),d=(d||"").slice(0,r).padEnd(t,"0"),d&&(d=i+d),f+d}function Ie(e,n){if(n){const i=P(e[0])||e[0]===Number.NEGATIVE_INFINITY?"-\u221E":e[0],o=P(e[1])||e[1]===+Number.POSITIVE_INFINITY?"+\u221E":e[1];return`${i+(i==="-\u221E"?" < ":" \u2264 ")+n} < ${o}`}const t=P(e[0])||e[0]==="-\u221E"||e[0]==="-Infinity"?"-\u221E":e[0],r=P(e[1])||e[1]==="+\u221E"||e[1]==="Infinity"?"+\u221E":e[1];return`${t==="-\u221E"?"(":"["} ${t}, ${r} )`}function xe(e){if(e=Number(e),Number.isNaN(e))return"";const n=["B","KB","MB","GB","TB","PB"];let t=0;for(;e>=1024&&t<n.length-1;)e/=1024,t++;return e=Math.round(e*100)/100,`${e} ${n[t]}`}function Te(e){return Number.isNaN(Number(e))?e||"":`${Number(e)}px`}const L=e=>new Promise(n=>{setTimeout(n,e)}),De=(e,n)=>new Promise((t,r)=>{(async()=>{try{const o=Date.now(),c=await e(),f=Date.now()-o;f<n&&await L(n-f),t(c)}catch(o){r(o)}})()}),Ae=()=>{const e=Date.now();return{delayTo:async t=>{const r=Date.now()-e;r<t&&await L(t-r)}}},Pe=(e,n,t)=>{let r,i=!1,o;const c=()=>{if(i||e()){r(void 0),clearTimeout(o);return}requestAnimationFrame(c)};return t&&(o=setTimeout(()=>{i=!0},t)),new Promise(f=>{r=f,n?setTimeout(c,n):requestAnimationFrame(c)})},Be=(e,n)=>Math.floor(e+Math.random()*(n-e));function Me(e){return new Promise((n,t)=>{const r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=()=>{if(r.status===200){const i=new FileReader;i.readAsDataURL(r.response),i.onload=o=>{n(o.target.result)},i.onerror=o=>t(o)}else t(new Error("Failed to load file"))},r.onerror=()=>{t(new Error("Failed to load file"))},r.send()})}function Ce(e){return new Promise((n,t)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=i=>{n(i.target.result)},r.onerror=i=>t(i)})}function Se(e){return URL.createObjectURL(e)}function Ue(e){return new Promise((n,t)=>{const r=new FileReader;r.readAsArrayBuffer(e),r.onload=i=>{n(new Blob([i.target.result]))},r.onerror=i=>t(i)})}async function ke(e){if(!e)throw new Error("url is empty");return(await fetch(e)).blob()}async function _e(e){if(!e)throw new Error("url is empty");return new Promise((n,t)=>{const r=new Image;r.onload=()=>{const i=document.createElement("canvas");i.width=r.width,i.height=r.height;const o=i.getContext("2d");o==null||o.drawImage(r,0,0,r.width,r.height),i.toBlob(c=>{c?n(c):t(new Error("transform image to blob failed"))},"image/png")},r.onerror=t,r.src=e})}function Le(e,n){if(!e)return"";if(typeof e=="string"&&(e=new URL(e)),n)for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.searchParams.append(t,n[t]);return e.toString()}function Re(e){return e.replace(/[<>&]/g,n=>`&#${n.charCodeAt(0)};`)}function Ne(e){const n=document.createElement("div");return n.innerHTML=e,n.textContent||n.innerText}async function*je(e,n){const t=new TextDecoder("utf-8"),{original:r}=n||{};let i="";for(;;){const{value:o,done:c}=await e.read();if(c)return;i+=t.decode(o);const f=i.split(`
|
|
2
2
|
`);i=f.pop()||"";for(let d of f)if(d=d.trim(),!!d)if(r)yield d;else{if(d==="event: ping")continue;const I=d.match(/^(?:(\w*):)?(.*)$/);if(!I){console.error("[BufferedReader] parse line failed:",d);continue}const E=I[1],x=W(I[2].trim());if(!x){console.error("[BufferedReader] parse json failed:",I[2].trim());continue}yield{event:E,data:x}}}}const $e=e=>{let{url:n,filename:t}=e;if(t=t||"\u672A\u547D\u540D",n||e.blob&&(n=URL.createObjectURL(e.blob),setTimeout(()=>{URL.revokeObjectURL(n)},1e4)),!n)throw new Error("No URL provided");const r=document.createElement("a");r.href=n,r.download=t,r.click()};function qe(e,n,t){let r,i,o,c,f,d,I=0,E=!1,x=!1,B=!0;if(typeof e!="function")throw new TypeError("Expected a function");n=+n||0,t&&A(t)&&(E=!!t.leading,x="maxWait"in t,o=x?Math.max(+t.maxWait||0,n):o,B="trailing"in t?!!t.trailing:B);function O(g){const v=r,F=i;return r=i=void 0,I=g,c=e.apply(F,v),c}function D(g,v){return setTimeout(g,v)}function s(g){clearTimeout(g)}function l(g){return I=g,f=D(p,n),E?O(g):c}function a(g){const v=g-d,F=g-I,T=n-v;return x?Math.min(T,o-F):T}function u(g){const v=g-d,F=g-I;return d===void 0||v>=n||v<0||x&&F>=o}function p(){const g=Date.now();if(u(g))return m(g);f=D(p,a(g))}function m(g){return f=void 0,B&&r?O(g):(r=i=void 0,c)}function b(){f!==void 0&&s(f),I=0,r=d=i=f=void 0}function h(){return f===void 0?c:m(Date.now())}function y(){return f!==void 0}function w(...g){const v=Date.now(),F=u(v);if(r=g,i=this,d=v,F){if(f===void 0)return l(d);if(x)return f=D(p,n),O(d)}return f===void 0&&(f=D(p,n)),c}return w.cancel=b,w.flush=h,w.pending=y,w}function He(e){const{el:n,msg:t}=e||{},r=t===void 0?"\u8BF7\u5B8C\u5584\u8868\u5355\u5185\u5BB9":t;if(r&&U.error(r),!n)return;const i=n.querySelector(".is-error");i&&i.scrollIntoView({behavior:"smooth",inline:"nearest",block:"center"})}async function We(e,n={successText:"\u590D\u5236\u6210\u529F"}){const{successText:t}=n||{};try{if(navigator.clipboard){await navigator.clipboard.writeText(e),t&&U.success(t);return}}catch(i){}const r=document.createElement("textarea");document.body.appendChild(r),r.style.position="fixed",r.style.clip="rect(0 0 0 0)",r.style.top="10px",r.value=e,r.select(),document.execCommand("copy",!0),document.body.removeChild(r),t&&U.success(t)}function ze(e,...n){if(!e)return;const t=document.createElement("a");t.addEventListener("click",r=>{r.preventDefault(),window.open(e,...n)}),t.click()}function Ye(e){if(!e)return[];const n=[`${e.slice(0,2)}0000`,`${e.slice(0,4)}00`,e.slice(0,6),e.slice(0,9),e.slice(0,12)],t=0,r=n.indexOf(e)+1;return n.slice(t,r)}class N{constructor(n){this._enumItems={};var t;if(n)if(Array.isArray(n))for(const[r,i]of n.entries())this.add((t=i.key)!=null?t:`${r}`,i);else for(const r in n){const i=n[r];this.add(r,i)}}add(n,t){if(this[n])throw new Error(`\u679A\u4E3E\u9879 ${n} \u5DF2\u5B58\u5728`);const r=t.value;return this[n]=r,this._enumItems[r]={...t},this}keys(){return Object.keys(this).filter(n=>n!=="_enumItems")}*[Symbol.iterator](){for(const n of this.keys())yield this.getItem(this[n])}getItem(n){return this._enumItems[n]}getLabel(n){var t;return(t=this.getItem(n))==null?void 0:t.label}getProps(n){var t;return(t=this.getItem(n))==null?void 0:t.props}filter(n){const t=new N;for(const r of this.keys()){const i=this.getItem(this[r]);n(i,r)&&t.add(r,i)}return t}clone(){return this.filter(()=>!0)}set(n,t){const r=this.getItem(this[n]);return r&&Object.assign(r,t),this}remove(n){const t=this[n];return t!==void 0&&(delete this[n],delete this._enumItems[t]),this}forEach(n){for(const t of this.keys())n(this.getItem(this[t]),t)}}const Ge=(e,n)=>{if(!e||!n)return!1;if(n.includes(" "))throw new Error("className should not contain space.");return e.classList.contains(n)};function Je(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var G={exports:{}},R={exports:{}},J;function Ve(){return J||(J=1,function(e,n){(function(t,r){e.exports=r()})(window,function(){return function(t){var r={};function i(o){if(r[o])return r[o].exports;var c=r[o]={i:o,l:!1,exports:{}};return t[o].call(c.exports,c,c.exports,i),c.l=!0,c.exports}return i.m=t,i.c=r,i.d=function(o,c,f){i.o(o,c)||Object.defineProperty(o,c,{enumerable:!0,get:f})},i.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},i.t=function(o,c){if(1&c&&(o=i(o)),8&c||4&c&&typeof o=="object"&&o&&o.__esModule)return o;var f=Object.create(null);if(i.r(f),Object.defineProperty(f,"default",{enumerable:!0,value:o}),2&c&&typeof o!="string")for(var d in o)i.d(f,d,function(I){return o[I]}.bind(null,d));return f},i.n=function(o){var c=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(c,"a",c),c},i.o=function(o,c){return Object.prototype.hasOwnProperty.call(o,c)},i.p="",i(i.s=0)}([function(t,r,i){i.r(r);var o=window,c=/^image\//,f=/\.\w+$/,d={},I={file:null,quality:.8,convertSize:2048e3,loose:!0,redressOrientation:!0},E=function(s){return typeof s=="function"},x=function(s){return c.test(s)};function B(s){s=Object.assign({},I,s),this.options=s,this.file=s.file,this.image=null,this.ParsedOrientationInfo=null,this.init()}var O=B.prototype;for(var D in r.default=B,O.init=function(){var s=this,l=this.file,a=this.options;l&&x(l.type)?(x(a.mimeType)||(a.mimeType=l.type),d.file2Image(l,function(u){E(s.beforeCompress)&&(s.image=u,l.width=u.naturalWidth,l.height=u.naturalHeight,s.beforeCompress(l)),l.type==="image/jpeg"&&a.redressOrientation?s.getParsedOrientationInfo(function(p){s.parsedOrientationInfo=p,s.rendCanvas()}):(s.parsedOrientationInfo={rotate:0,scaleX:1,scaleY:1},s.rendCanvas())},s.error)):s.error("\u8BF7\u4E0A\u4F20\u56FE\u7247\u6587\u4EF6!")},O.rendCanvas=function(){var s=this,l=this.options,a=this.image,u=this.getExpectedEdge(),p=u.dWidth,m=u.dHeight,b=u.width,h=u.height,y=d.image2Canvas(a,p,m,s.beforeDraw.bind(s),s.afterDraw.bind(s),b,h);d.canvas2Blob(y,function(w){w&&(w.width=y.width,w.height=y.height),s.success(w)},l.quality,l.mimeType)},O.beforeCompress=function(){E(this.options.beforeCompress)&&this.options.beforeCompress(this.file)},O.getExpectedEdge=function(){var s,l=this.image,a=this.parsedOrientationInfo.rotate,u=this.options,p=l.naturalWidth,m=l.naturalHeight,b=Math.abs(a)%180==90;b&&(s=m,m=p,p=s);var h=p/m,y=Math.max(u.maxWidth,0)||1/0,w=Math.max(u.maxHeight,0)||1/0,g=Math.max(u.minWidth,0)||0,v=Math.max(u.minHeight,0)||0,F=Math.max(u.width,0)||p,T=Math.max(u.height,0)||m;y<1/0&&w<1/0?w*h>y?w=y/h:y=w*h:y<1/0?w=y/h:w<1/0&&(y=w*h),g>0&&v>0?v*h>g?v=g/h:g=v*h:g>0?v=g/h:v>0&&(g=v*h),T*h>F?T=F/h:F=T*h;var C=F=Math.floor(Math.min(Math.max(F,g),y)),S=T=Math.floor(Math.min(Math.max(T,v),w));return b&&(s=S,S=C,C=s),{dWidth:C,dHeight:S,width:F,height:T}},O.getParsedOrientationInfo=function(s){var l=this;this.getOrientation(function(a){E(s)&&s(l.parseOrientation(a))})},O.getOrientation=function(s){var l=this;d.file2ArrayBuffer(this.file,function(a){E(s)&&s(l.resetAndGetOrientation(a))})},O.resetAndGetOrientation=function(s){var l,a=new DataView(s);try{var u,p,m;if(a.getUint8(0)===255&&a.getUint8(1)===216)for(var b=a.byteLength,h=2;h+1<b;){if(a.getUint8(h)===255&&a.getUint8(h+1)===225){p=h;break}h+=1}if(p){var y=p+4,w=p+10;if(d.getStringFromCharCode(a,y,4)==="Exif"){var g=a.getUint16(w);if(((u=g===18761)||g===19789)&&a.getUint16(w+2,u)===42){var v=a.getUint32(w+4,u);v>=8&&(m=w+v)}}}if(m){var F;for(b=a.getUint16(m,u),F=0;F<b;F+=1)if(h=m+12*F+2,a.getUint16(h,u)===274){h+=8,l=a.getUint16(h,u),a.setUint16(h,1,u);break}}}catch(T){console.error(T),l=1}return l},O.parseOrientation=function(s){var l=0,a=1,u=1;switch(s){case 2:a=-1;break;case 3:l=-180;break;case 4:u=-1;break;case 5:l=90,u=-1;break;case 6:l=90;break;case 7:l=90,a=-1;break;case 8:l=-90}return{rotate:l,scaleX:a,scaleY:u}},O.beforeDraw=function(s,l){var a=this.parsedOrientationInfo,u=a.rotate,p=a.scaleX,m=a.scaleY,b=this.file,h=this.options,y="transparent",w=l.width,g=l.height;switch(b.size>h.convertSize&&h.mimeType==="image/png"&&(y="#fff",h.mimeType="image/jpeg"),s.fillStyle=y,s.fillRect(0,0,w,g),E(h.beforeDraw)&&h.beforeDraw.call(this,s,l),s.save(),u){case 90:s.translate(w,0);break;case-90:s.translate(0,g);break;case-180:s.translate(w,g)}s.rotate(u*Math.PI/180),s.scale(p,m)},O.afterDraw=function(s,l){var a=this.options;E(a.afterDraw)&&a.afterDraw.call(this,s,l)},O.error=function(s){var l=this.options;if(!E(l.error))throw new Error(s);l.error.call(this,s)},O.success=function(s){var l,a,u=this.options,p=this.file,m=this.image,b=this.getExpectedEdge(),h=m.naturalHeight,y=m.naturalWidth;if(s&&s.size)if(!u.loose&&s.size>p.size&&!(b.width>y||b.height>h))console.warn("\u5F53\u524D\u8BBE\u7F6E\u7684\u662F\u975E\u5BBD\u677E\u6A21\u5F0F\uFF0C\u538B\u7F29\u7ED3\u679C\u5927\u4E8E\u6E90\u56FE\u7247\uFF0C\u8F93\u51FA\u6E90\u56FE\u7247"),s=p;else{var w=new Date;s.lastModified=w.getTime(),s.lastModifiedDate=w,s.name=p.name,s.name&&s.type!==p.type&&(s.name=s.name.replace(f,(l=s.type,(a=x(l)?l.substr(6):"")==="jpeg"&&(a="jpg"),"."+a)))}else console.warn("\u56FE\u7247\u538B\u7F29\u51FA\u4E86\u70B9\u610F\u5916\uFF0C\u8F93\u51FA\u6E90\u56FE\u7247"),s=p;E(u.success)&&u.success.call(this,s)},d.file2DataUrl=function(s,l,a){var u=new FileReader;u.onload=function(){l(u.result)},u.onerror=function(){E(a)&&a("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF01")},u.readAsDataURL(s)},d.file2ArrayBuffer=function(s,l,a){var u=new FileReader;u.onload=function(p){l(p.target.result)},u.onerror=function(){E(a)&&a("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF01")},u.readAsArrayBuffer(s)},d.getStringFromCharCode=function(s,l,a){var u,p="";for(a+=l,u=l;u<a;u+=1)p+=String.fromCharCode(s.getUint8(u));return p},d.file2Image=function(s,l,a){var u=new Image,p=o.URL||o.webkitURL;if(o.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(o.navigator.userAgent)&&(u.crossOrigin="anonymous"),u.alt=s.name,u.onerror=function(){E(a)&&a("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01")},p){var m=p.createObjectURL(s);u.onload=function(){l(u),p.revokeObjectURL(m)},u.src=m}else this.file2DataUrl(s,function(b){u.onload=function(){l(u)},u.src=b},a)},d.url2Image=function(s,l,a){var u=new Image;u.src=s,u.onload=function(){l(u)},u.onerror=function(){E(a)&&a("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01")}},d.image2Canvas=function(s,l,a,u,p,m,b){var h=document.createElement("canvas"),y=h.getContext("2d");return h.width=m||s.naturalWidth,h.height=b||s.naturalHeight,E(u)&&u(y,h),y.save(),y.drawImage(s,0,0,l,a),y.restore(),E(p)&&p(y,h),h},d.canvas2DataUrl=function(s,l,a){return s.toDataURL(a||"image/jpeg",l)},d.dataUrl2Image=function(s,l,a){var u=new Image;u.onload=function(){l(u)},u.error=function(){E(a)&&a("\u56FE\u7247\u52A0\u8F7D\u9519\u8BEF\uFF01")},u.src=s},d.dataUrl2Blob=function(s,l){for(var a=s.split(",")[1],u=s.match(/^data:(.*?)(;base64)?,/)[1],p=atob(a),m=a.length,b=new Uint8Array(m),h=0;h<m;h++)b[h]=p.charCodeAt(h);return new Blob([b],{type:l||u})},d.blob2DataUrl=function(s,l,a){this.file2DataUrl(s,l,a)},d.blob2Image=function(s,l,a){this.file2Image(s,l,a)},d.canvas2Blob=function(s,l,a,u){var p=this;HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(m,b,h){var y=this.toDataURL(b,h);m(p.dataUrl2Blob(y))}}),s.toBlob(function(m){l(m)},u||"image/jpeg",a||.8)},d.upload=function(s,l,a){var u=new XMLHttpRequest,p=new FormData;p.append("file",l),u.onreadystatechange=function(){if(u.readyState!==4||u.status!==200)throw new Error(u);a&&a(u.responseText)},u.open("POST",s,!0),u.send(p)},d)d.hasOwnProperty(D)&&(B[D]=d[D])}]).default})}(R)),R.exports}(function(e){e.exports=Ve()})(G);var Xe=Je(G.exports);const Ke=e=>{if(!e.file)throw new Error("file is required");const n=e.file.size/1024;let t=e.quality;if(t===void 0){if(n<200)return e.file;n>200&&n<=512?t=.9:n>512&&n<=1024?t=.8:n>1024&&n<=2048?t=.85:n>2048&&n<=10240?t=.8:n>10240&&n<=20480&&(t=.75)}return new Promise((r,i)=>{var o;new Xe({...e,quality:t,convertSize:(o=e.convertSize)!=null?o:1024,success:c=>{r(c)},error:c=>{i(c)}})})},V=e=>e&&e.split("?")[0].split("/").pop()||"",Ze=e=>(e=V(e),e?(e.split(".").pop()||"").toLowerCase():""),Qe=(e,n,t)=>Math.min(Math.max(t,e),n),M=new Map,et=(e,n=3)=>{if(!e)throw new Error("name is required");let t;return M.has(e)?t=M.get(e):(t={maxNum:n,currentNum:0,queue:[]},M.set(e,t)),{acquire:async()=>new Promise((f,d)=>{t.currentNum>=t.maxNum?t.queue.push({resolve:f,reject:d}):(t.currentNum++,f(!0))}),release:()=>{if(t.queue.length>0){const{resolve:f}=t.queue.shift();f(!0)}else t.currentNum--},destroy:async()=>{M.delete(e)},getMaxNum:()=>t.maxNum}};export{N as Enum,re as arrayDiff,j as arrayEquals,le as assign,ge as buildTree,Le as buildUrl,Qe as clamp,Ee as combineByField,Ke as compressImage,We as copyText,et as createLock,je as createStreamIterator,Ae as createTimer,qe as debounce,Ne as decodeHTMLEntities,H as deepAssign,de as deepClone,Pe as delayWhen,$e as downloadFile,Re as encodeHTMLEntities,Ue as fileToBlob,Ce as fileToDataURL,Se as fileToObjectURL,Y as filterTree,me as findNode,we as findNodeWithPath,ye as findParentAndIndex,ve as flatTree,xe as formatBytes,Fe as formatDate,Ie as formatInterval,Oe as formatNumber,Te as formatPx,Ze as getFileExt,V as getFilename,pe as getProp,_ as getProperty,Be as getRandInt,se as groupBy,He as handleFormValidateError,Ge as hasClass,Q as isBlob,te as isChildClassOf,P as isEmpty,ne as isEqual,Z as isIframe,ee as isImage,K as isObject,A as isPlainObject,k as looseEqual,z as mergeDefaultOptions,ce as omit,fe as omitEmpty,ze as openPage,Ye as parseAreaCode,W as parseJson,q as pick,De as runAtLeastTime,he as setProperty,L as sleep,oe as toArray,ae as toCamelCase,$ as toKebabCase,ue as toUnderscore,ke as urlToBlob,Me as urlToDataURL,_e as urlToPngBlob,be as walkTree,X as withInstall,ie as without};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const next: (n: any
|
|
1
|
+
export declare const next: (n: any) => any;
|
package/es/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.4.
|
|
1
|
+
export declare const version = "1.4.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const next: (n: any
|
|
1
|
+
export declare const next: (n: any) => any;
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.4.
|
|
1
|
+
export declare const version = "1.4.2";
|