@zuzjs/core 0.3.3 → 0.3.4
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 +1 -8
- package/dist/index.d.ts +1 -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'),Z=require('fs/promises'),
|
|
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'),Z=require('fs/promises'),q=require('hashids'),V=require('js-cookie'),G=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 Z__default=/*#__PURE__*/_interopDefault(Z);var q__default=/*#__PURE__*/_interopDefault(q);var V__default=/*#__PURE__*/_interopDefault(V);var G__default=/*#__PURE__*/_interopDefault(G);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",W=(e,t)=>Math.floor(Math.random()*(t-e+1))+e,J=(e,t=6,r=null)=>new q__default.default(r||H,t).encode(e),Ae=(e,t=null)=>{try{let r=new q__default.default(t||H,+process.env.HASHIDS_LENGTH).decode(e);return r.length>=0?Number(r[0]):0}catch{return 0}},Ce=e=>G__default.default(e),Te=e=>J(W(11111111111,999999999999)),z=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,Se=e=>decodeURIComponent(e.replace(/\+/g,"%20")),$e=e=>encodeURIComponent(e),Ee=(e,t)=>`${e}${t!==1?"s":""}`,Q=e=>M.test(e),X=e=>F.test(e),ee=e=>I.test(e),je=e=>O.includes(e.toLowerCase()),Ne=e=>Q(e)||X(e)||ee(e),Re=(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})`},Pe=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),De=()=>w__default.default.CancelToken.source(),Le=e=>w__default.default.defaults.withCredentials=e,Oe=async(e,t,r=60,n=false,s={},o)=>{let i=V__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}},Me=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}},Fe=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Ie=(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"),Ue=e=>$__default.default(e).fromNow(),ze=e=>e[Math.floor(Math.random()*e.length)],qe=({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)},He=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]},Be=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);}),Ye=(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"),j=(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=E(h),N=E(m),v=h.match(o),A=m.match(o),y=v&&A?parseInt(v[0],16):k.length!==1&&Date.parse(h),f=v&&A?parseInt(A[0],16):y&&m.match(c)&&Date.parse(m)||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 R=k.length,P=N.length;for(let b=0,D=Math.max(R,P);b<D;b+=1){let g=j(k[b]||"",R),d=j(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}},Ke=(e,t=false)=>e.toLowerCase().split(/[^a-zA-Z0-9]+/).map((r,n)=>n===0?t?z(r):r:z(r)).join(""),Ze=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),Ve=(e,t,r)=>Math.min(Math.max(e,t),r),Ge=(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"),""),We=e=>new Promise(t=>setTimeout(t,e)),Je=e=>Object.keys(e).filter(t=>isNaN(Number(t))),Qe=async e=>{try{return await Z__default.default.access(e),!0}catch{return false}},Xe=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},et=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=Ce;exports.PubSub=K;exports.SORT=B;exports._=T;exports.__SALT=H;exports.arrayRand=ze;exports.camelCase=Ke;exports.camelCaseToDash=Ze;exports.checkPasswordStrength=et;exports.clamp=Ve;exports.copyToClipboard=Be;exports.enumToKeys=Je;exports.exists=Qe;exports.formatNumber=qe;exports.formatSize=He;exports.fromHash=Ae;exports.getCancelToken=De;exports.hexToRgba=Re;exports.isColor=Ne;exports.isColorName=je;exports.isHexColor=Q;exports.isHslColor=ee;exports.isRgbaColor=X;exports.natsort=Ye;exports.numberInRange=W;exports.pluralize=Ee;exports.removeDuplicates=Pe;exports.sleep=We;exports.slugify=Ge;exports.time=Ie;exports.timeSince=Ue;exports.toHash=J;exports.ucfirst=z;exports.urlBase64ToUint8Array=Xe;exports.urldecode=Se;exports.urlencode=$e;exports.uuid=Te;exports.withCredentials=Le;exports.withGet=Me;exports.withPost=Oe;exports.withTime=Fe;
|
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;
|
|
@@ -146,20 +145,14 @@ declare const camelCase: (str: string, ucf?: boolean) => string;
|
|
|
146
145
|
declare const camelCaseToDash: (str: string) => string;
|
|
147
146
|
declare const clamp: (value: number, min: number, max: number) => number;
|
|
148
147
|
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
148
|
declare const sleep: (ms: number) => Promise<any>;
|
|
155
149
|
declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
|
|
156
150
|
declare const exists: (path: string) => Promise<boolean>;
|
|
157
151
|
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
152
|
declare const checkPasswordStrength: (password: string) => {
|
|
160
153
|
score: number;
|
|
161
154
|
result: string;
|
|
162
155
|
suggestion: string[];
|
|
163
156
|
};
|
|
164
157
|
|
|
165
|
-
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT,
|
|
158
|
+
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, exists, formatNumber, formatSize, fromHash, getCancelToken, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeDuplicates, 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;
|
|
@@ -146,20 +145,14 @@ declare const camelCase: (str: string, ucf?: boolean) => string;
|
|
|
146
145
|
declare const camelCaseToDash: (str: string) => string;
|
|
147
146
|
declare const clamp: (value: number, min: number, max: number) => number;
|
|
148
147
|
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
148
|
declare const sleep: (ms: number) => Promise<any>;
|
|
155
149
|
declare const enumToKeys: <T extends Record<string, any>>(obj: T) => Array<keyof T>;
|
|
156
150
|
declare const exists: (path: string) => Promise<boolean>;
|
|
157
151
|
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
152
|
declare const checkPasswordStrength: (password: string) => {
|
|
160
153
|
score: number;
|
|
161
154
|
result: string;
|
|
162
155
|
suggestion: string[];
|
|
163
156
|
};
|
|
164
157
|
|
|
165
|
-
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT,
|
|
158
|
+
export { _ as "_", type EventListener, type FormatNumberParams, MD5, Events as PubSub, SORT, __SALT, arrayRand, camelCase, camelCaseToDash, checkPasswordStrength, clamp, copyToClipboard, type dynamic, enumToKeys, exists, formatNumber, formatSize, fromHash, getCancelToken, hexToRgba, isColor, isColorName, isHexColor, isHslColor, isRgbaColor, natsort, numberInRange, pluralize, removeDuplicates, 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 V from'fs/promises';import H from'hashids';import G from'js-cookie';import W from'md5';import E from'moment';import z 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 z.v4({exact:true}).test(this._)}isIPv6(){return z.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);}},Z=$;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),Ce=(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}},Te=e=>W(e),Se=e=>Q(J(11111111111,999999999999)),q=e=>`${e.charAt(0).toUpperCase()}${e.substring(1,e.length)}`,$e=e=>decodeURIComponent(e.replace(/\+/g,"%20")),Ee=e=>encodeURIComponent(e),je=(e,t)=>`${e}${t!==1?"s":""}`,X=e=>F.test(e),ee=e=>I.test(e),te=e=>U.test(e),Ne=e=>M.includes(e.toLowerCase()),Re=e=>X(e)||ee(e)||te(e),Pe=(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})`},De=e=>e.reduce((t,r)=>(t.includes(r)||t.push(r),t),[]),Le=()=>_.CancelToken.source(),Oe=e=>_.defaults.withCredentials=e,Me=async(e,t,r=60,n=false,s={},o)=>{let i=G.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}},Fe=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}},Ie=e=>{let t=new Date().getTime(),r=e(),n=new Date().getTime();return {result:r,executionTime:n-t}},Ue=(e,t)=>e?E.unix(+e/1e3).format(t||"YYYY-MM-DD HH:mm:ss"):E().format(t||"YYYY-MM-DD HH:mm:ss"),ze=e=>E(e).fromNow(),qe=e=>e[Math.floor(Math.random()*e.length)],He=({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)},Be=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]},Ye=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);}),Ke=(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"),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=j(h),R=j(m),A=h.match(o),C=m.match(o),y=A&&C?parseInt(A[0],16):v.length!==1&&Date.parse(h),f=A&&C?parseInt(C[0],16):y&&m.match(c)&&Date.parse(m)||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=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}},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),We=(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"),""),Je=e=>new Promise(t=>setTimeout(t,e)),Qe=e=>Object.keys(e).filter(t=>isNaN(Number(t))),Xe=async e=>{try{return await V.access(e),!0}catch{return false}},et=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},tt=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{Te as MD5,Z as PubSub,Y as SORT,S as _,B as __SALT,qe as arrayRand,Ze as camelCase,Ve as camelCaseToDash,tt as checkPasswordStrength,Ge as clamp,Ye as copyToClipboard,Qe as enumToKeys,Xe as exists,He as formatNumber,Be as formatSize,Ce as fromHash,Le as getCancelToken,Pe as hexToRgba,Re as isColor,Ne as isColorName,X as isHexColor,te as isHslColor,ee as isRgbaColor,Ke as natsort,J as numberInRange,je as pluralize,De as removeDuplicates,Je as sleep,We as slugify,Ue as time,ze as timeSince,Q as toHash,q as ucfirst,et as urlBase64ToUint8Array,$e as urldecode,Ee as urlencode,Se as uuid,Oe as withCredentials,Fe as withGet,Me as withPost,Ie 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.4",
|
|
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": [
|