Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@inertiajs/react

Package Overview
Dependencies
Maintainers
6
Versions
33
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 1.0.15 to 1.0.16

4

dist/index.esm.js

@@ -1,6 +0,6 @@

import{router as Se}from"@inertiajs/core";import{setupProgress as Z}from"@inertiajs/core";import{createElement as ee}from"react";import{createHeadManager as z,router as $}from"@inertiajs/core";import{createElement as b,useEffect as G,useMemo as X,useState as Y}from"react";import{createContext as J}from"react";var B=J(void 0);B.displayName="InertiaHeadContext";var A=B;import{createContext as Q}from"react";var N=Q(void 0);N.displayName="InertiaPageContext";var E=N;function w({children:l,initialPage:c,initialComponent:s,resolveComponent:p,titleCallback:a,onHeadUpdate:S}){let[d,P]=Y({component:s||null,page:c,key:null}),u=X(()=>z(typeof window>"u",a||(f=>f),S||(()=>{})),[]);if(G(()=>{$.init({initialPage:c,resolveComponent:p,swapComponent:async({component:f,page:e,preserveState:i})=>{P(r=>({component:f,page:e,key:i?r.key:Date.now()}))}}),$.on("navigate",()=>u.forceUpdate())},[]),!d.component)return b(A.Provider,{value:u},b(E.Provider,{value:d.page},null));let g=l||(({Component:f,props:e,key:i})=>{let r=b(f,{key:i,...e});return typeof f.layout=="function"?f.layout(r):Array.isArray(f.layout)?f.layout.concat(r).reverse().reduce((y,T)=>b(T,{children:y,...e})):r});return b(A.Provider,{value:u},b(E.Provider,{value:d.page},g({Component:d.component,key:d.key,props:d.page.props})))}w.displayName="Inertia";async function j({id:l="app",resolve:c,setup:s,title:p,progress:a={},page:S,render:d}){let P=typeof window>"u",u=P?null:document.getElementById(l),g=S||JSON.parse(u.dataset.page),f=r=>Promise.resolve(c(r)).then(y=>y.default||y),e=[],i=await f(g.component).then(r=>s({el:u,App:w,props:{initialPage:g,initialComponent:r,resolveComponent:f,titleCallback:p,onHeadUpdate:P?y=>e=y:null}}));if(!P&&a&&Z(a),P){let r=await d(ee("div",{id:l,"data-page":JSON.stringify(g)},i));return{head:e,body:r}}}import U,{useContext as te,useEffect as re,useMemo as oe}from"react";var ne=function({children:l,title:c}){let s=te(A),p=oe(()=>s.createProvider(),[s]);re(()=>()=>{p.disconnect()},[p]);function a(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function S(e){let i=Object.keys(e.props).reduce((r,y)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(y))return r;let T=e.props[y];return T===""?r+` ${y}`:r+` ${y}="${T}"`},"");return`<${e.type}${i}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((i,r)=>i+P(r),"")}function P(e){let i=S(e);return e.props.children&&(i+=d(e)),e.props.dangerouslySetInnerHTML&&(i+=e.props.dangerouslySetInnerHTML.__html),a(e)||(i+=`</${e.type}>`),i}function u(e){return U.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function g(e){return P(u(e))}function f(e){let i=U.Children.toArray(e).filter(r=>r).map(r=>g(r));return c&&!i.find(r=>r.startsWith("<title"))&&i.push(`<title inertia>${c}</title>`),i}return p.update(f(l)),null},ae=ne;import{mergeDataIntoQueryString as se,router as ie,shouldIntercept as pe}from"@inertiajs/core";import{createElement as ue,forwardRef as ce,useCallback as le}from"react";var F=()=>{},V=ce(({children:l,as:c="a",data:s={},href:p,method:a="get",preserveScroll:S=!1,preserveState:d=null,replace:P=!1,only:u=[],headers:g={},queryStringArrayFormat:f="brackets",onClick:e=F,onCancelToken:i=F,onBefore:r=F,onStart:y=F,onProgress:T=F,onFinish:H=F,onCancel:h=F,onSuccess:M=F,onError:x=F,...O},R)=>{let I=le(o=>{e(o),pe(o)&&(o.preventDefault(),ie.visit(p,{data:s,method:a,preserveScroll:S,preserveState:d??a!=="get",replace:P,only:u,headers:g,onCancelToken:i,onBefore:r,onStart:y,onProgress:T,onFinish:H,onCancel:h,onSuccess:M,onError:x}))},[s,p,a,S,d,P,u,g,e,i,r,y,T,H,h,M,x]);c=c.toLowerCase(),a=a.toLowerCase();let[v,t]=se(a,p||"",s,f);return p=v,s=t,c==="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.
import{router as Se}from"@inertiajs/core";import N,{useContext as Q,useEffect as z,useMemo as G}from"react";import{createContext as J}from"react";var B=J(void 0);B.displayName="InertiaHeadContext";var A=B;var X=function({children:l,title:c}){let s=Q(A),p=G(()=>s.createProvider(),[s]);z(()=>()=>{p.disconnect()},[p]);function a(e){return["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(e.type)>-1}function S(e){let i=Object.keys(e.props).reduce((r,y)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(y))return r;let T=e.props[y];return T===""?r+` ${y}`:r+` ${y}="${T}"`},"");return`<${e.type}${i}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((i,r)=>i+P(r),"")}function P(e){let i=S(e);return e.props.children&&(i+=d(e)),e.props.dangerouslySetInnerHTML&&(i+=e.props.dangerouslySetInnerHTML.__html),a(e)||(i+=`</${e.type}>`),i}function u(e){return N.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function g(e){return P(u(e))}function f(e){let i=N.Children.toArray(e).filter(r=>r).map(r=>g(r));return c&&!i.find(r=>r.startsWith("<title"))&&i.push(`<title inertia>${c}</title>`),i}return p.update(f(l)),null},Y=X;import{mergeDataIntoQueryString as Z,router as ee,shouldIntercept as te}from"@inertiajs/core";import{createElement as re,forwardRef as oe,useCallback as ne}from"react";var F=()=>{},$=oe(({children:l,as:c="a",data:s={},href:p,method:a="get",preserveScroll:S=!1,preserveState:d=null,replace:P=!1,only:u=[],headers:g={},queryStringArrayFormat:f="brackets",onClick:e=F,onCancelToken:i=F,onBefore:r=F,onStart:y=F,onProgress:T=F,onFinish:H=F,onCancel:h=F,onSuccess:M=F,onError:x=F,...O},R)=>{let I=ne(o=>{e(o),te(o)&&(o.preventDefault(),ee.visit(p,{data:s,method:a,preserveScroll:S,preserveState:d??a!=="get",replace:P,only:u,headers:g,onCancelToken:i,onBefore:r,onStart:y,onProgress:T,onFinish:H,onCancel:h,onSuccess:M,onError:x}))},[s,p,a,S,d,P,u,g,e,i,r,y,T,H,h,M,x]);c=c.toLowerCase(),a=a.toLowerCase();let[v,t]=Z(a,p||"",s,f);return p=v,s=t,c==="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="${p}" method="${a}" as="button">...</Link>`),ue(c,{...O,...c==="a"?{href:p}:{},ref:R,onClick:I},l)});V.displayName="InertiaLink";var de=V;import{router as _}from"@inertiajs/core";import ge from"lodash.isequal";import{useCallback as ye,useEffect as Pe,useRef as L,useState as C}from"react";import{router as K}from"@inertiajs/core";import{useEffect as fe,useState as me}from"react";function D(l,c){let[s,p]=me(()=>{let a=K.restore(c);return a!==void 0?a:l});return fe(()=>{K.remember(s,c)},[s,c]),[s,p]}function W(l,c){let s=L(null),p=typeof l=="string"?l:null,[a,S]=C((typeof l=="string"?c:l)||{}),d=L(null),P=L(null),[u,g]=p?D(a,`${p}:data`):C(a),[f,e]=p?D({},`${p}:errors`):C({}),[i,r]=C(!1),[y,T]=C(!1),[H,h]=C(null),[M,x]=C(!1),[O,R]=C(!1),I=t=>t;Pe(()=>(s.current=!0,()=>{s.current=!1}),[]);let v=ye((t,o,n={})=>{let k={...n,onCancelToken:m=>{if(d.current=m,n.onCancelToken)return n.onCancelToken(m)},onBefore:m=>{if(x(!1),R(!1),clearTimeout(P.current),n.onBefore)return n.onBefore(m)},onStart:m=>{if(T(!0),n.onStart)return n.onStart(m)},onProgress:m=>{if(h(m),n.onProgress)return n.onProgress(m)},onSuccess:m=>{if(s.current&&(T(!1),h(null),e({}),r(!1),x(!0),R(!0),P.current=setTimeout(()=>{s.current&&R(!1)},2e3)),n.onSuccess)return n.onSuccess(m)},onError:m=>{if(s.current&&(T(!1),h(null),e(m),r(!0)),n.onError)return n.onError(m)},onCancel:()=>{if(s.current&&(T(!1),h(null)),n.onCancel)return n.onCancel()},onFinish:()=>{if(s.current&&(T(!1),h(null)),d.current=null,n.onFinish)return n.onFinish()}};t==="delete"?_.delete(o,{...k,data:I(u)}):_[t](o,I(u),k)},[u,e]);return{data:u,setData(t,o){g(typeof t=="string"?{...u,[t]:o}:typeof t=="function"?n=>t(n):t)},isDirty:!ge(u,a),errors:f,hasErrors:i,processing:y,progress:H,wasSuccessful:M,recentlySuccessful:O,transform(t){I=t},setDefaults(t,o){S(typeof t>"u"?()=>u:n=>({...n,...typeof t=="string"?{[t]:o}:t}))},reset(...t){t.length===0?g(a):g(Object.keys(a).filter(o=>t.includes(o)).reduce((o,n)=>(o[n]=a[n],o),{...u}))},setError(t,o){e(n=>{let k={...n,...typeof t=="string"?{[t]:o}:t};return r(Object.keys(k).length>0),k})},clearErrors(...t){e(o=>{let n=Object.keys(o).reduce((k,m)=>({...k,...t.length>0&&!t.includes(m)?{[m]:o[m]}:{}}),{});return r(Object.keys(n).length>0),n})},submit:v,get(t,o){v("get",t,o)},post(t,o){v("post",t,o)},put(t,o){v("put",t,o)},patch(t,o){v("patch",t,o)},delete(t,o){v("delete",t,o)},cancel(){d.current&&d.current.cancel()}}}import{useContext as Te}from"react";function q(){let l=Te(E);if(!l)throw new Error("usePage must be used within the Inertia component");return l}var yt=Se;export{ae as Head,de as Link,j as createInertiaApp,yt as router,W as useForm,q as usePage,D as useRemember};
<Link href="${p}" method="${a}" as="button">...</Link>`),re(c,{...O,...c==="a"?{href:p}:{},ref:R,onClick:I},l)});$.displayName="InertiaLink";var ae=$;import{setupProgress as le}from"@inertiajs/core";import{createElement as de}from"react";import{createHeadManager as ie,router as U}from"@inertiajs/core";import{createElement as b,useEffect as pe,useMemo as ue,useState as ce}from"react";import{createContext as se}from"react";var j=se(void 0);j.displayName="InertiaPageContext";var E=j;function w({children:l,initialPage:c,initialComponent:s,resolveComponent:p,titleCallback:a,onHeadUpdate:S}){let[d,P]=ce({component:s||null,page:c,key:null}),u=ue(()=>ie(typeof window>"u",a||(f=>f),S||(()=>{})),[]);if(pe(()=>{U.init({initialPage:c,resolveComponent:p,swapComponent:async({component:f,page:e,preserveState:i})=>{P(r=>({component:f,page:e,key:i?r.key:Date.now()}))}}),U.on("navigate",()=>u.forceUpdate())},[]),!d.component)return b(A.Provider,{value:u},b(E.Provider,{value:d.page},null));let g=l||(({Component:f,props:e,key:i})=>{let r=b(f,{key:i,...e});return typeof f.layout=="function"?f.layout(r):Array.isArray(f.layout)?f.layout.concat(r).reverse().reduce((y,T)=>b(T,{children:y,...e})):r});return b(A.Provider,{value:u},b(E.Provider,{value:d.page},g({Component:d.component,key:d.key,props:d.page.props})))}w.displayName="Inertia";async function V({id:l="app",resolve:c,setup:s,title:p,progress:a={},page:S,render:d}){let P=typeof window>"u",u=P?null:document.getElementById(l),g=S||JSON.parse(u.dataset.page),f=r=>Promise.resolve(c(r)).then(y=>y.default||y),e=[],i=await f(g.component).then(r=>s({el:u,App:w,props:{initialPage:g,initialComponent:r,resolveComponent:f,titleCallback:p,onHeadUpdate:P?y=>e=y:null}}));if(!P&&a&&le(a),P){let r=await d(de("div",{id:l,"data-page":JSON.stringify(g)},i));return{head:e,body:r}}}import{router as _}from"@inertiajs/core";import ge from"lodash.isequal";import{useCallback as ye,useEffect as Pe,useRef as L,useState as C}from"react";import{router as K}from"@inertiajs/core";import{useEffect as fe,useState as me}from"react";function D(l,c){let[s,p]=me(()=>{let a=K.restore(c);return a!==void 0?a:l});return fe(()=>{K.remember(s,c)},[s,c]),[s,p]}function W(l,c){let s=L(null),p=typeof l=="string"?l:null,[a,S]=C((typeof l=="string"?c:l)||{}),d=L(null),P=L(null),[u,g]=p?D(a,`${p}:data`):C(a),[f,e]=p?D({},`${p}:errors`):C({}),[i,r]=C(!1),[y,T]=C(!1),[H,h]=C(null),[M,x]=C(!1),[O,R]=C(!1),I=t=>t;Pe(()=>(s.current=!0,()=>{s.current=!1}),[]);let v=ye((t,o,n={})=>{let k={...n,onCancelToken:m=>{if(d.current=m,n.onCancelToken)return n.onCancelToken(m)},onBefore:m=>{if(x(!1),R(!1),clearTimeout(P.current),n.onBefore)return n.onBefore(m)},onStart:m=>{if(T(!0),n.onStart)return n.onStart(m)},onProgress:m=>{if(h(m),n.onProgress)return n.onProgress(m)},onSuccess:m=>{if(s.current&&(T(!1),h(null),e({}),r(!1),x(!0),R(!0),P.current=setTimeout(()=>{s.current&&R(!1)},2e3)),n.onSuccess)return n.onSuccess(m)},onError:m=>{if(s.current&&(T(!1),h(null),e(m),r(!0)),n.onError)return n.onError(m)},onCancel:()=>{if(s.current&&(T(!1),h(null)),n.onCancel)return n.onCancel()},onFinish:()=>{if(s.current&&(T(!1),h(null)),d.current=null,n.onFinish)return n.onFinish()}};t==="delete"?_.delete(o,{...k,data:I(u)}):_[t](o,I(u),k)},[u,e]);return{data:u,setData(t,o){g(typeof t=="string"?{...u,[t]:o}:typeof t=="function"?n=>t(n):t)},isDirty:!ge(u,a),errors:f,hasErrors:i,processing:y,progress:H,wasSuccessful:M,recentlySuccessful:O,transform(t){I=t},setDefaults(t,o){S(typeof t>"u"?()=>u:n=>({...n,...typeof t=="string"?{[t]:o}:t}))},reset(...t){t.length===0?g(a):g(Object.keys(a).filter(o=>t.includes(o)).reduce((o,n)=>(o[n]=a[n],o),{...u}))},setError(t,o){e(n=>{let k={...n,...typeof t=="string"?{[t]:o}:t};return r(Object.keys(k).length>0),k})},clearErrors(...t){e(o=>{let n=Object.keys(o).reduce((k,m)=>({...k,...t.length>0&&!t.includes(m)?{[m]:o[m]}:{}}),{});return r(Object.keys(n).length>0),n})},submit:v,get(t,o){v("get",t,o)},post(t,o){v("post",t,o)},put(t,o){v("put",t,o)},patch(t,o){v("patch",t,o)},delete(t,o){v("delete",t,o)},cancel(){d.current&&d.current.cancel()}}}import{useContext as Te}from"react";function q(){let l=Te(E);if(!l)throw new Error("usePage must be used within the Inertia component");return l}var yt=Se;export{Y as Head,ae as Link,V as createInertiaApp,yt as router,W as useForm,q as usePage,D as useRemember};
//# sourceMappingURL=index.esm.js.map

@@ -1,6 +0,6 @@

var ie=Object.create;var N=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var de=(r,n)=>{for(var o in n)N(r,o,{get:n[o],enumerable:!0})},J=(r,n,o,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of ue(n))!le.call(r,a)&&a!==o&&N(r,a,{get:()=>n[a],enumerable:!(u=pe(n,a))||u.enumerable});return r};var Q=(r,n,o)=>(o=r!=null?ie(ce(r)):{},J(n||!r||!r.__esModule?N(o,"default",{value:r,enumerable:!0}):o,r)),fe=r=>J(N({},"__esModule",{value:!0}),r);var ye={};de(ye,{Head:()=>te,Link:()=>oe,createInertiaApp:()=>V,router:()=>ge,useForm:()=>W,usePage:()=>q,useRemember:()=>A});module.exports=fe(ye);var se=require("@inertiajs/core");var Z=require("@inertiajs/core"),ee=require("react");var O=require("@inertiajs/core"),F=require("react");var z=require("react"),G=(0,z.createContext)(void 0);G.displayName="InertiaHeadContext";var M=G;var X=require("react"),Y=(0,X.createContext)(void 0);Y.displayName="InertiaPageContext";var w=Y;function $({children:r,initialPage:n,initialComponent:o,resolveComponent:u,titleCallback:a,onHeadUpdate:h}){let[d,T]=(0,F.useState)({component:o||null,page:n,key:null}),l=(0,F.useMemo)(()=>(0,O.createHeadManager)(typeof window>"u",a||(f=>f),h||(()=>{})),[]);if((0,F.useEffect)(()=>{O.router.init({initialPage:n,resolveComponent:u,swapComponent:async({component:f,page:e,preserveState:c})=>{T(s=>({component:f,page:e,key:c?s.key:Date.now()}))}}),O.router.on("navigate",()=>l.forceUpdate())},[]),!d.component)return(0,F.createElement)(M.Provider,{value:l},(0,F.createElement)(w.Provider,{value:d.page},null));let y=r||(({Component:f,props:e,key:c})=>{let s=(0,F.createElement)(f,{key:c,...e});return typeof f.layout=="function"?f.layout(s):Array.isArray(f.layout)?f.layout.concat(s).reverse().reduce((P,S)=>(0,F.createElement)(S,{children:P,...e})):s});return(0,F.createElement)(M.Provider,{value:l},(0,F.createElement)(w.Provider,{value:d.page},y({Component:d.component,key:d.key,props:d.page.props})))}$.displayName="Inertia";async function V({id:r="app",resolve:n,setup:o,title:u,progress:a={},page:h,render:d}){let T=typeof window>"u",l=T?null:document.getElementById(r),y=h||JSON.parse(l.dataset.page),f=s=>Promise.resolve(n(s)).then(P=>P.default||P),e=[],c=await f(y.component).then(s=>o({el:l,App:$,props:{initialPage:y,initialComponent:s,resolveComponent:f,titleCallback:u,onHeadUpdate:T?P=>e=P:null}}));if(!T&&a&&(0,Z.setupProgress)(a),T){let s=await d((0,ee.createElement)("div",{id:r,"data-page":JSON.stringify(y)},c));return{head:e,body:s}}}var v=Q(require("react"),1);var me=function({children:r,title:n}){let o=(0,v.useContext)(M),u=(0,v.useMemo)(()=>o.createProvider(),[o]);(0,v.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((s,P)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(P))return s;let S=e.props[P];return S===""?s+` ${P}`:s+` ${P}="${S}"`},"");return`<${e.type}${c}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,s)=>c+T(s),"")}function T(e){let c=h(e);return e.props.children&&(c+=d(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),a(e)||(c+=`</${e.type}>`),c}function l(e){return v.default.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function y(e){return T(l(e))}function f(e){let c=v.default.Children.toArray(e).filter(s=>s).map(s=>y(s));return n&&!c.find(s=>s.startsWith("<title"))&&c.push(`<title inertia>${n}</title>`),c}return u.update(f(r)),null},te=me;var R=require("@inertiajs/core"),I=require("react"),C=()=>{},re=(0,I.forwardRef)(({children:r,as:n="a",data:o={},href:u,method:a="get",preserveScroll:h=!1,preserveState:d=null,replace:T=!1,only:l=[],headers:y={},queryStringArrayFormat:f="brackets",onClick:e=C,onCancelToken:c=C,onBefore:s=C,onStart:P=C,onProgress:S=C,onFinish:L=C,onCancel:k=C,onSuccess:B=C,onError:E=C,...U},D)=>{let H=(0,I.useCallback)(i=>{e(i),(0,R.shouldIntercept)(i)&&(i.preventDefault(),R.router.visit(u,{data:o,method:a,preserveScroll:h,preserveState:d??a!=="get",replace:T,only:l,headers:y,onCancelToken:c,onBefore:s,onStart:P,onProgress:S,onFinish:L,onCancel:k,onSuccess:B,onError:E}))},[o,u,a,h,d,T,l,y,e,c,s,P,S,L,k,B,E]);n=n.toLowerCase(),a=a.toLowerCase();let[b,t]=(0,R.mergeDataIntoQueryString)(a,u||"",o,f);return u=b,o=t,n==="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 ie=Object.create;var N=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var de=(r,n)=>{for(var o in n)N(r,o,{get:n[o],enumerable:!0})},J=(r,n,o,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of ue(n))!le.call(r,a)&&a!==o&&N(r,a,{get:()=>n[a],enumerable:!(u=pe(n,a))||u.enumerable});return r};var Q=(r,n,o)=>(o=r!=null?ie(ce(r)):{},J(n||!r||!r.__esModule?N(o,"default",{value:r,enumerable:!0}):o,r)),fe=r=>J(N({},"__esModule",{value:!0}),r);var ye={};de(ye,{Head:()=>X,Link:()=>Z,createInertiaApp:()=>V,router:()=>ge,useForm:()=>W,usePage:()=>q,useRemember:()=>A});module.exports=fe(ye);var se=require("@inertiajs/core");var v=Q(require("react"),1);var z=require("react"),G=(0,z.createContext)(void 0);G.displayName="InertiaHeadContext";var M=G;var me=function({children:r,title:n}){let o=(0,v.useContext)(M),u=(0,v.useMemo)(()=>o.createProvider(),[o]);(0,v.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((s,P)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(P))return s;let S=e.props[P];return S===""?s+` ${P}`:s+` ${P}="${S}"`},"");return`<${e.type}${c}>`}function d(e){return typeof e.props.children=="string"?e.props.children:e.props.children.reduce((c,s)=>c+T(s),"")}function T(e){let c=h(e);return e.props.children&&(c+=d(e)),e.props.dangerouslySetInnerHTML&&(c+=e.props.dangerouslySetInnerHTML.__html),a(e)||(c+=`</${e.type}>`),c}function l(e){return v.default.cloneElement(e,{inertia:e.props["head-key"]!==void 0?e.props["head-key"]:""})}function y(e){return T(l(e))}function f(e){let c=v.default.Children.toArray(e).filter(s=>s).map(s=>y(s));return n&&!c.find(s=>s.startsWith("<title"))&&c.push(`<title inertia>${n}</title>`),c}return u.update(f(r)),null},X=me;var R=require("@inertiajs/core"),I=require("react"),C=()=>{},Y=(0,I.forwardRef)(({children:r,as:n="a",data:o={},href:u,method:a="get",preserveScroll:h=!1,preserveState:d=null,replace:T=!1,only:l=[],headers:y={},queryStringArrayFormat:f="brackets",onClick:e=C,onCancelToken:c=C,onBefore:s=C,onStart:P=C,onProgress:S=C,onFinish:L=C,onCancel:k=C,onSuccess:B=C,onError:E=C,...U},D)=>{let H=(0,I.useCallback)(i=>{e(i),(0,R.shouldIntercept)(i)&&(i.preventDefault(),R.router.visit(u,{data:o,method:a,preserveScroll:h,preserveState:d??a!=="get",replace:T,only:l,headers:y,onCancelToken:c,onBefore:s,onStart:P,onProgress:S,onFinish:L,onCancel:k,onSuccess:B,onError:E}))},[o,u,a,h,d,T,l,y,e,c,s,P,S,L,k,B,E]);n=n.toLowerCase(),a=a.toLowerCase();let[b,t]=(0,R.mergeDataIntoQueryString)(a,u||"",o,f);return u=b,o=t,n==="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)(n,{...U,...n==="a"?{href:u}:{},ref:D,onClick:H},r)});re.displayName="InertiaLink";var oe=re;var _=require("@inertiajs/core"),ne=Q(require("lodash.isequal"),1),g=require("react");var K=require("@inertiajs/core"),j=require("react");function A(r,n){let[o,u]=(0,j.useState)(()=>{let a=K.router.restore(n);return a!==void 0?a:r});return(0,j.useEffect)(()=>{K.router.remember(o,n)},[o,n]),[o,u]}function W(r,n){let o=(0,g.useRef)(null),u=typeof r=="string"?r:null,[a,h]=(0,g.useState)((typeof r=="string"?n:r)||{}),d=(0,g.useRef)(null),T=(0,g.useRef)(null),[l,y]=u?A(a,`${u}:data`):(0,g.useState)(a),[f,e]=u?A({},`${u}:errors`):(0,g.useState)({}),[c,s]=(0,g.useState)(!1),[P,S]=(0,g.useState)(!1),[L,k]=(0,g.useState)(null),[B,E]=(0,g.useState)(!1),[U,D]=(0,g.useState)(!1),H=t=>t;(0,g.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let b=(0,g.useCallback)((t,i,p={})=>{let x={...p,onCancelToken:m=>{if(d.current=m,p.onCancelToken)return p.onCancelToken(m)},onBefore:m=>{if(E(!1),D(!1),clearTimeout(T.current),p.onBefore)return p.onBefore(m)},onStart:m=>{if(S(!0),p.onStart)return p.onStart(m)},onProgress:m=>{if(k(m),p.onProgress)return p.onProgress(m)},onSuccess:m=>{if(o.current&&(S(!1),k(null),e({}),s(!1),E(!0),D(!0),T.current=setTimeout(()=>{o.current&&D(!1)},2e3)),p.onSuccess)return p.onSuccess(m)},onError:m=>{if(o.current&&(S(!1),k(null),e(m),s(!0)),p.onError)return p.onError(m)},onCancel:()=>{if(o.current&&(S(!1),k(null)),p.onCancel)return p.onCancel()},onFinish:()=>{if(o.current&&(S(!1),k(null)),d.current=null,p.onFinish)return p.onFinish()}};t==="delete"?_.router.delete(i,{...x,data:H(l)}):_.router[t](i,H(l),x)},[l,e]);return{data:l,setData(t,i){y(typeof t=="string"?{...l,[t]:i}:typeof t=="function"?p=>t(p):t)},isDirty:!(0,ne.default)(l,a),errors:f,hasErrors:c,processing:P,progress:L,wasSuccessful:B,recentlySuccessful:U,transform(t){H=t},setDefaults(t,i){h(typeof t>"u"?()=>l:p=>({...p,...typeof t=="string"?{[t]:i}:t}))},reset(...t){t.length===0?y(a):y(Object.keys(a).filter(i=>t.includes(i)).reduce((i,p)=>(i[p]=a[p],i),{...l}))},setError(t,i){e(p=>{let x={...p,...typeof t=="string"?{[t]:i}:t};return s(Object.keys(x).length>0),x})},clearErrors(...t){e(i=>{let p=Object.keys(i).reduce((x,m)=>({...x,...t.length>0&&!t.includes(m)?{[m]:i[m]}:{}}),{});return s(Object.keys(p).length>0),p})},submit:b,get(t,i){b("get",t,i)},post(t,i){b("post",t,i)},put(t,i){b("put",t,i)},patch(t,i){b("patch",t,i)},delete(t,i){b("delete",t,i)},cancel(){d.current&&d.current.cancel()}}}var ae=require("react");function q(){let r=(0,ae.useContext)(w);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var ge=se.router;
<Link href="${u}" method="${a}" as="button">...</Link>`),(0,I.createElement)(n,{...U,...n==="a"?{href:u}:{},ref:D,onClick:H},r)});Y.displayName="InertiaLink";var Z=Y;var re=require("@inertiajs/core"),oe=require("react");var O=require("@inertiajs/core"),F=require("react");var ee=require("react"),te=(0,ee.createContext)(void 0);te.displayName="InertiaPageContext";var w=te;function $({children:r,initialPage:n,initialComponent:o,resolveComponent:u,titleCallback:a,onHeadUpdate:h}){let[d,T]=(0,F.useState)({component:o||null,page:n,key:null}),l=(0,F.useMemo)(()=>(0,O.createHeadManager)(typeof window>"u",a||(f=>f),h||(()=>{})),[]);if((0,F.useEffect)(()=>{O.router.init({initialPage:n,resolveComponent:u,swapComponent:async({component:f,page:e,preserveState:c})=>{T(s=>({component:f,page:e,key:c?s.key:Date.now()}))}}),O.router.on("navigate",()=>l.forceUpdate())},[]),!d.component)return(0,F.createElement)(M.Provider,{value:l},(0,F.createElement)(w.Provider,{value:d.page},null));let y=r||(({Component:f,props:e,key:c})=>{let s=(0,F.createElement)(f,{key:c,...e});return typeof f.layout=="function"?f.layout(s):Array.isArray(f.layout)?f.layout.concat(s).reverse().reduce((P,S)=>(0,F.createElement)(S,{children:P,...e})):s});return(0,F.createElement)(M.Provider,{value:l},(0,F.createElement)(w.Provider,{value:d.page},y({Component:d.component,key:d.key,props:d.page.props})))}$.displayName="Inertia";async function V({id:r="app",resolve:n,setup:o,title:u,progress:a={},page:h,render:d}){let T=typeof window>"u",l=T?null:document.getElementById(r),y=h||JSON.parse(l.dataset.page),f=s=>Promise.resolve(n(s)).then(P=>P.default||P),e=[],c=await f(y.component).then(s=>o({el:l,App:$,props:{initialPage:y,initialComponent:s,resolveComponent:f,titleCallback:u,onHeadUpdate:T?P=>e=P:null}}));if(!T&&a&&(0,re.setupProgress)(a),T){let s=await d((0,oe.createElement)("div",{id:r,"data-page":JSON.stringify(y)},c));return{head:e,body:s}}}var _=require("@inertiajs/core"),ne=Q(require("lodash.isequal"),1),g=require("react");var K=require("@inertiajs/core"),j=require("react");function A(r,n){let[o,u]=(0,j.useState)(()=>{let a=K.router.restore(n);return a!==void 0?a:r});return(0,j.useEffect)(()=>{K.router.remember(o,n)},[o,n]),[o,u]}function W(r,n){let o=(0,g.useRef)(null),u=typeof r=="string"?r:null,[a,h]=(0,g.useState)((typeof r=="string"?n:r)||{}),d=(0,g.useRef)(null),T=(0,g.useRef)(null),[l,y]=u?A(a,`${u}:data`):(0,g.useState)(a),[f,e]=u?A({},`${u}:errors`):(0,g.useState)({}),[c,s]=(0,g.useState)(!1),[P,S]=(0,g.useState)(!1),[L,k]=(0,g.useState)(null),[B,E]=(0,g.useState)(!1),[U,D]=(0,g.useState)(!1),H=t=>t;(0,g.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let b=(0,g.useCallback)((t,i,p={})=>{let x={...p,onCancelToken:m=>{if(d.current=m,p.onCancelToken)return p.onCancelToken(m)},onBefore:m=>{if(E(!1),D(!1),clearTimeout(T.current),p.onBefore)return p.onBefore(m)},onStart:m=>{if(S(!0),p.onStart)return p.onStart(m)},onProgress:m=>{if(k(m),p.onProgress)return p.onProgress(m)},onSuccess:m=>{if(o.current&&(S(!1),k(null),e({}),s(!1),E(!0),D(!0),T.current=setTimeout(()=>{o.current&&D(!1)},2e3)),p.onSuccess)return p.onSuccess(m)},onError:m=>{if(o.current&&(S(!1),k(null),e(m),s(!0)),p.onError)return p.onError(m)},onCancel:()=>{if(o.current&&(S(!1),k(null)),p.onCancel)return p.onCancel()},onFinish:()=>{if(o.current&&(S(!1),k(null)),d.current=null,p.onFinish)return p.onFinish()}};t==="delete"?_.router.delete(i,{...x,data:H(l)}):_.router[t](i,H(l),x)},[l,e]);return{data:l,setData(t,i){y(typeof t=="string"?{...l,[t]:i}:typeof t=="function"?p=>t(p):t)},isDirty:!(0,ne.default)(l,a),errors:f,hasErrors:c,processing:P,progress:L,wasSuccessful:B,recentlySuccessful:U,transform(t){H=t},setDefaults(t,i){h(typeof t>"u"?()=>l:p=>({...p,...typeof t=="string"?{[t]:i}:t}))},reset(...t){t.length===0?y(a):y(Object.keys(a).filter(i=>t.includes(i)).reduce((i,p)=>(i[p]=a[p],i),{...l}))},setError(t,i){e(p=>{let x={...p,...typeof t=="string"?{[t]:i}:t};return s(Object.keys(x).length>0),x})},clearErrors(...t){e(i=>{let p=Object.keys(i).reduce((x,m)=>({...x,...t.length>0&&!t.includes(m)?{[m]:i[m]}:{}}),{});return s(Object.keys(p).length>0),p})},submit:b,get(t,i){b("get",t,i)},post(t,i){b("post",t,i)},put(t,i){b("put",t,i)},patch(t,i){b("patch",t,i)},delete(t,i){b("delete",t,i)},cancel(){d.current&&d.current.cancel()}}}var ae=require("react");function q(){let r=(0,ae.useContext)(w);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var ge=se.router;
//# sourceMappingURL=index.js.map
{
"name": "@inertiajs/react",
"version": "1.0.15",
"version": "1.0.16",
"license": "MIT",

@@ -62,5 +62,5 @@ "description": "The React adapter for Inertia.js",

"dependencies": {
"@inertiajs/core": "1.0.15",
"@inertiajs/core": "1.0.16",
"lodash.isequal": "^4.5.0"
}
}
export declare const router: import("@inertiajs/core").Router;
export { default as Head } from './Head';
export { InertiaLinkProps, default as Link } from './Link';
export { default as createInertiaApp } from './createInertiaApp';
export { default as Head } from './Head';
export { default as Link, InertiaLinkProps } from './Link';
export { default as useForm } from './useForm';
export { default as usePage } from './usePage';
export { default as useRemember } from './useRemember';

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