@primereact/hooks 11.0.0-alpha.8 → 11.0.0-alpha.9
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 +2 -0
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +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-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/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './use-attr-selector';
|
|
2
2
|
export * from './use-controlled-state';
|
|
3
3
|
export * from './use-event-listener';
|
|
4
|
+
export * from './use-hot-key';
|
|
4
5
|
export * from './use-id';
|
|
5
6
|
export * from './use-key-filter';
|
|
6
7
|
export * from './use-mask';
|
|
@@ -9,6 +10,7 @@ export * from './use-mount-effect';
|
|
|
9
10
|
export * from './use-presence';
|
|
10
11
|
export * from './use-previous';
|
|
11
12
|
export * from './use-props';
|
|
13
|
+
export * from './use-queue-task';
|
|
12
14
|
export * from './use-scrolltop';
|
|
13
15
|
export * from './use-unmount-effect';
|
|
14
16
|
export * from './use-update-effect';
|
package/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var he=Object.defineProperty;var ee=Object.getOwnPropertySymbols;var Me=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var te=(o,t,i)=>t in o?he(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,ne=(o,t)=>{for(var i in t||(t={}))Me.call(t,i)&&te(o,i,t[i]);if(ee)for(var i of ee(t))Le.call(t,i)&&te(o,i,t[i]);return o};import*as D from"react";function Pe(o=""){let t=D.useId();return D.useMemo(()=>`${o}${t.replaceAll(/:|«|»/g,"")}`.trim().toLowerCase(),[t,o])}import{resolve as xe}from"@primeuix/utils";import*as U from"react";function Se({value:o,defaultValue:t,onChange:i}){let[d,E]=U.useState(t!=null?t:o),p=o!==void 0,R=p?o:d,u=U.useCallback(l=>{let[f,a]=xe(l,R,p);i==null||i(a),p||E(f)},[R,p,i]);return U.useEffect(()=>{p||E(t)},[t,p]),[R,u,p]}import{getTargetElement as re,isNotEmpty as ke}from"@primeuix/utils";import*as x from"react";import*as V from"react";function q(o){let t=V.useRef(null);return V.useEffect(()=>(t.current=o,()=>{t.current=null}),[o]),t.current}function Fe({target:o="document",type:t,listener:i,options:d,when:E=!0}){let p=x.useRef(null),R=x.useRef(null),u=q(i),l=q(d),f=(v={})=>{let{target:H}=v;ke(H)&&(a(),(v.when||E)&&(p.current=re(H))),!R.current&&p.current&&(R.current=L=>i&&i(L),p.current.addEventListener(t,R.current,d))},a=()=>{var v;R.current&&((v=p.current)==null||v.removeEventListener(t,R.current,d),R.current=null)},m=()=>{a(),u=null,l=null},b=x.useCallback(()=>{E?p.current=re(o):(a(),p.current=null)},[o,E]);return x.useEffect(()=>()=>{m()},[]),x.useEffect(()=>{b()},[b]),x.useEffect(()=>{let v=`${u}`!=`${i}`,H=l!==d,L=R.current;L&&(v||H)?(a(),E&&f()):L||m()},[i,d,E]),[f,a]}import*as K from"react";function Ve(o){let t=K.useId(),[i,d]=K.useState(o||`pr_id_${t.replaceAll(/:|«|»/g,"")}`);return K.useEffect(()=>{d(o||`pr_id_${t.replaceAll(/:|«|»/g,"")}`)},[o,t]),i}import{isAndroid as se}from"@primeuix/utils";function je(o){let{pattern:t=/./,validateOnly:i=!1}=o,d={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_]/},E=()=>typeof t=="string"?d[t]:t,p=a=>{i||!se()||l(a,a.data)},R=a=>{i||se()||a.ctrlKey||a.altKey||a.metaKey||l(a,a.key)},u=a=>{if(i)return;let m=E();[...a.clipboardData.getData("text")].forEach(v=>{if(!m.test(v))return a.preventDefault(),!1})},l=(a,m)=>{if(m==null||!(m.length<=2))return;E().test(m)||a.preventDefault()};return{onBeforeInput:p,onKeyPress:R,onPaste:u,validate:a=>{let m=a.target.value,b=!0,v=E();return m&&!v.test(m)&&(b=!1),b}}}import{useMountEffect as ye}from"@primereact/hooks";import{getUserAgent as J}from"@primeuix/utils";import*as T from"react";function qe(o){let{mask:t,unmask:i,slotChar:d="_",autoClear:E=!0,readOnly:p=!1,onMaskChange:R,target:u}=o,l=T.useRef(0),f=T.useRef([]),a=T.useRef([]),m=T.useRef(null),b=T.useRef(0),v=T.useRef(!1),H=T.useRef(!1),L=T.useRef(null),w=T.useRef(null),ie=T.useRef(0),$=T.useRef(null),O=T.useRef(null),Q=T.useRef(null),ce=e=>{"isComposing"in e&&e.isComposing||(v.current?ve():Z(e))},le=e=>{var I;if(p)return;let n=e.code,s,r,c,g=/iphone/i.test(J());if(O.current=u==null?void 0:u.value,n==="Backspace"||n==="Delete"||g&&n==="Escape"){if(s=h(),!s)return;r=s.begin,c=s.end,c-r===0&&(r=n!=="Delete"?Ee(r):c=P(r-1),c=n==="Delete"?P(c):c),F(r,c),W(r,c-1),y(e.target.value),e.preventDefault()}else n==="Enter"?(u.blur(),y(e.target.value)):n==="Escape"&&(u&&(u.value=(I=L.current)!=null?I:""),h(0,k()),y(e.target.value),e.preventDefault())},fe=e=>{var I;if(p)return;let n=e.code,s=h(),r,c,g;s&&(e.ctrlKey||e.altKey||e.metaKey||e.shiftKey||e.key==="CapsLock"||e.key==="Escape"||e.key==="Tab"||(n&&n!=="Enter"&&(s.end-s.begin!==0&&(F(s.begin,s.end),W(s.begin,s.end-1)),r=P(s.begin-1),r<l.current&&(c=e.key,(I=f.current[r])!=null&&I.test(c)&&(Re(r),a.current[r]=c,C(),g=P(r),/android/i.test(J())?setTimeout(()=>{h(g)},0):h(g))),e.preventDefault()),y(e.target.value)))},pe=()=>{if(!p)if($.current&&clearTimeout($.current),H.current=!0,L.current=u.value,!u.value||u.value===m.current)requestAnimationFrame(()=>{u===document.activeElement&&h(0,0)});else{let e=k();$.current=setTimeout(()=>{u===document.activeElement&&(C(),e===(t==null?void 0:t.replace("?","").length)?h(0,e):h(e))},10)}},me=e=>{if(H.current=!1,k(),y(e.target.value),u.value!==L.current){let n=new Event("change",{bubbles:!0,cancelable:!1});u.dispatchEvent(n)}},de=e=>{Z(e)},h=(e,n)=>{var c,g;let s=0,r=0;return typeof e=="number"?(s=e,r=typeof n=="number"?n:s,u.setSelectionRange(s,r)):u&&(s=(c=u.selectionStart)!=null?c:0,r=(g=u.selectionEnd)!=null?g:0),{begin:s,end:r}},S=e=>e<d.length?d.charAt(e):d.charAt(0),P=e=>{for(;++e<l.current&&!f.current[e];);return e},Ee=e=>{for(;--e>=0&&!f.current[e];);return e},W=(e,n)=>{var c,g;let s,r;if(!(e<0)){for(s=e,r=P(n);s<l.current;s++)if(f.current[s]){if(r<l.current&&((c=f.current[s])!=null&&c.test(a.current[r])))a.current[s]=a.current[r],a.current[r]=S(r);else break;r=P(r)}C(),h(Math.max((g=w.current)!=null?g:0,e))}},Re=e=>{var g;let n,s,r,c;for(n=e,s=S(e);n<l.current;n++)if(f.current[n])if(r=P(n),c=a.current[n],a.current[n]=s,r<l.current&&((g=f.current[r])!=null&&g.test(c)))s=c;else break},ve=()=>{var s;let e=u.value,n=h();if(n)if(O.current&&O.current.length&&O.current.length>e.length){for(k(!0);n.begin>0&&!f.current[n.begin-1];)n.begin--;if(n.begin===0)for(;n.begin<((s=w.current)!=null?s:0)&&!f.current[n.begin];)n.begin++;h(n.begin,n.begin)}else{for(k(!0);n.begin<l.current&&!f.current[n.begin];)n.begin++;h(n.begin,n.begin)}},F=(e,n)=>{let s;for(s=e;s<n&&s<l.current;s++)f.current[s]&&(a.current[s]=S(s))},C=()=>{u&&(u.value=a.current.join(""))},k=(e=!1)=>{var I,z,Y,G;let n=u.value,s=-1,r,c,g;for(r=0,g=0;r<l.current;r++){let X=f.current[r];if(X!==null){for(a.current[r]=S(r);g++<((I=n==null?void 0:n.length)!=null?I:0);)if(c=(z=n==null?void 0:n.charAt(g-1))!=null?z:"",X.test(c)){a.current[r]=c,s=r;break}if(g>((Y=n==null?void 0:n.length)!=null?Y:0)){F(r+1,l.current);break}}else a.current[r]===(n==null?void 0:n.charAt(g))&&g++,r<b.current&&(s=r)}return e?C():s+1<b.current?E||a.current.join("")===m.current?(u.value&&(u.value=""),F(0,l.current)):C():(C(),u&&(u.value=u.value.substring(0,s+1))),b.current?r:(G=w.current)!=null?G:0},Z=e=>{let n=e.type==="paste";if(p||n)return;let s=k(!0);h(s),y(e.target.value)},ge=e=>{let n=[],s=e.split("");for(let r=0;r<s.length;r++){let c=s[r];f.current[r]&&c!==S(r)&&n.push(c)}return n.join("")},y=e=>{if(Q.current===e)return;let n=i?ge(e):e,s=m.current!==n?n:"";Q.current=e,u&&(u.value=s),R&&R({value:s})},be=(e=!0)=>{u&&(u.value==null?(u.value="",e&&y("")):(k(),setTimeout(()=>{u&&(C(),k(),e&&y(u.value))},10)),L.current=u.value)},Te=()=>{f.current=[],b.current=t?t.length:0,l.current=t?t.length:0,w.current=null;let e={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},n=J();v.current=/chrome/i.test(n)&&/android/i.test(n);let s=t?t.split(""):"";for(let r=0;r<s.length;r++){let c=s[r];c==="?"?(l.current--,b.current=r):e[c]?(f.current.push(new RegExp(e[c])),w.current===null&&(w.current=f.current.length-1),r<b.current&&(ie.current=f.current.length-1)):f.current.push(null)}a.current=[];for(let r=0;r<s.length;r++){let c=s[r];c!=="?"&&(e[c]?a.current.push(S(r)):a.current.push(c))}m.current=a.current.join(""),be(!1)};return ye(()=>{Te()}),{onMaskInput:ce,onMaskKeyDown:le,onMaskKeyPress:fe,onMaskFocus:pe,onMaskBlur:me,onMaskPaste:de}}import*as A from"react";function Qe(o,t=!0){let[i,d]=A.useState(!1),E=A.useRef(null),p=l=>d(l.matches),R=()=>{var l;return(l=E.current)==null?void 0:l.addEventListener("change",p)},u=()=>{var l;return((l=E.current)==null?void 0:l.removeEventListener("change",p))&&(E.current=null)};return A.useEffect(()=>(t&&(E.current=window.matchMedia(o),d(E.current.matches),R()),()=>{u()}),[o,t]),i}import*as B from"react";function Ze(o){let t=B.useRef(!1);B.useEffect(()=>{t.current||(t.current=!0,o==null||o())},[])}import*as M from"react";function Ge(o,t=500){let[i,d]=M.useState(o),[E,p]=M.useState(!1),[R,u]=M.useState(!1),l=M.useRef(null),f=M.useRef(null),a=M.useRef(null);return M.useEffect(()=>{if(f.current&&(f.current(),f.current=null),a.current&&(a.current(),a.current=null),o){d(!0),p(!1);let m=[];m.push(requestAnimationFrame(()=>{m.push(requestAnimationFrame(()=>{m.push(requestAnimationFrame(()=>u(!0)))}))})),a.current=()=>{m.forEach(b=>cancelAnimationFrame(b)),m.length=0}}else if(l.current){p(!0),u(!1);let m=l.current,b=!1,v=()=>{b||(b=!0,d(!1),p(!1),m.removeEventListener("transitionend",v),m.removeEventListener("animationend",v),f.current=null)};m.addEventListener("transitionend",v,{passive:!0}),m.addEventListener("animationend",v,{passive:!0}),f.current=()=>{b||(m.removeEventListener("transitionend",v),m.removeEventListener("animationend",v))}}else u(!1),d(!1),p(!1)},[o,t]),M.useEffect(()=>()=>{f.current&&f.current(),a.current&&a.current()},[]),{present:i,exiting:E,mounted:R,ref:l}}import*as oe from"react";function et(o={},t={}){return oe.useMemo(()=>{let i={props:ne({},t),attrs:{}};return Object.entries(o).forEach(([d,E])=>{d in t?i.props[d]=E:i.attrs[d]=E}),i},[o,t])}import{getWindowScrollTop as Ie}from"@primeuix/utils";import*as _ from"react";function st(o){let{target:t=typeof window!="undefined"?window:null,threshold:i=400,behavior:d="smooth"}=o||{},[E,p]=_.useState(!1),R=()=>{t==null||t.scroll({top:0,behavior:d})};return _.useEffect(()=>{if(!t)return;let u=f=>{f>i?p(!0):p(!1)},l=()=>{let f=t===window?Ie():t.scrollTop;u(f)};return t.addEventListener("scroll",l),()=>{t.removeEventListener("scroll",l)}},[t,i]),{visible:E,scrollToTop:R}}import*as ue from"react";function ut(o){ue.useEffect(()=>()=>{o==null||o()},[])}import*as j from"react";function it(o,t){let i=j.useRef(!1);j.useEffect(()=>{if(!i.current){i.current=!0;return}return o==null?void 0:o()},t)}import*as ae from"react";function lt(){return ae.useCallback(t=>{document.startViewTransition?document.startViewTransition(()=>{t()}):t()},[])}import*as N from"react";function pt(){let[o,t]=N.useState(!0);return N.useEffect(()=>{let i=()=>{t(!document.hidden)};return i(),document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i)}},[]),o}export{Pe as useAttrSelector,Se as useControlledState,Fe as useEventListener,Ve as useId,je as useKeyFilter,qe as useMask,Qe as useMatchMedia,Ze as useMountEffect,Ge as usePresence,q as usePrevious,et as useProps,st as useScrollTop,ut as useUnmountEffect,it as useUpdateEffect,lt as useViewTransition,pt as useVisibilityChange};
|
|
1
|
+
var Me=Object.defineProperty;var ne=Object.getOwnPropertySymbols;var ke=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var re=(r,e,a)=>e in r?Me(r,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[e]=a,se=(r,e)=>{for(var a in e||(e={}))ke.call(e,a)&&re(r,a,e[a]);if(ne)for(var a of ne(e))Le.call(e,a)&&re(r,a,e[a]);return r};import*as B from"react";function Ce(r=""){let e=B.useId();return B.useMemo(()=>`${r}${e.replaceAll(/:|«|»/g,"")}`.trim().toLowerCase(),[e,r])}import{resolve as xe}from"@primeuix/utils";import*as S from"react";function Ue({value:r,defaultValue:e,onChange:a}){let[p,d]=S.useState(e!=null?e:r),E=r!==void 0,g=E?r:p,c=S.useCallback(l=>{let[f,o]=xe(l,g,E);a==null||a(o),E||d(f)},[g,E,a]);return S.useEffect(()=>{E||d(e)},[e,E]),[g,c,E]}import{getTargetElement as oe,isNotEmpty as we}from"@primeuix/utils";import*as L from"react";import*as _ from"react";function J(r){let e=_.useRef(null);return _.useEffect(()=>(e.current=r,()=>{e.current=null}),[r]),e.current}function Ve({target:r="document",type:e,listener:a,options:p,when:d=!0}){let E=L.useRef(null),g=L.useRef(null),c=J(a),l=J(p),f=(v={})=>{let{target:T}=v;we(T)&&(o(),(v.when||d)&&(E.current=oe(T))),!g.current&&E.current&&(g.current=M=>a&&a(M),E.current.addEventListener(e,g.current,p))},o=()=>{var v;g.current&&((v=E.current)==null||v.removeEventListener(e,g.current,p),g.current=null)},i=()=>{o(),c=null,l=null},R=L.useCallback(()=>{d?E.current=oe(r):(o(),E.current=null)},[r,d]);return L.useEffect(()=>()=>{i()},[]),L.useEffect(()=>{R()},[R]),L.useEffect(()=>{let v=`${c}`!=`${a}`,T=l!==p,M=g.current;M&&(v||T)?(o(),d&&f()):M||i()},[a,p,d]),[f,o]}import*as F from"react";function _e(r,e,a={}){let{target:p,event:d="keydown",when:E=!0}=a,g=F.useRef(e),c=o=>{let i=o.toLowerCase();return i==="space"||i==="spacebar"?" ":i},l=o=>{let i=o.split("+").map(T=>T.trim().toLowerCase()).filter(Boolean),R,v={ctrl:!1,meta:!1,alt:!1,shift:!1};return i.forEach(T=>{switch(T){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:R=c(T)}}),{key:R,required:v}},f=(o,i)=>{if(!o.key)return!1;let{required:R}=o;return R.ctrl!==i.ctrlKey||R.meta!==i.metaKey||R.alt!==i.altKey||R.shift!==i.shiftKey?!1:c(i.key)===o.key};F.useEffect(()=>{g.current=e},[e]),F.useEffect(()=>{if(!E)return;let o=p!=null?p:typeof document!="undefined"?document:null;if(!o)return;let i=(Array.isArray(r)?r:[r]).map(l),R=v=>{var M;let T=v;i.some(x=>f(x,T))&&((M=g.current)==null||M.call(g,T))};return o.addEventListener(d,R),()=>{o.removeEventListener(d,R)}},[d,r,p,E])}import*as U from"react";function qe(r){let e=U.useId(),[a,p]=U.useState(r||`pr_id_${e.replaceAll(/:|«|»/g,"")}`);return U.useEffect(()=>{p(r||`pr_id_${e.replaceAll(/:|«|»/g,"")}`)},[r,e]),a}import{isAndroid as ue}from"@primeuix/utils";function $e(r){let{pattern:e=/./,validateOnly:a=!1}=r,p={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_]/},d=()=>typeof e=="string"?p[e]:e,E=o=>{a||!ue()||l(o,o.data)},g=o=>{a||ue()||o.ctrlKey||o.altKey||o.metaKey||l(o,o.key)},c=o=>{if(a)return;let i=d();[...o.clipboardData.getData("text")].forEach(v=>{if(!i.test(v))return o.preventDefault(),!1})},l=(o,i)=>{if(i==null||!(i.length<=2))return;d().test(i)||o.preventDefault()};return{onBeforeInput:E,onKeyPress:g,onPaste:c,validate:o=>{let i=o.target.value,R=!0,v=d();return i&&!v.test(i)&&(R=!1),R}}}import{useMountEffect as He}from"@primereact/hooks";import{getUserAgent as W}from"@primeuix/utils";import*as h from"react";function Ze(r){let{mask:e,unmask:a,slotChar:p="_",autoClear:d=!0,readOnly:E=!1,onMaskChange:g,target:c}=r,l=h.useRef(0),f=h.useRef([]),o=h.useRef([]),i=h.useRef(null),R=h.useRef(0),v=h.useRef(!1),T=h.useRef(!1),M=h.useRef(null),x=h.useRef(null),le=h.useRef(0),$=h.useRef(null),D=h.useRef(null),Z=h.useRef(null),fe=t=>{"isComposing"in t&&t.isComposing||(v.current?be():G(t))},pe=t=>{var K;if(E)return;let n=t.code,u,s,m,b=/iphone/i.test(W());if(D.current=c==null?void 0:c.value,n==="Backspace"||n==="Delete"||b&&n==="Escape"){if(u=y(),!u)return;s=u.begin,m=u.end,m-s===0&&(s=n!=="Delete"?ve(s):m=I(s-1),m=n==="Delete"?I(m):m),V(s,m),Y(s,m-1),H(t.target.value),t.preventDefault()}else n==="Enter"?(c.blur(),H(t.target.value)):n==="Escape"&&(c&&(c.value=(K=M.current)!=null?K:""),y(0,w()),H(t.target.value),t.preventDefault())},me=t=>{var K;if(E)return;let n=t.code,u=y(),s,m,b;u&&(t.ctrlKey||t.altKey||t.metaKey||t.shiftKey||t.key==="CapsLock"||t.key==="Escape"||t.key==="Tab"||(n&&n!=="Enter"&&(u.end-u.begin!==0&&(V(u.begin,u.end),Y(u.begin,u.end-1)),s=I(u.begin-1),s<l.current&&(m=t.key,(K=f.current[s])!=null&&K.test(m)&&(ge(s),o.current[s]=m,C(),b=I(s),/android/i.test(W())?setTimeout(()=>{y(b)},0):y(b))),t.preventDefault()),H(t.target.value)))},de=()=>{if(!E)if($.current&&clearTimeout($.current),T.current=!0,M.current=c.value,!c.value||c.value===i.current)requestAnimationFrame(()=>{c===document.activeElement&&y(0,0)});else{let t=w();$.current=setTimeout(()=>{c===document.activeElement&&(C(),t===(e==null?void 0:e.replace("?","").length)?y(0,t):y(t))},10)}},Ee=t=>{if(T.current=!1,w(),H(t.target.value),c.value!==M.current){let n=new Event("change",{bubbles:!0,cancelable:!1});c.dispatchEvent(n)}},Re=t=>{G(t)},y=(t,n)=>{var m,b;let u=0,s=0;return typeof t=="number"?(u=t,s=typeof n=="number"?n:u,c.setSelectionRange(u,s)):c&&(u=(m=c.selectionStart)!=null?m:0,s=(b=c.selectionEnd)!=null?b:0),{begin:u,end:s}},P=t=>t<p.length?p.charAt(t):p.charAt(0),I=t=>{for(;++t<l.current&&!f.current[t];);return t},ve=t=>{for(;--t>=0&&!f.current[t];);return t},Y=(t,n)=>{var m,b;let u,s;if(!(t<0)){for(u=t,s=I(n);u<l.current;u++)if(f.current[u]){if(s<l.current&&((m=f.current[u])!=null&&m.test(o.current[s])))o.current[u]=o.current[s],o.current[s]=P(s);else break;s=I(s)}C(),y(Math.max((b=x.current)!=null?b:0,t))}},ge=t=>{var b;let n,u,s,m;for(n=t,u=P(t);n<l.current;n++)if(f.current[n])if(s=I(n),m=o.current[n],o.current[n]=u,s<l.current&&((b=f.current[s])!=null&&b.test(m)))u=m;else break},be=()=>{var u;let t=c.value,n=y();if(n)if(D.current&&D.current.length&&D.current.length>t.length){for(w(!0);n.begin>0&&!f.current[n.begin-1];)n.begin--;if(n.begin===0)for(;n.begin<((u=x.current)!=null?u:0)&&!f.current[n.begin];)n.begin++;y(n.begin,n.begin)}else{for(w(!0);n.begin<l.current&&!f.current[n.begin];)n.begin++;y(n.begin,n.begin)}},V=(t,n)=>{let u;for(u=t;u<n&&u<l.current;u++)f.current[u]&&(o.current[u]=P(u))},C=()=>{c&&(c.value=o.current.join(""))},w=(t=!1)=>{var K,Q,X,ee;let n=c.value,u=-1,s,m,b;for(s=0,b=0;s<l.current;s++){let te=f.current[s];if(te!==null){for(o.current[s]=P(s);b++<((K=n==null?void 0:n.length)!=null?K:0);)if(m=(Q=n==null?void 0:n.charAt(b-1))!=null?Q:"",te.test(m)){o.current[s]=m,u=s;break}if(b>((X=n==null?void 0:n.length)!=null?X:0)){V(s+1,l.current);break}}else o.current[s]===(n==null?void 0:n.charAt(b))&&b++,s<R.current&&(u=s)}return t?C():u+1<R.current?d||o.current.join("")===i.current?(c.value&&(c.value=""),V(0,l.current)):C():(C(),c&&(c.value=c.value.substring(0,u+1))),R.current?s:(ee=x.current)!=null?ee:0},G=t=>{let n=t.type==="paste";if(E||n)return;let u=w(!0);y(u),H(t.target.value)},Te=t=>{let n=[],u=t.split("");for(let s=0;s<u.length;s++){let m=u[s];f.current[s]&&m!==P(s)&&n.push(m)}return n.join("")},H=t=>{if(Z.current===t)return;let n=a?Te(t):t,u=i.current!==n?n:"";Z.current=t,c&&(c.value=u),g&&g({value:u})},he=(t=!0)=>{c&&(c.value==null?(c.value="",t&&H("")):(w(),setTimeout(()=>{c&&(C(),w(),t&&H(c.value))},10)),M.current=c.value)},ye=()=>{f.current=[],R.current=e?e.length:0,l.current=e?e.length:0,x.current=null;let t={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},n=W();v.current=/chrome/i.test(n)&&/android/i.test(n);let u=e?e.split(""):"";for(let s=0;s<u.length;s++){let m=u[s];m==="?"?(l.current--,R.current=s):t[m]?(f.current.push(new RegExp(t[m])),x.current===null&&(x.current=f.current.length-1),s<R.current&&(le.current=f.current.length-1)):f.current.push(null)}o.current=[];for(let s=0;s<u.length;s++){let m=u[s];m!=="?"&&(t[m]?o.current.push(P(s)):o.current.push(m))}i.current=o.current.join(""),he(!1)};return He(()=>{ye()}),{onMaskInput:fe,onMaskKeyDown:pe,onMaskKeyPress:me,onMaskFocus:de,onMaskBlur:Ee,onMaskPaste:Re}}import*as A from"react";function Ge(r,e=!0){let[a,p]=A.useState(!1),d=A.useRef(null),E=l=>p(l.matches),g=()=>{var l;return(l=d.current)==null?void 0:l.addEventListener("change",E)},c=()=>{var l;return((l=d.current)==null?void 0:l.removeEventListener("change",E))&&(d.current=null)};return A.useEffect(()=>(e&&(d.current=window.matchMedia(r),p(d.current.matches),g()),()=>{c()}),[r,e]),a}import*as j from"react";function et(r){let e=j.useRef(!1);j.useEffect(()=>{e.current||(e.current=!0,r==null||r())},[])}import*as k from"react";function nt(r,e=500){let[a,p]=k.useState(r),[d,E]=k.useState(!1),[g,c]=k.useState(!1),l=k.useRef(null),f=k.useRef(null),o=k.useRef(null);return k.useEffect(()=>{if(f.current&&(f.current(),f.current=null),o.current&&(o.current(),o.current=null),r){p(!0),E(!1);let i=[];i.push(requestAnimationFrame(()=>{i.push(requestAnimationFrame(()=>{i.push(requestAnimationFrame(()=>c(!0)))}))})),o.current=()=>{i.forEach(R=>cancelAnimationFrame(R)),i.length=0}}else if(l.current){E(!0),c(!1);let i=l.current,R=!1,v=()=>{R||(R=!0,p(!1),E(!1),i.removeEventListener("transitionend",v),i.removeEventListener("animationend",v),f.current=null)};i.addEventListener("transitionend",v,{passive:!0}),i.addEventListener("animationend",v,{passive:!0}),f.current=()=>{R||(i.removeEventListener("transitionend",v),i.removeEventListener("animationend",v))}}else c(!1),p(!1),E(!1)},[r,e]),k.useEffect(()=>()=>{f.current&&f.current(),o.current&&o.current()},[]),{present:a,exiting:d,mounted:g,ref:l}}import*as ae from"react";function st(r={},e={}){return ae.useMemo(()=>{let a={props:se({},e),attrs:{}};return Object.entries(r).forEach(([p,d])=>{p in e?a.props[p]=d:a.attrs[p]=d}),a},[r,e])}import*as O from"react";var at=()=>{let r=O.useRef(new Map),e=O.useRef(!1),a=O.useCallback(()=>{e.current=!1;let p=r.current;r.current=new Map,p.forEach(d=>d())},[]);return O.useCallback((p,d)=>{r.current.set(p,d),e.current||(e.current=!0,queueMicrotask(a))},[a])};import{getWindowScrollTop as Ke}from"@primeuix/utils";import*as q from"react";function lt(r){let{target:e=typeof window!="undefined"?window:null,threshold:a=400,behavior:p="smooth"}=r||{},[d,E]=q.useState(!1),g=()=>{e==null||e.scroll({top:0,behavior:p})};return q.useEffect(()=>{if(!e)return;let c=f=>{f>a?E(!0):E(!1)},l=()=>{let f=e===window?Ke():e.scrollTop;c(f)};return e.addEventListener("scroll",l),()=>{e.removeEventListener("scroll",l)}},[e,a]),{visible:d,scrollToTop:g}}import*as ce from"react";function pt(r){ce.useEffect(()=>()=>{r==null||r()},[])}import*as z from"react";function dt(r,e){let a=z.useRef(!1);z.useEffect(()=>{if(!a.current){a.current=!0;return}return r==null?void 0:r()},e)}import*as ie from"react";function Rt(){return ie.useCallback(e=>{document.startViewTransition?document.startViewTransition(()=>{e()}):e()},[])}import*as N from"react";function gt(){let[r,e]=N.useState(!0);return N.useEffect(()=>{let a=()=>{e(!document.hidden)};return a(),document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a)}},[]),r}export{Ce as useAttrSelector,Ue as useControlledState,Ve as useEventListener,_e as useHotKey,qe as useId,$e as useKeyFilter,Ze as useMask,Ge as useMatchMedia,et as useMountEffect,nt as usePresence,J as usePrevious,st as useProps,at as useQueueTask,lt as useScrollTop,pt as useUnmountEffect,dt as useUpdateEffect,Rt as useViewTransition,gt 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-controlled-state/index.ts","../src/use-event-listener/index.ts","../src/use-previous/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-presence/index.ts","../src/use-props/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 [valueState, setValueState] = React.useState<T | undefined>(defaultValue ?? value);\n\n const isControlled = value !== undefined;\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\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 * 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 `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 { 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":"sWAAA,UAAYA,MAAW,QAchB,SAASC,GAAgBC,EAAiB,GAAY,CACzD,IAAMC,EAAW,QAAM,EAEvB,OAAa,UAAQ,IAAM,GAAGD,CAAM,GAAG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","id","resolve","React","useControlledState","value","defaultValue","onChange","valueState","setValueState","isControlled","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","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","next","shiftR","writeBuffer","onMaskFocus","onMaskBlur","e","onMaskPaste","first","last","_b","getPlaceholder","i","j","c","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","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","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"]}
|
|
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-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 [valueState, setValueState] = React.useState<T | undefined>(defaultValue ?? value);\n\n const isControlled = value !== undefined;\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 * 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 `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\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":"sWAAA,UAAYA,MAAW,QAchB,SAASC,GAAgBC,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,OAAS,WAAAE,OAAe,kBACxB,UAAYC,MAAW,QAiDhB,SAASC,GAAuC,CAAE,MAAAC,EAAO,aAAAC,EAAc,SAAAC,CAAS,EAAiF,CACpK,GAAM,CAACC,EAAYC,CAAa,EAAU,WAAwBH,GAAA,KAAAA,EAAgBD,CAAK,EAEjFK,EAAeL,IAAU,OACzBM,EAAgBD,EAAgBL,EAAcG,EAE9CI,EAAiB,cAClBC,GAA+C,CAE5C,GAAM,CAACC,EAAUC,CAAa,EAAIb,GAAQW,EAASF,EAAeD,CAAY,EAE9EH,GAAA,MAAAA,EAAWQ,GAENL,GACDD,EAAcK,CAAQ,CAE9B,EACA,CAACH,EAAeD,EAAcH,CAAQ,CAC1C,EAEA,OAAM,YAAU,IAAM,CACbG,GACDD,EAAcH,CAAY,CAElC,EAAG,CAACA,EAAcI,CAAY,CAAC,EAExB,CAACC,EAAeC,EAAUF,CAAY,CACjD,CC7EA,OAAS,oBAAAM,GAAkB,c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AAY,EAAU,WAAS,EAAI,EAErD,OAAM,YAAU,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","valueState","setValueState","isControlled","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","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
|
@@ -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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CAACA,CAAI,GAAG,IAAIU,CAAY,EAEjES,EAA2Bf,GAAU,CA7GnD,IAAAgB,EA8GY,IAAMC,EAAgBjB,EAElBc,EAAS,KAAMP,GAASK,EAAQL,EAAMU,CAAa,CAAC,KACpDD,EAAAd,EAAW,UAAX,MAAAc,EAAA,KAAAd,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 @@
|
|
|
1
|
+
export declare const useQueueTask: () => (id: string | number, task: () => void) => void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as e from"react";var a=()=>{let t=e.useRef(new Map),r=e.useRef(!1),u=e.useCallback(()=>{r.current=!1;let s=t.current;t.current=new Map,s.forEach(c=>c())},[]);return e.useCallback((s,c)=>{t.current.set(s,c),r.current||(r.current=!0,queueMicrotask(u))},[u])};export{a as useQueueTask};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/use-queue-task/index.ts"],"sourcesContent":["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"],"mappings":"AAAA,UAAYA,MAAW,QAEhB,IAAMC,EAAe,IAAM,CAC9B,IAAMC,EAAiB,SAAO,IAAI,GAAkC,EAC9DC,EAAqB,SAAO,EAAK,EAEjCC,EAAc,cAAY,IAAM,CAClCD,EAAa,QAAU,GACvB,IAAME,EAAQH,EAAS,QAEvBA,EAAS,QAAU,IAAI,IACvBG,EAAM,QAASC,GAASA,EAAK,CAAC,CAClC,EAAG,CAAC,CAAC,EAEL,OAAa,cACT,CAACC,EAAqBD,IAAqB,CACvCJ,EAAS,QAAQ,IAAIK,EAAID,CAAI,EAExBH,EAAa,UACdA,EAAa,QAAU,GACvB,eAAeC,CAAK,EAE5B,EACA,CAACA,CAAK,CACV,CACJ","names":["React","useQueueTask","tasksRef","scheduledRef","flush","tasks","task","id"]}
|
|
File without changes
|