@primereact/hooks 11.0.0-alpha.1 → 11.0.0-alpha.10
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/index.d.ts +12 -0
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +3 -3
- package/use-controlled-state/index.mjs +1 -1
- package/use-controlled-state/index.mjs.map +1 -1
- package/use-hot-key/index.d.ts +25 -0
- package/use-hot-key/index.mjs +2 -0
- package/use-hot-key/index.mjs.map +1 -0
- package/use-intersection-observer/index.d.ts +58 -0
- package/use-intersection-observer/index.mjs +2 -0
- package/use-intersection-observer/index.mjs.map +1 -0
- package/use-intersection-observer/index.test.d.ts +0 -0
- package/use-key-filter/index.d.ts +42 -0
- package/use-key-filter/index.mjs +2 -0
- package/use-key-filter/index.mjs.map +1 -0
- package/use-key-filter/index.test.d.ts +0 -0
- package/use-mask/index.d.ts +109 -0
- package/use-mask/index.mjs +2 -0
- package/use-mask/index.mjs.map +1 -0
- package/use-mask/index.test.d.ts +0 -0
- package/use-number-formatter/index.d.ts +194 -0
- package/use-number-formatter/index.mjs +2 -0
- package/use-number-formatter/index.mjs.map +1 -0
- package/use-number-formatter/index.test.d.ts +0 -0
- package/use-presence/index.d.ts +21 -0
- package/use-presence/index.mjs +2 -0
- package/use-presence/index.mjs.map +1 -0
- package/use-presence/index.test.d.ts +0 -0
- package/use-props/index.d.ts +11 -11
- package/use-props/index.mjs +1 -1
- package/use-props/index.mjs.map +1 -1
- package/use-queue-task/index.d.ts +1 -0
- package/use-queue-task/index.mjs +2 -0
- package/use-queue-task/index.mjs.map +1 -0
- package/use-queue-task/index.test.d.ts +0 -0
- package/use-scrolltop/index.d.ts +59 -0
- package/use-scrolltop/index.mjs +2 -0
- package/use-scrolltop/index.mjs.map +1 -0
- package/use-scrolltop/index.test.d.ts +0 -0
- package/use-visibility-change/index.d.ts +14 -0
- package/use-visibility-change/index.mjs +2 -0
- package/use-visibility-change/index.mjs.map +1 -0
- package/use-visibility-change/index.test.d.ts +0 -0
package/index.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
export * from './use-attr-selector';
|
|
2
|
+
export * from './use-controlled-state';
|
|
3
|
+
export * from './use-event-listener';
|
|
4
|
+
export * from './use-hot-key';
|
|
2
5
|
export * from './use-id';
|
|
6
|
+
export * from './use-key-filter';
|
|
7
|
+
export * from './use-mask';
|
|
8
|
+
export * from './use-match-media';
|
|
3
9
|
export * from './use-mount-effect';
|
|
10
|
+
export * from './use-number-formatter';
|
|
11
|
+
export * from './use-presence';
|
|
12
|
+
export * from './use-previous';
|
|
4
13
|
export * from './use-props';
|
|
14
|
+
export * from './use-queue-task';
|
|
15
|
+
export * from './use-scrolltop';
|
|
5
16
|
export * from './use-unmount-effect';
|
|
6
17
|
export * from './use-update-effect';
|
|
7
18
|
export * from './use-view-transition';
|
|
19
|
+
export * from './use-visibility-change';
|
package/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var l=Object.defineProperty;var i=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var p=(t,r,e)=>r in t?l(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,R=(t,r)=>{for(var e in r||(r={}))P.call(r,e)&&p(t,e,r[e]);if(i)for(var e of i(r))x.call(r,e)&&p(t,e,r[e]);return t};import*as n from"react";function E(t=""){let r=n.useId();return n.useMemo(()=>`${t}${r.replaceAll(/:|«|»/g,"")}`.trim().toLowerCase(),[r,t])}import*as o from"react";function w(t){let r=o.useId(),[e,s]=o.useState(t||`pr_id_${r.replaceAll(/:|«|»/g,"")}`);return o.useEffect(()=>{s(t||`pr_id_${r.replaceAll(/:|«|»/g,"")}`)},[t,r]),e}import*as a from"react";function b(t){let r=a.useRef(!1);a.useEffect(()=>{r.current||(r.current=!0,t==null||t())},[])}import*as m from"react";function T(t={},r={}){return m.useMemo(()=>{let e={props:R({},r),attrs:{}};return Object.entries(t).forEach(([s,u])=>{s in r?e.props[s]=u:e.attrs[s]=u}),e},[t,r])}import*as f from"react";function S(t){f.useEffect(()=>()=>{t==null||t()},[])}import*as c from"react";function $(t,r){let e=c.useRef(!1);c.useEffect(()=>{if(!e.current){e.current=!0;return}return t==null?void 0:t()},r)}import*as d from"react";function M(){return d.useCallback(r=>{document.startViewTransition?document.startViewTransition(()=>{r()}):r()},[])}export{E as useAttrSelector,w as useId,b as useMountEffect,T as useProps,S as useUnmountEffect,$ as useUpdateEffect,M as useViewTransition};
|
|
1
|
+
var Ce=Object.defineProperty,Se=Object.defineProperties;var Fe=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var ye=(n,e,r)=>e in n?Ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,se=(n,e)=>{for(var r in e||(e={}))Pe.call(e,r)&&ye(n,r,e[r]);if(ve)for(var r of ve(e))He.call(e,r)&&ye(n,r,e[r]);return n},Me=(n,e)=>Se(n,Fe(e));import*as ue from"react";function Ae(n=""){let e=ue.useId();return ue.useMemo(()=>`${n}${e.replaceAll(/:|«|»/g,"")}`.trim().toLowerCase(),[e,n])}import{resolve as De}from"@primeuix/utils";import*as z from"react";function $e({value:n,defaultValue:e,onChange:r}){let m=z.useRef(n!==void 0).current,[x,h]=z.useState(()=>m?void 0:e!=null?e:n),i=m?n:x,p=z.useCallback(d=>{let[u,f]=De(d,i,m);r==null||r(f),m||h(u)},[i,m,r]);return z.useEffect(()=>{m||h(e)},[e,m]),[i,p,m]}import{getTargetElement as Te,isNotEmpty as Ke}from"@primeuix/utils";import*as G from"react";import*as ce from"react";function be(n){let e=ce.useRef(null);return ce.useEffect(()=>(e.current=n,()=>{e.current=null}),[n]),e.current}function ze({target:n="document",type:e,listener:r,options:R,when:m=!0}){let x=G.useRef(null),h=G.useRef(null),i=be(r),p=be(R),d=(v={})=>{let{target:I}=v;Ke(I)&&(u(),(v.when||m)&&(x.current=Te(I))),!h.current&&x.current&&(h.current=C=>r&&r(C),x.current.addEventListener(e,h.current,R))},u=()=>{var v;h.current&&((v=x.current)==null||v.removeEventListener(e,h.current,R),h.current=null)},f=()=>{u(),i=null,p=null},E=G.useCallback(()=>{m?x.current=Te(n):(u(),x.current=null)},[n,m]);return G.useEffect(()=>()=>{f()},[]),G.useEffect(()=>{E()},[E]),G.useEffect(()=>{let v=`${i}`!=`${r}`,I=p!==R,C=h.current;C&&(v||I)?(u(),m&&d()):C||f()},[r,R,m]),[d,u]}import*as ee from"react";function Qe(n,e,r={}){let{target:R,event:m="keydown",when:x=!0}=r,h=ee.useRef(e),i=u=>{let f=u.toLowerCase();return f==="space"||f==="spacebar"?" ":f},p=u=>{let f=u.split("+").map(I=>I.trim().toLowerCase()).filter(Boolean),E,v={ctrl:!1,meta:!1,alt:!1,shift:!1};return f.forEach(I=>{switch(I){case"ctrl":case"control":v.ctrl=!0;break;case"meta":case"cmd":case"command":v.meta=!0;break;case"alt":case"option":v.alt=!0;break;case"shift":v.shift=!0;break;default:E=i(I)}}),{key:E,required:v}},d=(u,f)=>{if(!u.key)return!1;let{required:E}=u;return E.ctrl!==f.ctrlKey||E.meta!==f.metaKey||E.alt!==f.altKey||E.shift!==f.shiftKey?!1:i(f.key)===u.key};ee.useEffect(()=>{h.current=e},[e]),ee.useEffect(()=>{if(!x)return;let u=R!=null?R:typeof document!="undefined"?document:null;if(!u)return;let f=(Array.isArray(n)?n:[n]).map(p),E=v=>{var C;let I=v;f.some(P=>d(P,I))&&((C=h.current)==null||C.call(h,I))};return u.addEventListener(m,E),()=>{u.removeEventListener(m,E)}},[m,n,R,x])}import*as Z from"react";function Ze(n){let e=Z.useId(),[r,R]=Z.useState(n||`pr_id_${e.replaceAll(/:|«|»/g,"")}`);return Z.useEffect(()=>{R(n||`pr_id_${e.replaceAll(/:|«|»/g,"")}`)},[n,e]),r}import{isAndroid as Ie}from"@primeuix/utils";function et(n){let{pattern:e=/./,validateOnly:r=!1}=n,R={pint:/[\d]/,int:/[\d-]/,pnum:/[\d.]/,money:/[\d.\s,]/,num:/[\d-.]/,hex:/[0-9a-f]/i,email:/[a-z0-9_.-@]/i,alpha:/[a-z_]/i,alphanum:/[a-z0-9_]/},m=()=>typeof e=="string"?R[e]:e,x=u=>{r||!Ie()||p(u,u.data)},h=u=>{r||Ie()||u.ctrlKey||u.altKey||u.metaKey||p(u,u.key)},i=u=>{if(r)return;let f=m();[...u.clipboardData.getData("text")].forEach(v=>{if(!f.test(v))return u.preventDefault(),!1})},p=(u,f)=>{if(f==null||!(f.length<=2))return;m().test(f)||u.preventDefault()};return{onBeforeInput:x,onKeyPress:h,onPaste:i,validate:u=>{let f=u.target.value,E=!0,v=m();return f&&!v.test(f)&&(E=!1),E}}}import{useMountEffect as Ue}from"@primereact/hooks";import{getUserAgent as xe}from"@primeuix/utils";import*as F from"react";function st(n){let{mask:e,unmask:r,slotChar:R="_",autoClear:m=!0,readOnly:x=!1,onMaskChange:h,target:i}=n,p=F.useRef(0),d=F.useRef([]),u=F.useRef([]),f=F.useRef(null),E=F.useRef(0),v=F.useRef(!1),I=F.useRef(!1),C=F.useRef(null),P=F.useRef(null),W=F.useRef(0),H=F.useRef(null),L=F.useRef(null),D=F.useRef(null),k=t=>{"isComposing"in t&&t.isComposing||(v.current?pe():re(t))},A=t=>{var $;if(x)return;let s=t.code,a,o,b,T=/iphone/i.test(xe());if(L.current=i==null?void 0:i.value,s==="Backspace"||s==="Delete"||T&&s==="Escape"){if(a=w(),!a)return;o=a.begin,b=a.end,b-o===0&&(o=s!=="Delete"?fe(o):b=B(o-1),b=s==="Delete"?B(b):b),J(o,b),te(o,b-1),_(t.target.value),t.preventDefault()}else s==="Enter"?(i.blur(),_(t.target.value)):s==="Escape"&&(i&&(i.value=($=C.current)!=null?$:""),w(0,N()),_(t.target.value),t.preventDefault())},M=t=>{var $;if(x)return;let s=t.code,a=w(),o,b,T;a&&(t.ctrlKey||t.altKey||t.metaKey||t.shiftKey||t.key==="CapsLock"||t.key==="Escape"||t.key==="Tab"||(s&&s!=="Enter"&&(a.end-a.begin!==0&&(J(a.begin,a.end),te(a.begin,a.end-1)),o=B(a.begin-1),o<p.current&&(b=t.key,($=d.current[o])!=null&&$.test(b)&&(me(o),u.current[o]=b,V(),T=B(o),/android/i.test(xe())?setTimeout(()=>{w(T)},0):w(T))),t.preventDefault()),_(t.target.value)))},K=()=>{if(!x)if(H.current&&clearTimeout(H.current),I.current=!0,C.current=i.value,!i.value||i.value===f.current)requestAnimationFrame(()=>{i===document.activeElement&&w(0,0)});else{let t=N();H.current=setTimeout(()=>{i===document.activeElement&&(V(),t===(e==null?void 0:e.replace("?","").length)?w(0,t):w(t))},10)}},q=t=>{if(I.current=!1,N(),_(t.target.value),i.value!==C.current){let s=new Event("change",{bubbles:!0,cancelable:!1});i.dispatchEvent(s)}},Q=t=>{re(t)},w=(t,s)=>{var b,T;let a=0,o=0;return typeof t=="number"?(a=t,o=typeof s=="number"?s:a,i.setSelectionRange(a,o)):i&&(a=(b=i.selectionStart)!=null?b:0,o=(T=i.selectionEnd)!=null?T:0),{begin:a,end:o}},U=t=>t<R.length?R.charAt(t):R.charAt(0),B=t=>{for(;++t<p.current&&!d.current[t];);return t},fe=t=>{for(;--t>=0&&!d.current[t];);return t},te=(t,s)=>{var b,T;let a,o;if(!(t<0)){for(a=t,o=B(s);a<p.current;a++)if(d.current[a]){if(o<p.current&&((b=d.current[a])!=null&&b.test(u.current[o])))u.current[a]=u.current[o],u.current[o]=U(o);else break;o=B(o)}V(),w(Math.max((T=P.current)!=null?T:0,t))}},me=t=>{var T;let s,a,o,b;for(s=t,a=U(t);s<p.current;s++)if(d.current[s])if(o=B(s),b=u.current[s],u.current[s]=a,o<p.current&&((T=d.current[o])!=null&&T.test(b)))a=b;else break},pe=()=>{var a;let t=i.value,s=w();if(s)if(L.current&&L.current.length&&L.current.length>t.length){for(N(!0);s.begin>0&&!d.current[s.begin-1];)s.begin--;if(s.begin===0)for(;s.begin<((a=P.current)!=null?a:0)&&!d.current[s.begin];)s.begin++;w(s.begin,s.begin)}else{for(N(!0);s.begin<p.current&&!d.current[s.begin];)s.begin++;w(s.begin,s.begin)}},J=(t,s)=>{let a;for(a=t;a<s&&a<p.current;a++)d.current[a]&&(u.current[a]=U(a))},V=()=>{i&&(i.value=u.current.join(""))},N=(t=!1)=>{var $,c,l,g;let s=i.value,a=-1,o,b,T;for(o=0,T=0;o<p.current;o++){let y=d.current[o];if(y!==null){for(u.current[o]=U(o);T++<(($=s==null?void 0:s.length)!=null?$:0);)if(b=(c=s==null?void 0:s.charAt(T-1))!=null?c:"",y.test(b)){u.current[o]=b,a=o;break}if(T>((l=s==null?void 0:s.length)!=null?l:0)){J(o+1,p.current);break}}else u.current[o]===(s==null?void 0:s.charAt(T))&&T++,o<E.current&&(a=o)}return t?V():a+1<E.current?m||u.current.join("")===f.current?(i.value&&(i.value=""),J(0,p.current)):V():(V(),i&&(i.value=i.value.substring(0,a+1))),E.current?o:(g=P.current)!=null?g:0},re=t=>{let s=t.type==="paste";if(x||s)return;let a=N(!0);w(a),_(t.target.value)},de=t=>{let s=[],a=t.split("");for(let o=0;o<a.length;o++){let b=a[o];d.current[o]&&b!==U(o)&&s.push(b)}return s.join("")},_=t=>{if(D.current===t)return;let s=r?de(t):t,a=f.current!==s?s:"";D.current=t,i&&(i.value=a),h&&h({value:a})},ge=(t=!0)=>{i&&(i.value==null?(i.value="",t&&_("")):(N(),setTimeout(()=>{i&&(V(),N(),t&&_(i.value))},10)),C.current=i.value)},Re=()=>{d.current=[],E.current=e?e.length:0,p.current=e?e.length:0,P.current=null;let t={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},s=xe();v.current=/chrome/i.test(s)&&/android/i.test(s);let a=e?e.split(""):"";for(let o=0;o<a.length;o++){let b=a[o];b==="?"?(p.current--,E.current=o):t[b]?(d.current.push(new RegExp(t[b])),P.current===null&&(P.current=d.current.length-1),o<E.current&&(W.current=d.current.length-1)):d.current.push(null)}u.current=[];for(let o=0;o<a.length;o++){let b=a[o];b!=="?"&&(t[b]?u.current.push(U(o)):u.current.push(b))}f.current=u.current.join(""),ge(!1)};return Ue(()=>{Re()}),{onMaskInput:k,onMaskKeyDown:A,onMaskKeyPress:M,onMaskFocus:K,onMaskBlur:q,onMaskPaste:Q}}import*as Y from"react";function ct(n,e=!0){let[r,R]=Y.useState(!1),m=Y.useRef(null),x=p=>R(p.matches),h=()=>{var p;return(p=m.current)==null?void 0:p.addEventListener("change",x)},i=()=>{var p;return((p=m.current)==null?void 0:p.removeEventListener("change",x))&&(m.current=null)};return Y.useEffect(()=>(e&&(m.current=window.matchMedia(n),R(m.current.matches),h()),()=>{i()}),[n,e]),r}import*as oe from"react";function at(n){let e=oe.useRef(!1);oe.useEffect(()=>{e.current||(e.current=!0,n==null||n())},[])}import*as S from"react";function lt(n={}){let{value:e,locale:r,localeMatcher:R,mode:m="decimal",currency:x,currencyDisplay:h,useGrouping:i=!0,minFractionDigits:p,maxFractionDigits:d,roundingMode:u,prefix:f,suffix:E,min:v,format:I=!0}=n,C=S.useRef(null),P=S.useRef(null),W=S.useRef(null),H=S.useRef(null),L=S.useRef(null),D=S.useRef(null),k=S.useRef(null),A=S.useRef(null),M=S.useRef(null),K=S.useRef(null),q=S.useRef(null),Q=S.useRef(null),w=()=>({localeMatcher:R,style:m,currency:x,currencyDisplay:h,useGrouping:i,minimumFractionDigits:p!=null?p:void 0,maximumFractionDigits:d!=null?d:void 0,roundingMode:u}),U=c=>c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),B=()=>{var l,g;let c=new Intl.NumberFormat(r,Me(se({},w()),{useGrouping:!1}));return new RegExp(`[${c.format(1.1).replace((l=A.current)!=null?l:"","").trim().replace((g=L.current)!=null?g:"","")}]`,"g")},fe=()=>{var l;let c=new Intl.NumberFormat(r,{useGrouping:!0});return P.current=c.format(1e6).trim().replace((l=L.current)!=null?l:"","").charAt(0),new RegExp(`[${P.current}]`,"g")},te=()=>{var l;let c=new Intl.NumberFormat(r,{useGrouping:!1});return new RegExp(`[${c.format(-1).trim().replace((l=L.current)!=null?l:"","")}]`,"g")},me=()=>{var c,l;if(x){let g=new Intl.NumberFormat(r,{style:"currency",currency:x,currencyDisplay:h,minimumFractionDigits:0,maximumFractionDigits:0,roundingMode:u});return new RegExp(`[${g.format(1).replace(/\s/g,"").replace((c=L.current)!=null?c:"","").replace((l=D.current)!=null?l:"","")}]`,"g")}return new RegExp("[]","g")},pe=()=>{if(f)q.current=new RegExp(U(f),"g");else{let l=new Intl.NumberFormat(r,{style:m,currency:x,currencyDisplay:h}).format(1).split("1")[0];q.current=new RegExp(U(l),"g")}return q.current},J=()=>{if(E)K.current=new RegExp(U(E),"g");else{let l=new Intl.NumberFormat(r,{style:m,currency:x,currencyDisplay:h,minimumFractionDigits:0,maximumFractionDigits:0,roundingMode:u}).format(1).split("1")[1];K.current=new RegExp(U(l),"g")}return K.current},V=()=>{C.current=new Intl.NumberFormat(r,w());let c=[...new Intl.NumberFormat(r,{useGrouping:!1}).format(9876543210)].reverse(),l=new Map(c.map((g,y)=>[g,y]));if(L.current=new RegExp(`[${c.join("")}]`,"g"),D.current=fe(),k.current=te(),A.current=me(),M.current=B(),K.current=J(),q.current=pe(),Q.current=g=>l.get(g),f)W.current=f;else{let g=new Intl.NumberFormat(r,{style:m,currency:x,currencyDisplay:h});W.current=g.format(1).split("1")[0]}if(E)H.current=E;else{let g=new Intl.NumberFormat(r,{style:m,currency:x,currencyDisplay:h,minimumFractionDigits:0,maximumFractionDigits:0,roundingMode:u});H.current=g.format(1).split("1")[1]}},N=c=>{if(c!=null){if(typeof c=="string"&&c==="-")return c;if(I){let l=new Intl.NumberFormat(r,w()),g=typeof c=="string"?Number(c):c,y=l.format(g);return f&&(y=f+y),E&&(y=y+E),y}return c.toString()}return""},re=c=>{var g;let l=c.replace(K.current||"","").replace(q.current||"","").trim().replace(/\s/g,"").replace(A.current||"","");if(M.current&&k.current&&L.current){let y=new RegExp(`[${[...new Intl.NumberFormat(r,{useGrouping:!1}).format(9876543210)].reverse().join("")}${new Intl.NumberFormat(r).format(1.1).replace(/[0-9]/g,"")}${new Intl.NumberFormat(r).format(-1).replace(/[0-9]/g,"")}]`,"g");l=((g=l.match(y))==null?void 0:g.join(""))||""}if(D.current&&(l=l.replace(D.current,"")),k.current&&(l=l.replace(k.current,"-")),M.current&&(l=l.replace(M.current,".")),L.current&&Q.current&&(l=l.replace(L.current,y=>{let j=Q.current?Q.current(y):void 0;return j!==void 0?j.toString():""})),l){if(l==="-")return l;let y=+l;return isNaN(y)?null:y}return null},de=(c,l)=>{let g=c.toString(),y=l.toString(),j=g.includes(".")?g.split(".")[1].length:0,Ee=y.includes(".")?y.split(".")[1].length:0,ne=Math.max(j,Ee),he=Math.pow(10,ne);return Math.round((c+l)*he)/he},_=()=>m==="decimal",ge=()=>{L.current&&(L.current.lastIndex=0),M.current&&(M.current.lastIndex=0),D.current&&(D.current.lastIndex=0),k.current&&(k.current.lastIndex=0)},Re=c=>c.length===1&&(L.current&&L.current.test(c)||M.current&&M.current.test(c)||D.current&&D.current.test(c)||k.current&&k.current.test(c))?(ge(),!0):!1,t=c=>k.current&&k.current.test(c)||c==="-"?(k.current&&(k.current.lastIndex=0),!0):!1,s=c=>r!=null&&r.includes("fr")&&[".",","].includes(c)||M.current&&M.current.test(c)?(M.current&&(M.current.lastIndex=0),!0):!1,a=()=>v==null||v<0,o=c=>{let l=M.current?c.search(M.current):-1;M.current&&(M.current.lastIndex=0);let g=c.replace(q.current||"","").trim().replace(/\s/g,"").replace(A.current||"",""),y=M.current?g.search(M.current):-1;return M.current&&(M.current.lastIndex=0),{decimalCharIndex:l,decimalCharIndexWithoutPrefix:y}},b=c=>{let l=ne=>{ne&&(ne.lastIndex=0)},g=M.current?c.search(M.current):-1;l(M.current);let y=k.current?c.search(k.current):-1;l(k.current);let j=K.current?c.search(K.current):-1;l(K.current);let Ee=A.current?c.search(A.current):-1;return l(A.current),{decimalCharIndex:g,minusCharIndex:y,suffixCharIndex:j,currencyCharIndex:Ee}},T=c=>{var l,g,y;if(c){let j=c.split((l=M.current)!=null?l:"");if(j.length===2)return j[1].replace((g=K.current)!=null?g:"","").trim().replace(/\s/g,"").replace((y=A.current)!=null?y:"","").length}return 0},$=(c,l)=>{if(c&&l){let g=M.current,y=g?l.search(g):-1;if(g&&(g.lastIndex=0),H.current)return y!==-1?c.replace(H.current,"").split(g!=null?g:"")[0]+l.replace(H.current,"").slice(y)+H.current:c;if(W.current)return y!==-1?c.split(g!=null?g:"")[0]+l.slice(y):c}return c};return S.useEffect(()=>{V()},[r,R,m,x,h,i,p,d,u,f,E]),{formattedValue:N(e),formatValue:N,parseValue:re,addWithPrecision:de,isDecimalMode:_,isNumeralChar:Re,isMinusSign:t,isDecimalSign:s,allowMinusSign:a,getDecimalCharIndexes:o,getCharIndexes:b,getDecimalLength:T,concatValues:$,groupChar:P.current,prefixChar:W.current,suffixChar:H.current,resolvedOptions:()=>{var c;return(c=C.current)==null?void 0:c.resolvedOptions()},constructParser:V}}import*as O from"react";function pt(n,e=500){let[r,R]=O.useState(n),[m,x]=O.useState(!1),[h,i]=O.useState(!1),p=O.useRef(null),d=O.useRef(null),u=O.useRef(null);return O.useEffect(()=>{if(d.current&&(d.current(),d.current=null),u.current&&(u.current(),u.current=null),n){R(!0),x(!1);let f=[];f.push(requestAnimationFrame(()=>{f.push(requestAnimationFrame(()=>{f.push(requestAnimationFrame(()=>i(!0)))}))})),u.current=()=>{f.forEach(E=>cancelAnimationFrame(E)),f.length=0}}else if(p.current){x(!0),i(!1);let f=p.current,E=!1,v=()=>{E||(E=!0,R(!1),x(!1),f.removeEventListener("transitionend",v),f.removeEventListener("animationend",v),d.current=null)};f.addEventListener("transitionend",v,{passive:!0}),f.addEventListener("animationend",v,{passive:!0}),d.current=()=>{E||(f.removeEventListener("transitionend",v),f.removeEventListener("animationend",v))}}else i(!1),R(!1),x(!1)},[n,e]),O.useEffect(()=>()=>{d.current&&d.current(),u.current&&u.current()},[]),{present:r,exiting:m,mounted:h,ref:p}}import*as Le from"react";function gt(n={},e={}){return Le.useMemo(()=>{let r={props:se({},n),attrs:{}};return Object.entries(e).forEach(([R,m])=>{R in n?r.props[R]=m:r.attrs[R]=m}),r},[n,e])}import*as X from"react";var bt=()=>{let n=X.useRef(new Map),e=X.useRef(!1),r=X.useCallback(()=>{e.current=!1;let R=n.current;n.current=new Map,R.forEach(m=>m())},[]);return X.useCallback((R,m)=>{n.current.set(R,m),e.current||(e.current=!0,queueMicrotask(r))},[r])};import{getWindowScrollTop as Ne}from"@primeuix/utils";import*as ae from"react";function vt(n){let{target:e=typeof window!="undefined"?window:null,threshold:r=400,behavior:R="smooth"}=n||{},[m,x]=ae.useState(!1),h=()=>{e==null||e.scroll({top:0,behavior:R})};return ae.useEffect(()=>{if(!e)return;let i=d=>{d>r?x(!0):x(!1)},p=()=>{let d=e===window?Ne():e.scrollTop;i(d)};return e.addEventListener("scroll",p),()=>{e.removeEventListener("scroll",p)}},[e,r]),{visible:m,scrollToTop:h}}import*as ke from"react";function Mt(n){ke.useEffect(()=>()=>{n==null||n()},[])}import*as ie from"react";function It(n,e){let r=ie.useRef(!1);ie.useEffect(()=>{if(!r.current){r.current=!0;return}return n==null?void 0:n()},e)}import*as we from"react";function kt(){return we.useCallback(e=>{document.startViewTransition?document.startViewTransition(()=>{e()}):e()},[])}import*as le from"react";function Ct(){let[n,e]=le.useState(!0);return le.useEffect(()=>{let r=()=>{e(!document.hidden)};return r(),document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]),n}export{Ae as useAttrSelector,$e as useControlledState,ze as useEventListener,Qe as useHotKey,Ze as useId,et as useKeyFilter,st as useMask,ct as useMatchMedia,at as useMountEffect,lt as useNumberFormatter,pt as usePresence,be as usePrevious,gt as useProps,bt as useQueueTask,vt as useScrollTop,Mt as useUnmountEffect,It as useUpdateEffect,kt as useViewTransition,Ct as useVisibilityChange};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-attr-selector/index.ts","../src/use-id/index.ts","../src/use-mount-effect/index.ts","../src/use-props/index.ts","../src/use-unmount-effect/index.ts","../src/use-update-effect/index.ts","../src/use-view-transition/index.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * Generates a unique attribute selector based on the provided prefix.\n *\n * @param prefix - The prefix to prepend to the generated selector.\n * @returns A unique string combining the prefix and the selector.\n *\n * @example\n * ```ts\n * const selector = useAttrSelector('foo');\n * console.log(selector); // e.g., 'foo0'\n * ```\n */\nexport function useAttrSelector(prefix: string = ''): string {\n const id = React.useId();\n\n return React.useMemo(() => `${prefix}${id.replaceAll(/:|«|»/g, '')}`.trim().toLowerCase(), [id, prefix]);\n}\n","import * as React from 'react';\n\n/**\n * Generates a unique identifier.\n *\n * @param initialValue Optional initial value for the ID.\n * @returns The generated or provided ID.\n *\n * @example\n * ```tsx\n * const id = useId('foo');\n * console.log(id); // 'foo'\n * ```\n *\n * @example\n * ```tsx\n * const defaultId = useId();\n * console.log(defaultId); // e.g., 'pr_id_0'\n * ```\n */\nexport function useId(initialValue?: string): string {\n const idx = React.useId();\n const [idState, setIdState] = React.useState<string>(initialValue || `pr_id_${idx.replaceAll(/:|«|»/g, '')}`);\n\n React.useEffect(() => {\n setIdState(initialValue || `pr_id_${idx.replaceAll(/:|«|»/g, '')}`);\n }, [initialValue, idx]);\n\n return idState;\n}\n","import * as React from 'react';\n\n/**\n * Custom hook that runs a mount effect only once.\n * This is similar to `useEffect`, but it only runs on mount.\n *\n * @param {React.EffectCallback} effect the callback function\n * @returns {void}\n *\n * @example\n * ```tsx\n * const MyComponent = () => {\n * useMountEffect(() => {\n * console.log('Mounted');\n * });\n * };\n * ```\n */\nexport function useMountEffect(effect: React.EffectCallback): void {\n const mounted = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!mounted.current) {\n mounted.current = true;\n\n effect?.();\n }\n }, []);\n}\n","import * as React from 'react';\n\n/**\n * Used to merge and differentiate incoming props with the default props.\n * - Keys that exist in both `props1` and `props2` are placed in `props`, with values from `props1`.\n * - Keys that exist in `props1` but not in `props2` are placed in `attrs`.\n *\n * @template P1 The type of the incoming set of props.\n * @template P2 The type of the default set of props.\n *\n * @param props1 The incoming set of props (e.g., user-defined or dynamic props).\n * @param props2 The default set of props (e.g., default props).\n * @returns An object containing:\n * - `props`: A new object containing keys that exist in both `props1` and `props2`, using values from `props1`.\n * - `attrs`: A new object containing keys that exist only in `props1`, excluding any keys from `props2`.\n *\n * @example\n * ```ts\n * const { props, attrs } = useProps({ id: 'foo', className: 'bar' }, { className: 'baz' });\n *\n * console.log(props); // { className: 'bar' }\n * console.log(attrs); // { id: 'foo' }\n * ```\n */\nexport function useProps<P1, P2>(props1: P1 = {} as P1, props2: P2 = {} as P2) {\n type Props = Pick<P1 & P2, keyof P2>;\n type Attrs = Omit<P1, keyof P2>;\n type Result = { props: Props; attrs: Attrs };\n\n return React.useMemo(() => {\n const result: Result = { props: { ...props2 } as Props, attrs: {} as Attrs };\n\n Object.entries(props1 as Record<string, unknown>).forEach(([key, value]) => {\n if (key in (props2 as Record<string, unknown>)) {\n (result.props as Record<string, unknown>)[key] = value;\n } else {\n (result.attrs as Record<string, unknown>)[key] = value;\n }\n });\n\n return result;\n }, [props1, props2]);\n}\n","import * as React from 'react';\n\n/**\n * Custom hook that runs an unmount effect only once.\n * This is similar to `useEffect`, but it only runs on unmount.\n *\n * @param {React.EffectCallback} effect the callback function\n * @returns {void}\n *\n * @example\n * ```tsx\n * const Component = () => {\n * useUnmountEffect(() => {\n * console.log('Unmounted');\n * });\n * };\n * ```\n */\nexport function useUnmountEffect(effect: React.EffectCallback): void {\n React.useEffect(() => {\n return () => {\n effect?.();\n };\n }, []);\n}\n","import * as React from 'react';\n\n/**\n * Custom hook that runs an update effect whenever dependencies change.\n * This is similar to `useEffect`, but it does not run on mount.\n *\n * @param {React.EffectCallback} effect the callback function\n * @param {React.DependencyList} dependencies the dependencies\n * @returns {void}\n *\n * @example\n * ```tsx\n * const Component = ({ value }) => {\n * useUpdateEffect(() => {\n * console.log('Updated');\n * }, [value]);\n * };\n * ```\n */\nexport function useUpdateEffect(effect: React.EffectCallback, dependencies?: React.DependencyList): void {\n const mounted = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!mounted.current) {\n mounted.current = true;\n\n return;\n }\n\n return effect?.();\n }, dependencies);\n}\n","import * as React from 'react';\n\n/**\n * Starts a view transition.\n *\n * @returns A function that starts a view transition.\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const startTransition = useViewTransition();\n *\n * const handleClick = () => {\n * startTransition(() => {\n * // Perform some work\n * });\n * };\n *\n * return <button onClick={handleClick}>Click me</button>;\n * };\n */\nexport function useViewTransition() {\n const startTransition = React.useCallback((callback: () => void) => {\n if (document.startViewTransition) {\n document.startViewTransition(() => {\n callback();\n });\n } else {\n callback();\n }\n }, []);\n\n return startTransition;\n}\n"],"mappings":"yVAAA,UAAYA,MAAW,QAchB,SAASC,EAAgBC,EAAiB,GAAY,CACzD,IAAMC,EAAW,QAAM,EAEvB,OAAa,UAAQ,IAAM,GAAGD,CAAM,GAAGC,EAAG,WAAW,SAAU,EAAE,CAAC,GAAG,KAAK,EAAE,YAAY,EAAG,CAACA,EAAID,CAAM,CAAC,CAC3G,CClBA,UAAYE,MAAW,QAoBhB,SAASC,EAAMC,EAA+B,CACjD,IAAMC,EAAY,QAAM,EAClB,CAACC,EAASC,CAAU,EAAU,WAAiBH,GAAgB,SAASC,EAAI,WAAW,SAAU,EAAE,CAAC,EAAE,EAE5G,OAAM,YAAU,IAAM,CAClBE,EAAWH,GAAgB,SAASC,EAAI,WAAW,SAAU,EAAE,CAAC,EAAE,CACtE,EAAG,CAACD,EAAcC,CAAG,CAAC,EAEfC,CACX,CC7BA,UAAYE,MAAW,QAkBhB,SAASC,EAAeC,EAAoC,CAC/D,IAAMC,EAAgB,SAAgB,EAAK,EAErC,YAAU,IAAM,CACbA,EAAQ,UACTA,EAAQ,QAAU,GAElBD,GAAA,MAAAA,IAER,EAAG,CAAC,CAAC,CACT,CC5BA,UAAYE,MAAW,QAwBhB,SAASC,EAAiBC,EAAa,CAAC,EAASC,EAAa,CAAC,EAAS,CAK3E,OAAa,UAAQ,IAAM,CACvB,IAAMC,EAAiB,CAAE,MAAOC,EAAA,GAAKF,GAAmB,MAAO,CAAC,CAAW,EAE3E,cAAO,QAAQD,CAAiC,EAAE,QAAQ,CAAC,CAACI,EAAKC,CAAK,IAAM,CACpED,KAAQH,EACPC,EAAO,MAAkCE,CAAG,EAAIC,EAEhDH,EAAO,MAAkCE,CAAG,EAAIC,CAEzD,CAAC,EAEMH,CACX,EAAG,CAACF,EAAQC,CAAM,CAAC,CACvB,CC1CA,UAAYK,MAAW,QAkBhB,SAASC,EAAiBC,EAAoC,CAC3D,YAAU,IACL,IAAM,CACTA,GAAA,MAAAA,GACJ,EACD,CAAC,CAAC,CACT,CCxBA,UAAYC,MAAW,QAmBhB,SAASC,EAAgBC,EAA8BC,EAA2C,CACrG,IAAMC,EAAgB,SAAgB,EAAK,EAErC,YAAU,IAAM,CAClB,GAAI,CAACA,EAAQ,QAAS,CAClBA,EAAQ,QAAU,GAElB,MACJ,CAEA,OAAOF,GAAA,YAAAA,GACX,EAAGC,CAAY,CACnB,CC/BA,UAAYE,MAAW,QAqBhB,SAASC,GAAoB,CAWhC,OAV8B,cAAaC,GAAyB,CAC5D,SAAS,oBACT,SAAS,oBAAoB,IAAM,CAC/BA,EAAS,CACb,CAAC,EAEDA,EAAS,CAEjB,EAAG,CAAC,CAAC,CAGT","names":["React","useAttrSelector","prefix","id","React","useId","initialValue","idx","idState","setIdState","React","useMountEffect","effect","mounted","React","useProps","props1","props2","result","__spreadValues","key","value","React","useUnmountEffect","effect","React","useUpdateEffect","effect","dependencies","mounted","React","useViewTransition","callback"]}
|
|
1
|
+
{"version":3,"sources":["../src/use-attr-selector/index.ts","../src/use-controlled-state/index.ts","../src/use-event-listener/index.ts","../src/use-previous/index.ts","../src/use-hot-key/index.ts","../src/use-id/index.ts","../src/use-key-filter/index.ts","../src/use-mask/index.ts","../src/use-match-media/index.ts","../src/use-mount-effect/index.ts","../src/use-number-formatter/index.ts","../src/use-presence/index.ts","../src/use-props/index.ts","../src/use-queue-task/index.ts","../src/use-scrolltop/index.ts","../src/use-unmount-effect/index.ts","../src/use-update-effect/index.ts","../src/use-view-transition/index.ts","../src/use-visibility-change/index.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * Generates a unique attribute selector based on the provided prefix.\n *\n * @param prefix - The prefix to prepend to the generated selector.\n * @returns A unique string combining the prefix and the selector.\n *\n * @example\n * ```ts\n * const selector = useAttrSelector('foo');\n * console.log(selector); // e.g., 'foo0'\n * ```\n */\nexport function useAttrSelector(prefix: string = ''): string {\n const id = React.useId();\n\n return React.useMemo(() => `${prefix}${id.replaceAll(/:|«|»/g, '')}`.trim().toLowerCase(), [id, prefix]);\n}\n","import { resolve } from '@primeuix/utils';\nimport * as React from 'react';\n\n/**\n * The options for the `useControlledState` hook.\n */\nexport interface UseControlledStateOptions<T = unknown, E = unknown> {\n /**\n * The value of the controlled state.\n */\n value?: T | undefined;\n /**\n * The default value of the uncontrolled state.\n */\n defaultValue?: T | undefined;\n /**\n * Callback function that is called when the value changes.\n */\n onChange?: (newValue: E) => void;\n}\n\n/**\n * The return type of the `useControlledState` hook.\n * A tuple containing the current value and a function to update it.\n */\nexport type UseControlledStateReturnType<T = unknown> = [T | undefined, (inValue: unknown | ((prev?: T) => unknown)) => void, boolean];\n\n/**\n * A custom hook that manages controlled and uncontrolled state.\n *\n * @param {UseControlledStateOptions} options - The options for the controlled state.\n * @returns A tuple containing the current value and a function to update it.\n *\n * @example\n * ```tsx\n * const ControlledComponent = () => {\n * const [controlledValue, setControlledValue] = React.useState('');\n *\n * const [value, setValue] = useControlledState({\n * value: controlledValue,\n * defaultValue: 'initial value',\n * onChange: (newValue) => {\n * setControlledValue(newValue);\n * }\n * });\n *\n * return <Component value={value} onChange={(e) => setValue(e.target.value)} />;\n * };\n * ```\n */\nexport function useControlledState<T = unknown, E = T>({ value, defaultValue, onChange }: UseControlledStateOptions<T, E>): UseControlledStateReturnType<T | undefined> {\n const isControlledRef = React.useRef(value !== undefined);\n const isControlled = isControlledRef.current;\n\n const [valueState, setValueState] = React.useState<T | undefined>(() => {\n return isControlled ? undefined : (defaultValue ?? value);\n });\n\n const computedValue = isControlled ? (value as T) : valueState;\n\n const setValue = React.useCallback(\n (inValue: unknown | ((prev?: T) => unknown)) => {\n // @todo - update resolve to accept multiple parameters\n const [newValue, onChangeParam] = resolve(inValue, computedValue, isControlled) as [T, E];\n\n onChange?.(onChangeParam);\n\n if (!isControlled) {\n setValueState(newValue);\n }\n },\n [computedValue, isControlled, onChange]\n );\n\n React.useEffect(() => {\n if (!isControlled) {\n setValueState(defaultValue);\n }\n }, [defaultValue, isControlled]);\n\n return [computedValue, setValue, isControlled];\n}\n","import { getTargetElement, isNotEmpty } from '@primeuix/utils';\nimport * as React from 'react';\nimport { usePrevious } from '../use-previous';\n\n/**\n * The options for the `useEventListener` hook.\n */\nexport interface UseEventListenerOptions<T = keyof HTMLElementEventMap> {\n /**\n * The target element to bind the event listener to.\n * @default 'document'\n */\n target?: 'document' | 'window' | 'body' | HTMLElement | (() => HTMLElement) | React.Ref<HTMLElement> | string | null;\n /**\n * The event type to listen for.\n */\n type: T | string;\n /**\n * The event listener callback.\n */\n listener: EventListener;\n /**\n * The event listener options\n */\n options?: AddEventListenerOptions | boolean;\n /**\n * A boolean indicating whether the event listener should be active.\n */\n when?: boolean;\n}\n\n/**\n * The return type of the `useEventListener` hook.\n * A tuple containing functions;\n * 1. `bind` function is used to bind the event listener.\n * 2. `unbind` function is used to unbind the event listener.\n */\nexport type UseEventListenerReturnType = [(options?: Partial<Omit<UseEventListenerOptions, 'target'>> & { target?: UseEventListenerOptions['target'] | Document | null }) => void, () => void];\n\n/**\n * Listens for the specified event type on the target element.\n *\n * @param {UseEventListenerOptions} options - The options for the event listener.\n * @returns A tuple containing functions;\n * 1. `bind` function is used to bind the event listener.\n * 2. `unbind` function is used to unbind the event listener.\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const [bind, unbind] = useEventListener({\n * target: 'document',\n * type: 'click',\n * listener: (event) => {\n * console.log(event);\n * },\n * when: true\n * });\n *\n * return <div>Click me</div>;\n * };\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const [bind, unbind] = useEventListener({\n * target: () => document.querySelector('.element'),\n * type: 'mouseover',\n * listener: (event) => {\n * console.log(event);\n * }\n * });\n *\n * return <div>MouseOver to `.element`</div>;\n * };\n * ```\n */\nexport function useEventListener({ target = 'document', type, listener, options, when = true }: UseEventListenerOptions): UseEventListenerReturnType {\n const targetRef = React.useRef<HTMLElement | null>(null);\n const listenerRef = React.useRef<EventListener | null>(null);\n let prevListener = usePrevious(listener);\n let prevOptions = usePrevious(options);\n\n const bind = (bindOptions: Partial<Omit<UseEventListenerOptions, 'target'>> & { target?: UseEventListenerOptions['target'] | Document | null } = {}) => {\n const { target: bindTarget } = bindOptions;\n\n if (isNotEmpty(bindTarget)) {\n unbind();\n\n if (bindOptions.when || when) {\n targetRef.current = getTargetElement(bindTarget) as HTMLElement;\n }\n }\n\n if (!listenerRef.current && targetRef.current) {\n listenerRef.current = (event: Event) => listener && listener(event);\n targetRef.current.addEventListener(type, listenerRef.current, options);\n }\n };\n\n const unbind = () => {\n if (listenerRef.current) {\n targetRef.current?.removeEventListener(type, listenerRef.current, options);\n listenerRef.current = null;\n }\n };\n\n const dispose = () => {\n unbind();\n // Prevent memory leak by releasing\n prevListener = null;\n prevOptions = null;\n };\n\n const updateTarget = React.useCallback(() => {\n if (when) {\n targetRef.current = getTargetElement(target) as HTMLElement;\n } else {\n unbind();\n targetRef.current = null;\n }\n }, [target, when]);\n\n React.useEffect(() => {\n return () => {\n dispose();\n };\n }, []);\n\n React.useEffect(() => {\n updateTarget();\n }, [updateTarget]);\n\n React.useEffect(() => {\n const listenerChanged = `${prevListener}` !== `${listener}`;\n const optionsChanged = prevOptions !== options;\n const listenerExists = listenerRef.current;\n\n if (listenerExists && (listenerChanged || optionsChanged)) {\n unbind();\n\n if (when) {\n bind();\n }\n } else if (!listenerExists) {\n dispose();\n }\n }, [listener, options, when]);\n\n return [bind, unbind];\n}\n","import * as React from 'react';\n\n/**\n * Returns the previous value of the provided value.\n *\n * @param value - The value to track.\n * @returns The previous value of the provided value.\n *\n * @example\n * ```tsx\n * const [count, setCount] = React.useState(5);\n * const prevCount = usePrevious(count);\n *\n * console.log(prevCount); // undefined\n *\n * setCount(10);\n *\n * console.log(prevCount); // 5\n * ```\n */\nexport function usePrevious<T>(value: T): T | null | undefined {\n const ref = React.useRef<T | null>(null);\n\n React.useEffect(() => {\n ref.current = value;\n\n return () => {\n ref.current = null;\n };\n }, [value]);\n\n return ref.current;\n}\n","import * as React from 'react';\n\nexport type UseHotKeyTarget = Document | HTMLElement | null | undefined;\n\nexport interface UseHotKeyOptions {\n /**\n * Target to listen on. Defaults to `document` when available.\n */\n target?: UseHotKeyTarget;\n /**\n * Keyboard event type.\n * @default 'keydown'\n */\n event?: 'keydown' | 'keyup' | 'keypress';\n /**\n * Enables or disables the listener.\n * @default true\n */\n when?: boolean;\n}\n\n/**\n * Runs the provided handler when any of the given keys is pressed.\n *\n * @param keys A single key or an array of keys to listen for (e.g. 'k' or 'ctrl+k').\n * @param handler Callback fired when a matching key event occurs.\n * @param options Optional configuration for target, event type, and enable flag.\n */\nexport function useHotKey(keys: string | string[], handler: (event: KeyboardEvent) => void, options: UseHotKeyOptions = {}) {\n const { target, event = 'keydown', when = true } = options;\n const handlerRef = React.useRef(handler);\n\n const normalizeKey = (key: string) => {\n const lower = key.toLowerCase();\n\n if (lower === 'space' || lower === 'spacebar') return ' ';\n\n return lower;\n };\n\n const parseKeySpec = (spec: string) => {\n const parts = spec\n .split('+')\n .map((p) => p.trim().toLowerCase())\n .filter(Boolean);\n\n let key: string | undefined;\n const required = {\n ctrl: false,\n meta: false,\n alt: false,\n shift: false\n };\n\n parts.forEach((part) => {\n switch (part) {\n case 'ctrl':\n case 'control':\n required.ctrl = true;\n break;\n case 'meta':\n case 'cmd':\n case 'command':\n required.meta = true;\n break;\n case 'alt':\n case 'option':\n required.alt = true;\n break;\n case 'shift':\n required.shift = true;\n break;\n default:\n key = normalizeKey(part);\n }\n });\n\n return { key, required };\n };\n\n const matches = (spec: ReturnType<typeof parseKeySpec>, event: KeyboardEvent) => {\n if (!spec.key) return false;\n\n const { required } = spec;\n\n if (required.ctrl !== event.ctrlKey || required.meta !== event.metaKey || required.alt !== event.altKey || required.shift !== event.shiftKey) {\n return false;\n }\n\n return normalizeKey(event.key) === spec.key;\n };\n\n React.useEffect(() => {\n handlerRef.current = handler;\n }, [handler]);\n\n React.useEffect(() => {\n if (!when) {\n return;\n }\n\n const targetElement: UseHotKeyTarget = target ?? (typeof document !== 'undefined' ? document : null);\n\n if (!targetElement) {\n return;\n }\n\n const keySpecs = (Array.isArray(keys) ? keys : [keys]).map(parseKeySpec);\n\n const listener: EventListener = (event) => {\n const keyboardEvent = event as KeyboardEvent;\n\n if (keySpecs.some((spec) => matches(spec, keyboardEvent))) {\n handlerRef.current?.(keyboardEvent);\n }\n };\n\n targetElement.addEventListener(event, listener);\n\n return () => {\n targetElement.removeEventListener(event, listener);\n };\n }, [event, keys, target, when]);\n}\n","import * as React from 'react';\n\n/**\n * Generates a unique identifier.\n *\n * @param initialValue Optional initial value for the ID.\n * @returns The generated or provided ID.\n *\n * @example\n * ```tsx\n * const id = useId('foo');\n * console.log(id); // 'foo'\n * ```\n *\n * @example\n * ```tsx\n * const defaultId = useId();\n * console.log(defaultId); // e.g., 'pr_id_0'\n * ```\n */\nexport function useId(initialValue?: string): string {\n const idx = React.useId();\n const [idState, setIdState] = React.useState<string>(initialValue || `pr_id_${idx.replaceAll(/:|«|»/g, '')}`);\n\n React.useEffect(() => {\n setIdState(initialValue || `pr_id_${idx.replaceAll(/:|«|»/g, '')}`);\n }, [initialValue, idx]);\n\n return idState;\n}\n","import { isAndroid } from '@primeuix/utils';\n\n/**\n * The options for the `useKeyFilter` hook.\n */\nexport interface UseKeyFilterOptions {\n /**\n * Sets the pattern for key filtering.\n * @default /./\n */\n pattern?: 'pint' | 'int' | 'pnum' | 'money' | 'num' | 'hex' | 'email' | 'alpha' | 'alphanum' | RegExp;\n /**\n * When enabled, instead of blocking keys, input is validated internally to test against the regular expression.\n * @default false\n */\n validateOnly?: boolean;\n}\n\nexport interface UseKeyFilterExposes {\n /**\n * Handles input events for key filter.\n * Processes character input and composition events while applying the filter pattern.\n * @param event - The form or composition event from the input element\n */\n onBeforeInput: (event: React.CompositionEvent<HTMLInputElement>) => void;\n /**\n * Handles keypress events for character input validation.\n * Validates and places characters according to the filter pattern.\n * @param event - The keyboard event from the input element\n */\n onKeyPress: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Handles paste events for clipboard content insertion.\n * Processes pasted content according to the mask pattern.\n * @param event - The clipboard event from the input element\n */\n onPaste: (event: React.ClipboardEvent<HTMLInputElement>) => void;\n /**\n * Validates the current input value against the filter pattern.\n * @param event - The form event from the input element\n * @returns true if the value matches the pattern, false otherwise\n */\n validate: (event: React.FormEvent<HTMLInputElement>) => boolean;\n}\n\nexport function useKeyFilter(options: UseKeyFilterOptions): UseKeyFilterExposes {\n const { pattern = /./, validateOnly = false } = options;\n\n const DEFAULT_MASKS = {\n pint: /[\\d]/,\n int: /[\\d-]/,\n pnum: /[\\d.]/,\n money: /[\\d.\\s,]/,\n num: /[\\d-.]/,\n hex: /[0-9a-f]/i,\n email: /[a-z0-9_.-@]/i,\n alpha: /[a-z_]/i,\n alphanum: /[a-z0-9_]/\n };\n\n const getRegex = (): RegExp => {\n return typeof pattern === 'string' ? DEFAULT_MASKS[pattern] : pattern;\n };\n\n const onBeforeInput = (event: React.CompositionEvent<HTMLInputElement>) => {\n // android devices must use beforeinput https://stackoverflow.com/questions/36753548/keycode-on-android-is-always-229\n if (validateOnly || !isAndroid()) {\n return;\n }\n\n validateKey(event, event.data);\n };\n\n const onKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n // non android devices use keydown\n if (validateOnly || isAndroid()) {\n return;\n }\n\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n\n validateKey(event, event.key);\n };\n\n const onPaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n if (validateOnly) {\n return;\n }\n\n const regex = getRegex();\n const clipboard = event.clipboardData.getData('text');\n\n // loop over each letter pasted and if any fail prevent the paste\n [...clipboard].forEach((c) => {\n if (!regex.test(c)) {\n event.preventDefault();\n\n return false;\n }\n });\n };\n\n const validateKey = (event: React.CompositionEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement>, key: string) => {\n if (key === null || key === undefined) {\n return;\n }\n\n // some AZERTY keys come in with 2 chars like ´ç if Dead key is pressed first\n const isPrintableKey = key.length <= 2;\n\n if (!isPrintableKey) {\n return;\n }\n\n const regex = getRegex();\n\n if (!regex.test(key)) {\n event.preventDefault();\n }\n };\n\n const validate = (event: React.FormEvent<HTMLInputElement>) => {\n const value = (event.target as HTMLInputElement).value;\n let validatePattern = true;\n\n const regex = getRegex();\n\n if (value && !regex.test(value)) {\n validatePattern = false;\n }\n\n return validatePattern;\n };\n\n return {\n onBeforeInput,\n onKeyPress,\n onPaste,\n validate\n };\n}\n","import { useMountEffect } from '@primereact/hooks';\nimport { getUserAgent } from '@primeuix/utils';\nimport * as React from 'react';\n\n/**\n * Event fired when the component's state changes.\n */\nexport interface UseMaskChangeEvent {\n /**\n * The value of the component.\n */\n value: string | undefined;\n}\n\n/**\n * The options for the `useMask` hook.\n */\nexport interface UseMaskOptions {\n /**\n * Mask pattern.\n */\n mask: string;\n /**\n * Defines if model sets the raw unmasked value to bound value or the formatted mask value.\n * @default false\n */\n unmask?: string;\n /**\n * Placeholder character in mask, default is underscore.\n * @default _\n */\n slotChar?: string;\n /**\n * Clears the incomplete value on blur.\n * @default true\n */\n autoClear?: boolean;\n /**\n * Whether the components are clickable or not.\n * @default false\n */\n readOnly?: boolean;\n /**\n * Callback function that is called when the value is changed.\n * @param event The event that triggered the change.\n * @param event.value The value of the component.\n * @returns void\n */\n onMaskChange?: (event: UseMaskChangeEvent) => void;\n /**\n * Reference to the mask element.\n */\n target: HTMLInputElement;\n}\n\nexport interface UseMaskExposes {\n /**\n * Handles input events for the masked input field.\n * Processes character input and composition events while applying the mask pattern.\n * @param event - The form or composition event from the input element\n */\n onMaskInput: (event: React.FormEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => void;\n /**\n * Handles keydown events for special key operations.\n * Manages backspace, delete, escape, and enter key behaviors.\n * @param event - The keyboard event from the input element\n */\n onMaskKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Handles keypress events for character input validation.\n * Validates and places characters according to the mask pattern.\n * @param event - The keyboard event from the input element\n */\n onMaskKeyPress: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Handles focus events when the input gains focus.\n * Initializes the mask display and sets the cursor position.\n * @param event - The focus event from the input element\n */\n onMaskFocus: (event: React.FocusEvent<HTMLInputElement>) => void;\n /**\n * Handles blur events when the input loses focus.\n * Validates the final value and triggers change events if needed.\n * @param event - The focus event from the input element\n */\n onMaskBlur: (event: React.FocusEvent<HTMLInputElement>) => void;\n /**\n * Handles paste events for clipboard content insertion.\n * Processes pasted content according to the mask pattern.\n * @param event - The clipboard event from the input element\n */\n onMaskPaste: (event: React.ClipboardEvent<HTMLInputElement>) => void;\n}\n\n/**\n * useMask hook is used to enter input in a certain format such as numeric, date, currency, email and phone.\n *\n * @param {UseMaskOptions} options - The options for the mask.\n * @returns {UseMaskExposes} - The exposed methods for the mask.\n *\n * @example\n * ```tsx\n * const { onMaskInput, onMaskKeyDown, onMaskKeyPress, onMaskFocus, onMaskBlur, onMaskPaste } = useMask({\n * mask: '99/99/9999',\n * onMaskChange: (event: UseMaskChangeEvent) => setValue(event.value ?? ''),\n * target: ref\n * });\n *\n * return (\n * <div className=\"card flex justify-center\">\n * <InputText ref={ref} value={value} placeholder=\"99/99/9999\" onInput={onMaskInput} onKeyDown={onMaskKeyDown} onKeyPress={onMaskKeyPress} onFocus={onMaskFocus} onBlur={onMaskBlur} onPaste={onMaskPaste} />\n * </div>\n * );\n */\nexport function useMask(options: UseMaskOptions): UseMaskExposes {\n const { mask, unmask, slotChar = '_', autoClear = true, readOnly = false, onMaskChange, target } = options;\n\n const len = React.useRef(0);\n const tests = React.useRef<Array<RegExp | null>>([]);\n const buffer = React.useRef<string[]>([]);\n const defaultBuffer = React.useRef<string | null>(null);\n const partialPosition = React.useRef<number>(0);\n const androidChrome = React.useRef(false);\n const focus = React.useRef(false);\n const focusText = React.useRef<string | null>(null);\n const firstNonMaskPos = React.useRef<number | null>(null);\n const lastRequiredNonMaskPos = React.useRef<number>(0);\n const caretTimeoutId = React.useRef<NodeJS.Timeout | null>(null);\n const oldVal = React.useRef<string | null>(null);\n const currentVal = React.useRef<string | null>(null);\n\n const onMaskInput = (event: React.FormEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => {\n // Check if the event is part of a text composition process (e.g., for Asian languages).\n // If event.isComposing is true, it means the user is still composing text and the input is not finalized.\n if ('isComposing' in event && event.isComposing) {\n return;\n }\n\n if (androidChrome.current) handleAndroidInput();\n else handleInputChange(event);\n };\n\n const onMaskKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (readOnly) {\n return;\n }\n\n const k = event.code;\n let pos, begin, end;\n const iPhone = /iphone/i.test(getUserAgent());\n\n oldVal.current = target?.value as string;\n\n //backspace, delete, and escape get special treatment\n if (k === 'Backspace' || k === 'Delete' || (iPhone && k === 'Escape')) {\n pos = caret();\n\n if (!pos) {\n return;\n }\n\n begin = pos.begin;\n end = pos.end;\n\n if (end - begin === 0) {\n begin = k !== 'Delete' ? seekPrev(begin) : (end = seekNext(begin - 1));\n end = k === 'Delete' ? seekNext(end) : end;\n }\n\n clearBuffer(begin, end);\n shiftL(begin, end - 1);\n updateModelValue((event.target as HTMLInputElement).value);\n\n event.preventDefault();\n } else if (k === 'Enter') {\n // enter\n target.blur();\n updateModelValue((event.target as HTMLInputElement).value);\n } else if (k === 'Escape') {\n // escape\n if (target) {\n target.value = focusText.current ?? '';\n }\n\n caret(0, checkVal());\n updateModelValue((event.target as HTMLInputElement).value);\n event.preventDefault();\n }\n };\n\n const onMaskKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (readOnly) {\n return;\n }\n\n const k = event.code,\n pos = caret();\n let p: number, c: string, next: number;\n\n if (!pos) {\n return;\n }\n\n if (event.ctrlKey || event.altKey || event.metaKey || event.shiftKey || event.key === 'CapsLock' || event.key === 'Escape' || event.key === 'Tab') {\n //Ignore\n return;\n } else if (k && k !== 'Enter') {\n if (pos.end - pos.begin !== 0) {\n clearBuffer(pos.begin, pos.end);\n shiftL(pos.begin, pos.end - 1);\n }\n\n p = seekNext(pos.begin - 1);\n\n if (p < len.current) {\n c = event.key;\n\n if (tests.current[p]?.test(c)) {\n shiftR(p);\n\n buffer.current[p] = c;\n writeBuffer();\n next = seekNext(p);\n\n if (/android/i.test(getUserAgent())) {\n //Path for CSP Violation on FireFox OS 1.1\n const proxy = () => {\n caret(next);\n };\n\n setTimeout(proxy, 0);\n } else {\n caret(next);\n }\n }\n }\n\n event.preventDefault();\n }\n\n updateModelValue((event.target as HTMLInputElement).value);\n };\n\n const onMaskFocus = () => {\n if (readOnly) {\n return;\n }\n\n if (caretTimeoutId.current) {\n clearTimeout(caretTimeoutId.current as NodeJS.Timeout);\n }\n\n focus.current = true;\n focusText.current = target.value as string;\n\n if (!target.value || target.value === defaultBuffer.current) {\n requestAnimationFrame(() => {\n if (target === document.activeElement) {\n caret(0, 0);\n }\n });\n } else {\n const pos = checkVal();\n\n caretTimeoutId.current = setTimeout(() => {\n if (target !== document.activeElement) {\n return;\n }\n\n writeBuffer();\n\n if (pos === mask?.replace('?', '').length) {\n caret(0, pos);\n } else {\n caret(pos);\n }\n }, 10);\n }\n };\n\n const onMaskBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n focus.current = false;\n checkVal();\n updateModelValue(event.target.value);\n\n if (target.value !== focusText.current) {\n const e = new Event('change', { bubbles: true, cancelable: false });\n\n target.dispatchEvent(e);\n }\n };\n\n const onMaskPaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n handleInputChange(event);\n };\n\n const caret = (first?: number, last?: number): { begin: number; end: number } | undefined => {\n let begin = 0,\n end = 0;\n\n if (typeof first === 'number') {\n begin = first;\n end = typeof last === 'number' ? last : begin;\n\n target.setSelectionRange(begin, end);\n } else {\n if (target) {\n begin = target.selectionStart ?? 0;\n end = target.selectionEnd ?? 0;\n }\n }\n\n return { begin, end };\n };\n\n const getPlaceholder = (i: number) => {\n if (i < slotChar.length) {\n return slotChar.charAt(i);\n }\n\n return slotChar.charAt(0);\n };\n\n const seekNext = (pos: number) => {\n while (++pos < len.current && !tests.current[pos]);\n\n return pos;\n };\n\n const seekPrev = (pos: number) => {\n while (--pos >= 0 && !tests.current[pos]);\n\n return pos;\n };\n\n const shiftL = (begin: number, end: number) => {\n let i, j;\n\n if (begin < 0) {\n return;\n }\n\n for (i = begin, j = seekNext(end); i < len.current; i++) {\n if (tests.current[i]) {\n if (j < len.current && tests.current[i]?.test(buffer.current[j])) {\n buffer.current[i] = buffer.current[j];\n buffer.current[j] = getPlaceholder(j);\n } else {\n break;\n }\n\n j = seekNext(j);\n }\n }\n\n writeBuffer();\n caret(Math.max(firstNonMaskPos.current ?? 0, begin));\n };\n\n const shiftR = (pos: number) => {\n let i, c, j, t;\n\n for (i = pos, c = getPlaceholder(pos); i < len.current; i++) {\n if (tests.current[i]) {\n j = seekNext(i);\n t = buffer.current[i];\n buffer.current[i] = c;\n\n if (j < len.current && tests.current[j]?.test(t)) {\n c = t;\n } else {\n break;\n }\n }\n }\n };\n\n const handleAndroidInput = () => {\n const curVal = target.value as string;\n const pos = caret();\n\n if (!pos) {\n return;\n }\n\n if (oldVal.current && oldVal.current.length && oldVal.current.length > curVal.length) {\n // a deletion or backspace happened\n checkVal(true);\n while (pos.begin > 0 && !tests.current[pos.begin - 1]) pos.begin--;\n\n if (pos.begin === 0) {\n while (pos.begin < (firstNonMaskPos.current ?? 0) && !tests.current[pos.begin]) pos.begin++;\n }\n\n caret(pos.begin, pos.begin);\n } else {\n checkVal(true);\n while (pos.begin < len.current && !tests.current[pos.begin]) pos.begin++;\n\n caret(pos.begin, pos.begin);\n }\n };\n\n const clearBuffer = (start: number, end: number) => {\n let i;\n\n for (i = start; i < end && i < len.current; i++) {\n if (tests.current[i]) {\n buffer.current[i] = getPlaceholder(i);\n }\n }\n };\n\n const writeBuffer = () => {\n if (target) {\n target.value = buffer.current.join('');\n }\n };\n\n const checkVal = (allow = false): number => {\n //try to place characters where they belong\n const test = target.value;\n let lastMatch = -1,\n i,\n c,\n pos;\n\n for (i = 0, pos = 0; i < len.current; i++) {\n const currentTest = tests.current[i];\n\n if (currentTest !== null) {\n buffer.current[i] = getPlaceholder(i);\n\n while (pos++ < (test?.length ?? 0)) {\n c = test?.charAt(pos - 1) ?? '';\n\n if (currentTest.test(c)) {\n buffer.current[i] = c;\n lastMatch = i;\n break;\n }\n }\n\n if (pos > (test?.length ?? 0)) {\n clearBuffer(i + 1, len.current);\n break;\n }\n } else {\n if (buffer.current[i] === test?.charAt(pos)) {\n pos++;\n }\n\n if (i < partialPosition.current) {\n lastMatch = i;\n }\n }\n }\n\n if (allow) {\n writeBuffer();\n } else if (lastMatch + 1 < partialPosition.current) {\n if (autoClear || buffer.current.join('') === defaultBuffer.current) {\n // Invalid value. Remove it and replace it with the\n // mask, which is the default behavior.\n if (target.value) {\n target.value = '';\n }\n\n clearBuffer(0, len.current);\n } else {\n // Invalid value, but we opt to show the value to the\n // user and allow them to correct their mistake.\n writeBuffer();\n }\n } else {\n writeBuffer();\n\n if (target) {\n target.value = target.value.substring(0, lastMatch + 1);\n }\n }\n\n return partialPosition.current ? i : (firstNonMaskPos.current ?? 0);\n };\n\n const handleInputChange = (event: React.FormEvent<HTMLInputElement> | React.ClipboardEvent<HTMLInputElement>) => {\n const isPasteEvent = event.type === 'paste';\n\n if (readOnly || isPasteEvent) {\n return;\n }\n\n const pos = checkVal(true);\n\n caret(pos);\n updateModelValue((event.target as HTMLInputElement).value);\n };\n\n const unmaskValue = (value: string) => {\n const unmaskedBuffer = [];\n const thisbuffer = value.split('');\n\n for (let i = 0; i < thisbuffer.length; i++) {\n const c = thisbuffer[i];\n\n if (tests.current[i] && c !== getPlaceholder(i)) {\n unmaskedBuffer.push(c);\n }\n }\n\n return unmaskedBuffer.join('');\n };\n\n const updateModelValue = (value: string) => {\n if (currentVal.current === value) return;\n\n const val = unmask ? unmaskValue(value) : value;\n const finalValue = defaultBuffer.current !== val ? val : '';\n\n currentVal.current = value;\n\n if (target) {\n target.value = finalValue;\n }\n\n // Call the onMaskChange callback to update React state\n if (onMaskChange) {\n onMaskChange({ value: finalValue });\n }\n };\n\n const updateValue = (updateModel = true) => {\n if (target) {\n if (target.value == null) {\n target.value = '';\n\n if (updateModel) {\n updateModelValue('');\n }\n } else {\n checkVal();\n\n setTimeout(() => {\n if (target) {\n writeBuffer();\n checkVal();\n\n if (updateModel) updateModelValue(target.value);\n }\n }, 10);\n }\n\n focusText.current = target.value;\n }\n };\n\n const initMask = () => {\n tests.current = [];\n partialPosition.current = mask ? mask.length : 0;\n len.current = mask ? mask.length : 0;\n firstNonMaskPos.current = null;\n const defs = {\n 9: '[0-9]',\n a: '[A-Za-z]',\n '*': '[A-Za-z0-9]'\n } as Record<string, string>;\n\n const ua = getUserAgent();\n\n androidChrome.current = /chrome/i.test(ua) && /android/i.test(ua);\n\n const maskTokens = mask ? mask.split('') : '';\n\n for (let i = 0; i < maskTokens.length; i++) {\n const c = maskTokens[i];\n\n if (c === '?') {\n len.current--;\n partialPosition.current = i;\n } else if (defs[c]) {\n tests.current.push(new RegExp(defs[c]));\n\n if (firstNonMaskPos.current === null) {\n firstNonMaskPos.current = tests.current.length - 1;\n }\n\n if (i < partialPosition.current) {\n lastRequiredNonMaskPos.current = tests.current.length - 1;\n }\n } else {\n tests.current.push(null);\n }\n }\n\n buffer.current = [];\n\n for (let i = 0; i < maskTokens.length; i++) {\n const c = maskTokens[i];\n\n if (c !== '?') {\n if (defs[c]) buffer.current.push(getPlaceholder(i));\n else buffer.current.push(c);\n }\n }\n\n defaultBuffer.current = buffer.current.join('');\n\n updateValue(false);\n };\n\n useMountEffect(() => {\n initMask();\n });\n\n return {\n onMaskInput,\n onMaskKeyDown,\n onMaskKeyPress,\n onMaskFocus,\n onMaskBlur,\n onMaskPaste\n };\n}\n","import * as React from 'react';\n\n/**\n * Listens for the specified media query.\n *\n * @param query - The media query to match.\n * @param when - A boolean indicating whether the media query should be active.\n * @returns A boolean indicating whether the media query matches.\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const isMobile = useMatchMedia('(max-width: 768px)');\n *\n * return <div>{isMobile ? 'Mobile' : 'Desktop'}</div>;\n * };\n */\nexport function useMatchMedia(query: string, when: boolean = true): boolean {\n const [matches, setMatches] = React.useState(false);\n const matchMedia = React.useRef<MediaQueryList | null>(null);\n\n const handleChange = (event: MediaQueryListEvent) => setMatches(event.matches);\n const bind = () => matchMedia.current?.addEventListener('change', handleChange);\n const unbind = () => matchMedia.current?.removeEventListener('change', handleChange) && (matchMedia.current = null);\n\n React.useEffect(() => {\n if (when) {\n matchMedia.current = window.matchMedia(query);\n setMatches(matchMedia.current.matches);\n\n bind();\n }\n\n return () => {\n unbind();\n };\n }, [query, when]);\n\n return matches;\n}\n","import * as React from 'react';\n\n/**\n * Custom hook that runs a mount effect only once.\n * This is similar to `useEffect`, but it only runs on mount.\n *\n * @param {React.EffectCallback} effect the callback function\n * @returns {void}\n *\n * @example\n * ```tsx\n * const MyComponent = () => {\n * useMountEffect(() => {\n * console.log('Mounted');\n * });\n * };\n * ```\n */\nexport function useMountEffect(effect: React.EffectCallback): void {\n const mounted = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!mounted.current) {\n mounted.current = true;\n\n effect?.();\n }\n }, []);\n}\n","import * as React from 'react';\n\n/**\n * The options for the `useNumberFormatter` hook.\n */\nexport interface UseNumberFormatterOptions {\n /**\n * The numeric value to be formatted.\n */\n value?: number | string | null | undefined;\n /**\n * Locale to be used in formatting.\n */\n locale?: string;\n /**\n * The locale matching algorithm to use. Possible values are 'lookup' and 'best fit'.\n * @default 'best fit'\n */\n localeMatcher?: 'lookup' | 'best fit';\n /**\n * Defines the behavior of the component.\n * @default 'decimal'\n */\n mode?: 'decimal' | 'currency';\n /**\n * The currency to use in currency formatting (ISO 4217 currency codes).\n */\n currency?: string;\n /**\n * How to display the currency in currency formatting.\n */\n currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';\n /**\n * Whether to use grouping separators, such as thousands separators.\n * @default true\n */\n useGrouping?: boolean;\n /**\n * The minimum number of fraction digits to use.\n */\n minFractionDigits?: number;\n /**\n * The maximum number of fraction digits to use.\n */\n maxFractionDigits?: number;\n /**\n * How decimals should be rounded.\n */\n roundingMode?: 'ceil' | 'floor' | 'expand' | 'trunc' | 'halfCeil' | 'halfFloor' | 'halfExpand' | 'halfTrunc' | 'halfEven';\n /**\n * Text to display before the value.\n */\n prefix?: string;\n /**\n * Text to display after the value.\n */\n suffix?: string;\n /**\n * Minimum boundary value (used to determine if minus sign is allowed).\n */\n min?: number;\n /**\n * Whether to format the value.\n * @default true\n */\n format?: boolean;\n}\n\n/**\n * The exposes for the `useNumberFormatter` hook.\n */\nexport interface UseNumberFormatterExposes {\n /**\n * The formatted value based on the provided value and options.\n */\n formattedValue: string;\n /**\n * Formats a numeric value to a localized string.\n * @param value - The value to format\n * @returns The formatted string\n */\n formatValue: (value: number | string | null | undefined) => string;\n /**\n * Parses a formatted string back to a numeric value.\n * @param text - The text to parse\n * @returns The parsed number, '-' for minus sign only, or null if invalid\n */\n parseValue: (text: string) => number | string | null;\n /**\n * Adds two numbers with floating-point precision handling.\n * @param base - The base number\n * @param increment - The increment to add\n * @returns The sum with proper precision\n */\n addWithPrecision: (base: number, increment: number) => number;\n /**\n * Checks if the mode is decimal.\n * @returns True if mode is 'decimal'\n */\n isDecimalMode: () => boolean;\n /**\n * Checks if a character is a numeral character (digit, decimal, group separator, or minus sign).\n * @param char - The character to check\n * @returns True if the character is a numeral character\n */\n isNumeralChar: (char: string) => boolean;\n /**\n * Checks if a character is a minus sign.\n * @param char - The character to check\n * @returns True if the character is a minus sign\n */\n isMinusSign: (char: string) => boolean;\n /**\n * Checks if a character is a decimal sign.\n * @param char - The character to check\n * @returns True if the character is a decimal sign\n */\n isDecimalSign: (char: string) => boolean;\n /**\n * Checks if minus sign is allowed based on min value.\n * @returns True if minus sign is allowed\n */\n allowMinusSign: () => boolean;\n /**\n * Gets the decimal character indexes in a value string.\n * @param val - The value string to analyze\n * @returns Object with decimalCharIndex and decimalCharIndexWithoutPrefix\n */\n getDecimalCharIndexes: (val: string) => { decimalCharIndex: number; decimalCharIndexWithoutPrefix: number };\n /**\n * Gets various character indexes (decimal, minus, suffix, currency) in a value string.\n * @param val - The value string to analyze\n * @returns Object with character indexes\n */\n getCharIndexes: (val: string) => { decimalCharIndex: number; minusCharIndex: number; suffixCharIndex: number; currencyCharIndex: number };\n /**\n * Gets the length of decimal part in a formatted value.\n * @param value - The formatted value string\n * @returns The decimal length\n */\n getDecimalLength: (value: string) => number;\n /**\n * Concatenates two value strings, handling decimal positions.\n * @param val1 - The first value\n * @param val2 - The second value\n * @returns The concatenated result\n */\n concatValues: (val1: string, val2: string) => string;\n /**\n * The group character used for thousands separator.\n */\n groupChar: string | null;\n /**\n * The prefix character/string.\n */\n prefixChar: string | null;\n /**\n * The suffix character/string.\n */\n suffixChar: string | null;\n /**\n * The resolved Intl.NumberFormat options.\n */\n resolvedOptions: () => Intl.ResolvedNumberFormatOptions | undefined;\n /**\n * Reinitializes the parser (call when options change).\n */\n constructParser: () => void;\n}\n\n/**\n * useNumberFormatter hook is used to format and parse numbers using Intl.NumberFormat.\n *\n * @param {UseNumberFormatterOptions} options - The options for the number formatter.\n * @returns {UseNumberFormatterExposes} - The exposed methods for the number formatter.\n *\n * @example\n * ```tsx\n * const formatter = useNumberFormatter({\n * value: 1234.56,\n * locale: 'en-US',\n * mode: 'currency',\n * currency: 'USD'\n * });\n *\n * const formatted = formatter.formatValue(1234.56); // \"$1,234.56\"\n * const parsed = formatter.parseValue(\"$1,234.56\"); // 1234.56\n * ```\n */\nexport function useNumberFormatter(options: UseNumberFormatterOptions = {}): UseNumberFormatterExposes {\n const { value, locale, localeMatcher, mode = 'decimal', currency, currencyDisplay, useGrouping = true, minFractionDigits, maxFractionDigits, roundingMode, prefix, suffix, min, format = true } = options;\n\n // Internal refs for regex patterns\n const numberFormat = React.useRef<Intl.NumberFormat | null>(null);\n const groupCharRef = React.useRef<string | null>(null);\n const prefixCharRef = React.useRef<string | null>(null);\n const suffixCharRef = React.useRef<string | null>(null);\n const _numeral = React.useRef<RegExp | null>(null);\n const _group = React.useRef<RegExp | null>(null);\n const _minusSign = React.useRef<RegExp | null>(null);\n const _currency = React.useRef<RegExp | null>(null);\n const _decimal = React.useRef<RegExp | null>(null);\n const _suffix = React.useRef<RegExp | null>(null);\n const _prefix = React.useRef<RegExp | null>(null);\n const _index = React.useRef<((d: string) => number | undefined) | null>(null);\n\n const getOptions = () => {\n return {\n localeMatcher: localeMatcher,\n style: mode,\n currency: currency,\n currencyDisplay: currencyDisplay,\n useGrouping: useGrouping,\n minimumFractionDigits: minFractionDigits ?? undefined,\n maximumFractionDigits: maxFractionDigits ?? undefined,\n roundingMode: roundingMode\n };\n };\n\n const escapeRegExp = (text: string) => {\n return text.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n };\n\n const getDecimalExpression = () => {\n const formatter = new Intl.NumberFormat(locale, { ...getOptions(), useGrouping: false });\n\n return new RegExp(\n `[${formatter\n .format(1.1)\n .replace(_currency.current ?? '', '')\n .trim()\n .replace(_numeral.current ?? '', '')}]`,\n 'g'\n );\n };\n\n const getGroupingExpression = () => {\n const formatter = new Intl.NumberFormat(locale, { useGrouping: true });\n\n groupCharRef.current = formatter\n .format(1000000)\n .trim()\n .replace(_numeral.current ?? '', '')\n .charAt(0);\n\n return new RegExp(`[${groupCharRef.current}]`, 'g');\n };\n\n const getMinusSignExpression = () => {\n const formatter = new Intl.NumberFormat(locale, { useGrouping: false });\n\n return new RegExp(\n `[${formatter\n .format(-1)\n .trim()\n .replace(_numeral.current ?? '', '')}]`,\n 'g'\n );\n };\n\n const getCurrencyExpression = () => {\n if (currency) {\n const formatter = new Intl.NumberFormat(locale, { style: 'currency', currency: currency, currencyDisplay: currencyDisplay, minimumFractionDigits: 0, maximumFractionDigits: 0, roundingMode: roundingMode });\n\n return new RegExp(\n `[${formatter\n .format(1)\n .replace(/\\s/g, '')\n .replace(_numeral.current ?? '', '')\n .replace(_group.current ?? '', '')}]`,\n 'g'\n );\n }\n\n return new RegExp(`[]`, 'g');\n };\n\n const getPrefixExpression = () => {\n if (prefix) {\n _prefix.current = new RegExp(escapeRegExp(prefix), 'g');\n } else {\n const formatter = new Intl.NumberFormat(locale, { style: mode, currency: currency, currencyDisplay: currencyDisplay });\n\n const prefixStr = formatter.format(1).split('1')[0];\n\n _prefix.current = new RegExp(escapeRegExp(prefixStr), 'g');\n }\n\n return _prefix.current;\n };\n\n const getSuffixExpression = () => {\n if (suffix) {\n _suffix.current = new RegExp(escapeRegExp(suffix), 'g');\n } else {\n const formatter = new Intl.NumberFormat(locale, { style: mode, currency: currency, currencyDisplay: currencyDisplay, minimumFractionDigits: 0, maximumFractionDigits: 0, roundingMode: roundingMode });\n\n const suffixStr = formatter.format(1).split('1')[1];\n\n _suffix.current = new RegExp(escapeRegExp(suffixStr), 'g');\n }\n\n return _suffix.current;\n };\n\n const constructParser = () => {\n numberFormat.current = new Intl.NumberFormat(locale, getOptions());\n const numerals = [...new Intl.NumberFormat(locale, { useGrouping: false }).format(9876543210)].reverse();\n const index = new Map(numerals.map((d, i) => [d, i]));\n\n _numeral.current = new RegExp(`[${numerals.join('')}]`, 'g');\n _group.current = getGroupingExpression();\n _minusSign.current = getMinusSignExpression();\n _currency.current = getCurrencyExpression();\n _decimal.current = getDecimalExpression();\n _suffix.current = getSuffixExpression();\n _prefix.current = getPrefixExpression();\n _index.current = (d) => index.get(d);\n\n // Set prefix and suffix chars\n if (prefix) {\n prefixCharRef.current = prefix;\n } else {\n const formatter = new Intl.NumberFormat(locale, { style: mode, currency: currency, currencyDisplay: currencyDisplay });\n\n prefixCharRef.current = formatter.format(1).split('1')[0];\n }\n\n if (suffix) {\n suffixCharRef.current = suffix;\n } else {\n const formatter = new Intl.NumberFormat(locale, { style: mode, currency: currency, currencyDisplay: currencyDisplay, minimumFractionDigits: 0, maximumFractionDigits: 0, roundingMode: roundingMode });\n\n suffixCharRef.current = formatter.format(1).split('1')[1];\n }\n };\n\n const formatValue = (value: number | string | null | undefined) => {\n if (value != null) {\n if (typeof value === 'string' && value === '-') {\n // Minus sign\n return value;\n }\n\n if (format) {\n const formatter = new Intl.NumberFormat(locale, getOptions());\n const numericValue = typeof value === 'string' ? Number(value) : value;\n let formattedValue = formatter.format(numericValue);\n\n if (prefix) {\n formattedValue = prefix + formattedValue;\n }\n\n if (suffix) {\n formattedValue = formattedValue + suffix;\n }\n\n return formattedValue;\n }\n\n return value.toString();\n }\n\n return '';\n };\n\n const parseValue = (text: string) => {\n let cleanText = text\n .replace(_suffix.current || '', '')\n .replace(_prefix.current || '', '')\n .trim()\n .replace(/\\s/g, '')\n .replace(_currency.current || '', '');\n\n if (_decimal.current && _minusSign.current && _numeral.current) {\n const validChars = new RegExp(\n `[${[...new Intl.NumberFormat(locale, { useGrouping: false }).format(9876543210)].reverse().join('')}${new Intl.NumberFormat(locale).format(1.1).replace(/[0-9]/g, '')}${new Intl.NumberFormat(locale)\n .format(-1)\n .replace(/[0-9]/g, '')}]`,\n 'g'\n );\n\n cleanText = cleanText.match(validChars)?.join('') || '';\n }\n\n if (_group.current) {\n cleanText = cleanText.replace(_group.current, '');\n }\n\n if (_minusSign.current) {\n cleanText = cleanText.replace(_minusSign.current, '-');\n }\n\n if (_decimal.current) {\n cleanText = cleanText.replace(_decimal.current, '.');\n }\n\n if (_numeral.current && _index.current) {\n cleanText = cleanText.replace(_numeral.current, (d) => {\n const res = _index.current ? _index.current(d) : undefined;\n\n return res !== undefined ? res.toString() : '';\n });\n }\n\n if (cleanText) {\n if (cleanText === '-') return cleanText;\n\n const parsedValue = +cleanText;\n\n return isNaN(parsedValue) ? null : parsedValue;\n }\n\n return null;\n };\n\n const addWithPrecision = (base: number, increment: number) => {\n const baseStr = base.toString();\n const stepStr = increment.toString();\n\n const baseDecimalPlaces = baseStr.includes('.') ? baseStr.split('.')[1].length : 0;\n const stepDecimalPlaces = stepStr.includes('.') ? stepStr.split('.')[1].length : 0;\n\n const maxDecimalPlaces = Math.max(baseDecimalPlaces, stepDecimalPlaces);\n const precision = Math.pow(10, maxDecimalPlaces);\n\n return Math.round((base + increment) * precision) / precision;\n };\n\n const isDecimalMode = () => {\n return mode === 'decimal';\n };\n\n const resetRegex = () => {\n if (_numeral.current) _numeral.current.lastIndex = 0;\n\n if (_decimal.current) _decimal.current.lastIndex = 0;\n\n if (_group.current) _group.current.lastIndex = 0;\n\n if (_minusSign.current) _minusSign.current.lastIndex = 0;\n };\n\n const isNumeralChar = (char: string) => {\n if (char.length === 1 && ((_numeral.current && _numeral.current.test(char)) || (_decimal.current && _decimal.current.test(char)) || (_group.current && _group.current.test(char)) || (_minusSign.current && _minusSign.current.test(char)))) {\n resetRegex();\n\n return true;\n }\n\n return false;\n };\n\n const isMinusSignFn = (char: string) => {\n if ((_minusSign.current && _minusSign.current.test(char)) || char === '-') {\n if (_minusSign.current) {\n _minusSign.current.lastIndex = 0;\n }\n\n return true;\n }\n\n return false;\n };\n\n const isDecimalSignFn = (char: string) => {\n if ((locale?.includes('fr') && ['.', ','].includes(char)) || (_decimal.current && _decimal.current.test(char))) {\n if (_decimal.current) {\n _decimal.current.lastIndex = 0;\n }\n\n return true;\n }\n\n return false;\n };\n\n const allowMinusSign = () => {\n return min === undefined || min === null || min < 0;\n };\n\n const getDecimalCharIndexes = (val: string) => {\n const decimalCharIndex = _decimal.current ? val.search(_decimal.current) : -1;\n\n if (_decimal.current) {\n _decimal.current.lastIndex = 0;\n }\n\n const filteredVal = val\n .replace(_prefix.current || '', '')\n .trim()\n .replace(/\\s/g, '')\n .replace(_currency.current || '', '');\n const decimalCharIndexWithoutPrefix = _decimal.current ? filteredVal.search(_decimal.current) : -1;\n\n if (_decimal.current) {\n _decimal.current.lastIndex = 0;\n }\n\n return { decimalCharIndex, decimalCharIndexWithoutPrefix };\n };\n\n const getCharIndexes = (val: string) => {\n const resetRegexLastIndex = (regex: RegExp | null) => {\n if (regex) {\n regex.lastIndex = 0;\n }\n };\n\n const decimalCharIndex = _decimal.current ? val.search(_decimal.current) : -1;\n\n resetRegexLastIndex(_decimal.current);\n\n const minusCharIndex = _minusSign.current ? val.search(_minusSign.current) : -1;\n\n resetRegexLastIndex(_minusSign.current);\n\n const suffixCharIndex = _suffix.current ? val.search(_suffix.current) : -1;\n\n resetRegexLastIndex(_suffix.current);\n\n const currencyCharIndex = _currency.current ? val.search(_currency.current) : -1;\n\n resetRegexLastIndex(_currency.current);\n\n return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex };\n };\n\n const getDecimalLength = (value: string) => {\n if (value) {\n const valueSplit = value.split(_decimal.current ?? '');\n\n if (valueSplit.length === 2) {\n return valueSplit[1]\n .replace(_suffix.current ?? '', '')\n .trim()\n .replace(/\\s/g, '')\n .replace(_currency.current ?? '', '').length;\n }\n }\n\n return 0;\n };\n\n const concatValues = (val1: string, val2: string) => {\n if (val1 && val2) {\n const decimalRegex = _decimal.current;\n const decimalCharIndex = decimalRegex ? val2.search(decimalRegex) : -1;\n\n if (decimalRegex) {\n decimalRegex.lastIndex = 0;\n }\n\n if (suffixCharRef.current) {\n return decimalCharIndex !== -1 ? val1.replace(suffixCharRef.current, '').split(decimalRegex ?? '')[0] + val2.replace(suffixCharRef.current, '').slice(decimalCharIndex) + suffixCharRef.current : val1;\n } else if (prefixCharRef.current) {\n return decimalCharIndex !== -1 ? val1.split(decimalRegex ?? '')[0] + val2.slice(decimalCharIndex) : val1;\n }\n }\n\n return val1;\n };\n\n React.useEffect(() => {\n constructParser();\n }, [locale, localeMatcher, mode, currency, currencyDisplay, useGrouping, minFractionDigits, maxFractionDigits, roundingMode, prefix, suffix]);\n\n return {\n formattedValue: formatValue(value),\n formatValue,\n parseValue,\n addWithPrecision,\n isDecimalMode,\n isNumeralChar,\n isMinusSign: isMinusSignFn,\n isDecimalSign: isDecimalSignFn,\n allowMinusSign,\n getDecimalCharIndexes,\n getCharIndexes,\n getDecimalLength,\n concatValues,\n groupChar: groupCharRef.current,\n prefixChar: prefixCharRef.current,\n suffixChar: suffixCharRef.current,\n resolvedOptions: () => numberFormat.current?.resolvedOptions(),\n constructParser\n };\n}\n","import * as React from 'react';\n\n/**\n * usePresence hook is used to manage the presence of a component.\n *\n * @param open - The open state.\n * @returns An object containing the present, exiting, mounted, and ref states.\n *\n * @example\n * ```tsx\n * const { present, exiting, mounted, ref } = usePresence(true);\n *\n * return present && (\n * <div className=\"card flex justify-center\"></div>\n * );\n */\n\nexport function usePresence(open: boolean, fallbackMs: number = 500) {\n const [present, setPresent] = React.useState(open);\n const [exiting, setExiting] = React.useState(false);\n const [mounted, setMounted] = React.useState(false);\n const ref = React.useRef<HTMLElement>(null);\n const cleanupRef = React.useRef<(() => void) | null>(null);\n const rafCleanupRef = React.useRef<(() => void) | null>(null);\n\n React.useEffect(() => {\n if (cleanupRef.current) {\n cleanupRef.current();\n cleanupRef.current = null;\n }\n\n if (rafCleanupRef.current) {\n rafCleanupRef.current();\n rafCleanupRef.current = null;\n }\n\n if (open) {\n setPresent(true);\n setExiting(false);\n\n const rafs: number[] = [];\n\n rafs.push(\n requestAnimationFrame(() => {\n rafs.push(\n requestAnimationFrame(() => {\n rafs.push(requestAnimationFrame(() => setMounted(true)));\n })\n );\n })\n );\n\n rafCleanupRef.current = () => {\n rafs.forEach((raf) => cancelAnimationFrame(raf));\n rafs.length = 0;\n };\n } else if (ref.current) {\n setExiting(true);\n setMounted(false);\n const node = ref.current;\n let isHandled = false;\n\n const handleEnd = () => {\n if (isHandled) return;\n\n isHandled = true;\n\n setPresent(false);\n setExiting(false);\n\n node.removeEventListener('transitionend', handleEnd);\n node.removeEventListener('animationend', handleEnd);\n\n cleanupRef.current = null;\n };\n\n node.addEventListener('transitionend', handleEnd, { passive: true });\n node.addEventListener('animationend', handleEnd, { passive: true });\n\n // const fallbackTimeout = setTimeout(() => {\n // if (!isHandled) {\n // handleEnd();\n // }\n // }, fallbackMs);\n\n cleanupRef.current = () => {\n // clearTimeout(fallbackTimeout);\n\n if (!isHandled) {\n node.removeEventListener('transitionend', handleEnd);\n node.removeEventListener('animationend', handleEnd);\n }\n };\n } else {\n setMounted(false);\n setPresent(false);\n setExiting(false);\n }\n }, [open, fallbackMs]);\n\n React.useEffect(() => {\n return () => {\n if (cleanupRef.current) {\n cleanupRef.current();\n }\n\n if (rafCleanupRef.current) {\n rafCleanupRef.current();\n }\n };\n }, []);\n\n return { present, exiting, mounted, ref };\n}\n","import * as React from 'react';\n\n/**\n * Used to merge and differentiate incoming props with the default props.\n * - Keys that exist in both `props1` and `props2` are placed in `props`, with values from `props2`.\n * - Keys that exist in `props2` but not in `props1` are placed in `attrs`.\n *\n * @template P1 The type of the default set of props.\n * @template P2 The type of the incoming set of props.\n *\n * @param props1 The default set of props (e.g., default props).\n * @param props2 The incoming set of props (e.g., user-defined or dynamic props).\n * @returns An object containing:\n * - `props`: A new object containing keys that exist in both `props1` and `props2`, using values from `props2`.\n * - `attrs`: A new object containing keys that exist only in `props2`, excluding any keys from `props1`.\n *\n * @example\n * ```ts\n * const { props, attrs } = useProps({ className: 'baz' }, { id: 'foo', className: 'bar' });\n *\n * console.log(props); // { className: 'bar' }\n * console.log(attrs); // { id: 'foo' }\n * ```\n */\nexport function useProps<P1, P2>(props1: P1 = {} as P1, props2: P2 = {} as P2) {\n type Props = Pick<P1 & P2, keyof P1>;\n type Attrs = Omit<P2, keyof P1>;\n type Result = { props: Props; attrs: Attrs };\n\n return React.useMemo(() => {\n const result: Result = { props: { ...props1 } as Props, attrs: {} as Attrs };\n\n Object.entries(props2 as Record<string, unknown>).forEach(([key, value]) => {\n if (key in (props1 as Record<string, unknown>)) {\n (result.props as Record<string, unknown>)[key] = value;\n } else {\n (result.attrs as Record<string, unknown>)[key] = value;\n }\n });\n\n return result;\n }, [props1, props2]);\n}\n","import * as React from 'react';\n\nexport const useQueueTask = () => {\n const tasksRef = React.useRef(new Map<string | number, () => void>());\n const scheduledRef = React.useRef(false);\n\n const flush = React.useCallback(() => {\n scheduledRef.current = false;\n const tasks = tasksRef.current;\n\n tasksRef.current = new Map();\n tasks.forEach((task) => task());\n }, []);\n\n return React.useCallback(\n (id: string | number, task: () => void) => {\n tasksRef.current.set(id, task);\n\n if (!scheduledRef.current) {\n scheduledRef.current = true;\n queueMicrotask(flush);\n }\n },\n [flush]\n );\n};\n","import { getWindowScrollTop } from '@primeuix/utils';\nimport * as React from 'react';\n\n/**\n * The options for the `useScrollTop` hook.\n */\nexport interface UseScrollTopOptions {\n /**\n * Reference to the target element.\n * @default window\n */\n target?: Window | Element | null;\n /**\n * Defines the threshold value of the vertical scroll position of the target to toggle the visibility.\n * @default 400\n */\n threshold?: number;\n /**\n * Defines the scrolling behaviour, 'smooth' adds an animation and 'auto' scrolls with a jump.\n * @default smooth\n */\n behavior?: ScrollBehavior;\n}\n\n/**\n * The exposes for the `useScrollTop` hook.\n */\nexport interface UseScrollTopExposes {\n /**\n * Current visible state as a boolean.\n * @default false\n */\n visible: boolean;\n /**\n * Scrolls the target element to the top.\n */\n scrollToTop: () => void;\n}\n\n/**\n * useScrollTop hook is used to enter input in a certain format such as numeric, date, currency, email and phone.\n *\n * @param {UseScrollTopOptions} options - The options for the scroll top behavior.\n * @returns {UseScrollTopExposes} - The exposed methods for the scroll top behavior.\n *\n * @example\n * ```tsx\n * const { scrollToTop, visible } = useScrollTop({\n * target: elementRef.current,\n * threshold: 400,\n * behavior: 'smooth'\n * });\n *\n * return (\n * <div ref={elementRef}>\n * {visible && (\n * <Button onClick={scrollToTop}>\n * <i className=\"pi pi-arrow-up\" />\n * </Button>\n * )}\n * </div>\n * );\n */\nexport function useScrollTop(options?: UseScrollTopOptions): UseScrollTopExposes {\n const { target = typeof window !== 'undefined' ? window : null, threshold = 400, behavior = 'smooth' } = options || {};\n const [visible, setVisible] = React.useState(false);\n\n const scrollToTop = () => {\n target?.scroll({\n top: 0,\n behavior: behavior\n });\n };\n\n React.useEffect(() => {\n if (!target) return;\n\n const checkVisibility = (scrollY: number) => {\n if (scrollY > threshold) setVisible(true);\n else setVisible(false);\n };\n\n const onScroll = () => {\n const scrollY = target === window ? getWindowScrollTop() : (target as Element).scrollTop;\n\n checkVisibility(scrollY);\n };\n\n target.addEventListener('scroll', onScroll);\n\n return () => {\n target.removeEventListener('scroll', onScroll);\n };\n }, [target, threshold]);\n\n return {\n //state\n visible,\n //methods\n scrollToTop\n };\n}\n","import * as React from 'react';\n\n/**\n * Custom hook that runs an unmount effect only once.\n * This is similar to `useEffect`, but it only runs on unmount.\n *\n * @param {React.EffectCallback} effect the callback function\n * @returns {void}\n *\n * @example\n * ```tsx\n * const Component = () => {\n * useUnmountEffect(() => {\n * console.log('Unmounted');\n * });\n * };\n * ```\n */\nexport function useUnmountEffect(effect: React.EffectCallback): void {\n React.useEffect(() => {\n return () => {\n effect?.();\n };\n }, []);\n}\n","import * as React from 'react';\n\n/**\n * Custom hook that runs an update effect whenever dependencies change.\n * This is similar to `useEffect`, but it does not run on mount.\n *\n * @param {React.EffectCallback} effect the callback function\n * @param {React.DependencyList} dependencies the dependencies\n * @returns {void}\n *\n * @example\n * ```tsx\n * const Component = ({ value }) => {\n * useUpdateEffect(() => {\n * console.log('Updated');\n * }, [value]);\n * };\n * ```\n */\nexport function useUpdateEffect(effect: React.EffectCallback, dependencies?: React.DependencyList): void {\n const mounted = React.useRef<boolean>(false);\n\n React.useEffect(() => {\n if (!mounted.current) {\n mounted.current = true;\n\n return;\n }\n\n return effect?.();\n }, dependencies);\n}\n","import * as React from 'react';\n\n/**\n * Starts a view transition.\n *\n * @returns A function that starts a view transition.\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const startTransition = useViewTransition();\n *\n * const handleClick = () => {\n * startTransition(() => {\n * // Perform some work\n * });\n * };\n *\n * return <button onClick={handleClick}>Click me</button>;\n * };\n */\nexport function useViewTransition() {\n const startTransition = React.useCallback((callback: () => void) => {\n if (document.startViewTransition) {\n document.startViewTransition(() => {\n callback();\n });\n } else {\n callback();\n }\n }, []);\n\n return startTransition;\n}\n","import * as React from 'react';\n\n/**\n * useVisibilityChange hook is used to check if the document is visible.\n *\n * @returns A boolean indicating whether the document is visible.\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const isVisible = useVisibilityChange();\n *\n * return <div>{isVisible ? 'Visible' : 'Hidden'}</div>;\n * };\n */\nexport function useVisibilityChange() {\n const [isVisible, setIsVisible] = React.useState(true);\n\n React.useEffect(() => {\n const handleVisibilityChange = () => {\n setIsVisible(!document.hidden);\n };\n\n handleVisibilityChange();\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange);\n };\n }, []);\n\n return isVisible;\n}\n"],"mappings":"+bAAA,UAAYA,OAAW,QAchB,SAASC,GAAgBC,EAAiB,GAAY,CACzD,IAAMC,EAAW,SAAM,EAEvB,OAAa,WAAQ,IAAM,GAAGD,CAAM,GAAGC,EAAG,WAAW,SAAU,EAAE,CAAC,GAAG,KAAK,EAAE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BA,UAAYE,OAAW,QAqBhB,SAASC,IAAoB,CAWhC,OAV8B,eAAaC,GAAyB,CAC5D,SAAS,oBACT,SAAS,oBAAoB,IAAM,CAC/BA,EAAS,CACb,CAAC,EAEDA,EAAS,CAEjB,EAAG,CAAC,CAAC,CAGT,CCjCA,UAAYC,OAAW,QAehB,SAASC,IAAsB,CAClC,GAAM,CAACC,EAAWC,CAAY,EAAU,YAAS,EAAI,EAErD,OAAM,aAAU,IAAM,CAClB,IAAMC,EAAyB,IAAM,CACjCD,EAAa,CAAC,SAAS,MAAM,CACjC,EAEA,OAAAC,EAAuB,EAEvB,SAAS,iBAAiB,mBAAoBA,CAAsB,EAE7D,IAAM,CACT,SAAS,oBAAoB,mBAAoBA,CAAsB,CAC3E,CACJ,EAAG,CAAC,CAAC,EAEEF,CACX","names":["React","useAttrSelector","prefix","id","resolve","React","useControlledState","value","defaultValue","onChange","isControlled","valueState","setValueState","computedValue","setValue","inValue","newValue","onChangeParam","getTargetElement","isNotEmpty","React","React","usePrevious","value","ref","useEventListener","target","type","listener","options","when","targetRef","listenerRef","prevListener","usePrevious","prevOptions","bind","bindOptions","bindTarget","isNotEmpty","unbind","getTargetElement","event","_a","dispose","updateTarget","listenerChanged","optionsChanged","listenerExists","React","useHotKey","keys","handler","options","target","event","when","handlerRef","normalizeKey","key","lower","parseKeySpec","spec","parts","p","required","part","matches","targetElement","keySpecs","listener","_a","keyboardEvent","React","useId","initialValue","idx","idState","setIdState","isAndroid","useKeyFilter","options","pattern","validateOnly","DEFAULT_MASKS","getRegex","onBeforeInput","event","validateKey","onKeyPress","onPaste","regex","c","key","value","validatePattern","useMountEffect","getUserAgent","React","useMask","options","mask","unmask","slotChar","autoClear","readOnly","onMaskChange","target","len","tests","buffer","defaultBuffer","partialPosition","androidChrome","focus","focusText","firstNonMaskPos","lastRequiredNonMaskPos","caretTimeoutId","oldVal","currentVal","onMaskInput","event","handleAndroidInput","handleInputChange","onMaskKeyDown","_a","k","pos","begin","end","iPhone","caret","seekPrev","seekNext","clearBuffer","shiftL","updateModelValue","checkVal","onMaskKeyPress","p","c","next","shiftR","writeBuffer","onMaskFocus","onMaskBlur","e","onMaskPaste","first","last","_b","getPlaceholder","i","j","t","curVal","start","allow","_c","_d","test","lastMatch","currentTest","isPasteEvent","unmaskValue","value","unmaskedBuffer","thisbuffer","val","finalValue","updateValue","updateModel","initMask","defs","ua","maskTokens","React","useMatchMedia","query","when","matches","setMatches","matchMedia","handleChange","event","bind","_a","unbind","React","useMountEffect","effect","mounted","React","useNumberFormatter","options","value","locale","localeMatcher","mode","currency","currencyDisplay","useGrouping","minFractionDigits","maxFractionDigits","roundingMode","prefix","suffix","min","format","numberFormat","groupCharRef","prefixCharRef","suffixCharRef","_numeral","_group","_minusSign","_currency","_decimal","_suffix","_prefix","_index","getOptions","escapeRegExp","text","getDecimalExpression","_a","_b","formatter","__spreadProps","__spreadValues","getGroupingExpression","getMinusSignExpression","getCurrencyExpression","getPrefixExpression","prefixStr","getSuffixExpression","suffixStr","constructParser","numerals","index","d","i","formatValue","numericValue","formattedValue","parseValue","cleanText","validChars","res","parsedValue","addWithPrecision","base","increment","baseStr","stepStr","baseDecimalPlaces","stepDecimalPlaces","maxDecimalPlaces","precision","isDecimalMode","resetRegex","isNumeralChar","char","isMinusSignFn","isDecimalSignFn","allowMinusSign","getDecimalCharIndexes","val","decimalCharIndex","filteredVal","decimalCharIndexWithoutPrefix","getCharIndexes","resetRegexLastIndex","regex","minusCharIndex","suffixCharIndex","currencyCharIndex","getDecimalLength","_c","valueSplit","concatValues","val1","val2","decimalRegex","React","usePresence","open","fallbackMs","present","setPresent","exiting","setExiting","mounted","setMounted","ref","cleanupRef","rafCleanupRef","rafs","raf","node","isHandled","handleEnd","React","useProps","props1","props2","result","__spreadValues","key","value","React","useQueueTask","tasksRef","scheduledRef","flush","tasks","task","id","getWindowScrollTop","React","useScrollTop","options","target","threshold","behavior","visible","setVisible","scrollToTop","checkVisibility","scrollY","onScroll","React","useUnmountEffect","effect","React","useUpdateEffect","effect","dependencies","mounted","React","useViewTransition","callback","React","useVisibilityChange","isVisible","setIsVisible","handleVisibilityChange"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primereact/hooks",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.10",
|
|
4
4
|
"author": "PrimeTek Informatics",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://primereact.org/",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/primefaces/primereact.git",
|
|
11
|
-
"directory": "packages/hooks"
|
|
11
|
+
"directory": "packages/@primereact/hooks"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/primefaces/primereact/issues"
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@primeuix/utils": "^0.6.
|
|
35
|
+
"@primeuix/utils": "^0.6.4"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{resolve as
|
|
1
|
+
import{resolve as a}from"@primeuix/utils";import*as n from"react";function w({value:r,defaultValue:t,onChange:o}){let e=n.useRef(r!==void 0).current,[i,u]=n.useState(()=>e?void 0:t!=null?t:r),s=e?r:i,d=n.useCallback(c=>{let[l,T]=a(c,s,e);o==null||o(T),e||u(l)},[s,e,o]);return n.useEffect(()=>{e||u(t)},[t,e]),[s,d,e]}export{w as useControlledState};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/use-controlled-state/index.ts"],"sourcesContent":["import { resolve } from '@primeuix/utils';\nimport * as React from 'react';\n\n/**\n * The options for the `useControlledState` hook.\n */\nexport interface UseControlledStateOptions<T = unknown, E = unknown> {\n /**\n * The value of the controlled state.\n */\n value?: T | undefined;\n /**\n * The default value of the uncontrolled state.\n */\n defaultValue?: T | undefined;\n /**\n * Callback function that is called when the value changes.\n */\n onChange?: (newValue: E) => void;\n}\n\n/**\n * The return type of the `useControlledState` hook.\n * A tuple containing the current value and a function to update it.\n */\nexport type UseControlledStateReturnType<T = unknown> = [T | undefined, (inValue: unknown | ((prev?: T) => unknown)) => void, boolean];\n\n/**\n * A custom hook that manages controlled and uncontrolled state.\n *\n * @param {UseControlledStateOptions} options - The options for the controlled state.\n * @returns A tuple containing the current value and a function to update it.\n *\n * @example\n * ```tsx\n * const ControlledComponent = () => {\n * const [controlledValue, setControlledValue] = React.useState('');\n *\n * const [value, setValue] = useControlledState({\n * value: controlledValue,\n * defaultValue: 'initial value',\n * onChange: (newValue) => {\n * setControlledValue(newValue);\n * }\n * });\n *\n * return <Component value={value} onChange={(e) => setValue(e.target.value)} />;\n * };\n * ```\n */\nexport function useControlledState<T = unknown, E = T>({ value, defaultValue, onChange }: UseControlledStateOptions<T, E>): UseControlledStateReturnType<T | undefined> {\n const [valueState, setValueState] = React.useState<T | undefined>(
|
|
1
|
+
{"version":3,"sources":["../../src/use-controlled-state/index.ts"],"sourcesContent":["import { resolve } from '@primeuix/utils';\nimport * as React from 'react';\n\n/**\n * The options for the `useControlledState` hook.\n */\nexport interface UseControlledStateOptions<T = unknown, E = unknown> {\n /**\n * The value of the controlled state.\n */\n value?: T | undefined;\n /**\n * The default value of the uncontrolled state.\n */\n defaultValue?: T | undefined;\n /**\n * Callback function that is called when the value changes.\n */\n onChange?: (newValue: E) => void;\n}\n\n/**\n * The return type of the `useControlledState` hook.\n * A tuple containing the current value and a function to update it.\n */\nexport type UseControlledStateReturnType<T = unknown> = [T | undefined, (inValue: unknown | ((prev?: T) => unknown)) => void, boolean];\n\n/**\n * A custom hook that manages controlled and uncontrolled state.\n *\n * @param {UseControlledStateOptions} options - The options for the controlled state.\n * @returns A tuple containing the current value and a function to update it.\n *\n * @example\n * ```tsx\n * const ControlledComponent = () => {\n * const [controlledValue, setControlledValue] = React.useState('');\n *\n * const [value, setValue] = useControlledState({\n * value: controlledValue,\n * defaultValue: 'initial value',\n * onChange: (newValue) => {\n * setControlledValue(newValue);\n * }\n * });\n *\n * return <Component value={value} onChange={(e) => setValue(e.target.value)} />;\n * };\n * ```\n */\nexport function useControlledState<T = unknown, E = T>({ value, defaultValue, onChange }: UseControlledStateOptions<T, E>): UseControlledStateReturnType<T | undefined> {\n const isControlledRef = React.useRef(value !== undefined);\n const isControlled = isControlledRef.current;\n\n const [valueState, setValueState] = React.useState<T | undefined>(() => {\n return isControlled ? undefined : (defaultValue ?? value);\n });\n\n const computedValue = isControlled ? (value as T) : valueState;\n\n const setValue = React.useCallback(\n (inValue: unknown | ((prev?: T) => unknown)) => {\n // @todo - update resolve to accept multiple parameters\n const [newValue, onChangeParam] = resolve(inValue, computedValue, isControlled) as [T, E];\n\n onChange?.(onChangeParam);\n\n if (!isControlled) {\n setValueState(newValue);\n }\n },\n [computedValue, isControlled, onChange]\n );\n\n React.useEffect(() => {\n if (!isControlled) {\n setValueState(defaultValue);\n }\n }, [defaultValue, isControlled]);\n\n return [computedValue, setValue, isControlled];\n}\n"],"mappings":"AAAA,OAAS,WAAAA,MAAe,kBACxB,UAAYC,MAAW,QAiDhB,SAASC,EAAuC,CAAE,MAAAC,EAAO,aAAAC,EAAc,SAAAC,CAAS,EAAiF,CAEpK,IAAMC,EADwB,SAAOH,IAAU,MAAS,EACnB,QAE/B,CAACI,EAAYC,CAAa,EAAU,WAAwB,IACvDF,EAAe,OAAaF,GAAA,KAAAA,EAAgBD,CACtD,EAEKM,EAAgBH,EAAgBH,EAAcI,EAE9CG,EAAiB,cAClBC,GAA+C,CAE5C,GAAM,CAACC,EAAUC,CAAa,EAAIb,EAAQW,EAASF,EAAeH,CAAY,EAE9ED,GAAA,MAAAA,EAAWQ,GAENP,GACDE,EAAcI,CAAQ,CAE9B,EACA,CAACH,EAAeH,EAAcD,CAAQ,CAC1C,EAEA,OAAM,YAAU,IAAM,CACbC,GACDE,EAAcJ,CAAY,CAElC,EAAG,CAACA,EAAcE,CAAY,CAAC,EAExB,CAACG,EAAeC,EAAUJ,CAAY,CACjD","names":["resolve","React","useControlledState","value","defaultValue","onChange","isControlled","valueState","setValueState","computedValue","setValue","inValue","newValue","onChangeParam"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type UseHotKeyTarget = Document | HTMLElement | null | undefined;
|
|
2
|
+
export interface UseHotKeyOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Target to listen on. Defaults to `document` when available.
|
|
5
|
+
*/
|
|
6
|
+
target?: UseHotKeyTarget;
|
|
7
|
+
/**
|
|
8
|
+
* Keyboard event type.
|
|
9
|
+
* @default 'keydown'
|
|
10
|
+
*/
|
|
11
|
+
event?: 'keydown' | 'keyup' | 'keypress';
|
|
12
|
+
/**
|
|
13
|
+
* Enables or disables the listener.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
when?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Runs the provided handler when any of the given keys is pressed.
|
|
20
|
+
*
|
|
21
|
+
* @param keys A single key or an array of keys to listen for (e.g. 'k' or 'ctrl+k').
|
|
22
|
+
* @param handler Callback fired when a matching key event occurs.
|
|
23
|
+
* @param options Optional configuration for target, event type, and enable flag.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useHotKey(keys: string | string[], handler: (event: KeyboardEvent) => void, options?: UseHotKeyOptions): void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as a from"react";function k(o,u,p={}){let{target:c,event:f="keydown",when:l=!0}=p,i=a.useRef(u),y=t=>{let e=t.toLowerCase();return e==="space"||e==="spacebar"?" ":e},d=t=>{let e=t.split("+").map(s=>s.trim().toLowerCase()).filter(Boolean),r,n={ctrl:!1,meta:!1,alt:!1,shift:!1};return e.forEach(s=>{switch(s){case"ctrl":case"control":n.ctrl=!0;break;case"meta":case"cmd":case"command":n.meta=!0;break;case"alt":case"option":n.alt=!0;break;case"shift":n.shift=!0;break;default:r=y(s)}}),{key:r,required:n}},K=(t,e)=>{if(!t.key)return!1;let{required:r}=t;return r.ctrl!==e.ctrlKey||r.meta!==e.metaKey||r.alt!==e.altKey||r.shift!==e.shiftKey?!1:y(e.key)===t.key};a.useEffect(()=>{i.current=u},[u]),a.useEffect(()=>{if(!l)return;let t=c!=null?c:typeof document!="undefined"?document:null;if(!t)return;let e=(Array.isArray(o)?o:[o]).map(d),r=n=>{var m;let s=n;e.some(E=>K(E,s))&&((m=i.current)==null||m.call(i,s))};return t.addEventListener(f,r),()=>{t.removeEventListener(f,r)}},[f,o,c,l])}export{k as useHotKey};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/use-hot-key/index.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type UseHotKeyTarget = Document | HTMLElement | null | undefined;\n\nexport interface UseHotKeyOptions {\n /**\n * Target to listen on. Defaults to `document` when available.\n */\n target?: UseHotKeyTarget;\n /**\n * Keyboard event type.\n * @default 'keydown'\n */\n event?: 'keydown' | 'keyup' | 'keypress';\n /**\n * Enables or disables the listener.\n * @default true\n */\n when?: boolean;\n}\n\n/**\n * Runs the provided handler when any of the given keys is pressed.\n *\n * @param keys A single key or an array of keys to listen for (e.g. 'k' or 'ctrl+k').\n * @param handler Callback fired when a matching key event occurs.\n * @param options Optional configuration for target, event type, and enable flag.\n */\nexport function useHotKey(keys: string | string[], handler: (event: KeyboardEvent) => void, options: UseHotKeyOptions = {}) {\n const { target, event = 'keydown', when = true } = options;\n const handlerRef = React.useRef(handler);\n\n const normalizeKey = (key: string) => {\n const lower = key.toLowerCase();\n\n if (lower === 'space' || lower === 'spacebar') return ' ';\n\n return lower;\n };\n\n const parseKeySpec = (spec: string) => {\n const parts = spec\n .split('+')\n .map((p) => p.trim().toLowerCase())\n .filter(Boolean);\n\n let key: string | undefined;\n const required = {\n ctrl: false,\n meta: false,\n alt: false,\n shift: false\n };\n\n parts.forEach((part) => {\n switch (part) {\n case 'ctrl':\n case 'control':\n required.ctrl = true;\n break;\n case 'meta':\n case 'cmd':\n case 'command':\n required.meta = true;\n break;\n case 'alt':\n case 'option':\n required.alt = true;\n break;\n case 'shift':\n required.shift = true;\n break;\n default:\n key = normalizeKey(part);\n }\n });\n\n return { key, required };\n };\n\n const matches = (spec: ReturnType<typeof parseKeySpec>, event: KeyboardEvent) => {\n if (!spec.key) return false;\n\n const { required } = spec;\n\n if (required.ctrl !== event.ctrlKey || required.meta !== event.metaKey || required.alt !== event.altKey || required.shift !== event.shiftKey) {\n return false;\n }\n\n return normalizeKey(event.key) === spec.key;\n };\n\n React.useEffect(() => {\n handlerRef.current = handler;\n }, [handler]);\n\n React.useEffect(() => {\n if (!when) {\n return;\n }\n\n const targetElement: UseHotKeyTarget = target ?? (typeof document !== 'undefined' ? document : null);\n\n if (!targetElement) {\n return;\n }\n\n const keySpecs = (Array.isArray(keys) ? keys : [keys]).map(parseKeySpec);\n\n const listener: EventListener = (event) => {\n const keyboardEvent = event as KeyboardEvent;\n\n if (keySpecs.some((spec) => matches(spec, keyboardEvent))) {\n handlerRef.current?.(keyboardEvent);\n }\n };\n\n targetElement.addEventListener(event, listener);\n\n return () => {\n targetElement.removeEventListener(event, listener);\n };\n }, [event, keys, target, when]);\n}\n"],"mappings":"AAAA,UAAYA,MAAW,QA4BhB,SAASC,EAAUC,EAAyBC,EAAyCC,EAA4B,CAAC,EAAG,CACxH,GAAM,CAAE,OAAAC,EAAQ,MAAAC,EAAQ,UAAW,KAAAC,EAAO,EAAK,EAAIH,EAC7CI,EAAmB,SAAOL,CAAO,EAEjCM,EAAgBC,GAAgB,CAClC,IAAMC,EAAQD,EAAI,YAAY,EAE9B,OAAIC,IAAU,SAAWA,IAAU,WAAmB,IAE/CA,CACX,EAEMC,EAAgBC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AAAd,EAAqBe,GAE7B,EAEA,OAAAJ,EAAc,iBAAiBb,EAAOe,CAAQ,EAEvC,IAAM,CACTF,EAAc,oBAAoBb,EAAOe,CAAQ,CACrD,CACJ,EAAG,CAACf,EAAOJ,EAAMG,EAAQE,CAAI,CAAC,CAClC","names":["React","useHotKey","keys","handler","options","target","event","when","handlerRef","normalizeKey","key","lower","parseKeySpec","spec","parts","p","required","part","matches","targetElement","keySpecs","listener","_a","keyboardEvent"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface UseIntersectionObserverOptions extends IntersectionObserverInit {
|
|
2
|
+
/**
|
|
3
|
+
* Skip creating the IntersectionObserver
|
|
4
|
+
* @default false
|
|
5
|
+
*/
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Callback function that will be called when intersection changes
|
|
9
|
+
*/
|
|
10
|
+
onIntersect?: (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void;
|
|
11
|
+
/**
|
|
12
|
+
* If the IntersectionObserver API isn't available, set this fallback behavior
|
|
13
|
+
*/
|
|
14
|
+
fallback?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface UseIntersectionObserverResult {
|
|
17
|
+
/** The current intersection entries */
|
|
18
|
+
entries: IntersectionObserverEntry[];
|
|
19
|
+
/** Whether any of the observed elements are intersecting */
|
|
20
|
+
isIntersecting: boolean;
|
|
21
|
+
/** Function to start observing an element */
|
|
22
|
+
observe: (element: Element) => void;
|
|
23
|
+
/** Function to stop observing an element */
|
|
24
|
+
unobserve: (element: Element) => void;
|
|
25
|
+
/** Function to stop observing all elements */
|
|
26
|
+
disconnect: () => void;
|
|
27
|
+
/** The IntersectionObserver instance */
|
|
28
|
+
observer: IntersectionObserver | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Low-level hook for IntersectionObserver API.
|
|
32
|
+
* Provides direct access to observe/unobserve methods and entries.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Configuration options for the IntersectionObserver
|
|
35
|
+
* @returns Object containing observer methods and current entries
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const Component = () => {
|
|
40
|
+
* const ref = useRef(null);
|
|
41
|
+
* const { observe, isIntersecting, entries } = useIntersectionObserver({
|
|
42
|
+
* threshold: 0.5,
|
|
43
|
+
* onIntersect: (entries) => {
|
|
44
|
+
* console.log('Intersection changed:', entries);
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* useEffect(() => {
|
|
49
|
+
* if (ref.current) {
|
|
50
|
+
* observe(ref.current);
|
|
51
|
+
* }
|
|
52
|
+
* }, [observe]);
|
|
53
|
+
*
|
|
54
|
+
* return <div ref={ref}>Content</div>;
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function useIntersectionObserver(options?: UseIntersectionObserverOptions): UseIntersectionObserverResult;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var d=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var I=(s,o)=>{var c={};for(var t in s)k.call(s,t)&&o.indexOf(t)<0&&(c[t]=s[t]);if(s!=null&&d)for(var t of d(s))o.indexOf(t)<0&&g.call(s,t)&&(c[t]=s[t]);return c};import*as r from"react";function x(s={}){let v=s,{disabled:o=!1,onIntersect:c,fallback:t}=v,i=I(v,["disabled","onIntersect","fallback"]),[a,b]=r.useState([]),n=r.useRef(null),u=r.useRef(new Set),l=r.useRef(c);r.useEffect(()=>{l.current=c},[c]);let R=r.useMemo(()=>a.some(e=>e.isIntersecting),[a]);r.useEffect(()=>{if(!o){if(typeof window.IntersectionObserver=="undefined"){t&&t();return}return n.current=new IntersectionObserver((e,f)=>{b(e),l.current&&l.current(e,f)},i),u.current.forEach(e=>{n.current&&n.current.observe(e)}),()=>{n.current&&(n.current.disconnect(),n.current=null)}}},[o,t,i.root,i.rootMargin,i.threshold]);let O=r.useCallback(e=>{e&&(u.current.add(e),n.current&&n.current.observe(e))},[]),E=r.useCallback(e=>{e&&(u.current.delete(e),n.current&&n.current.unobserve(e),b(f=>f.filter(m=>m.target!==e)))},[]),p=r.useCallback(()=>{n.current&&n.current.disconnect(),u.current.clear(),b([])},[]);return{entries:a,isIntersecting:R,observe:O,unobserve:E,disconnect:p,observer:n.current}}export{x as useIntersectionObserver};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/use-intersection-observer/index.ts"],"sourcesContent":["import * as React from 'react';\n\nexport interface UseIntersectionObserverOptions extends IntersectionObserverInit {\n /**\n * Skip creating the IntersectionObserver\n * @default false\n */\n disabled?: boolean;\n /**\n * Callback function that will be called when intersection changes\n */\n onIntersect?: (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void;\n /**\n * If the IntersectionObserver API isn't available, set this fallback behavior\n */\n fallback?: () => void;\n}\n\nexport interface UseIntersectionObserverResult {\n /** The current intersection entries */\n entries: IntersectionObserverEntry[];\n /** Whether any of the observed elements are intersecting */\n isIntersecting: boolean;\n /** Function to start observing an element */\n observe: (element: Element) => void;\n /** Function to stop observing an element */\n unobserve: (element: Element) => void;\n /** Function to stop observing all elements */\n disconnect: () => void;\n /** The IntersectionObserver instance */\n observer: IntersectionObserver | null;\n}\n\n/**\n * Low-level hook for IntersectionObserver API.\n * Provides direct access to observe/unobserve methods and entries.\n *\n * @param options - Configuration options for the IntersectionObserver\n * @returns Object containing observer methods and current entries\n *\n * @example\n * ```tsx\n * const Component = () => {\n * const ref = useRef(null);\n * const { observe, isIntersecting, entries } = useIntersectionObserver({\n * threshold: 0.5,\n * onIntersect: (entries) => {\n * console.log('Intersection changed:', entries);\n * }\n * });\n *\n * useEffect(() => {\n * if (ref.current) {\n * observe(ref.current);\n * }\n * }, [observe]);\n *\n * return <div ref={ref}>Content</div>;\n * };\n * ```\n */\n\nexport function useIntersectionObserver(options: UseIntersectionObserverOptions = {}): UseIntersectionObserverResult {\n const { disabled = false, onIntersect, fallback, ...observerOptions } = options;\n\n const [entries, setEntries] = React.useState<IntersectionObserverEntry[]>([]);\n const observerRef = React.useRef<IntersectionObserver | null>(null);\n const elementsRef = React.useRef<Set<Element>>(new Set());\n\n const callbackRef = React.useRef(onIntersect);\n\n React.useEffect(() => {\n callbackRef.current = onIntersect;\n }, [onIntersect]);\n\n const isIntersecting = React.useMemo(() => {\n return entries.some((entry) => entry.isIntersecting);\n }, [entries]);\n\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n if (typeof window.IntersectionObserver === 'undefined') {\n if (fallback) {\n fallback();\n }\n\n return;\n }\n\n observerRef.current = new IntersectionObserver((observerEntries, observer) => {\n setEntries(observerEntries);\n\n if (callbackRef.current) {\n callbackRef.current(observerEntries, observer);\n }\n }, observerOptions);\n\n elementsRef.current.forEach((element) => {\n if (observerRef.current) {\n observerRef.current.observe(element);\n }\n });\n\n return () => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n };\n }, [disabled, fallback, observerOptions.root, observerOptions.rootMargin, observerOptions.threshold]);\n\n const observe = React.useCallback((element: Element) => {\n if (!element) return;\n\n elementsRef.current.add(element);\n\n if (observerRef.current) {\n observerRef.current.observe(element);\n }\n }, []);\n\n const unobserve = React.useCallback((element: Element) => {\n if (!element) return;\n\n elementsRef.current.delete(element);\n\n if (observerRef.current) {\n observerRef.current.unobserve(element);\n }\n\n setEntries((prev) => prev.filter((entry) => entry.target !== element));\n }, []);\n\n const disconnect = React.useCallback(() => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n }\n\n elementsRef.current.clear();\n setEntries([]);\n }, []);\n\n return {\n entries,\n isIntersecting,\n observe,\n unobserve,\n disconnect,\n observer: observerRef.current\n };\n}\n"],"mappings":"mRAAA,UAAYA,MAAW,QA8DhB,SAASC,EAAwBC,EAA0C,CAAC,EAAkC,CACjH,IAAwEC,EAAAD,EA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,EAAM,SAAWG,CAAO,CAAC,EACzE,EAAG,CAAC,CAAC,EAECI,EAAmB,cAAY,IAAM,CACnCX,EAAY,SACZA,EAAY,QAAQ,WAAW,EAGnCC,EAAY,QAAQ,MAAM,EAC1BF,EAAW,CAAC,CAAC,CACjB,EAAG,CAAC,CAAC,EAEL,MAAO,CACH,QAAAD,EACA,eAAAK,EACA,QAAAK,EACA,UAAAC,EACA,WAAAE,EACA,SAAUX,EAAY,OAC1B,CACJ","names":["React","useIntersectionObserver","options","_a","disabled","onIntersect","fallback","observerOptions","__objRest","entries","setEntries","observerRef","elementsRef","callbackRef","isIntersecting","entry","observerEntries","observer","element","observe","unobserve","prev","disconnect"]}
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The options for the `useKeyFilter` hook.
|
|
3
|
+
*/
|
|
4
|
+
export interface UseKeyFilterOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Sets the pattern for key filtering.
|
|
7
|
+
* @default /./
|
|
8
|
+
*/
|
|
9
|
+
pattern?: 'pint' | 'int' | 'pnum' | 'money' | 'num' | 'hex' | 'email' | 'alpha' | 'alphanum' | RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* When enabled, instead of blocking keys, input is validated internally to test against the regular expression.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
validateOnly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface UseKeyFilterExposes {
|
|
17
|
+
/**
|
|
18
|
+
* Handles input events for key filter.
|
|
19
|
+
* Processes character input and composition events while applying the filter pattern.
|
|
20
|
+
* @param event - The form or composition event from the input element
|
|
21
|
+
*/
|
|
22
|
+
onBeforeInput: (event: React.CompositionEvent<HTMLInputElement>) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Handles keypress events for character input validation.
|
|
25
|
+
* Validates and places characters according to the filter pattern.
|
|
26
|
+
* @param event - The keyboard event from the input element
|
|
27
|
+
*/
|
|
28
|
+
onKeyPress: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Handles paste events for clipboard content insertion.
|
|
31
|
+
* Processes pasted content according to the mask pattern.
|
|
32
|
+
* @param event - The clipboard event from the input element
|
|
33
|
+
*/
|
|
34
|
+
onPaste: (event: React.ClipboardEvent<HTMLInputElement>) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Validates the current input value against the filter pattern.
|
|
37
|
+
* @param event - The form event from the input element
|
|
38
|
+
* @returns true if the value matches the pattern, false otherwise
|
|
39
|
+
*/
|
|
40
|
+
validate: (event: React.FormEvent<HTMLInputElement>) => boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function useKeyFilter(options: UseKeyFilterOptions): UseKeyFilterExposes;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isAndroid as s}from"@primeuix/utils";function v(p){let{pattern:r=/./,validateOnly:o=!1}=p,u={pint:/[\d]/,int:/[\d-]/,pnum:/[\d.]/,money:/[\d.\s,]/,num:/[\d-.]/,hex:/[0-9a-f]/i,email:/[a-z0-9_.-@]/i,alpha:/[a-z_]/i,alphanum:/[a-z0-9_]/},i=()=>typeof r=="string"?u[r]:r,c=e=>{o||!s()||l(e,e.data)},m=e=>{o||s()||e.ctrlKey||e.altKey||e.metaKey||l(e,e.key)},d=e=>{if(o)return;let t=i();[...e.clipboardData.getData("text")].forEach(a=>{if(!t.test(a))return e.preventDefault(),!1})},l=(e,t)=>{if(t==null||!(t.length<=2))return;i().test(t)||e.preventDefault()};return{onBeforeInput:c,onKeyPress:m,onPaste:d,validate:e=>{let t=e.target.value,n=!0,a=i();return t&&!a.test(t)&&(n=!1),n}}}export{v as useKeyFilter};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|