@inertiajs/react
Advanced tools
Comparing version 1.3.0-beta.2 to 1.3.0
@@ -1,6 +0,6 @@ | ||
import{router as Me}from"@inertiajs/core";import{setupProgress as fe}from"@inertiajs/core";import{createElement as me}from"react";import{createHeadManager as ue,router as _}from"@inertiajs/core";import{createElement as x,useEffect as ce,useMemo as le,useState as de}from"react";import{createContext as ie}from"react";var V=ie(void 0);V.displayName="InertiaHeadContext";var M=V;import{createContext as pe}from"react";var K=pe(void 0);K.displayName="InertiaPageContext";var H=K;function N({children:l,initialPage:p,initialComponent:a,resolveComponent:i,titleCallback:n,onHeadUpdate:F}){let[d,y]=de({component:a||null,page:p,key:null}),u=le(()=>ue(typeof window>"u",n||(c=>c),F||(()=>{})),[]);if(ce(()=>{_.init({initialPage:p,resolveComponent:i,swapComponent:async({component:c,page:e,preserveState:s})=>{y(r=>({component:c,page:e,key:s?r.key:Date.now()}))}}),_.on("navigate",()=>u.forceUpdate())},[]),!d.component)return x(M.Provider,{value:u},x(H.Provider,{value:d.page},null));let f=l||(({Component:c,props:e,key:s})=>{let r=x(c,{key:s,...e});return typeof c.layout=="function"?c.layout(r):Array.isArray(c.layout)?c.layout.concat(r).reverse().reduce((g,T)=>x(T,{children:g,...e})):r});return x(M.Provider,{value:u},x(H.Provider,{value:d.page},f({Component:d.component,key:d.key,props:d.page.props})))}N.displayName="Inertia";async function W({id:l="app",resolve:p,setup:a,title:i,progress:n={},page:F,render:d}){let y=typeof window>"u",u=y?null:document.getElementById(l),f=F||JSON.parse(u.dataset.page),c=r=>Promise.resolve(p(r)).then(g=>g.default||g),e=[],s=await c(f.component).then(r=>a({el:u,App:N,props:{initialPage:f,initialComponent:r,resolveComponent:c,titleCallback:i,onHeadUpdate:y?g=>e=g:null}}));if(!y&&n&&fe(n),y){let r=await d(me("div",{id:l,"data-page":JSON.stringify(f)},s));return{head:e,body:r}}}import q,{useContext as ge,useEffect as ye,useMemo as Pe}from"react";var Te=function({children:l,title:p}){let a=ge(M),i=Pe(()=>a.createProvider(),[a]);ye(()=>()=>{i.disconnect()},[i]);function n(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function F(e){let s=Object.keys(e.props).reduce((r,g)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(g))return r;let T=e.props[g];return T===""?r+` ${g}`:r+` ${g}="${T}"`},"");return`<${e.type}${s}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((s,r)=>s+y(r),"")}function y(e){let s=F(e);return e.props.children&&(s+=d(e)),e.props.dangerouslySetInnerHTML&&(s+=e.props.dangerouslySetInnerHTML.__html),n(e)||(s+=`</${e.type}>`),s}function u(e){return q.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function f(e){return y(u(e))}function c(e){let s=q.Children.toArray(e).filter(r=>r).map(r=>f(r));return p&&!s.find(r=>r.startsWith("<title"))&&s.push(`<title inertia>${p}</title>`),s}return i.update(c(l)),null},Se=Te;import{mergeDataIntoQueryString as Fe,router as ve,shouldIntercept as he}from"@inertiajs/core";import{createElement as Ce,forwardRef as ke,useCallback as be}from"react";var C=()=>{},J=ke(({children:l,as:p="a",data:a={},href:i,method:n="get",preserveScroll:F=!1,preserveState:d=null,replace:y=!1,only:u=[],except:f=[],headers:c={},queryStringArrayFormat:e="brackets",onClick:s=C,onCancelToken:r=C,onBefore:g=C,onStart:T=C,onProgress:O=C,onFinish:k=C,onCancel:L=C,onSuccess:R=C,onError:B=C,...I},A)=>{let h=be(E=>{s(E),he(E.nativeEvent)&&(E.preventDefault(),ve.visit(i,{data:a,method:n,preserveScroll:F,preserveState:d??n!=="get",replace:y,only:u,except:f,headers:c,onCancelToken:r,onBefore:g,onStart:T,onProgress:O,onFinish:k,onCancel:L,onSuccess:R,onError:B}))},[a,i,n,F,d,y,u,f,c,s,r,g,T,O,k,L,R,B]);p=p.toLowerCase(),n=n.toLowerCase();let[j,U]=Fe(n,i||"",a,e);return i=j,a=U,p==="a"&&n!=="get"&&console.warn(`Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes "Open Link in New Tab/Window" accessibility issues. | ||
import{router as Me}from"@inertiajs/core";import{setupProgress as fe}from"@inertiajs/core";import{createElement as me}from"react";import{createHeadManager as ue,router as _}from"@inertiajs/core";import{createElement as x,useEffect as ce,useMemo as le,useState as de}from"react";import{createContext as ie}from"react";var V=ie(void 0);V.displayName="InertiaHeadContext";var M=V;import{createContext as pe}from"react";var K=pe(void 0);K.displayName="InertiaPageContext";var H=K;function N({children:l,initialPage:p,initialComponent:a,resolveComponent:i,titleCallback:n,onHeadUpdate:F}){let[d,y]=de({component:a||null,page:p,key:null}),u=le(()=>ue(typeof window>"u",n||(c=>c),F||(()=>{})),[]);if(ce(()=>{_.init({initialPage:p,resolveComponent:i,swapComponent:async({component:c,page:e,preserveState:s})=>{y(r=>({component:c,page:e,key:s?r.key:Date.now()}))}}),_.on("navigate",()=>u.forceUpdate())},[]),!d.component)return x(M.Provider,{value:u},x(H.Provider,{value:d.page},null));let f=l||(({Component:c,props:e,key:s})=>{let r=x(c,{key:s,...e});return typeof c.layout=="function"?c.layout(r):Array.isArray(c.layout)?c.layout.concat(r).reverse().reduce((g,T)=>x(T,{children:g,...e})):r});return x(M.Provider,{value:u},x(H.Provider,{value:d.page},f({Component:d.component,key:d.key,props:d.page.props})))}N.displayName="Inertia";async function W({id:l="app",resolve:p,setup:a,title:i,progress:n={},page:F,render:d}){let y=typeof window>"u",u=y?null:document.getElementById(l),f=F||JSON.parse(u.dataset.page),c=r=>Promise.resolve(p(r)).then(g=>g.default||g),e=[],s=await c(f.component).then(r=>a({el:u,App:N,props:{initialPage:f,initialComponent:r,resolveComponent:c,titleCallback:i,onHeadUpdate:y?g=>e=g:null}}));if(!y&&n&&fe(n),y){let r=await d(me("div",{id:l,"data-page":JSON.stringify(f)},s));return{head:e,body:r}}}import q,{useContext as ge,useEffect as ye,useMemo as Pe}from"react";var Te=function({children:l,title:p}){let a=ge(M),i=Pe(()=>a.createProvider(),[a]);ye(()=>()=>{i.disconnect()},[i]);function n(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function F(e){let s=Object.keys(e.props).reduce((r,g)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(g))return r;let T=e.props[g];return T===""?r+` ${g}`:r+` ${g}="${T}"`},"");return`<${e.type}${s}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((s,r)=>s+y(r),"")}function y(e){let s=F(e);return e.props.children&&(s+=d(e)),e.props.dangerouslySetInnerHTML&&(s+=e.props.dangerouslySetInnerHTML.__html),n(e)||(s+=`</${e.type}>`),s}function u(e){return q.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function f(e){return y(u(e))}function c(e){let s=q.Children.toArray(e).filter(r=>r).map(r=>f(r));return p&&!s.find(r=>r.startsWith("<title"))&&s.push(`<title inertia>${p}</title>`),s}return i.update(c(l)),null},Se=Te;import{mergeDataIntoQueryString as Fe,router as he,shouldIntercept as ve}from"@inertiajs/core";import{createElement as Ce,forwardRef as ke,useCallback as be}from"react";var C=()=>{},J=ke(({children:l,as:p="a",data:a={},href:i,method:n="get",preserveScroll:F=!1,preserveState:d=null,replace:y=!1,only:u=[],except:f=[],headers:c={},queryStringArrayFormat:e="brackets",onClick:s=C,onCancelToken:r=C,onBefore:g=C,onStart:T=C,onProgress:O=C,onFinish:k=C,onCancel:L=C,onSuccess:R=C,onError:B=C,...I},A)=>{let v=be(E=>{s(E),ve(E)&&(E.preventDefault(),he.visit(i,{data:a,method:n,preserveScroll:F,preserveState:d??n!=="get",replace:y,only:u,except:f,headers:c,onCancelToken:r,onBefore:g,onStart:T,onProgress:O,onFinish:k,onCancel:L,onSuccess:R,onError:B}))},[a,i,n,F,d,y,u,f,c,s,r,g,T,O,k,L,R,B]);p=p.toLowerCase(),n=n.toLowerCase();let[j,U]=Fe(n,i||"",a,e);return i=j,a=U,p==="a"&&n!=="get"&&console.warn(`Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes "Open Link in New Tab/Window" accessibility issues. | ||
Please specify a more appropriate element using the "as" attribute. For example: | ||
<Link href="${i}" method="${n}" as="button">...</Link>`),Ce(p,{...I,...p==="a"?{href:i}:{},ref:A,onClick:h},l)});J.displayName="InertiaLink";var xe=J;import{router as z}from"@inertiajs/core";import Ae from"lodash.isequal";import{useCallback as S,useEffect as Ee,useRef as $,useState as b}from"react";import{router as Q}from"@inertiajs/core";import{useEffect as Re,useState as Ie}from"react";function w(l,p){let[a,i]=Ie(()=>{let n=Q.restore(p);return n!==void 0?n:l});return Re(()=>{Q.remember(a,p)},[a,p]),[a,i]}function G(l,p){let a=$(null),i=typeof l=="string"?l:null,[n,F]=b((typeof l=="string"?p:l)||{}),d=$(null),y=$(null),[u,f]=i?w(n,`${i}:data`):b(n),[c,e]=i?w({},`${i}:errors`):b({}),[s,r]=b(!1),[g,T]=b(!1),[O,k]=b(null),[L,R]=b(!1),[B,I]=b(!1),A=$(o=>o);Ee(()=>(a.current=!0,()=>{a.current=!1}),[]);let h=S((o,P,t={})=>{let v={...t,onCancelToken:m=>{if(d.current=m,t.onCancelToken)return t.onCancelToken(m)},onBefore:m=>{if(R(!1),I(!1),clearTimeout(y.current),t.onBefore)return t.onBefore(m)},onStart:m=>{if(T(!0),t.onStart)return t.onStart(m)},onProgress:m=>{if(k(m),t.onProgress)return t.onProgress(m)},onSuccess:m=>{if(a.current&&(T(!1),k(null),e({}),r(!1),R(!0),I(!0),y.current=setTimeout(()=>{a.current&&I(!1)},2e3)),t.onSuccess)return t.onSuccess(m)},onError:m=>{if(a.current&&(T(!1),k(null),e(m),r(!0)),t.onError)return t.onError(m)},onCancel:()=>{if(a.current&&(T(!1),k(null)),t.onCancel)return t.onCancel()},onFinish:()=>{if(a.current&&(T(!1),k(null)),d.current=null,t.onFinish)return t.onFinish()}};o==="delete"?z.delete(P,{...v,data:A.current(u)}):z[o](P,A.current(u),v)},[u,e]),j=S((o,P)=>{f(typeof o=="string"?t=>({...t,[o]:P}):typeof o=="function"?t=>o(t):o)},[f]),U=S((o,P)=>{F(typeof o>"u"?()=>u:t=>({...t,...typeof o=="string"?{[o]:P}:o}))},[u,F]),E=S((...o)=>{o.length===0?f(n):f(P=>Object.keys(n).filter(t=>o.includes(t)).reduce((t,v)=>(t[v]=n[v],t),{...P}))},[f,n]),Y=S((o,P)=>{e(t=>{let v={...t,...typeof o=="string"?{[o]:P}:o};return r(Object.keys(v).length>0),v})},[e,r]),Z=S((...o)=>{e(P=>{let t=Object.keys(P).reduce((v,m)=>({...v,...o.length>0&&!o.includes(m)?{[m]:P[m]}:{}}),{});return r(Object.keys(t).length>0),t})},[e,r]),D=o=>(P,t)=>{h(o,P,t)},ee=S(D("get"),[h]),te=S(D("post"),[h]),re=S(D("put"),[h]),oe=S(D("patch"),[h]),ne=S(D("delete"),[h]),ae=S(()=>{d.current&&d.current.cancel()},[]),se=S(o=>{A.current=o},[]);return{data:u,setData:j,isDirty:!Ae(u,n),errors:c,hasErrors:s,processing:g,progress:O,wasSuccessful:L,recentlySuccessful:B,transform:se,setDefaults:U,reset:E,setError:Y,clearErrors:Z,submit:h,get:ee,post:te,put:re,patch:oe,delete:ne,cancel:ae}}import{useContext as De}from"react";function X(){let l=De(H);if(!l)throw new Error("usePage must be used within the Inertia component");return l}var At=Me;export{Se as Head,xe as Link,W as createInertiaApp,At as router,G as useForm,X as usePage,w as useRemember}; | ||
<Link href="${i}" method="${n}" as="button">...</Link>`),Ce(p,{...I,...p==="a"?{href:i}:{},ref:A,onClick:v},l)});J.displayName="InertiaLink";var xe=J;import{router as z}from"@inertiajs/core";import Ae from"lodash.isequal";import{useCallback as S,useEffect as Ee,useRef as $,useState as b}from"react";import{router as Q}from"@inertiajs/core";import{useEffect as Re,useState as Ie}from"react";function w(l,p){let[a,i]=Ie(()=>{let n=Q.restore(p);return n!==void 0?n:l});return Re(()=>{Q.remember(a,p)},[a,p]),[a,i]}function G(l,p){let a=$(null),i=typeof l=="string"?l:null,[n,F]=b((typeof l=="string"?p:l)||{}),d=$(null),y=$(null),[u,f]=i?w(n,`${i}:data`):b(n),[c,e]=i?w({},`${i}:errors`):b({}),[s,r]=b(!1),[g,T]=b(!1),[O,k]=b(null),[L,R]=b(!1),[B,I]=b(!1),A=$(o=>o);Ee(()=>(a.current=!0,()=>{a.current=!1}),[]);let v=S((o,P,t={})=>{let h={...t,onCancelToken:m=>{if(d.current=m,t.onCancelToken)return t.onCancelToken(m)},onBefore:m=>{if(R(!1),I(!1),clearTimeout(y.current),t.onBefore)return t.onBefore(m)},onStart:m=>{if(T(!0),t.onStart)return t.onStart(m)},onProgress:m=>{if(k(m),t.onProgress)return t.onProgress(m)},onSuccess:m=>{if(a.current&&(T(!1),k(null),e({}),r(!1),R(!0),I(!0),y.current=setTimeout(()=>{a.current&&I(!1)},2e3)),t.onSuccess)return t.onSuccess(m)},onError:m=>{if(a.current&&(T(!1),k(null),e(m),r(!0)),t.onError)return t.onError(m)},onCancel:()=>{if(a.current&&(T(!1),k(null)),t.onCancel)return t.onCancel()},onFinish:()=>{if(a.current&&(T(!1),k(null)),d.current=null,t.onFinish)return t.onFinish()}};o==="delete"?z.delete(P,{...h,data:A.current(u)}):z[o](P,A.current(u),h)},[u,e]),j=S((o,P)=>{f(typeof o=="string"?t=>({...t,[o]:P}):typeof o=="function"?t=>o(t):o)},[f]),U=S((o,P)=>{F(typeof o>"u"?()=>u:t=>({...t,...typeof o=="string"?{[o]:P}:o}))},[u,F]),E=S((...o)=>{o.length===0?f(n):f(P=>Object.keys(n).filter(t=>o.includes(t)).reduce((t,h)=>(t[h]=n[h],t),{...P}))},[f,n]),Y=S((o,P)=>{e(t=>{let h={...t,...typeof o=="string"?{[o]:P}:o};return r(Object.keys(h).length>0),h})},[e,r]),Z=S((...o)=>{e(P=>{let t=Object.keys(P).reduce((h,m)=>({...h,...o.length>0&&!o.includes(m)?{[m]:P[m]}:{}}),{});return r(Object.keys(t).length>0),t})},[e,r]),D=o=>(P,t)=>{v(o,P,t)},ee=S(D("get"),[v]),te=S(D("post"),[v]),re=S(D("put"),[v]),oe=S(D("patch"),[v]),ne=S(D("delete"),[v]),ae=S(()=>{d.current&&d.current.cancel()},[]),se=S(o=>{A.current=o},[]);return{data:u,setData:j,isDirty:!Ae(u,n),errors:c,hasErrors:s,processing:g,progress:O,wasSuccessful:L,recentlySuccessful:B,transform:se,setDefaults:U,reset:E,setError:Y,clearErrors:Z,submit:v,get:ee,post:te,put:re,patch:oe,delete:ne,cancel:ae}}import{useContext as De}from"react";function X(){let l=De(H);if(!l)throw new Error("usePage must be used within the Inertia component");return l}var At=Me;export{Se as Head,xe as Link,W as createInertiaApp,At as router,G as useForm,X as usePage,w as useRemember}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,6 +0,6 @@ | ||
var Fe=Object.create;var U=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var be=(r,s)=>{for(var n in s)U(r,n,{get:s[n],enumerable:!0})},X=(r,s,n,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of he(s))!ke.call(r,a)&&a!==n&&U(r,a,{get:()=>s[a],enumerable:!(u=ve(s,a))||u.enumerable});return r};var Y=(r,s,n)=>(n=r!=null?Fe(Ce(r)):{},X(s||!r||!r.__esModule?U(n,"default",{value:r,enumerable:!0}):n,r)),xe=r=>X(U({},"__esModule",{value:!0}),r);var Ae={};be(Ae,{Head:()=>ae,Link:()=>ie,createInertiaApp:()=>q,router:()=>Ie,useForm:()=>z,usePage:()=>G,useRemember:()=>A});module.exports=xe(Ae);var ce=require("@inertiajs/core");var oe=require("@inertiajs/core"),ne=require("react");var B=require("@inertiajs/core"),F=require("react");var Z=require("react"),ee=(0,Z.createContext)(void 0);ee.displayName="InertiaHeadContext";var O=ee;var te=require("react"),re=(0,te.createContext)(void 0);re.displayName="InertiaPageContext";var L=re;function V({children:r,initialPage:s,initialComponent:n,resolveComponent:u,titleCallback:a,onHeadUpdate:v}){let[f,P]=(0,F.useState)({component:n||null,page:s,key:null}),l=(0,F.useMemo)(()=>(0,B.createHeadManager)(typeof window>"u",a||(d=>d),v||(()=>{})),[]);if((0,F.useEffect)(()=>{B.router.init({initialPage:s,resolveComponent:u,swapComponent:async({component:d,page:e,preserveState:c})=>{P(o=>({component:d,page:e,key:c?o.key:Date.now()}))}}),B.router.on("navigate",()=>l.forceUpdate())},[]),!f.component)return(0,F.createElement)(O.Provider,{value:l},(0,F.createElement)(L.Provider,{value:f.page},null));let m=r||(({Component:d,props:e,key:c})=>{let o=(0,F.createElement)(d,{key:c,...e});return typeof d.layout=="function"?d.layout(o):Array.isArray(d.layout)?d.layout.concat(o).reverse().reduce((y,S)=>(0,F.createElement)(S,{children:y,...e})):o});return(0,F.createElement)(O.Provider,{value:l},(0,F.createElement)(L.Provider,{value:f.page},m({Component:f.component,key:f.key,props:f.page.props})))}V.displayName="Inertia";async function q({id:r="app",resolve:s,setup:n,title:u,progress:a={},page:v,render:f}){let P=typeof window>"u",l=P?null:document.getElementById(r),m=v||JSON.parse(l.dataset.page),d=o=>Promise.resolve(s(o)).then(y=>y.default||y),e=[],c=await d(m.component).then(o=>n({el:l,App:V,props:{initialPage:m,initialComponent:o,resolveComponent:d,titleCallback:u,onHeadUpdate:P?y=>e=y:null}}));if(!P&&a&&(0,oe.setupProgress)(a),P){let o=await f((0,ne.createElement)("div",{id:r,"data-page":JSON.stringify(m)},c));return{head:e,body:o}}}var k=Y(require("react"),1);var Re=function({children:r,title:s}){let n=(0,k.useContext)(O),u=(0,k.useMemo)(()=>n.createProvider(),[n]);(0,k.useEffect)(()=>()=>{u.disconnect()},[u]);function a(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function v(e){let c=Object.keys(e.props).reduce((o,y)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(y))return o;let S=e.props[y];return S===""?o+` ${y}`:o+` ${y}="${S}"`},"");return`<${e.type}${c}>`}function f(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,o)=>c+P(o),"")}function P(e){let c=v(e);return e.props.children&&(c+=f(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),a(e)||(c+=`</${e.type}>`),c}function l(e){return k.default.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function m(e){return P(l(e))}function d(e){let c=k.default.Children.toArray(e).filter(o=>o).map(o=>m(o));return s&&!c.find(o=>o.startsWith("<title"))&&c.push(`<title inertia>${s}</title>`),c}return u.update(d(r)),null},ae=Re;var R=require("@inertiajs/core"),I=require("react"),b=()=>{},se=(0,I.forwardRef)(({children:r,as:s="a",data:n={},href:u,method:a="get",preserveScroll:v=!1,preserveState:f=null,replace:P=!1,only:l=[],except:m=[],headers:d={},queryStringArrayFormat:e="brackets",onClick:c=b,onCancelToken:o=b,onBefore:y=b,onStart:S=b,onProgress:N=b,onFinish:x=b,onCancel:$=b,onSuccess:E=b,onError:j=b,...D},M)=>{let C=(0,I.useCallback)(H=>{c(H),(0,R.shouldIntercept)(H.nativeEvent)&&(H.preventDefault(),R.router.visit(u,{data:n,method:a,preserveScroll:v,preserveState:f??a!=="get",replace:P,only:l,except:m,headers:d,onCancelToken:o,onBefore:y,onStart:S,onProgress:N,onFinish:x,onCancel:$,onSuccess:E,onError:j}))},[n,u,a,v,f,P,l,m,d,c,o,y,S,N,x,$,E,j]);s=s.toLowerCase(),a=a.toLowerCase();let[_,W]=(0,R.mergeDataIntoQueryString)(a,u||"",n,e);return u=_,n=W,s==="a"&&a!=="get"&&console.warn(`Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes "Open Link in New Tab/Window" accessibility issues. | ||
var Fe=Object.create;var U=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var be=(r,s)=>{for(var n in s)U(r,n,{get:s[n],enumerable:!0})},X=(r,s,n,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of ve(s))!ke.call(r,a)&&a!==n&&U(r,a,{get:()=>s[a],enumerable:!(u=he(s,a))||u.enumerable});return r};var Y=(r,s,n)=>(n=r!=null?Fe(Ce(r)):{},X(s||!r||!r.__esModule?U(n,"default",{value:r,enumerable:!0}):n,r)),xe=r=>X(U({},"__esModule",{value:!0}),r);var Ae={};be(Ae,{Head:()=>ae,Link:()=>ie,createInertiaApp:()=>q,router:()=>Ie,useForm:()=>z,usePage:()=>G,useRemember:()=>A});module.exports=xe(Ae);var ce=require("@inertiajs/core");var oe=require("@inertiajs/core"),ne=require("react");var B=require("@inertiajs/core"),F=require("react");var Z=require("react"),ee=(0,Z.createContext)(void 0);ee.displayName="InertiaHeadContext";var O=ee;var te=require("react"),re=(0,te.createContext)(void 0);re.displayName="InertiaPageContext";var L=re;function V({children:r,initialPage:s,initialComponent:n,resolveComponent:u,titleCallback:a,onHeadUpdate:h}){let[f,P]=(0,F.useState)({component:n||null,page:s,key:null}),l=(0,F.useMemo)(()=>(0,B.createHeadManager)(typeof window>"u",a||(d=>d),h||(()=>{})),[]);if((0,F.useEffect)(()=>{B.router.init({initialPage:s,resolveComponent:u,swapComponent:async({component:d,page:e,preserveState:c})=>{P(o=>({component:d,page:e,key:c?o.key:Date.now()}))}}),B.router.on("navigate",()=>l.forceUpdate())},[]),!f.component)return(0,F.createElement)(O.Provider,{value:l},(0,F.createElement)(L.Provider,{value:f.page},null));let m=r||(({Component:d,props:e,key:c})=>{let o=(0,F.createElement)(d,{key:c,...e});return typeof d.layout=="function"?d.layout(o):Array.isArray(d.layout)?d.layout.concat(o).reverse().reduce((y,S)=>(0,F.createElement)(S,{children:y,...e})):o});return(0,F.createElement)(O.Provider,{value:l},(0,F.createElement)(L.Provider,{value:f.page},m({Component:f.component,key:f.key,props:f.page.props})))}V.displayName="Inertia";async function q({id:r="app",resolve:s,setup:n,title:u,progress:a={},page:h,render:f}){let P=typeof window>"u",l=P?null:document.getElementById(r),m=h||JSON.parse(l.dataset.page),d=o=>Promise.resolve(s(o)).then(y=>y.default||y),e=[],c=await d(m.component).then(o=>n({el:l,App:V,props:{initialPage:m,initialComponent:o,resolveComponent:d,titleCallback:u,onHeadUpdate:P?y=>e=y:null}}));if(!P&&a&&(0,oe.setupProgress)(a),P){let o=await f((0,ne.createElement)("div",{id:r,"data-page":JSON.stringify(m)},c));return{head:e,body:o}}}var k=Y(require("react"),1);var Re=function({children:r,title:s}){let n=(0,k.useContext)(O),u=(0,k.useMemo)(()=>n.createProvider(),[n]);(0,k.useEffect)(()=>()=>{u.disconnect()},[u]);function a(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function h(e){let c=Object.keys(e.props).reduce((o,y)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(y))return o;let S=e.props[y];return S===""?o+` ${y}`:o+` ${y}="${S}"`},"");return`<${e.type}${c}>`}function f(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,o)=>c+P(o),"")}function P(e){let c=h(e);return e.props.children&&(c+=f(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),a(e)||(c+=`</${e.type}>`),c}function l(e){return k.default.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function m(e){return P(l(e))}function d(e){let c=k.default.Children.toArray(e).filter(o=>o).map(o=>m(o));return s&&!c.find(o=>o.startsWith("<title"))&&c.push(`<title inertia>${s}</title>`),c}return u.update(d(r)),null},ae=Re;var R=require("@inertiajs/core"),I=require("react"),b=()=>{},se=(0,I.forwardRef)(({children:r,as:s="a",data:n={},href:u,method:a="get",preserveScroll:h=!1,preserveState:f=null,replace:P=!1,only:l=[],except:m=[],headers:d={},queryStringArrayFormat:e="brackets",onClick:c=b,onCancelToken:o=b,onBefore:y=b,onStart:S=b,onProgress:N=b,onFinish:x=b,onCancel:$=b,onSuccess:E=b,onError:j=b,...D},M)=>{let C=(0,I.useCallback)(H=>{c(H),(0,R.shouldIntercept)(H)&&(H.preventDefault(),R.router.visit(u,{data:n,method:a,preserveScroll:h,preserveState:f??a!=="get",replace:P,only:l,except:m,headers:d,onCancelToken:o,onBefore:y,onStart:S,onProgress:N,onFinish:x,onCancel:$,onSuccess:E,onError:j}))},[n,u,a,h,f,P,l,m,d,c,o,y,S,N,x,$,E,j]);s=s.toLowerCase(),a=a.toLowerCase();let[_,W]=(0,R.mergeDataIntoQueryString)(a,u||"",n,e);return u=_,n=W,s==="a"&&a!=="get"&&console.warn(`Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes "Open Link in New Tab/Window" accessibility issues. | ||
Please specify a more appropriate element using the "as" attribute. For example: | ||
<Link href="${u}" method="${a}" as="button">...</Link>`),(0,I.createElement)(s,{...D,...s==="a"?{href:u}:{},ref:M,onClick:C},r)});se.displayName="InertiaLink";var ie=se;var Q=require("@inertiajs/core"),pe=Y(require("lodash.isequal"),1),i=require("react");var J=require("@inertiajs/core"),K=require("react");function A(r,s){let[n,u]=(0,K.useState)(()=>{let a=J.router.restore(s);return a!==void 0?a:r});return(0,K.useEffect)(()=>{J.router.remember(n,s)},[n,s]),[n,u]}function z(r,s){let n=(0,i.useRef)(null),u=typeof r=="string"?r:null,[a,v]=(0,i.useState)((typeof r=="string"?s:r)||{}),f=(0,i.useRef)(null),P=(0,i.useRef)(null),[l,m]=u?A(a,`${u}:data`):(0,i.useState)(a),[d,e]=u?A({},`${u}:errors`):(0,i.useState)({}),[c,o]=(0,i.useState)(!1),[y,S]=(0,i.useState)(!1),[N,x]=(0,i.useState)(null),[$,E]=(0,i.useState)(!1),[j,D]=(0,i.useState)(!1),M=(0,i.useRef)(p=>p);(0,i.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);let C=(0,i.useCallback)((p,T,t={})=>{let h={...t,onCancelToken:g=>{if(f.current=g,t.onCancelToken)return t.onCancelToken(g)},onBefore:g=>{if(E(!1),D(!1),clearTimeout(P.current),t.onBefore)return t.onBefore(g)},onStart:g=>{if(S(!0),t.onStart)return t.onStart(g)},onProgress:g=>{if(x(g),t.onProgress)return t.onProgress(g)},onSuccess:g=>{if(n.current&&(S(!1),x(null),e({}),o(!1),E(!0),D(!0),P.current=setTimeout(()=>{n.current&&D(!1)},2e3)),t.onSuccess)return t.onSuccess(g)},onError:g=>{if(n.current&&(S(!1),x(null),e(g),o(!0)),t.onError)return t.onError(g)},onCancel:()=>{if(n.current&&(S(!1),x(null)),t.onCancel)return t.onCancel()},onFinish:()=>{if(n.current&&(S(!1),x(null)),f.current=null,t.onFinish)return t.onFinish()}};p==="delete"?Q.router.delete(T,{...h,data:M.current(l)}):Q.router[p](T,M.current(l),h)},[l,e]),_=(0,i.useCallback)((p,T)=>{m(typeof p=="string"?t=>({...t,[p]:T}):typeof p=="function"?t=>p(t):p)},[m]),W=(0,i.useCallback)((p,T)=>{v(typeof p>"u"?()=>l:t=>({...t,...typeof p=="string"?{[p]:T}:p}))},[l,v]),H=(0,i.useCallback)((...p)=>{p.length===0?m(a):m(T=>Object.keys(a).filter(t=>p.includes(t)).reduce((t,h)=>(t[h]=a[h],t),{...T}))},[m,a]),le=(0,i.useCallback)((p,T)=>{e(t=>{let h={...t,...typeof p=="string"?{[p]:T}:p};return o(Object.keys(h).length>0),h})},[e,o]),de=(0,i.useCallback)((...p)=>{e(T=>{let t=Object.keys(T).reduce((h,g)=>({...h,...p.length>0&&!p.includes(g)?{[g]:T[g]}:{}}),{});return o(Object.keys(t).length>0),t})},[e,o]),w=p=>(T,t)=>{C(p,T,t)},fe=(0,i.useCallback)(w("get"),[C]),me=(0,i.useCallback)(w("post"),[C]),ge=(0,i.useCallback)(w("put"),[C]),ye=(0,i.useCallback)(w("patch"),[C]),Pe=(0,i.useCallback)(w("delete"),[C]),Te=(0,i.useCallback)(()=>{f.current&&f.current.cancel()},[]),Se=(0,i.useCallback)(p=>{M.current=p},[]);return{data:l,setData:_,isDirty:!(0,pe.default)(l,a),errors:d,hasErrors:c,processing:y,progress:N,wasSuccessful:$,recentlySuccessful:j,transform:Se,setDefaults:W,reset:H,setError:le,clearErrors:de,submit:C,get:fe,post:me,put:ge,patch:ye,delete:Pe,cancel:Te}}var ue=require("react");function G(){let r=(0,ue.useContext)(L);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var Ie=ce.router; | ||
<Link href="${u}" method="${a}" as="button">...</Link>`),(0,I.createElement)(s,{...D,...s==="a"?{href:u}:{},ref:M,onClick:C},r)});se.displayName="InertiaLink";var ie=se;var Q=require("@inertiajs/core"),pe=Y(require("lodash.isequal"),1),i=require("react");var J=require("@inertiajs/core"),K=require("react");function A(r,s){let[n,u]=(0,K.useState)(()=>{let a=J.router.restore(s);return a!==void 0?a:r});return(0,K.useEffect)(()=>{J.router.remember(n,s)},[n,s]),[n,u]}function z(r,s){let n=(0,i.useRef)(null),u=typeof r=="string"?r:null,[a,h]=(0,i.useState)((typeof r=="string"?s:r)||{}),f=(0,i.useRef)(null),P=(0,i.useRef)(null),[l,m]=u?A(a,`${u}:data`):(0,i.useState)(a),[d,e]=u?A({},`${u}:errors`):(0,i.useState)({}),[c,o]=(0,i.useState)(!1),[y,S]=(0,i.useState)(!1),[N,x]=(0,i.useState)(null),[$,E]=(0,i.useState)(!1),[j,D]=(0,i.useState)(!1),M=(0,i.useRef)(p=>p);(0,i.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);let C=(0,i.useCallback)((p,T,t={})=>{let v={...t,onCancelToken:g=>{if(f.current=g,t.onCancelToken)return t.onCancelToken(g)},onBefore:g=>{if(E(!1),D(!1),clearTimeout(P.current),t.onBefore)return t.onBefore(g)},onStart:g=>{if(S(!0),t.onStart)return t.onStart(g)},onProgress:g=>{if(x(g),t.onProgress)return t.onProgress(g)},onSuccess:g=>{if(n.current&&(S(!1),x(null),e({}),o(!1),E(!0),D(!0),P.current=setTimeout(()=>{n.current&&D(!1)},2e3)),t.onSuccess)return t.onSuccess(g)},onError:g=>{if(n.current&&(S(!1),x(null),e(g),o(!0)),t.onError)return t.onError(g)},onCancel:()=>{if(n.current&&(S(!1),x(null)),t.onCancel)return t.onCancel()},onFinish:()=>{if(n.current&&(S(!1),x(null)),f.current=null,t.onFinish)return t.onFinish()}};p==="delete"?Q.router.delete(T,{...v,data:M.current(l)}):Q.router[p](T,M.current(l),v)},[l,e]),_=(0,i.useCallback)((p,T)=>{m(typeof p=="string"?t=>({...t,[p]:T}):typeof p=="function"?t=>p(t):p)},[m]),W=(0,i.useCallback)((p,T)=>{h(typeof p>"u"?()=>l:t=>({...t,...typeof p=="string"?{[p]:T}:p}))},[l,h]),H=(0,i.useCallback)((...p)=>{p.length===0?m(a):m(T=>Object.keys(a).filter(t=>p.includes(t)).reduce((t,v)=>(t[v]=a[v],t),{...T}))},[m,a]),le=(0,i.useCallback)((p,T)=>{e(t=>{let v={...t,...typeof p=="string"?{[p]:T}:p};return o(Object.keys(v).length>0),v})},[e,o]),de=(0,i.useCallback)((...p)=>{e(T=>{let t=Object.keys(T).reduce((v,g)=>({...v,...p.length>0&&!p.includes(g)?{[g]:T[g]}:{}}),{});return o(Object.keys(t).length>0),t})},[e,o]),w=p=>(T,t)=>{C(p,T,t)},fe=(0,i.useCallback)(w("get"),[C]),me=(0,i.useCallback)(w("post"),[C]),ge=(0,i.useCallback)(w("put"),[C]),ye=(0,i.useCallback)(w("patch"),[C]),Pe=(0,i.useCallback)(w("delete"),[C]),Te=(0,i.useCallback)(()=>{f.current&&f.current.cancel()},[]),Se=(0,i.useCallback)(p=>{M.current=p},[]);return{data:l,setData:_,isDirty:!(0,pe.default)(l,a),errors:d,hasErrors:c,processing:y,progress:N,wasSuccessful:$,recentlySuccessful:j,transform:Se,setDefaults:W,reset:H,setError:le,clearErrors:de,submit:C,get:fe,post:me,put:ge,patch:ye,delete:Pe,cancel:Te}}var ue=require("react");function G(){let r=(0,ue.useContext)(L);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var Ie=ce.router; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@inertiajs/react", | ||
"version": "1.3.0-beta.2", | ||
"version": "1.3.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": "1.3.0-beta.2", | ||
"@inertiajs/core": "1.3.0", | ||
"lodash.isequal": "^4.5.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
98693
2
+ Added@inertiajs/core@1.3.0(transitive)
+ Addedreact@19.0.0(transitive)
- Removed@inertiajs/core@1.3.0-beta.2(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.3.1(transitive)
Updated@inertiajs/core@1.3.0