@zuzjs/core 0.3.3 → 0.3.5
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.cjs +2 -2
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +1 -1
- package/dist/react.cjs +2 -0
- package/dist/react.d.cts +10 -0
- package/dist/react.d.ts +10 -0
- package/dist/react.js +1 -0
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var w=require('axios'),
|
|
2
|
-
var O=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var L=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,M=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,I=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var Y=(r=>(r.Asc="ASC",r.Desc="DESC",r))(Y||{});var C=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return U__default.default.v4({exact:true}).test(this._)}isIPv6(){return U__default.default.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this._)}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(i,c)=>{if(i===c)return true;if(i===null||typeof i!="object"||c===null||typeof c!="object")return false;if(Array.isArray(i)&&Array.isArray(c)){if(i.length!==c.length)return false;for(let a=0;a<i.length;a++)if(!s(i[a],c[a]))return false;return true}if(this.isObjectValue(i)&&this.isObjectValue(c)){let a=Object.keys(i),l=Object.keys(c);if(a.length!==l.length)return false;for(let p of a)if(!l.includes(p)||!s(i[p],c[p]))return false;return true}return false},o=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return this.isObjectValue=o,Array.isArray(r)&&Array.isArray(n)||o(r)&&o(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,o)=>n[Number(o)]?.toString()||`%${o}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((o,i)=>t==="desc"?i.localeCompare(o):o.localeCompare(i)),s={};for(let o of n)s[o]=r[o];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},K=e=>new C(e),T=K;var S=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(c=>c.event===t),o=Symbol("listener_id"),i={fun:r,context:n,id:o};return s?s.listeners.push(i):this._events.push({event:t,listeners:[i]}),()=>{let c=this._events.find(a=>a.event===t);c&&(c.listeners=c.listeners.filter(a=>a.id!==o),c.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:o})=>{try{s.apply(o,r);}catch(i){console.error(`Error during event '${String(t)}' emission:`,i);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},V=S;var B="zuzjs-core",X=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,ee=(e,t=6,r=null)=>new H__default.default(r||B,t).encode(e),Ne=(e,t=null)=>{try{let r=new H__default.default(t||B,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},Pe=e=>W__default.default(e),De=e=>ee(X(11111111111,999999999999)),z=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Fe=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Oe=e=>encodeURIComponent(e),Le=(e,t)=>`${e}${t!==1?"s":""}`,te=e=>L.test(e),re=e=>M.test(e),ne=e=>I.test(e),Me=e=>O.includes(e.toLowerCase()),Ie=e=>te(e)||re(e)||ne(e),Ue=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(i=>i+i).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,o=r&255;return `rgba(${n}, ${s}, ${o}, ${t})`},qe=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),ze=()=>w__default.default.CancelToken.source(),He=e=>w__default.default.defaults.withCredentials=e,Be=async(e,t,r=60,n=false,s={},o)=>{let i=G__default.default.get(),c=t,a="application/json";if(t instanceof FormData){a="multipart/form-data";for(let[l,p]of Object.entries(i))t.append(l,p);}else if(typeof t=="object"&&!Array.isArray(t)&&t!==null)c={...t,...i,__stmp:Date.now()/1e3};else if(!T(t).isString())throw new Error("Unsupported data type for withPost");try{let l=await w__default.default({method:"post",url:e,data:c,timeout:r*1e3,headers:{"Content-Type":a,...s},onUploadProgress:o});if(l.data&&(n||"kind"in l.data))return l.data;throw l.data}catch(l){throw l?.response?.data?l.response.data:l.code==="ERR_NETWORK"?{error:l.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:l}},Ye=async(e,t=60,r=false,n={})=>{try{let s=await w__default.default.get(e,{timeout:t*1e3,headers:n});if(s.data&&(r||"kind"in s.data))return s.data;throw s.data}catch(s){throw s?.response?.data?s.response.data:s.code==="ERR_NETWORK"?{error:s.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:s}},Ke=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Ve=(e,t)=>e?E__default.default.unix(+e/1e3).format(t||"YYYY-MM-DD HH:mm:ss"):E__default.default().format(t||"YYYY-MM-DD HH:mm:ss"),Ze=e=>E__default.default(e).fromNow(),Ge=e=>e[Math.floor(Math.random()*e.length)],We=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:o})=>{if(r==="currency"&&!o)throw new TypeError("Currency code is required with currency style.");if(o){let{code:i,style:c,symbol:a}=o,l=new Intl.NumberFormat(t,{style:"currency",currency:i,currencyDisplay:c,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?l.replace(new RegExp(`\\${i}`,"g"),a):l}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},Je=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},Qe=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),Xe=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,o=/^0x[0-9a-f]+$/i,i=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,c=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,l=-a,p=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),R=u=>u.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),$=(u,_)=>(!u.match(t)||_===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,_){let h=p(u),g=p(_);if(!h&&!g)return 0;if(!h&&g)return l;if(h&&!g)return a;let A=R(h),j=R(g),k=h.match(o),v=g.match(o),y=k&&v?parseInt(k[0],16):A.length!==1&&Date.parse(h),f=k&&v?parseInt(v[0],16):y&&g.match(c)&&Date.parse(g)||null;if(f){if(y===f)return 0;if(typeof y=="number"&&typeof f=="number"&&y<f)return l;if(typeof y=="number"&&y>f)return a}let N=A.length,P=j.length;for(let b=0,D=Math.max(N,P);b<D;b+=1){let m=$(A[b]||"",N),d=$(j[b]||"",P);if(isNaN(m)!==isNaN(d))return isNaN(m)?a:l;if(s.test(m+d)&&m.localeCompare){let F=m.localeCompare(d);if(F>0)return a;if(F<0)return l;if(b===D-1)return 0}if(m<d)return l;if(m>d)return a;if(`${m}`<`${d}`)return l;if(`${m}`>`${d}`)return a}return 0}},et=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?z(r):r:z(r)).join(""),tt=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),rt=(e,t,r)=>Math.min(Math.max(e,t),r),nt=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),st=(e,t,r,{lerpFactor:n=.1,threshold:s=.1,multiplier:o=1}={})=>{if(!e.current)return;let i=parseFloat(getComputedStyle(e.current).getPropertyValue(t))||0,c=r*o,a=null,l=()=>{i+=(c-i)*n,e.current&&e.current.style.setProperty(t,`${i}px`),Math.abs(c-i)>s&&(a=requestAnimationFrame(l));};a&&cancelAnimationFrame(a),requestAnimationFrame(l);},ot=e=>new Promise(t=>setTimeout(t,e)),it=e=>Object.keys(e).filter(t=>isNaN(Number(t))),at=async e=>{try{return await Z__default.default.access(e),!0}catch{return false}},lt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;++o)s[o]=n.charCodeAt(o);return s},se=(e,t,r)=>{let n=0;return react.Children.map(e,s=>{if(react.isValidElement(s)){let o=s,i=t(o)?react.cloneElement(o,r(n++,o)):o;return o.props.children?react.cloneElement(i,{children:se(o.props.children,t,r)}):i}return s})},ct=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}};exports.MD5=Pe;exports.PubSub=V;exports.SORT=Y;exports._=T;exports.__SALT=B;exports.addPropsToChildren=se;exports.animateCSSVar=st;exports.arrayRand=Ge;exports.camelCase=et;exports.camelCaseToDash=tt;exports.checkPasswordStrength=ct;exports.clamp=rt;exports.copyToClipboard=Qe;exports.enumToKeys=it;exports.exists=at;exports.formatNumber=We;exports.formatSize=Je;exports.fromHash=Ne;exports.getCancelToken=ze;exports.hexToRgba=Ue;exports.isColor=Ie;exports.isColorName=Me;exports.isHexColor=te;exports.isHslColor=ne;exports.isRgbaColor=re;exports.natsort=Xe;exports.numberInRange=X;exports.pluralize=Le;exports.removeDuplicates=qe;exports.sleep=ot;exports.slugify=nt;exports.time=Ve;exports.timeSince=Ze;exports.toHash=ee;exports.ucfirst=z;exports.urlBase64ToUint8Array=lt;exports.urldecode=Fe;exports.urlencode=Oe;exports.uuid=De;exports.withCredentials=He;exports.withGet=Ye;exports.withPost=Be;exports.withTime=Ke;
|
|
1
|
+
'use strict';var w=require('axios'),W=require('fs/promises'),z=require('hashids'),Z=require('js-cookie'),V=require('md5'),$=require('moment'),U=require('ip-regex');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);var W__default=/*#__PURE__*/_interopDefault(W);var z__default=/*#__PURE__*/_interopDefault(z);var Z__default=/*#__PURE__*/_interopDefault(Z);var V__default=/*#__PURE__*/_interopDefault(V);var $__default=/*#__PURE__*/_interopDefault($);var U__default=/*#__PURE__*/_interopDefault(U);/* ZuzJS Core */
|
|
2
|
+
var O=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var M=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,F=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,I=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var B=(r=>(r.Asc="ASC",r.Desc="DESC",r))(B||{});var C=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return U__default.default.v4({exact:true}).test(this._)}isIPv6(){return U__default.default.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this._)}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(i,c)=>{if(i===c)return true;if(i===null||typeof i!="object"||c===null||typeof c!="object")return false;if(Array.isArray(i)&&Array.isArray(c)){if(i.length!==c.length)return false;for(let a=0;a<i.length;a++)if(!s(i[a],c[a]))return false;return true}if(this.isObjectValue(i)&&this.isObjectValue(c)){let a=Object.keys(i),l=Object.keys(c);if(a.length!==l.length)return false;for(let p of a)if(!l.includes(p)||!s(i[p],c[p]))return false;return true}return false},o=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return this.isObjectValue=o,Array.isArray(r)&&Array.isArray(n)||o(r)&&o(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,o)=>n[Number(o)]?.toString()||`%${o}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((o,i)=>t==="desc"?i.localeCompare(o):o.localeCompare(i)),s={};for(let o of n)s[o]=r[o];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},Y=e=>new C(e),T=Y;var S=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(c=>c.event===t),o=Symbol("listener_id"),i={fun:r,context:n,id:o};return s?s.listeners.push(i):this._events.push({event:t,listeners:[i]}),()=>{let c=this._events.find(a=>a.event===t);c&&(c.listeners=c.listeners.filter(a=>a.id!==o),c.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:o})=>{try{s.apply(o,r);}catch(i){console.error(`Error during event '${String(t)}' emission:`,i);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},K=S;var H="zuzjs-core",G=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,J=(e,t=6,r=null)=>new z__default.default(r||H,t).encode(e),Te=(e,t=null)=>{try{let r=new z__default.default(t||H,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},Se=e=>V__default.default(e),$e=e=>J(G(11111111111,999999999999)),q=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,je=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Ee=e=>encodeURIComponent(e),Ne=(e,t)=>`${e}${t!==1?"s":""}`,Q=e=>M.test(e),X=e=>F.test(e),ee=e=>I.test(e),Re=e=>O.includes(e.toLowerCase()),Pe=e=>Q(e)||X(e)||ee(e),De=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(i=>i+i).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,o=r&255;return `rgba(${n}, ${s}, ${o}, ${t})`},te=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Le=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return te(t).join(" ")},Oe=()=>w__default.default.CancelToken.source(),Me=e=>w__default.default.defaults.withCredentials=e,Fe=async(e,t,r=60,n=false,s={},o)=>{let i=Z__default.default.get(),c=t,a="application/json";if(t instanceof FormData){a="multipart/form-data";for(let[l,p]of Object.entries(i))t.append(l,p);}else if(typeof t=="object"&&!Array.isArray(t)&&t!==null)c={...t,...i,__stmp:Date.now()/1e3};else if(!T(t).isString())throw new Error("Unsupported data type for withPost");try{let l=await w__default.default({method:"post",url:e,data:c,timeout:r*1e3,headers:{"Content-Type":a,...s},onUploadProgress:o});if(l.data&&(n||"kind"in l.data))return l.data;throw l.data}catch(l){throw l?.response?.data?l.response.data:l.code==="ERR_NETWORK"?{error:l.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:l}},Ie=async(e,t=60,r=false,n={})=>{try{let s=await w__default.default.get(e,{timeout:t*1e3,headers:n});if(s.data&&(r||"kind"in s.data))return s.data;throw s.data}catch(s){throw s?.response?.data?s.response.data:s.code==="ERR_NETWORK"?{error:s.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:s}},Ue=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},qe=(e,t)=>e?$__default.default.unix(+e/1e3).format(t||"YYYY-MM-DD HH:mm:ss"):$__default.default().format(t||"YYYY-MM-DD HH:mm:ss"),ze=e=>$__default.default(e).fromNow(),He=e=>e[Math.floor(Math.random()*e.length)],Be=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:o})=>{if(r==="currency"&&!o)throw new TypeError("Currency code is required with currency style.");if(o){let{code:i,style:c,symbol:a}=o,l=new Intl.NumberFormat(t,{style:"currency",currency:i,currencyDisplay:c,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?l.replace(new RegExp(`\\${i}`,"g"),a):l}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},Ye=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},Ke=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),We=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,o=/^0x[0-9a-f]+$/i,i=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,c=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,l=-a,p=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),j=u=>u.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),E=(u,_)=>(!u.match(t)||_===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,_){let h=p(u),m=p(_);if(!h&&!m)return 0;if(!h&&m)return l;if(h&&!m)return a;let k=j(h),N=j(m),v=h.match(o),A=m.match(o),f=v&&A?parseInt(v[0],16):k.length!==1&&Date.parse(h),y=v&&A?parseInt(A[0],16):f&&m.match(c)&&Date.parse(m)||null;if(y){if(f===y)return 0;if(typeof f=="number"&&typeof y=="number"&&f<y)return l;if(typeof f=="number"&&f>y)return a}let R=k.length,P=N.length;for(let b=0,D=Math.max(R,P);b<D;b+=1){let g=E(k[b]||"",R),d=E(N[b]||"",P);if(isNaN(g)!==isNaN(d))return isNaN(g)?a:l;if(s.test(g+d)&&g.localeCompare){let L=g.localeCompare(d);if(L>0)return a;if(L<0)return l;if(b===D-1)return 0}if(g<d)return l;if(g>d)return a;if(`${g}`<`${d}`)return l;if(`${g}`>`${d}`)return a}return 0}},Ze=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?q(r):r:q(r)).join(""),Ve=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Ge=(e,t,r)=>Math.min(Math.max(e,t),r),Je=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),Qe=e=>new Promise(t=>setTimeout(t,e)),Xe=e=>Object.keys(e).filter(t=>isNaN(Number(t))),et=async e=>{try{return await W__default.default.access(e),!0}catch{return false}},tt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;++o)s[o]=n.charCodeAt(o);return s},rt=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}},re=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),nt=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(re);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()};exports.MD5=Se;exports.PubSub=K;exports.SORT=B;exports._=T;exports.__SALT=H;exports.arrayRand=He;exports.camelCase=Ze;exports.camelCaseToDash=Ve;exports.checkPasswordStrength=rt;exports.clamp=Ge;exports.copyToClipboard=Ke;exports.enumToKeys=Xe;exports.escapeRegex=re;exports.exists=et;exports.formatNumber=Be;exports.formatSize=Ye;exports.fromHash=Te;exports.getCancelToken=Oe;exports.hexToRgba=De;exports.isColor=Pe;exports.isColorName=Re;exports.isHexColor=Q;exports.isHslColor=ee;exports.isRgbaColor=X;exports.natsort=We;exports.numberInRange=G;exports.pluralize=Ne;exports.removeDuplicateWords=Le;exports.removeDuplicates=te;exports.removeWords=nt;exports.sleep=Qe;exports.slugify=Je;exports.time=qe;exports.timeSince=ze;exports.toHash=J;exports.ucfirst=q;exports.urlBase64ToUint8Array=tt;exports.urldecode=je;exports.urlencode=Ee;exports.uuid=$e;exports.withCredentials=Me;exports.withGet=Ie;exports.withPost=Fe;exports.withTime=Ue;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CancelTokenSource, AxiosRequestConfig, AxiosProgressEvent } from 'axios';
|
|
2
2
|
export { CancelTokenSource, AxiosProgressEvent as UploadProgressEvent } from 'axios';
|
|
3
|
-
import { ReactNode, ReactElement, RefObject } from 'react';
|
|
4
3
|
|
|
5
4
|
type dynamic = {
|
|
6
5
|
[x: string]: any;
|
|
@@ -126,6 +125,7 @@ declare const isColorName: (color: string) => boolean;
|
|
|
126
125
|
declare const isColor: (color: string) => boolean;
|
|
127
126
|
declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
128
127
|
declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
128
|
+
declare const removeDuplicateWords: (text: string) => string;
|
|
129
129
|
declare const getCancelToken: () => CancelTokenSource;
|
|
130
130
|
declare const withCredentials: (include: boolean) => boolean;
|
|
131
131
|
declare const withPost: <T>(uri: string, data: any, // 'dynamic' usually maps to 'any' or 'Record<string, any>'
|
|
@@ -146,20 +146,16 @@ declare const camelCase: (str: string, ucf?: boolean) => string;
|
|
|
146
146
|
declare const camelCaseToDash: (str: string) => string;
|
|
147
147
|
declare const clamp: (value: number, min: number, max: number) => number;
|
|
148
148
|
declare const slugify: (text: string, separator?: string) => string;
|
|
149
|
-
declare const animateCSSVar: (ref: RefObject<HTMLElement>, variable: string, to: number, { lerpFactor, threshold, multiplier, }?: {
|
|
150
|
-
lerpFactor?: number;
|
|
151
|
-
threshold?: number;
|
|
152
|
-
multiplier?: number;
|
|
153
|
-
}) => void;
|
|
154
149
|
declare const sleep: (ms: number) => Promise<any>;
|
|
155
150
|
declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
|
|
156
151
|
declare const exists: (path: string) => Promise<boolean>;
|
|
157
152
|
declare const urlBase64ToUint8Array: (base64String: string) => Uint8Array;
|
|
158
|
-
declare const addPropsToChildren: (children: ReactNode, conditions: (child: ReactElement<any>) => boolean, getProps: (index: number, element: ReactElement<any>) => object) => ReactNode;
|
|
159
153
|
declare const checkPasswordStrength: (password: string) => {
|
|
160
154
|
score: number;
|
|
161
155
|
result: string;
|
|
162
156
|
suggestion: string[];
|
|
163
157
|
};
|
|
158
|
+
declare const escapeRegex: (str: string) => string;
|
|
159
|
+
declare const removeWords: (text: string, wordsToRemove: string[]) => string;
|
|
164
160
|
|
|
165
|
-
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT,
|
|
161
|
+
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, escapeRegex, exists, formatNumber, formatSize, fromHash, getCancelToken, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeDuplicateWords, removeDuplicates, removeWords, sleep, slugify, type sortOptions, time, timeSince, toHash, ucfirst, urlBase64ToUint8Array, urldecode, urlencode, uuid, withCredentials, withGet, withPost, withTime };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CancelTokenSource, AxiosRequestConfig, AxiosProgressEvent } from 'axios';
|
|
2
2
|
export { CancelTokenSource, AxiosProgressEvent as UploadProgressEvent } from 'axios';
|
|
3
|
-
import { ReactNode, ReactElement, RefObject } from 'react';
|
|
4
3
|
|
|
5
4
|
type dynamic = {
|
|
6
5
|
[x: string]: any;
|
|
@@ -126,6 +125,7 @@ declare const isColorName: (color: string) => boolean;
|
|
|
126
125
|
declare const isColor: (color: string) => boolean;
|
|
127
126
|
declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
128
127
|
declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
128
|
+
declare const removeDuplicateWords: (text: string) => string;
|
|
129
129
|
declare const getCancelToken: () => CancelTokenSource;
|
|
130
130
|
declare const withCredentials: (include: boolean) => boolean;
|
|
131
131
|
declare const withPost: <T>(uri: string, data: any, // 'dynamic' usually maps to 'any' or 'Record<string, any>'
|
|
@@ -146,20 +146,16 @@ declare const camelCase: (str: string, ucf?: boolean) => string;
|
|
|
146
146
|
declare const camelCaseToDash: (str: string) => string;
|
|
147
147
|
declare const clamp: (value: number, min: number, max: number) => number;
|
|
148
148
|
declare const slugify: (text: string, separator?: string) => string;
|
|
149
|
-
declare const animateCSSVar: (ref: RefObject<HTMLElement>, variable: string, to: number, { lerpFactor, threshold, multiplier, }?: {
|
|
150
|
-
lerpFactor?: number;
|
|
151
|
-
threshold?: number;
|
|
152
|
-
multiplier?: number;
|
|
153
|
-
}) => void;
|
|
154
149
|
declare const sleep: (ms: number) => Promise<any>;
|
|
155
150
|
declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
|
|
156
151
|
declare const exists: (path: string) => Promise<boolean>;
|
|
157
152
|
declare const urlBase64ToUint8Array: (base64String: string) => Uint8Array;
|
|
158
|
-
declare const addPropsToChildren: (children: ReactNode, conditions: (child: ReactElement<any>) => boolean, getProps: (index: number, element: ReactElement<any>) => object) => ReactNode;
|
|
159
153
|
declare const checkPasswordStrength: (password: string) => {
|
|
160
154
|
score: number;
|
|
161
155
|
result: string;
|
|
162
156
|
suggestion: string[];
|
|
163
157
|
};
|
|
158
|
+
declare const escapeRegex: (str: string) => string;
|
|
159
|
+
declare const removeWords: (text: string, wordsToRemove: string[]) => string;
|
|
164
160
|
|
|
165
|
-
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT,
|
|
161
|
+
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, escapeRegex, exists, formatNumber, formatSize, fromHash, getCancelToken, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeDuplicateWords, removeDuplicates, removeWords, sleep, slugify, type sortOptions, time, timeSince, toHash, ucfirst, urlBase64ToUint8Array, urldecode, urlencode, uuid, withCredentials, withGet, withPost, withTime };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import _ from'axios';import G from'fs/promises';import B from'hashids';import W from'js-cookie';import J from'md5';import R from'moment';import {Children,isValidElement,cloneElement}from'react';import q from'ip-regex';var L=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var M=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,I=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,U=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var K=(r=>(r.Asc="ASC",r.Desc="DESC",r))(K||{});var T=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return q.v4({exact:true}).test(this._)}isIPv6(){return q.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this._)}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(i,c)=>{if(i===c)return true;if(i===null||typeof i!="object"||c===null||typeof c!="object")return false;if(Array.isArray(i)&&Array.isArray(c)){if(i.length!==c.length)return false;for(let a=0;a<i.length;a++)if(!s(i[a],c[a]))return false;return true}if(this.isObjectValue(i)&&this.isObjectValue(c)){let a=Object.keys(i),l=Object.keys(c);if(a.length!==l.length)return false;for(let p of a)if(!l.includes(p)||!s(i[p],c[p]))return false;return true}return false},o=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return this.isObjectValue=o,Array.isArray(r)&&Array.isArray(n)||o(r)&&o(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,o)=>n[Number(o)]?.toString()||`%${o}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((o,i)=>t==="desc"?i.localeCompare(o):o.localeCompare(i)),s={};for(let o of n)s[o]=r[o];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},V=e=>new T(e),S=V;var E=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(c=>c.event===t),o=Symbol("listener_id"),i={fun:r,context:n,id:o};return s?s.listeners.push(i):this._events.push({event:t,listeners:[i]}),()=>{let c=this._events.find(a=>a.event===t);c&&(c.listeners=c.listeners.filter(a=>a.id!==o),c.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:o})=>{try{s.apply(o,r);}catch(i){console.error(`Error during event '${String(t)}' emission:`,i);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},Z=E;var Y="zuzjs-core",ee=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,te=(e,t=6,r=null)=>new B(r||Y,t).encode(e),Pe=(e,t=null)=>{try{let r=new B(t||Y,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},De=e=>J(e),Fe=e=>te(ee(11111111111,999999999999)),H=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Oe=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Le=e=>encodeURIComponent(e),Me=(e,t)=>`${e}${t!==1?"s":""}`,re=e=>M.test(e),ne=e=>I.test(e),se=e=>U.test(e),Ie=e=>L.includes(e.toLowerCase()),Ue=e=>re(e)||ne(e)||se(e),qe=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(i=>i+i).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,o=r&255;return `rgba(${n}, ${s}, ${o}, ${t})`},ze=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),He=()=>_.CancelToken.source(),Be=e=>_.defaults.withCredentials=e,Ye=async(e,t,r=60,n=false,s={},o)=>{let i=W.get(),c=t,a="application/json";if(t instanceof FormData){a="multipart/form-data";for(let[l,p]of Object.entries(i))t.append(l,p);}else if(typeof t=="object"&&!Array.isArray(t)&&t!==null)c={...t,...i,__stmp:Date.now()/1e3};else if(!S(t).isString())throw new Error("Unsupported data type for withPost");try{let l=await _({method:"post",url:e,data:c,timeout:r*1e3,headers:{"Content-Type":a,...s},onUploadProgress:o});if(l.data&&(n||"kind"in l.data))return l.data;throw l.data}catch(l){throw l?.response?.data?l.response.data:l.code==="ERR_NETWORK"?{error:l.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:l}},Ke=async(e,t=60,r=false,n={})=>{try{let s=await _.get(e,{timeout:t*1e3,headers:n});if(s.data&&(r||"kind"in s.data))return s.data;throw s.data}catch(s){throw s?.response?.data?s.response.data:s.code==="ERR_NETWORK"?{error:s.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:s}},Ve=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Ze=(e,t)=>e?R.unix(+e/1e3).format(t||"YYYY-MM-DD HH:mm:ss"):R().format(t||"YYYY-MM-DD HH:mm:ss"),Ge=e=>R(e).fromNow(),We=e=>e[Math.floor(Math.random()*e.length)],Je=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:o})=>{if(r==="currency"&&!o)throw new TypeError("Currency code is required with currency style.");if(o){let{code:i,style:c,symbol:a}=o,l=new Intl.NumberFormat(t,{style:"currency",currency:i,currencyDisplay:c,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?l.replace(new RegExp(`\\${i}`,"g"),a):l}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},Qe=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},Xe=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),et=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,o=/^0x[0-9a-f]+$/i,i=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,c=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,l=-a,p=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),$=u=>u.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),j=(u,A)=>(!u.match(t)||A===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,A){let h=p(u),g=p(A);if(!h&&!g)return 0;if(!h&&g)return l;if(h&&!g)return a;let k=$(h),N=$(g),v=h.match(o),C=g.match(o),y=v&&C?parseInt(v[0],16):k.length!==1&&Date.parse(h),f=v&&C?parseInt(C[0],16):y&&g.match(c)&&Date.parse(g)||null;if(f){if(y===f)return 0;if(typeof y=="number"&&typeof f=="number"&&y<f)return l;if(typeof y=="number"&&y>f)return a}let P=k.length,D=N.length;for(let b=0,F=Math.max(P,D);b<F;b+=1){let m=j(k[b]||"",P),d=j(N[b]||"",D);if(isNaN(m)!==isNaN(d))return isNaN(m)?a:l;if(s.test(m+d)&&m.localeCompare){let O=m.localeCompare(d);if(O>0)return a;if(O<0)return l;if(b===F-1)return 0}if(m<d)return l;if(m>d)return a;if(`${m}`<`${d}`)return l;if(`${m}`>`${d}`)return a}return 0}},tt=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?H(r):r:H(r)).join(""),rt=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),nt=(e,t,r)=>Math.min(Math.max(e,t),r),st=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),ot=(e,t,r,{lerpFactor:n=.1,threshold:s=.1,multiplier:o=1}={})=>{if(!e.current)return;let i=parseFloat(getComputedStyle(e.current).getPropertyValue(t))||0,c=r*o,a=null,l=()=>{i+=(c-i)*n,e.current&&e.current.style.setProperty(t,`${i}px`),Math.abs(c-i)>s&&(a=requestAnimationFrame(l));};a&&cancelAnimationFrame(a),requestAnimationFrame(l);},it=e=>new Promise(t=>setTimeout(t,e)),at=e=>Object.keys(e).filter(t=>isNaN(Number(t))),lt=async e=>{try{return await G.access(e),!0}catch{return false}},ct=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;++o)s[o]=n.charCodeAt(o);return s},oe=(e,t,r)=>{let n=0;return Children.map(e,s=>{if(isValidElement(s)){let o=s,i=t(o)?cloneElement(o,r(n++,o)):o;return o.props.children?cloneElement(i,{children:oe(o.props.children,t,r)}):i}return s})},ut=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}};export{De as MD5,Z as PubSub,K as SORT,S as _,Y as __SALT,oe as addPropsToChildren,ot as animateCSSVar,We as arrayRand,tt as camelCase,rt as camelCaseToDash,ut as checkPasswordStrength,nt as clamp,Xe as copyToClipboard,at as enumToKeys,lt as exists,Je as formatNumber,Qe as formatSize,Pe as fromHash,He as getCancelToken,qe as hexToRgba,Ue as isColor,Ie as isColorName,re as isHexColor,se as isHslColor,ne as isRgbaColor,et as natsort,ee as numberInRange,Me as pluralize,ze as removeDuplicates,it as sleep,st as slugify,Ze as time,Ge as timeSince,te as toHash,H as ucfirst,ct as urlBase64ToUint8Array,Oe as urldecode,Le as urlencode,Fe as uuid,Be as withCredentials,Ke as withGet,Ye as withPost,Ve as withTime};
|
|
1
|
+
import _ from'axios';import Z from'fs/promises';import H from'hashids';import V from'js-cookie';import G from'md5';import j from'moment';import q from'ip-regex';var M=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];var F=/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/,I=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/,U=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;var Y=(r=>(r.Asc="ASC",r.Desc="DESC",r))(Y||{});var T=class{_;constructor(t){this._=t;}isIP(){return this.isIPv4()||this.isIPv6()}isIPv4(){return q.v4({exact:true}).test(this._)}isIPv6(){return q.v6({exact:true}).test(this._)}isTypeof(t){return typeof this._==typeof t}isFunction(){return typeof this._=="function"}isArray(){return Array.isArray(this._)}isNull(){return this._===null}isString(){return typeof this._=="string"}isNumber(){return /^[+-]?\d+(\.\d+)?$/.test(this._)}isObject(){return typeof this._=="object"&&!Array.isArray(this._)&&this._!==null}isEmpty(){return Array.isArray(this._)?this._.length===0:typeof this._=="object"&&this._!==null?Object.keys(this._).length===0:this._===""||String(this._).length===0}isEmail(){return typeof this._=="string"&&/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(this._)}isUrl(){return typeof this._=="string"&&/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/.test(this._)}toLowerCase(){return this._=typeof this._=="string"?this._.toLowerCase():String(this._).toLowerCase(),this}equals(t){let r=this._,n=t,s=(i,c)=>{if(i===c)return true;if(i===null||typeof i!="object"||c===null||typeof c!="object")return false;if(Array.isArray(i)&&Array.isArray(c)){if(i.length!==c.length)return false;for(let a=0;a<i.length;a++)if(!s(i[a],c[a]))return false;return true}if(this.isObjectValue(i)&&this.isObjectValue(c)){let a=Object.keys(i),l=Object.keys(c);if(a.length!==l.length)return false;for(let p of a)if(!l.includes(p)||!s(i[p],c[p]))return false;return true}return false},o=i=>typeof i=="object"&&i!==null&&!Array.isArray(i);return this.isObjectValue=o,Array.isArray(r)&&Array.isArray(n)||o(r)&&o(n)?s(r,n):r===n}isObjectValue(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}ucfirst(){return this._=typeof this._=="string"?this._.charAt(0).toUpperCase()+this._.slice(1):this._,this}formatString(t,...r){typeof this._!="string"&&(this._="");let n=[t,...r];return this._=this._.replace(/%(\d+)/g,(s,o)=>n[Number(o)]?.toString()||`%${o}`),this}camelCase(){return this._=typeof this._=="string"?this._.split(/[^a-zA-Z0-9]+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join(""):this._,this}sort(t="asc"){if(!this.isObject())return console.warn("sortKeys can only be applied to objects. Current value is not an object."),this;let r=this._,n=Object.keys(r).sort((o,i)=>t==="desc"?i.localeCompare(o):o.localeCompare(i)),s={};for(let o of n)s[o]=r[o];return this._=s,this}value(){return this._}valueOf(){return this._}toString(){return String(this._)}[Symbol.toPrimitive](t){return t==="number"?Number(this._):t==="boolean"?!!this._:String(this._)}},K=e=>new T(e),S=K;var $=class{_events;constructor(){this._events=[];}on(t,r,n){let s=this._events.find(c=>c.event===t),o=Symbol("listener_id"),i={fun:r,context:n,id:o};return s?s.listeners.push(i):this._events.push({event:t,listeners:[i]}),()=>{let c=this._events.find(a=>a.event===t);c&&(c.listeners=c.listeners.filter(a=>a.id!==o),c.listeners.length===0&&(this._events=this._events.filter(a=>a.event!==t)));}}off(t,r){let n=this._events.find(s=>s.event===t);n&&(n.listeners=n.listeners.filter(s=>s.fun!==r),n.listeners.length===0&&(this._events=this._events.filter(s=>s.event!==t)));}emit(t,...r){let n=this._events.find(s=>s.event===t);n&&[...n.listeners].forEach(({fun:s,context:o})=>{try{s.apply(o,r);}catch(i){console.error(`Error during event '${String(t)}' emission:`,i);}});}removeAllListeners(t){this._events=this._events.filter(r=>r.event!==t);}},W=$;var B="zuzjs-core",J=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,Q=(e,t=6,r=null)=>new H(r||B,t).encode(e),Se=(e,t=null)=>{try{let r=new H(t||B,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},$e=e=>G(e),je=e=>Q(J(11111111111,999999999999)),z=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Ee=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Ne=e=>encodeURIComponent(e),Re=(e,t)=>`${e}${t!==1?"s":""}`,X=e=>F.test(e),ee=e=>I.test(e),te=e=>U.test(e),Pe=e=>M.includes(e.toLowerCase()),De=e=>X(e)||ee(e)||te(e),Le=(e,t=1)=>{e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(i=>i+i).join(""));let r=parseInt(e,16),n=r>>16&255,s=r>>8&255,o=r&255;return `rgba(${n}, ${s}, ${o}, ${t})`},re=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Oe=e=>{if(!e.trim())return "";let t=e.split(/\s+/).filter(Boolean);return re(t).join(" ")},Me=()=>_.CancelToken.source(),Fe=e=>_.defaults.withCredentials=e,Ie=async(e,t,r=60,n=false,s={},o)=>{let i=V.get(),c=t,a="application/json";if(t instanceof FormData){a="multipart/form-data";for(let[l,p]of Object.entries(i))t.append(l,p);}else if(typeof t=="object"&&!Array.isArray(t)&&t!==null)c={...t,...i,__stmp:Date.now()/1e3};else if(!S(t).isString())throw new Error("Unsupported data type for withPost");try{let l=await _({method:"post",url:e,data:c,timeout:r*1e3,headers:{"Content-Type":a,...s},onUploadProgress:o});if(l.data&&(n||"kind"in l.data))return l.data;throw l.data}catch(l){throw l?.response?.data?l.response.data:l.code==="ERR_NETWORK"?{error:l.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:l}},Ue=async(e,t=60,r=false,n={})=>{try{let s=await _.get(e,{timeout:t*1e3,headers:n});if(s.data&&(r||"kind"in s.data))return s.data;throw s.data}catch(s){throw s?.response?.data?s.response.data:s.code==="ERR_NETWORK"?{error:s.code,message:navigator.onLine?"Unable to connect to the server. It may be temporarily down.":"Network error: Unable to connect. Please check your internet connection and try again."}:s}},qe=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},ze=(e,t)=>e?j.unix(+e/1e3).format(t||"YYYY-MM-DD HH:mm:ss"):j().format(t||"YYYY-MM-DD HH:mm:ss"),He=e=>j(e).fromNow(),Be=e=>e[Math.floor(Math.random()*e.length)],Ye=({number:e,locale:t="en-US",style:r="decimal",decimal:n=2,forceDecimal:s=false,currency:o})=>{if(r==="currency"&&!o)throw new TypeError("Currency code is required with currency style.");if(o){let{code:i,style:c,symbol:a}=o,l=new Intl.NumberFormat(t,{style:"currency",currency:i,currencyDisplay:c,minimumFractionDigits:s||+e%1>0?n:0,maximumFractionDigits:s||+e%1>0?n:0}).format(+e);return a?l.replace(new RegExp(`\\${i}`,"g"),a):l}return new Intl.NumberFormat(t,{style:r,minimumFractionDigits:s?n:+e%1>0?2:0,maximumFractionDigits:s?n:+e%1>0?2:0}).format(+e)},Ke=e=>{let t=["Bytes","KB","MB","GB","TB"],r=typeof e=="string"?parseFloat(e):e;if(r==0)return "0 Byte";let n=Math.floor(Math.log(r)/Math.log(1024)),s=typeof n=="string"?parseInt(n):n;return (r/Math.pow(1024,s)).toFixed(2)+" "+t[s]},We=e=>navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e):new Promise((t,r)=>{let n=document.createElement("textarea");n.value=e,n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),t("Copied to clipboard");}catch(s){r(s);}document.body.removeChild(n);}),Ze=(e={direction:"ASC",caseSensitive:false})=>{let t=/^0/,r=/\s+/g,n=/^\s+|\s+$/g,s=/[^\x00-\x80]/,o=/^0x[0-9a-f]+$/i,i=/(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g,c=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=e.direction=="DESC"?-1:1,l=-a,p=e.caseSensitive?u=>`${u}`.replace(n,""):u=>u.toString().toLowerCase().replace(n,""),E=u=>u.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),N=(u,k)=>(!u.match(t)||k===1)&&parseFloat(u)||u.replace(r," ").replace(n,"")||0;return function(u,k){let h=p(u),m=p(k);if(!h&&!m)return 0;if(!h&&m)return l;if(h&&!m)return a;let v=E(h),R=E(m),A=h.match(o),C=m.match(o),f=A&&C?parseInt(A[0],16):v.length!==1&&Date.parse(h),y=A&&C?parseInt(C[0],16):f&&m.match(c)&&Date.parse(m)||null;if(y){if(f===y)return 0;if(typeof f=="number"&&typeof y=="number"&&f<y)return l;if(typeof f=="number"&&f>y)return a}let P=v.length,D=R.length;for(let b=0,L=Math.max(P,D);b<L;b+=1){let g=N(v[b]||"",P),d=N(R[b]||"",D);if(isNaN(g)!==isNaN(d))return isNaN(g)?a:l;if(s.test(g+d)&&g.localeCompare){let O=g.localeCompare(d);if(O>0)return a;if(O<0)return l;if(b===L-1)return 0}if(g<d)return l;if(g>d)return a;if(`${g}`<`${d}`)return l;if(`${g}`>`${d}`)return a}return 0}},Ve=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?z(r):r:z(r)).join(""),Ge=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Je=(e,t,r)=>Math.min(Math.max(e,t),r),Qe=(e,t="-")=>e==null?(console.log(e,"is undefined"),""):e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\p{L}\p{N}]+/gu,t).replace(new RegExp(`\\${t}{2,}`,"g"),t).replace(new RegExp(`^\\${t}|\\${t}$`,"g"),""),Xe=e=>new Promise(t=>setTimeout(t,e)),et=e=>Object.keys(e).filter(t=>isNaN(Number(t))),tt=async e=>{try{return await Z.access(e),!0}catch{return false}},rt=e=>{let t="=".repeat((4-e.length%4)%4),r=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;++o)s[o]=n.charCodeAt(o);return s},nt=e=>{let t=[],r=0;return e.length>=8?r++:t.push("Use at least 8 characters"),/[a-z]/.test(e)?r++:t.push("Add lowercase letters"),/[A-Z]/.test(e)?r++:t.push("Add uppercase letters"),/\d/.test(e)?r++:t.push("Include numbers"),/[^A-Za-z0-9]/.test(e)?r++:t.push("Add special characters (e.g. !, @, #)"),{score:r,result:r<=2?"Weak":r==3?"Moderate":r==4?"Strong":"Excellent",suggestion:t}},ne=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),st=(e,t)=>{if(t.length===0)return e.trim();let r=t.map(s=>s.trim()).filter(Boolean).map(ne);if(r.length===0)return e.trim();let n=new RegExp(`\\b(${r.join("|")})\\b`,"gi");return e.replace(n,"").replace(/\s+/g," ").trim()};export{$e as MD5,W as PubSub,Y as SORT,S as _,B as __SALT,Be as arrayRand,Ve as camelCase,Ge as camelCaseToDash,nt as checkPasswordStrength,Je as clamp,We as copyToClipboard,et as enumToKeys,ne as escapeRegex,tt as exists,Ye as formatNumber,Ke as formatSize,Se as fromHash,Me as getCancelToken,Le as hexToRgba,De as isColor,Pe as isColorName,X as isHexColor,te as isHslColor,ee as isRgbaColor,Ze as natsort,J as numberInRange,Re as pluralize,Oe as removeDuplicateWords,re as removeDuplicates,st as removeWords,Xe as sleep,Qe as slugify,ze as time,He as timeSince,Q as toHash,z as ucfirst,rt as urlBase64ToUint8Array,Ee as urldecode,Ne as urlencode,je as uuid,Fe as withCredentials,Ue as withGet,Ie as withPost,qe as withTime};
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var react=require('react');/* ZuzJS Core */
|
|
2
|
+
var E=(n,r,a,{lerpFactor:m=.1,threshold:l=.1,multiplier:e=1}={})=>{if(!n.current)return;let t=parseFloat(getComputedStyle(n.current).getPropertyValue(r))||0,o=a*e,c=null,i=()=>{t+=(o-t)*m,n.current&&n.current.style.setProperty(r,`${t}px`),Math.abs(o-t)>l&&(c=requestAnimationFrame(i));};c&&cancelAnimationFrame(c),requestAnimationFrame(i);},d=(n,r,a)=>{let m=0;return react.Children.map(n,l=>{if(react.isValidElement(l)){let e=l,t=r(e)?react.cloneElement(e,a(m++,e)):e;return e.props.children?react.cloneElement(t,{children:d(e.props.children,r,a)}):t}return l})};exports.addPropsToChildren=d;exports.animateCSSVar=E;
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode, ReactElement, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const animateCSSVar: (ref: RefObject<HTMLElement>, variable: string, to: number, { lerpFactor, threshold, multiplier, }?: {
|
|
4
|
+
lerpFactor?: number;
|
|
5
|
+
threshold?: number;
|
|
6
|
+
multiplier?: number;
|
|
7
|
+
}) => void;
|
|
8
|
+
declare const addPropsToChildren: (children: ReactNode, conditions: (child: ReactElement<any>) => boolean, getProps: (index: number, element: ReactElement<any>) => object) => ReactNode;
|
|
9
|
+
|
|
10
|
+
export { addPropsToChildren, animateCSSVar };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode, ReactElement, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const animateCSSVar: (ref: RefObject<HTMLElement>, variable: string, to: number, { lerpFactor, threshold, multiplier, }?: {
|
|
4
|
+
lerpFactor?: number;
|
|
5
|
+
threshold?: number;
|
|
6
|
+
multiplier?: number;
|
|
7
|
+
}) => void;
|
|
8
|
+
declare const addPropsToChildren: (children: ReactNode, conditions: (child: ReactElement<any>) => boolean, getProps: (index: number, element: ReactElement<any>) => object) => ReactNode;
|
|
9
|
+
|
|
10
|
+
export { addPropsToChildren, animateCSSVar };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {Children,isValidElement,cloneElement}from'react';var C=(n,r,a,{lerpFactor:m=.1,threshold:l=.1,multiplier:e=1}={})=>{if(!n.current)return;let t=parseFloat(getComputedStyle(n.current).getPropertyValue(r))||0,o=a*e,c=null,i=()=>{t+=(o-t)*m,n.current&&n.current.style.setProperty(r,`${t}px`),Math.abs(o-t)>l&&(c=requestAnimationFrame(i));};c&&cancelAnimationFrame(c),requestAnimationFrame(i);},d=(n,r,a)=>{let m=0;return Children.map(n,l=>{if(isValidElement(l)){let e=l,t=r(e)?cloneElement(e,a(m++,e)):e;return e.props.children?cloneElement(t,{children:d(e.props.children,r,a)}):t}return l})};export{d as addPropsToChildren,C as animateCSSVar};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuzjs/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"core",
|
|
6
6
|
"zuz",
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"import": "./dist/index.js",
|
|
22
22
|
"require": "./dist/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./react": {
|
|
25
|
+
"types": "./dist/react.d.ts",
|
|
26
|
+
"import": "./dist/react.js",
|
|
27
|
+
"require": "./dist/react.cjs"
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
30
|
"files": [
|