New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@inertiajs/react

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inertiajs/react - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0

2

dist/index.esm.js

@@ -1,2 +0,2 @@

import{router as et}from"@inertiajs/core";import{router as Ce,setupProgress as be}from"@inertiajs/core";import{createElement as ke}from"react";import{createHeadManager as Se,router as G}from"@inertiajs/core";import{createElement as A,useEffect as Te,useMemo as ve,useState as Fe}from"react";import{createContext as ye}from"react";var Y=ye(void 0);Y.displayName="InertiaHeadContext";var w=Y;import{createContext as he}from"react";var z=he(void 0);z.displayName="InertiaPageContext";var O=z;function H({children:p,initialPage:r,initialComponent:s,resolveComponent:a,titleCallback:i,onHeadUpdate:P}){let[l,d]=Fe({component:s||null,page:r,key:null}),m=ve(()=>Se(typeof window>"u",i||(f=>f),P||(()=>{})),[]);if(Te(()=>{G.init({initialPage:r,resolveComponent:a,swapComponent:async({component:f,page:e,preserveState:c})=>{d(o=>({component:f,page:e,key:c?o.key:Date.now()}))}}),G.on("navigate",()=>m.forceUpdate())},[]),!l.component)return A(w.Provider,{value:m},A(O.Provider,{value:l.page},null));let y=p||(({Component:f,props:e,key:c})=>{let o=A(f,{key:c,...e});return typeof f.layout=="function"?f.layout(o):Array.isArray(f.layout)?f.layout.concat(o).reverse().reduce((h,S)=>A(S,{children:h,...e})):o});return A(w.Provider,{value:m},A(O.Provider,{value:l.page},y({Component:l.component,key:l.key,props:l.page.props})))}H.displayName="Inertia";async function X({id:p="app",resolve:r,setup:s,title:a,progress:i={},page:P,render:l}){let d=typeof window>"u",m=d?null:document.getElementById(p),y=P||JSON.parse(m.dataset.page),f=o=>Promise.resolve(r(o)).then(h=>h.default||h),e=[],c=await Promise.all([f(y.component),Ce.decryptHistory().catch(()=>{})]).then(([o])=>s({el:m,App:H,props:{initialPage:y,initialComponent:o,resolveComponent:f,titleCallback:a,onHeadUpdate:d?h=>e=h:null}}));if(!d&&i&&be(i),d){let o=await l(ke("div",{id:p,"data-page":JSON.stringify(y)},c));return{head:e,body:o}}}import{useEffect as xe,useState as Ie}from"react";import{useContext as Re}from"react";function V(){let p=Re(O);if(!p)throw new Error("usePage must be used within the Inertia component");return p}var Z=({children:p,data:r,fallback:s})=>{if(!r)throw new Error("`<Deferred>` requires a `data` prop");let[a,i]=Ie(!1),P=V().props,l=Array.isArray(r)?r:[r];return xe(()=>{i(l.every(d=>P[d]!==void 0))},[P,l]),a?p:s};Z.displayName="InertiaDeferred";var Ae=Z;import ee,{useContext as Ee,useEffect as we,useMemo as Oe}from"react";var De=function({children:p,title:r}){let s=Ee(w),a=Oe(()=>s.createProvider(),[s]);we(()=>()=>{a.disconnect()},[a]);function i(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function P(e){let c=Object.keys(e.props).reduce((o,h)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(h))return o;let S=e.props[h];return S===""?o+` ${h}`:o+` ${h}="${S}"`},"");return`<${e.type}${c}>`}function l(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,o)=>c+d(o),"")}function d(e){let c=P(e);return e.props.children&&(c+=l(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),i(e)||(c+=`</${e.type}>`),c}function m(e){return ee.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function y(e){return d(m(e))}function f(e){let c=ee.Children.toArray(e).filter(o=>o).map(o=>y(o));return r&&!c.find(o=>o.startsWith("<title"))&&c.push(`<title inertia>${r}</title>`),c}return a.update(f(p)),null},Me=De;import{mergeDataIntoQueryString as Le,router as j,shouldIntercept as W}from"@inertiajs/core";import{createElement as He,forwardRef as Ve,useEffect as te,useMemo as re,useRef as Be,useState as Ne}from"react";var b=()=>{},oe=Ve(({children:p,as:r="a",data:s={},href:a,method:i="get",preserveScroll:P=!1,preserveState:l=null,replace:d=!1,only:m=[],except:y=[],headers:f={},queryStringArrayFormat:e="brackets",async:c=!1,onClick:o=b,onCancelToken:h=b,onBefore:S=b,onStart:R=b,onProgress:x=b,onFinish:B=b,onCancel:L=b,onSuccess:N=b,onError:E=b,prefetch:v=!1,cacheFor:F=0,...t},u)=>{let[n,C]=Ne(0),g=Be();r=r.toLowerCase(),i=i.toLowerCase();let[fe,de]=Le(i,a||"",s,e);a=fe,s=de;let q={data:s,method:i,preserveScroll:P,preserveState:l??i!=="get",replace:d,only:m,except:y,headers:f,async:c},J={...q,onCancelToken:h,onBefore:S,onStart(T){C($=>$+1),R(T)},onProgress:x,onFinish(T){C($=>$-1),B(T)},onCancel:L,onSuccess:N,onError:E},U=()=>{j.prefetch(a,q,{cacheFor:me})},I=re(()=>v===!0?["hover"]:v===!1?[]:Array.isArray(v)?v:[v],Array.isArray(v)?v:[v]),me=re(()=>F!==0?F:I.length===1&&I[0]==="click"?0:3e4,[F,I]);te(()=>()=>{clearTimeout(g.current)},[]),te(()=>{I.includes("mount")&&setTimeout(()=>U())},I);let Q={onClick:T=>{o(T),W(T)&&(T.preventDefault(),j.visit(a,J))}},ge={onMouseEnter:()=>{g.current=window.setTimeout(()=>{U()},75)},onMouseLeave:()=>{clearTimeout(g.current)},onClick:Q.onClick},Pe={onMouseDown:T=>{W(T)&&(T.preventDefault(),U())},onMouseUp:T=>{T.preventDefault(),j.visit(a,J)},onClick:T=>{o(T),W(T)&&T.preventDefault()}};return i!=="get"&&(r="button"),He(r,{...t,...{a:{href:a},button:{type:"button"}}[r]||{},ref:u,...(()=>I.includes("hover")?ge:I.includes("click")?Pe:Q)(),"data-loading":n>0?"":void 0},p)});oe.displayName="InertiaLink";var Ue=oe;import{router as se}from"@inertiajs/core";import We from"lodash.isequal";import{useCallback as Ke,useEffect as _e,useRef as K,useState as k}from"react";import{router as ne}from"@inertiajs/core";import{useEffect as $e,useState as je}from"react";function D(p,r){let[s,a]=je(()=>{let i=ne.restore(r);return i!==void 0?i:p});return $e(()=>{ne.remember(s,r)},[s,r]),[s,a]}function ae(p,r){let s=K(null),a=typeof p=="string"?p:null,[i,P]=k((typeof p=="string"?r:p)||{}),l=K(null),d=K(null),[m,y]=a?D(i,`${a}:data`):k(i),[f,e]=a?D({},`${a}:errors`):k({}),[c,o]=k(!1),[h,S]=k(!1),[R,x]=k(null),[B,L]=k(!1),[N,E]=k(!1),v=t=>t;_e(()=>(s.current=!0,()=>{s.current=!1}),[]);let F=Ke((t,u,n={})=>{let C={...n,onCancelToken:g=>{if(l.current=g,n.onCancelToken)return n.onCancelToken(g)},onBefore:g=>{if(L(!1),E(!1),clearTimeout(d.current),n.onBefore)return n.onBefore(g)},onStart:g=>{if(S(!0),n.onStart)return n.onStart(g)},onProgress:g=>{if(x(g),n.onProgress)return n.onProgress(g)},onSuccess:g=>{if(s.current&&(S(!1),x(null),e({}),o(!1),L(!0),E(!0),d.current=setTimeout(()=>{s.current&&E(!1)},2e3)),n.onSuccess)return n.onSuccess(g)},onError:g=>{if(s.current&&(S(!1),x(null),e(g),o(!0)),n.onError)return n.onError(g)},onCancel:()=>{if(s.current&&(S(!1),x(null)),n.onCancel)return n.onCancel()},onFinish:()=>{if(s.current&&(S(!1),x(null)),l.current=null,n.onFinish)return n.onFinish()}};t==="delete"?se.delete(u,{...C,data:v(m)}):se[t](u,v(m),C)},[m,e,v]);return{data:m,setData(t,u){y(typeof t=="string"?n=>({...n,[t]:u}):typeof t=="function"?n=>t(n):t)},isDirty:!We(m,i),errors:f,hasErrors:c,processing:h,progress:R,wasSuccessful:B,recentlySuccessful:N,transform(t){v=t},setDefaults(t,u){P(typeof t>"u"?()=>m:n=>({...n,...typeof t=="string"?{[t]:u}:t}))},reset(...t){t.length===0?y(i):y(Object.keys(i).filter(u=>t.includes(u)).reduce((u,n)=>(u[n]=i[n],u),{...m}))},setError(t,u){e(n=>{let C={...n,...typeof t=="string"?{[t]:u}:t};return o(Object.keys(C).length>0),C})},clearErrors(...t){e(u=>{let n=Object.keys(u).reduce((C,g)=>({...C,...t.length>0&&!t.includes(g)?{[g]:u[g]}:{}}),{});return o(Object.keys(n).length>0),n})},submit:F,get(t,u){F("get",t,u)},post(t,u){F("post",t,u)},put(t,u){F("put",t,u)},patch(t,u){F("patch",t,u)},delete(t,u){F("delete",t,u)},cancel(){l.current&&l.current.cancel()}}}import{router as qe}from"@inertiajs/core";import{useEffect as Je,useRef as Qe}from"react";function ie(p,r={},s={keepAlive:!1,autoStart:!0}){let a=Qe(qe.poll(p,r,{...s,autoStart:!1}));return Je(()=>((s.autoStart??!0)&&a.current.start(),()=>a.current.stop()),[]),{stop:a.current.stop,start:a.current.start}}import{router as M}from"@inertiajs/core";import{useEffect as Ye,useState as _}from"react";function pe(p={}){let r=typeof window>"u"?null:M.getCached(window.location.pathname,p),s=typeof window>"u"?null:M.getPrefetching(window.location.pathname,p),[a,i]=_(r?.staleTimestamp||null),[P,l]=_(s!==null),[d,m]=_(r!==null);return Ye(()=>{let y=M.on("prefetching",e=>{e.detail.visit.url.pathname===window.location.pathname&&l(!0)}),f=M.on("prefetched",e=>{e.detail.visit.url.pathname===window.location.pathname&&(l(!1),m(!0),i(e.detail.fetchedAt))});return()=>{f(),y()}},[]),{lastUpdatedAt:a,isPrefetching:P,isPrefetched:d,flush:()=>M.flush(window.location.pathname,p)}}import{router as ze}from"@inertiajs/core";import{createElement as Ge,useEffect as Xe,useRef as ue,useState as le}from"react";var ce=({children:p,data:r,params:s,buffer:a,as:i,always:P,fallback:l})=>{P=P??!1,i=i??"div",l=l??null;let[d,m]=le(!1),[y,f]=le(!1),e=ue(null),c=ue(null),o=()=>{if(r)return{only:Array.isArray(r)?r:[r]};if(!s)throw new Error("You must provide either a `data` or `params` prop.");return s};return Xe(()=>{if(c.current)return e.current=new IntersectionObserver(h=>{if(!h[0].isIntersecting||(P||e.current?.disconnect(),y))return;f(!0);let S=o();ze.reload({...S,onStart:R=>{f(!0),S.onStart?.(R)},onFinish:R=>{m(!0),f(!1),S.onFinish?.(R)}})},{rootMargin:`${a||0}px`}),e.current.observe(c.current),()=>{e.current?.disconnect()}},[c]),P||!d?Ge(i,{props:null,ref:c},d?p:l):d?p:null};ce.displayName="InertiaWhenVisible";var Ze=ce;var hr=et;export{Ae as Deferred,Me as Head,Ue as Link,Ze as WhenVisible,X as createInertiaApp,hr as router,ae as useForm,V as usePage,ie as usePoll,pe as usePrefetch,D as useRemember};
import{router as et}from"@inertiajs/core";import{router as be,setupProgress as ke}from"@inertiajs/core";import{createElement as Ce}from"react";import{createHeadManager as Se,router as G}from"@inertiajs/core";import{createElement as E,useEffect as Te,useMemo as ve,useState as Fe}from"react";import{createContext as ye}from"react";var Y=ye(void 0);Y.displayName="InertiaHeadContext";var w=Y;import{createContext as he}from"react";var z=he(void 0);z.displayName="InertiaPageContext";var O=z;function H({children:p,initialPage:r,initialComponent:s,resolveComponent:a,titleCallback:i,onHeadUpdate:P}){let[l,m]=Fe({component:s||null,page:r,key:null}),g=ve(()=>Se(typeof window>"u",i||(f=>f),P||(()=>{})),[]);if(Te(()=>{G.init({initialPage:r,resolveComponent:a,swapComponent:async({component:f,page:e,preserveState:c})=>{m(n=>({component:f,page:e,key:c?n.key:Date.now()}))}}),G.on("navigate",()=>g.forceUpdate())},[]),!l.component)return E(w.Provider,{value:g},E(O.Provider,{value:l.page},null));let y=p||(({Component:f,props:e,key:c})=>{let n=E(f,{key:c,...e});return typeof f.layout=="function"?f.layout(n):Array.isArray(f.layout)?f.layout.concat(n).reverse().reduce((h,S)=>E(S,{children:h,...e})):n});return E(w.Provider,{value:g},E(O.Provider,{value:l.page},y({Component:l.component,key:l.key,props:l.page.props})))}H.displayName="Inertia";async function X({id:p="app",resolve:r,setup:s,title:a,progress:i={},page:P,render:l}){let m=typeof window>"u",g=m?null:document.getElementById(p),y=P||JSON.parse(g.dataset.page),f=n=>Promise.resolve(r(n)).then(h=>h.default||h),e=[],c=await Promise.all([f(y.component),be.decryptHistory().catch(()=>{})]).then(([n])=>s({el:g,App:H,props:{initialPage:y,initialComponent:n,resolveComponent:f,titleCallback:a,onHeadUpdate:m?h=>e=h:null}}));if(!m&&i&&ke(i),m){let n=await l(Ce("div",{id:p,"data-page":JSON.stringify(y)},c));return{head:e,body:n}}}import{useEffect as xe,useState as Ie}from"react";import{useContext as Re}from"react";function V(){let p=Re(O);if(!p)throw new Error("usePage must be used within the Inertia component");return p}var Z=({children:p,data:r,fallback:s})=>{if(!r)throw new Error("`<Deferred>` requires a `data` prop");let[a,i]=Ie(!1),P=V().props,l=Array.isArray(r)?r:[r];return xe(()=>{i(l.every(m=>P[m]!==void 0))},[P,l]),a?p:s};Z.displayName="InertiaDeferred";var Ee=Z;import ee,{useContext as Ae,useEffect as we,useMemo as Oe}from"react";var De=function({children:p,title:r}){let s=Ae(w),a=Oe(()=>s.createProvider(),[s]);we(()=>()=>{a.disconnect()},[a]);function i(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function P(e){let c=Object.keys(e.props).reduce((n,h)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(h))return n;let S=e.props[h];return S===""?n+` ${h}`:n+` ${h}="${S}"`},"");return`<${e.type}${c}>`}function l(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,n)=>c+m(n),"")}function m(e){let c=P(e);return e.props.children&&(c+=l(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),i(e)||(c+=`</${e.type}>`),c}function g(e){return ee.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function y(e){return m(g(e))}function f(e){let c=ee.Children.toArray(e).filter(n=>n).map(n=>y(n));return r&&!c.find(n=>n.startsWith("<title"))&&c.push(`<title inertia>${r}</title>`),c}return a.update(f(p)),null},Me=De;import{mergeDataIntoQueryString as Le,router as j,shouldIntercept as W}from"@inertiajs/core";import{createElement as He,forwardRef as Ve,useEffect as te,useMemo as re,useRef as Be,useState as Ne}from"react";var k=()=>{},ne=Ve(({children:p,as:r="a",data:s={},href:a,method:i="get",preserveScroll:P=!1,preserveState:l=null,replace:m=!1,only:g=[],except:y=[],headers:f={},queryStringArrayFormat:e="brackets",async:c=!1,onClick:n=k,onCancelToken:h=k,onBefore:S=k,onStart:R=k,onProgress:x=k,onFinish:B=k,onCancel:L=k,onSuccess:N=k,onError:A=k,prefetch:v=!1,cacheFor:F=0,...t},u)=>{let[o,b]=Ne(0),d=Be(null);r=r.toLowerCase(),i=i.toLowerCase();let[fe,de]=Le(i,a||"",s,e);a=fe,s=de;let q={data:s,method:i,preserveScroll:P,preserveState:l??i!=="get",replace:m,only:g,except:y,headers:f,async:c},J={...q,onCancelToken:h,onBefore:S,onStart(T){b($=>$+1),R(T)},onProgress:x,onFinish(T){b($=>$-1),B(T)},onCancel:L,onSuccess:N,onError:A},U=()=>{j.prefetch(a,q,{cacheFor:me})},I=re(()=>v===!0?["hover"]:v===!1?[]:Array.isArray(v)?v:[v],Array.isArray(v)?v:[v]),me=re(()=>F!==0?F:I.length===1&&I[0]==="click"?0:3e4,[F,I]);te(()=>()=>{clearTimeout(d.current)},[]),te(()=>{I.includes("mount")&&setTimeout(()=>U())},I);let Q={onClick:T=>{n(T),W(T)&&(T.preventDefault(),j.visit(a,J))}},ge={onMouseEnter:()=>{d.current=window.setTimeout(()=>{U()},75)},onMouseLeave:()=>{clearTimeout(d.current)},onClick:Q.onClick},Pe={onMouseDown:T=>{W(T)&&(T.preventDefault(),U())},onMouseUp:T=>{T.preventDefault(),j.visit(a,J)},onClick:T=>{n(T),W(T)&&T.preventDefault()}};return i!=="get"&&(r="button"),He(r,{...t,...{a:{href:a},button:{type:"button"}}[r]||{},ref:u,...(()=>I.includes("hover")?ge:I.includes("click")?Pe:Q)(),"data-loading":o>0?"":void 0},p)});ne.displayName="InertiaLink";var Ue=ne;import{router as se}from"@inertiajs/core";import We from"lodash.isequal";import{useCallback as Ke,useEffect as _e,useRef as K,useState as C}from"react";import{router as oe}from"@inertiajs/core";import{useEffect as $e,useState as je}from"react";function D(p,r){let[s,a]=je(()=>{let i=oe.restore(r);return i!==void 0?i:p});return $e(()=>{oe.remember(s,r)},[s,r]),[s,a]}function ae(p,r){let s=K(null),a=typeof p=="string"?p:null,[i,P]=C((typeof p=="string"?r:p)||{}),l=K(null),m=K(null),[g,y]=a?D(i,`${a}:data`):C(i),[f,e]=a?D({},`${a}:errors`):C({}),[c,n]=C(!1),[h,S]=C(!1),[R,x]=C(null),[B,L]=C(!1),[N,A]=C(!1),v=t=>t;_e(()=>(s.current=!0,()=>{s.current=!1}),[]);let F=Ke((t,u,o={})=>{let b={...o,onCancelToken:d=>{if(l.current=d,o.onCancelToken)return o.onCancelToken(d)},onBefore:d=>{if(L(!1),A(!1),clearTimeout(m.current),o.onBefore)return o.onBefore(d)},onStart:d=>{if(S(!0),o.onStart)return o.onStart(d)},onProgress:d=>{if(x(d),o.onProgress)return o.onProgress(d)},onSuccess:d=>{if(s.current&&(S(!1),x(null),e({}),n(!1),L(!0),A(!0),m.current=setTimeout(()=>{s.current&&A(!1)},2e3)),o.onSuccess)return o.onSuccess(d)},onError:d=>{if(s.current&&(S(!1),x(null),e(d),n(!0)),o.onError)return o.onError(d)},onCancel:()=>{if(s.current&&(S(!1),x(null)),o.onCancel)return o.onCancel()},onFinish:d=>{if(s.current&&(S(!1),x(null)),l.current=null,o.onFinish)return o.onFinish(d)}};t==="delete"?se.delete(u,{...b,data:v(g)}):se[t](u,v(g),b)},[g,e,v]);return{data:g,setData(t,u){y(typeof t=="string"?o=>({...o,[t]:u}):typeof t=="function"?o=>t(o):t)},isDirty:!We(g,i),errors:f,hasErrors:c,processing:h,progress:R,wasSuccessful:B,recentlySuccessful:N,transform(t){v=t},setDefaults(t,u){P(typeof t>"u"?()=>g:o=>({...o,...typeof t=="string"?{[t]:u}:t}))},reset(...t){t.length===0?y(i):y(Object.keys(i).filter(u=>t.includes(u)).reduce((u,o)=>(u[o]=i[o],u),{...g}))},setError(t,u){e(o=>{let b={...o,...typeof t=="string"?{[t]:u}:t};return n(Object.keys(b).length>0),b})},clearErrors(...t){e(u=>{let o=Object.keys(u).reduce((b,d)=>({...b,...t.length>0&&!t.includes(d)?{[d]:u[d]}:{}}),{});return n(Object.keys(o).length>0),o})},submit:F,get(t,u){F("get",t,u)},post(t,u){F("post",t,u)},put(t,u){F("put",t,u)},patch(t,u){F("patch",t,u)},delete(t,u){F("delete",t,u)},cancel(){l.current&&l.current.cancel()}}}import{router as qe}from"@inertiajs/core";import{useEffect as Je,useRef as Qe}from"react";function ie(p,r={},s={keepAlive:!1,autoStart:!0}){let a=Qe(qe.poll(p,r,{...s,autoStart:!1}));return Je(()=>((s.autoStart??!0)&&a.current.start(),()=>a.current.stop()),[]),{stop:a.current.stop,start:a.current.start}}import{router as M}from"@inertiajs/core";import{useEffect as Ye,useState as _}from"react";function pe(p={}){let r=typeof window>"u"?null:M.getCached(window.location.pathname,p),s=typeof window>"u"?null:M.getPrefetching(window.location.pathname,p),[a,i]=_(r?.staleTimestamp||null),[P,l]=_(s!==null),[m,g]=_(r!==null);return Ye(()=>{let y=M.on("prefetching",e=>{e.detail.visit.url.pathname===window.location.pathname&&l(!0)}),f=M.on("prefetched",e=>{e.detail.visit.url.pathname===window.location.pathname&&(l(!1),g(!0),i(e.detail.fetchedAt))});return()=>{f(),y()}},[]),{lastUpdatedAt:a,isPrefetching:P,isPrefetched:m,flush:()=>M.flush(window.location.pathname,p)}}import{router as ze}from"@inertiajs/core";import{createElement as Ge,useEffect as Xe,useRef as ue,useState as le}from"react";var ce=({children:p,data:r,params:s,buffer:a,as:i,always:P,fallback:l})=>{P=P??!1,i=i??"div",l=l??null;let[m,g]=le(!1),[y,f]=le(!1),e=ue(null),c=ue(null),n=()=>{if(r)return{only:Array.isArray(r)?r:[r]};if(!s)throw new Error("You must provide either a `data` or `params` prop.");return s};return Xe(()=>{if(c.current)return e.current=new IntersectionObserver(h=>{if(!h[0].isIntersecting||(P||e.current?.disconnect(),y))return;f(!0);let S=n();ze.reload({...S,onStart:R=>{f(!0),S.onStart?.(R)},onFinish:R=>{g(!0),f(!1),S.onFinish?.(R)}})},{rootMargin:`${a||0}px`}),e.current.observe(c.current),()=>{e.current?.disconnect()}},[c]),P||!m?Ge(i,{props:null,ref:c},m?p:l):m?p:null};ce.displayName="InertiaWhenVisible";var Ze=ce;var hr=et;export{Ee as Deferred,Me as Head,Ue as Link,Ze as WhenVisible,X as createInertiaApp,hr as router,ae as useForm,V as usePage,ie as usePoll,pe as usePrefetch,D as useRemember};
//# sourceMappingURL=index.esm.js.map

@@ -1,2 +0,2 @@

var Oe=Object.create;var W=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Ve=(r,t)=>{for(var o in t)W(r,o,{get:t[o],enumerable:!0})},pe=(r,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Me(t))!He.call(r,s)&&s!==o&&W(r,s,{get:()=>t[s],enumerable:!(a=De(t,s))||a.enumerable});return r};var ue=(r,t,o)=>(o=r!=null?Oe(Le(r)):{},pe(t||!r||!r.__esModule?W(o,"default",{value:r,enumerable:!0}):o,r)),Be=r=>pe(W({},"__esModule",{value:!0}),r);var $e={};Ve($e,{Deferred:()=>ye,Head:()=>he,Link:()=>Te,WhenVisible:()=>ke,createInertiaApp:()=>Z,router:()=>Ue,useForm:()=>re,usePage:()=>$,usePoll:()=>oe,usePrefetch:()=>ne,useRemember:()=>M});module.exports=Be($e);var Re=require("@inertiajs/core");var _=require("@inertiajs/core"),me=require("react");var U=require("@inertiajs/core"),b=require("react");var le=require("react"),ce=(0,le.createContext)(void 0);ce.displayName="InertiaHeadContext";var B=ce;var fe=require("react"),de=(0,fe.createContext)(void 0);de.displayName="InertiaPageContext";var N=de;function K({children:r,initialPage:t,initialComponent:o,resolveComponent:a,titleCallback:s,onHeadUpdate:P}){let[l,d]=(0,b.useState)({component:o||null,page:t,key:null}),m=(0,b.useMemo)(()=>(0,U.createHeadManager)(typeof window>"u",s||(f=>f),P||(()=>{})),[]);if((0,b.useEffect)(()=>{U.router.init({initialPage:t,resolveComponent:a,swapComponent:async({component:f,page:e,preserveState:c})=>{d(i=>({component:f,page:e,key:c?i.key:Date.now()}))}}),U.router.on("navigate",()=>m.forceUpdate())},[]),!l.component)return(0,b.createElement)(B.Provider,{value:m},(0,b.createElement)(N.Provider,{value:l.page},null));let y=r||(({Component:f,props:e,key:c})=>{let i=(0,b.createElement)(f,{key:c,...e});return typeof f.layout=="function"?f.layout(i):Array.isArray(f.layout)?f.layout.concat(i).reverse().reduce((h,T)=>(0,b.createElement)(T,{children:h,...e})):i});return(0,b.createElement)(B.Provider,{value:m},(0,b.createElement)(N.Provider,{value:l.page},y({Component:l.component,key:l.key,props:l.page.props})))}K.displayName="Inertia";async function Z({id:r="app",resolve:t,setup:o,title:a,progress:s={},page:P,render:l}){let d=typeof window>"u",m=d?null:document.getElementById(r),y=P||JSON.parse(m.dataset.page),f=i=>Promise.resolve(t(i)).then(h=>h.default||h),e=[],c=await Promise.all([f(y.component),_.router.decryptHistory().catch(()=>{})]).then(([i])=>o({el:m,App:K,props:{initialPage:y,initialComponent:i,resolveComponent:f,titleCallback:a,onHeadUpdate:d?h=>e=h:null}}));if(!d&&s&&(0,_.setupProgress)(s),d){let i=await l((0,me.createElement)("div",{id:r,"data-page":JSON.stringify(y)},c));return{head:e,body:i}}}var q=require("react");var ge=require("react");function $(){let r=(0,ge.useContext)(N);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var Pe=({children:r,data:t,fallback:o})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop");let[a,s]=(0,q.useState)(!1),P=$().props,l=Array.isArray(t)?t:[t];return(0,q.useEffect)(()=>{s(l.every(d=>P[d]!==void 0))},[P,l]),a?r:o};Pe.displayName="InertiaDeferred";var ye=Pe;var A=ue(require("react"),1);var Ne=function({children:r,title:t}){let o=(0,A.useContext)(B),a=(0,A.useMemo)(()=>o.createProvider(),[o]);(0,A.useEffect)(()=>()=>{a.disconnect()},[a]);function s(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function P(e){let c=Object.keys(e.props).reduce((i,h)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(h))return i;let T=e.props[h];return T===""?i+` ${h}`:i+` ${h}="${T}"`},"");return`<${e.type}${c}>`}function l(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,i)=>c+d(i),"")}function d(e){let c=P(e);return e.props.children&&(c+=l(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),s(e)||(c+=`</${e.type}>`),c}function m(e){return A.default.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function y(e){return d(m(e))}function f(e){let c=A.default.Children.toArray(e).filter(i=>i).map(i=>y(i));return t&&!c.find(i=>i.startsWith("<title"))&&c.push(`<title inertia>${t}</title>`),c}return a.update(f(r)),null},he=Ne;var x=require("@inertiajs/core"),F=require("react"),E=()=>{},Se=(0,F.forwardRef)(({children:r,as:t="a",data:o={},href:a,method:s="get",preserveScroll:P=!1,preserveState:l=null,replace:d=!1,only:m=[],except:y=[],headers:f={},queryStringArrayFormat:e="brackets",async:c=!1,onClick:i=E,onCancelToken:h=E,onBefore:T=E,onStart:w=E,onProgress:O=E,onFinish:Y=E,onCancel:j=E,onSuccess:z=E,onError:V=E,prefetch:C=!1,cacheFor:k=0,...n},u)=>{let[p,R]=(0,F.useState)(0),g=(0,F.useRef)();t=t.toLowerCase(),s=s.toLowerCase();let[xe,Ie]=(0,x.mergeDataIntoQueryString)(s,a||"",o,e);a=xe,o=Ie;let se={data:o,method:s,preserveScroll:P,preserveState:l??s!=="get",replace:d,only:m,except:y,headers:f,async:c},ae={...se,onCancelToken:h,onBefore:T,onStart(v){R(X=>X+1),w(v)},onProgress:O,onFinish(v){R(X=>X-1),Y(v)},onCancel:j,onSuccess:z,onError:V},G=()=>{x.router.prefetch(a,se,{cacheFor:Ae})},D=(0,F.useMemo)(()=>C===!0?["hover"]:C===!1?[]:Array.isArray(C)?C:[C],Array.isArray(C)?C:[C]),Ae=(0,F.useMemo)(()=>k!==0?k:D.length===1&&D[0]==="click"?0:3e4,[k,D]);(0,F.useEffect)(()=>()=>{clearTimeout(g.current)},[]),(0,F.useEffect)(()=>{D.includes("mount")&&setTimeout(()=>G())},D);let ie={onClick:v=>{i(v),(0,x.shouldIntercept)(v)&&(v.preventDefault(),x.router.visit(a,ae))}},Ee={onMouseEnter:()=>{g.current=window.setTimeout(()=>{G()},75)},onMouseLeave:()=>{clearTimeout(g.current)},onClick:ie.onClick},we={onMouseDown:v=>{(0,x.shouldIntercept)(v)&&(v.preventDefault(),G())},onMouseUp:v=>{v.preventDefault(),x.router.visit(a,ae)},onClick:v=>{i(v),(0,x.shouldIntercept)(v)&&v.preventDefault()}};return s!=="get"&&(t="button"),(0,F.createElement)(t,{...n,...{a:{href:a},button:{type:"button"}}[t]||{},ref:u,...(()=>D.includes("hover")?Ee:D.includes("click")?we:ie)(),"data-loading":p>0?"":void 0},r)});Se.displayName="InertiaLink";var Te=Se;var te=require("@inertiajs/core"),ve=ue(require("lodash.isequal"),1),S=require("react");var ee=require("@inertiajs/core"),J=require("react");function M(r,t){let[o,a]=(0,J.useState)(()=>{let s=ee.router.restore(t);return s!==void 0?s:r});return(0,J.useEffect)(()=>{ee.router.remember(o,t)},[o,t]),[o,a]}function re(r,t){let o=(0,S.useRef)(null),a=typeof r=="string"?r:null,[s,P]=(0,S.useState)((typeof r=="string"?t:r)||{}),l=(0,S.useRef)(null),d=(0,S.useRef)(null),[m,y]=a?M(s,`${a}:data`):(0,S.useState)(s),[f,e]=a?M({},`${a}:errors`):(0,S.useState)({}),[c,i]=(0,S.useState)(!1),[h,T]=(0,S.useState)(!1),[w,O]=(0,S.useState)(null),[Y,j]=(0,S.useState)(!1),[z,V]=(0,S.useState)(!1),C=n=>n;(0,S.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let k=(0,S.useCallback)((n,u,p={})=>{let R={...p,onCancelToken:g=>{if(l.current=g,p.onCancelToken)return p.onCancelToken(g)},onBefore:g=>{if(j(!1),V(!1),clearTimeout(d.current),p.onBefore)return p.onBefore(g)},onStart:g=>{if(T(!0),p.onStart)return p.onStart(g)},onProgress:g=>{if(O(g),p.onProgress)return p.onProgress(g)},onSuccess:g=>{if(o.current&&(T(!1),O(null),e({}),i(!1),j(!0),V(!0),d.current=setTimeout(()=>{o.current&&V(!1)},2e3)),p.onSuccess)return p.onSuccess(g)},onError:g=>{if(o.current&&(T(!1),O(null),e(g),i(!0)),p.onError)return p.onError(g)},onCancel:()=>{if(o.current&&(T(!1),O(null)),p.onCancel)return p.onCancel()},onFinish:()=>{if(o.current&&(T(!1),O(null)),l.current=null,p.onFinish)return p.onFinish()}};n==="delete"?te.router.delete(u,{...R,data:C(m)}):te.router[n](u,C(m),R)},[m,e,C]);return{data:m,setData(n,u){y(typeof n=="string"?p=>({...p,[n]:u}):typeof n=="function"?p=>n(p):n)},isDirty:!(0,ve.default)(m,s),errors:f,hasErrors:c,processing:h,progress:w,wasSuccessful:Y,recentlySuccessful:z,transform(n){C=n},setDefaults(n,u){P(typeof n>"u"?()=>m:p=>({...p,...typeof n=="string"?{[n]:u}:n}))},reset(...n){n.length===0?y(s):y(Object.keys(s).filter(u=>n.includes(u)).reduce((u,p)=>(u[p]=s[p],u),{...m}))},setError(n,u){e(p=>{let R={...p,...typeof n=="string"?{[n]:u}:n};return i(Object.keys(R).length>0),R})},clearErrors(...n){e(u=>{let p=Object.keys(u).reduce((R,g)=>({...R,...n.length>0&&!n.includes(g)?{[g]:u[g]}:{}}),{});return i(Object.keys(p).length>0),p})},submit:k,get(n,u){k("get",n,u)},post(n,u){k("post",n,u)},put(n,u){k("put",n,u)},patch(n,u){k("patch",n,u)},delete(n,u){k("delete",n,u)},cancel(){l.current&&l.current.cancel()}}}var Fe=require("@inertiajs/core"),Q=require("react");function oe(r,t={},o={keepAlive:!1,autoStart:!0}){let a=(0,Q.useRef)(Fe.router.poll(r,t,{...o,autoStart:!1}));return(0,Q.useEffect)(()=>((o.autoStart??!0)&&a.current.start(),()=>a.current.stop()),[]),{stop:a.current.stop,start:a.current.start}}var L=require("@inertiajs/core"),H=require("react");function ne(r={}){let t=typeof window>"u"?null:L.router.getCached(window.location.pathname,r),o=typeof window>"u"?null:L.router.getPrefetching(window.location.pathname,r),[a,s]=(0,H.useState)(t?.staleTimestamp||null),[P,l]=(0,H.useState)(o!==null),[d,m]=(0,H.useState)(t!==null);return(0,H.useEffect)(()=>{let y=L.router.on("prefetching",e=>{e.detail.visit.url.pathname===window.location.pathname&&l(!0)}),f=L.router.on("prefetched",e=>{e.detail.visit.url.pathname===window.location.pathname&&(l(!1),m(!0),s(e.detail.fetchedAt))});return()=>{f(),y()}},[]),{lastUpdatedAt:a,isPrefetching:P,isPrefetched:d,flush:()=>L.router.flush(window.location.pathname,r)}}var Ce=require("@inertiajs/core"),I=require("react"),be=({children:r,data:t,params:o,buffer:a,as:s,always:P,fallback:l})=>{P=P??!1,s=s??"div",l=l??null;let[d,m]=(0,I.useState)(!1),[y,f]=(0,I.useState)(!1),e=(0,I.useRef)(null),c=(0,I.useRef)(null),i=()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!o)throw new Error("You must provide either a `data` or `params` prop.");return o};return(0,I.useEffect)(()=>{if(c.current)return e.current=new IntersectionObserver(h=>{if(!h[0].isIntersecting||(P||e.current?.disconnect(),y))return;f(!0);let T=i();Ce.router.reload({...T,onStart:w=>{f(!0),T.onStart?.(w)},onFinish:w=>{m(!0),f(!1),T.onFinish?.(w)}})},{rootMargin:`${a||0}px`}),e.current.observe(c.current),()=>{e.current?.disconnect()}},[c]),P||!d?(0,I.createElement)(s,{props:null,ref:c},d?r:l):d?r:null};be.displayName="InertiaWhenVisible";var ke=be;var Ue=Re.router;
var Oe=Object.create;var W=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Ve=(r,t)=>{for(var n in t)W(r,n,{get:t[n],enumerable:!0})},pe=(r,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Me(t))!He.call(r,s)&&s!==n&&W(r,s,{get:()=>t[s],enumerable:!(a=De(t,s))||a.enumerable});return r};var ue=(r,t,n)=>(n=r!=null?Oe(Le(r)):{},pe(t||!r||!r.__esModule?W(n,"default",{value:r,enumerable:!0}):n,r)),Be=r=>pe(W({},"__esModule",{value:!0}),r);var $e={};Ve($e,{Deferred:()=>ye,Head:()=>he,Link:()=>Te,WhenVisible:()=>Ce,createInertiaApp:()=>Z,router:()=>Ue,useForm:()=>re,usePage:()=>$,usePoll:()=>ne,usePrefetch:()=>oe,useRemember:()=>M});module.exports=Be($e);var Re=require("@inertiajs/core");var _=require("@inertiajs/core"),me=require("react");var U=require("@inertiajs/core"),k=require("react");var le=require("react"),ce=(0,le.createContext)(void 0);ce.displayName="InertiaHeadContext";var B=ce;var fe=require("react"),de=(0,fe.createContext)(void 0);de.displayName="InertiaPageContext";var N=de;function K({children:r,initialPage:t,initialComponent:n,resolveComponent:a,titleCallback:s,onHeadUpdate:P}){let[l,m]=(0,k.useState)({component:n||null,page:t,key:null}),g=(0,k.useMemo)(()=>(0,U.createHeadManager)(typeof window>"u",s||(f=>f),P||(()=>{})),[]);if((0,k.useEffect)(()=>{U.router.init({initialPage:t,resolveComponent:a,swapComponent:async({component:f,page:e,preserveState:c})=>{m(i=>({component:f,page:e,key:c?i.key:Date.now()}))}}),U.router.on("navigate",()=>g.forceUpdate())},[]),!l.component)return(0,k.createElement)(B.Provider,{value:g},(0,k.createElement)(N.Provider,{value:l.page},null));let y=r||(({Component:f,props:e,key:c})=>{let i=(0,k.createElement)(f,{key:c,...e});return typeof f.layout=="function"?f.layout(i):Array.isArray(f.layout)?f.layout.concat(i).reverse().reduce((h,T)=>(0,k.createElement)(T,{children:h,...e})):i});return(0,k.createElement)(B.Provider,{value:g},(0,k.createElement)(N.Provider,{value:l.page},y({Component:l.component,key:l.key,props:l.page.props})))}K.displayName="Inertia";async function Z({id:r="app",resolve:t,setup:n,title:a,progress:s={},page:P,render:l}){let m=typeof window>"u",g=m?null:document.getElementById(r),y=P||JSON.parse(g.dataset.page),f=i=>Promise.resolve(t(i)).then(h=>h.default||h),e=[],c=await Promise.all([f(y.component),_.router.decryptHistory().catch(()=>{})]).then(([i])=>n({el:g,App:K,props:{initialPage:y,initialComponent:i,resolveComponent:f,titleCallback:a,onHeadUpdate:m?h=>e=h:null}}));if(!m&&s&&(0,_.setupProgress)(s),m){let i=await l((0,me.createElement)("div",{id:r,"data-page":JSON.stringify(y)},c));return{head:e,body:i}}}var q=require("react");var ge=require("react");function $(){let r=(0,ge.useContext)(N);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var Pe=({children:r,data:t,fallback:n})=>{if(!t)throw new Error("`<Deferred>` requires a `data` prop");let[a,s]=(0,q.useState)(!1),P=$().props,l=Array.isArray(t)?t:[t];return(0,q.useEffect)(()=>{s(l.every(m=>P[m]!==void 0))},[P,l]),a?r:n};Pe.displayName="InertiaDeferred";var ye=Pe;var E=ue(require("react"),1);var Ne=function({children:r,title:t}){let n=(0,E.useContext)(B),a=(0,E.useMemo)(()=>n.createProvider(),[n]);(0,E.useEffect)(()=>()=>{a.disconnect()},[a]);function s(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function P(e){let c=Object.keys(e.props).reduce((i,h)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(h))return i;let T=e.props[h];return T===""?i+` ${h}`:i+` ${h}="${T}"`},"");return`<${e.type}${c}>`}function l(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,i)=>c+m(i),"")}function m(e){let c=P(e);return e.props.children&&(c+=l(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),s(e)||(c+=`</${e.type}>`),c}function g(e){return E.default.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function y(e){return m(g(e))}function f(e){let c=E.default.Children.toArray(e).filter(i=>i).map(i=>y(i));return t&&!c.find(i=>i.startsWith("<title"))&&c.push(`<title inertia>${t}</title>`),c}return a.update(f(r)),null},he=Ne;var x=require("@inertiajs/core"),F=require("react"),A=()=>{},Se=(0,F.forwardRef)(({children:r,as:t="a",data:n={},href:a,method:s="get",preserveScroll:P=!1,preserveState:l=null,replace:m=!1,only:g=[],except:y=[],headers:f={},queryStringArrayFormat:e="brackets",async:c=!1,onClick:i=A,onCancelToken:h=A,onBefore:T=A,onStart:w=A,onProgress:O=A,onFinish:Y=A,onCancel:j=A,onSuccess:z=A,onError:V=A,prefetch:b=!1,cacheFor:C=0,...o},u)=>{let[p,R]=(0,F.useState)(0),d=(0,F.useRef)(null);t=t.toLowerCase(),s=s.toLowerCase();let[xe,Ie]=(0,x.mergeDataIntoQueryString)(s,a||"",n,e);a=xe,n=Ie;let se={data:n,method:s,preserveScroll:P,preserveState:l??s!=="get",replace:m,only:g,except:y,headers:f,async:c},ae={...se,onCancelToken:h,onBefore:T,onStart(v){R(X=>X+1),w(v)},onProgress:O,onFinish(v){R(X=>X-1),Y(v)},onCancel:j,onSuccess:z,onError:V},G=()=>{x.router.prefetch(a,se,{cacheFor:Ee})},D=(0,F.useMemo)(()=>b===!0?["hover"]:b===!1?[]:Array.isArray(b)?b:[b],Array.isArray(b)?b:[b]),Ee=(0,F.useMemo)(()=>C!==0?C:D.length===1&&D[0]==="click"?0:3e4,[C,D]);(0,F.useEffect)(()=>()=>{clearTimeout(d.current)},[]),(0,F.useEffect)(()=>{D.includes("mount")&&setTimeout(()=>G())},D);let ie={onClick:v=>{i(v),(0,x.shouldIntercept)(v)&&(v.preventDefault(),x.router.visit(a,ae))}},Ae={onMouseEnter:()=>{d.current=window.setTimeout(()=>{G()},75)},onMouseLeave:()=>{clearTimeout(d.current)},onClick:ie.onClick},we={onMouseDown:v=>{(0,x.shouldIntercept)(v)&&(v.preventDefault(),G())},onMouseUp:v=>{v.preventDefault(),x.router.visit(a,ae)},onClick:v=>{i(v),(0,x.shouldIntercept)(v)&&v.preventDefault()}};return s!=="get"&&(t="button"),(0,F.createElement)(t,{...o,...{a:{href:a},button:{type:"button"}}[t]||{},ref:u,...(()=>D.includes("hover")?Ae:D.includes("click")?we:ie)(),"data-loading":p>0?"":void 0},r)});Se.displayName="InertiaLink";var Te=Se;var te=require("@inertiajs/core"),ve=ue(require("lodash.isequal"),1),S=require("react");var ee=require("@inertiajs/core"),J=require("react");function M(r,t){let[n,a]=(0,J.useState)(()=>{let s=ee.router.restore(t);return s!==void 0?s:r});return(0,J.useEffect)(()=>{ee.router.remember(n,t)},[n,t]),[n,a]}function re(r,t){let n=(0,S.useRef)(null),a=typeof r=="string"?r:null,[s,P]=(0,S.useState)((typeof r=="string"?t:r)||{}),l=(0,S.useRef)(null),m=(0,S.useRef)(null),[g,y]=a?M(s,`${a}:data`):(0,S.useState)(s),[f,e]=a?M({},`${a}:errors`):(0,S.useState)({}),[c,i]=(0,S.useState)(!1),[h,T]=(0,S.useState)(!1),[w,O]=(0,S.useState)(null),[Y,j]=(0,S.useState)(!1),[z,V]=(0,S.useState)(!1),b=o=>o;(0,S.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);let C=(0,S.useCallback)((o,u,p={})=>{let R={...p,onCancelToken:d=>{if(l.current=d,p.onCancelToken)return p.onCancelToken(d)},onBefore:d=>{if(j(!1),V(!1),clearTimeout(m.current),p.onBefore)return p.onBefore(d)},onStart:d=>{if(T(!0),p.onStart)return p.onStart(d)},onProgress:d=>{if(O(d),p.onProgress)return p.onProgress(d)},onSuccess:d=>{if(n.current&&(T(!1),O(null),e({}),i(!1),j(!0),V(!0),m.current=setTimeout(()=>{n.current&&V(!1)},2e3)),p.onSuccess)return p.onSuccess(d)},onError:d=>{if(n.current&&(T(!1),O(null),e(d),i(!0)),p.onError)return p.onError(d)},onCancel:()=>{if(n.current&&(T(!1),O(null)),p.onCancel)return p.onCancel()},onFinish:d=>{if(n.current&&(T(!1),O(null)),l.current=null,p.onFinish)return p.onFinish(d)}};o==="delete"?te.router.delete(u,{...R,data:b(g)}):te.router[o](u,b(g),R)},[g,e,b]);return{data:g,setData(o,u){y(typeof o=="string"?p=>({...p,[o]:u}):typeof o=="function"?p=>o(p):o)},isDirty:!(0,ve.default)(g,s),errors:f,hasErrors:c,processing:h,progress:w,wasSuccessful:Y,recentlySuccessful:z,transform(o){b=o},setDefaults(o,u){P(typeof o>"u"?()=>g:p=>({...p,...typeof o=="string"?{[o]:u}:o}))},reset(...o){o.length===0?y(s):y(Object.keys(s).filter(u=>o.includes(u)).reduce((u,p)=>(u[p]=s[p],u),{...g}))},setError(o,u){e(p=>{let R={...p,...typeof o=="string"?{[o]:u}:o};return i(Object.keys(R).length>0),R})},clearErrors(...o){e(u=>{let p=Object.keys(u).reduce((R,d)=>({...R,...o.length>0&&!o.includes(d)?{[d]:u[d]}:{}}),{});return i(Object.keys(p).length>0),p})},submit:C,get(o,u){C("get",o,u)},post(o,u){C("post",o,u)},put(o,u){C("put",o,u)},patch(o,u){C("patch",o,u)},delete(o,u){C("delete",o,u)},cancel(){l.current&&l.current.cancel()}}}var Fe=require("@inertiajs/core"),Q=require("react");function ne(r,t={},n={keepAlive:!1,autoStart:!0}){let a=(0,Q.useRef)(Fe.router.poll(r,t,{...n,autoStart:!1}));return(0,Q.useEffect)(()=>((n.autoStart??!0)&&a.current.start(),()=>a.current.stop()),[]),{stop:a.current.stop,start:a.current.start}}var L=require("@inertiajs/core"),H=require("react");function oe(r={}){let t=typeof window>"u"?null:L.router.getCached(window.location.pathname,r),n=typeof window>"u"?null:L.router.getPrefetching(window.location.pathname,r),[a,s]=(0,H.useState)(t?.staleTimestamp||null),[P,l]=(0,H.useState)(n!==null),[m,g]=(0,H.useState)(t!==null);return(0,H.useEffect)(()=>{let y=L.router.on("prefetching",e=>{e.detail.visit.url.pathname===window.location.pathname&&l(!0)}),f=L.router.on("prefetched",e=>{e.detail.visit.url.pathname===window.location.pathname&&(l(!1),g(!0),s(e.detail.fetchedAt))});return()=>{f(),y()}},[]),{lastUpdatedAt:a,isPrefetching:P,isPrefetched:m,flush:()=>L.router.flush(window.location.pathname,r)}}var be=require("@inertiajs/core"),I=require("react"),ke=({children:r,data:t,params:n,buffer:a,as:s,always:P,fallback:l})=>{P=P??!1,s=s??"div",l=l??null;let[m,g]=(0,I.useState)(!1),[y,f]=(0,I.useState)(!1),e=(0,I.useRef)(null),c=(0,I.useRef)(null),i=()=>{if(t)return{only:Array.isArray(t)?t:[t]};if(!n)throw new Error("You must provide either a `data` or `params` prop.");return n};return(0,I.useEffect)(()=>{if(c.current)return e.current=new IntersectionObserver(h=>{if(!h[0].isIntersecting||(P||e.current?.disconnect(),y))return;f(!0);let T=i();be.router.reload({...T,onStart:w=>{f(!0),T.onStart?.(w)},onFinish:w=>{g(!0),f(!1),T.onFinish?.(w)}})},{rootMargin:`${a||0}px`}),e.current.observe(c.current),()=>{e.current?.disconnect()}},[c]),P||!m?(0,I.createElement)(s,{props:null,ref:c},m?r:l):m?r:null};ke.displayName="InertiaWhenVisible";var Ce=ke;var Ue=Re.router;
//# sourceMappingURL=index.js.map
{
"name": "@inertiajs/react",
"version": "2.0.0-beta.3",
"version": "2.0.0",
"license": "MIT",

@@ -52,15 +52,15 @@ "description": "The React adapter for Inertia.js",

"devDependencies": {
"@types/react": "^16.9.1",
"@types/react-dom": "^16.9.17",
"@types/react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"@types/react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"esbuild": "^0.16.13",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"typescript": "^4.9.4"
},
"peerDependencies": {
"react": "^16.9.0 || ^17.0.0 || ^18.0.0"
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
},
"dependencies": {
"@inertiajs/core": "2.0.0-beta.3",
"@inertiajs/core": "2.0.0",
"lodash.isequal": "^4.5.0"
}
}

@@ -1,11 +0,11 @@

import { ReactChild } from 'react';
import { ReactElement } from 'react';
interface DeferredProps {
children: ReactChild;
fallback: ReactChild;
children: ReactElement | number | string;
fallback: ReactElement | number | string;
data: string | string[];
}
declare const Deferred: {
({ children, data, fallback }: DeferredProps): ReactChild;
({ children, data, fallback }: DeferredProps): string | number | ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
displayName: string;
};
export default Deferred;
import { ReloadOptions } from '@inertiajs/core';
import { ReactChild } from 'react';
import { ReactElement } from 'react';
interface WhenVisibleProps {
children: ReactChild;
fallback: ReactChild;
children: ReactElement | number | string;
fallback: ReactElement | number | string;
data: string | string[];

@@ -13,5 +13,5 @@ params?: ReloadOptions;

declare const WhenVisible: {
({ children, data, params, buffer, as, always, fallback }: WhenVisibleProps): ReactChild;
({ children, data, params, buffer, as, always, fallback }: WhenVisibleProps): string | number | ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
displayName: string;
};
export default WhenVisible;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc