@inertiajs/react 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +7 -2
- package/types/App.d.ts +12 -0
- package/types/Head.d.ts +7 -0
- package/types/HeadContext.d.ts +2 -0
- package/types/Link.d.ts +26 -0
- package/types/PageContext.d.ts +2 -0
- package/types/createInertiaApp.d.ts +56 -0
- package/types/index.d.ts +7 -0
- package/types/useForm.d.ts +33 -0
- package/types/usePage.d.ts +2 -0
- package/types/useRemember.d.ts +3 -0
- package/build.js +0 -40
- package/src/App.ts +0 -86
- package/src/Head.ts +0 -99
- package/src/HeadContext.ts +0 -6
- package/src/Link.ts +0 -141
- package/src/PageContext.ts +0 -6
- package/src/createInertiaApp.ts +0 -119
- package/src/index.ts +0 -9
- package/src/server.ts +0 -1
- package/src/useForm.ts +0 -263
- package/src/usePage.ts +0 -13
- package/src/useRemember.ts +0 -27
- package/tsconfig.json +0 -27
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var se=Object.create;var N=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var le=(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 pe(n))!ce.call(r,a)&&a!==o&&N(r,a,{get:()=>n[a],enumerable:!(u=ie(n,a))||u.enumerable});return r};var G=(r,n,o)=>(o=r!=null?se(ue(r)):{},J(n||!r||!r.__esModule?N(o,"default",{value:r,enumerable:!0}):o,r)),de=r=>J(N({},"__esModule",{value:!0}),r);var ye={};le(ye,{Head:()=>te,Link:()=>re,createInertiaApp:()=>j,router:()=>ge,useForm:()=>W,usePage:()=>q,useRemember:()=>A});module.exports=de(ye);var ae=require("@inertiajs/core");var Z=require("@inertiajs/core"),ee=require("react");var O=require("@inertiajs/core"),k=require("react");var Q=require("react"),z=(0,Q.createContext)(void 0);z.displayName="InertiaHeadContext";var M=z;var X=require("react"),Y=(0,X.createContext)(void 0);Y.displayName="InertiaPageContext";var L=Y;function $({children:r,initialPage:n,initialComponent:o,resolveComponent:u,titleCallback:a,onHeadUpdate:F}){let[d,T]=(0,k.useState)({component:o||null,page:n,key:null}),l=(0,k.useMemo)(()=>(0,O.createHeadManager)(typeof window>"u",a||(f=>f),F||(()=>{})),[]);if((0,k.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,k.createElement)(M.Provider,{value:l},(0,k.createElement)(L.Provider,{value:d.page},null));let y=r||(({Component:f,props:e,key:c})=>{let s=(0,k.createElement)(f,{key:c,...e});return typeof f.layout=="function"?f.layout(s):Array.isArray(f.layout)?f.layout.concat(s).reverse().reduce((S,P)=>(0,k.createElement)(P,{children:S,...e})):s});return(0,k.createElement)(M.Provider,{value:l},(0,k.createElement)(L.Provider,{value:d.page},y({Component:d.component,key:d.key,props:d.page.props})))}$.displayName="Inertia";async function j({id:r="app",resolve:n,setup:o,title:u,progress:a={},page:F,render:d}){let T=typeof window>"u",l=T?null:document.getElementById(r),y=F||JSON.parse(l.dataset.page),f=s=>Promise.resolve(n(s)).then(S=>S.default||S),e=[],c=await f(y.component).then(s=>o({el:l,App:$,props:{initialPage:y,initialComponent:s,resolveComponent:f,titleCallback:u,onHeadUpdate:T?S=>e=S: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 R=G(require("react"));var fe=function({children:r,title:n}){let o=(0,R.useContext)(M),u=(0,R.useMemo)(()=>o.createProvider(),[o]);(0,R.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 F(e){let c=Object.keys(e.props).reduce((s,S)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(S))return s;let P=e.props[S];return P===""?s+` ${S}`:s+` ${S}="${P}"`},"");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=F(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 R.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=(Array.isArray(e)?e:[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=fe;var b=require("@inertiajs/core"),x=require("react"),h=()=>{},me=(0,x.forwardRef)(({children:r,as:n="a",data:o={},href:u,method:a=b.Method.GET,preserveScroll:F=!1,preserveState:d=null,replace:T=!1,only:l=[],headers:y={},queryStringArrayFormat:f="brackets",onClick:e=h,onCancelToken:c=h,onBefore:s=h,onStart:S=h,onProgress:P=h,onFinish:D=h,onCancel:v=h,onSuccess:B=h,onError:E=h,...V},w)=>{let H=(0,x.useCallback)(i=>{e(i),(0,b.shouldIntercept)(i)&&(i.preventDefault(),b.router.visit(u,{data:o,method:a,preserveScroll:F,preserveState:d??a!=="get",replace:T,only:l,headers:y,onCancelToken:c,onBefore:s,onStart:S,onProgress:P,onFinish:D,onCancel:v,onSuccess:B,onError:E}))},[o,u,a,F,d,T,l,y,e,c,s,S,P,D,v,B,E]);n=n.toLowerCase(),a=a.toLowerCase();let[C,t]=(0,b.mergeDataIntoQueryString)(a,u||"",o,f);return u=C,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.
|
|
1
|
+
var se=Object.create;var N=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var le=(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 pe(n))!ce.call(r,a)&&a!==o&&N(r,a,{get:()=>n[a],enumerable:!(u=ie(n,a))||u.enumerable});return r};var G=(r,n,o)=>(o=r!=null?se(ue(r)):{},J(n||!r||!r.__esModule?N(o,"default",{value:r,enumerable:!0}):o,r)),de=r=>J(N({},"__esModule",{value:!0}),r);var ye={};le(ye,{Head:()=>te,Link:()=>re,createInertiaApp:()=>j,router:()=>ge,useForm:()=>W,usePage:()=>q,useRemember:()=>A});module.exports=de(ye);var ae=require("@inertiajs/core");var Z=require("@inertiajs/core"),ee=require("react");var O=require("@inertiajs/core"),k=require("react");var Q=require("react"),z=(0,Q.createContext)(void 0);z.displayName="InertiaHeadContext";var M=z;var X=require("react"),Y=(0,X.createContext)(void 0);Y.displayName="InertiaPageContext";var L=Y;function $({children:r,initialPage:n,initialComponent:o,resolveComponent:u,titleCallback:a,onHeadUpdate:F}){let[d,T]=(0,k.useState)({component:o||null,page:n,key:null}),l=(0,k.useMemo)(()=>(0,O.createHeadManager)(typeof window>"u",a||(f=>f),F||(()=>{})),[]);if((0,k.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,k.createElement)(M.Provider,{value:l},(0,k.createElement)(L.Provider,{value:d.page},null));let y=r||(({Component:f,props:e,key:c})=>{let s=(0,k.createElement)(f,{key:c,...e});return typeof f.layout=="function"?f.layout(s):Array.isArray(f.layout)?f.layout.concat(s).reverse().reduce((S,P)=>(0,k.createElement)(P,{children:S,...e})):s});return(0,k.createElement)(M.Provider,{value:l},(0,k.createElement)(L.Provider,{value:d.page},y({Component:d.component,key:d.key,props:d.page.props})))}$.displayName="Inertia";async function j({id:r="app",resolve:n,setup:o,title:u,progress:a={},page:F,render:d}){let T=typeof window>"u",l=T?null:document.getElementById(r),y=F||JSON.parse(l.dataset.page),f=s=>Promise.resolve(n(s)).then(S=>S.default||S),e=[],c=await f(y.component).then(s=>o({el:l,App:$,props:{initialPage:y,initialComponent:s,resolveComponent:f,titleCallback:u,onHeadUpdate:T?S=>e=S: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 R=G(require("react"),1);var fe=function({children:r,title:n}){let o=(0,R.useContext)(M),u=(0,R.useMemo)(()=>o.createProvider(),[o]);(0,R.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 F(e){let c=Object.keys(e.props).reduce((s,S)=>{if(["head-key","children","dangerouslySetInnerHTML"].includes(S))return s;let P=e.props[S];return P===""?s+` ${S}`:s+` ${S}="${P}"`},"");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=F(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 R.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=(Array.isArray(e)?e:[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=fe;var b=require("@inertiajs/core"),x=require("react"),h=()=>{},me=(0,x.forwardRef)(({children:r,as:n="a",data:o={},href:u,method:a=b.Method.GET,preserveScroll:F=!1,preserveState:d=null,replace:T=!1,only:l=[],headers:y={},queryStringArrayFormat:f="brackets",onClick:e=h,onCancelToken:c=h,onBefore:s=h,onStart:S=h,onProgress:P=h,onFinish:D=h,onCancel:v=h,onSuccess:B=h,onError:E=h,...V},w)=>{let H=(0,x.useCallback)(i=>{e(i),(0,b.shouldIntercept)(i)&&(i.preventDefault(),b.router.visit(u,{data:o,method:a,preserveScroll:F,preserveState:d??a!=="get",replace:T,only:l,headers:y,onCancelToken:c,onBefore:s,onStart:S,onProgress:P,onFinish:D,onCancel:v,onSuccess:B,onError:E}))},[o,u,a,F,d,T,l,y,e,c,s,S,P,D,v,B,E]);n=n.toLowerCase(),a=a.toLowerCase();let[C,t]=(0,b.mergeDataIntoQueryString)(a,u||"",o,f);return u=C,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.
|
|
2
2
|
|
|
3
3
|
Please specify a more appropriate element using the "as" attribute. For example:
|
|
4
4
|
|
|
5
|
-
<Link href="${u}" method="${a}" as="button">...</Link>`),(0,x.createElement)(n,{...V,...n==="a"?{href:u}:{},ref:w,onClick:H},r)}),re=me;var _=require("@inertiajs/core"),oe=G(require("lodash.isequal")),g=require("react");var K=require("@inertiajs/core"),U=require("react");function A(r,n){let[o,u]=(0,U.useState)(()=>{let a=K.router.restore(n);return a!==void 0?a:r});return(0,U.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,F]=(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),[S,P]=(0,g.useState)(!1),[D,v]=(0,g.useState)(null),[B,E]=(0,g.useState)(!1),[V,w]=(0,g.useState)(!1),H=t=>t;(0,g.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let C=(0,g.useCallback)((t,i,p={})=>{let I={...p,onCancelToken:m=>{if(d.current=m,p.onCancelToken)return p.onCancelToken(m)},onBefore:m=>{if(E(!1),w(!1),clearTimeout(T.current),p.onBefore)return p.onBefore(m)},onStart:m=>{if(P(!0),p.onStart)return p.onStart(m)},onProgress:m=>{if(v(m),p.onProgress)return p.onProgress(m)},onSuccess:m=>{if(o.current&&(P(!1),v(null),e({}),s(!1),E(!0),w(!0),T.current=setTimeout(()=>{o.current&&w(!1)},2e3)),p.onSuccess)return p.onSuccess(m)},onError:m=>{if(o.current&&(P(!1),v(null),e(m),s(!0)),p.onError)return p.onError(m)},onCancel:()=>{if(o.current&&(P(!1),v(null)),p.onCancel)return p.onCancel()},onFinish:()=>{if(o.current&&(P(!1),v(null)),d.current=null,p.onFinish)return p.onFinish()}};t==="delete"?_.router.delete(i,{...I,data:H(l)}):_.router[t](i,H(l),I)},[l,e]);return{data:l,setData(t,i){y(typeof t=="string"?{...l,[t]:i}:typeof t=="function"?p=>t(p):t)},isDirty:!(0,oe.default)(l,a),errors:f,hasErrors:c,processing:S,progress:D,wasSuccessful:B,recentlySuccessful:V,transform(t){H=t},setDefaults(t,i){F(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 I={...p,...typeof t=="string"?{[t]:i}:t};return s(Object.keys(I).length>0),I})},clearErrors(...t){e(i=>{let p=Object.keys(i).reduce((I,m)=>({...I,...t.length>0&&!t.includes(m)?{[m]:i[m]}:{}}),{});return s(Object.keys(p).length>0),p})},submit:C,get(t,i){C("get",t,i)},post(t,i){C("post",t,i)},put(t,i){C("put",t,i)},patch(t,i){C("patch",t,i)},delete(t,i){C("delete",t,i)},cancel(){d.current&&d.current.cancel()}}}var ne=require("react");function q(){let r=(0,ne.useContext)(L);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var ge=ae.router;
|
|
5
|
+
<Link href="${u}" method="${a}" as="button">...</Link>`),(0,x.createElement)(n,{...V,...n==="a"?{href:u}:{},ref:w,onClick:H},r)}),re=me;var _=require("@inertiajs/core"),oe=G(require("lodash.isequal"),1),g=require("react");var K=require("@inertiajs/core"),U=require("react");function A(r,n){let[o,u]=(0,U.useState)(()=>{let a=K.router.restore(n);return a!==void 0?a:r});return(0,U.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,F]=(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),[S,P]=(0,g.useState)(!1),[D,v]=(0,g.useState)(null),[B,E]=(0,g.useState)(!1),[V,w]=(0,g.useState)(!1),H=t=>t;(0,g.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let C=(0,g.useCallback)((t,i,p={})=>{let I={...p,onCancelToken:m=>{if(d.current=m,p.onCancelToken)return p.onCancelToken(m)},onBefore:m=>{if(E(!1),w(!1),clearTimeout(T.current),p.onBefore)return p.onBefore(m)},onStart:m=>{if(P(!0),p.onStart)return p.onStart(m)},onProgress:m=>{if(v(m),p.onProgress)return p.onProgress(m)},onSuccess:m=>{if(o.current&&(P(!1),v(null),e({}),s(!1),E(!0),w(!0),T.current=setTimeout(()=>{o.current&&w(!1)},2e3)),p.onSuccess)return p.onSuccess(m)},onError:m=>{if(o.current&&(P(!1),v(null),e(m),s(!0)),p.onError)return p.onError(m)},onCancel:()=>{if(o.current&&(P(!1),v(null)),p.onCancel)return p.onCancel()},onFinish:()=>{if(o.current&&(P(!1),v(null)),d.current=null,p.onFinish)return p.onFinish()}};t==="delete"?_.router.delete(i,{...I,data:H(l)}):_.router[t](i,H(l),I)},[l,e]);return{data:l,setData(t,i){y(typeof t=="string"?{...l,[t]:i}:typeof t=="function"?p=>t(p):t)},isDirty:!(0,oe.default)(l,a),errors:f,hasErrors:c,processing:S,progress:D,wasSuccessful:B,recentlySuccessful:V,transform(t){H=t},setDefaults(t,i){F(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 I={...p,...typeof t=="string"?{[t]:i}:t};return s(Object.keys(I).length>0),I})},clearErrors(...t){e(i=>{let p=Object.keys(i).reduce((I,m)=>({...I,...t.length>0&&!t.includes(m)?{[m]:i[m]}:{}}),{});return s(Object.keys(p).length>0),p})},submit:C,get(t,i){C("get",t,i)},post(t,i){C("post",t,i)},put(t,i){C("put",t,i)},patch(t,i){C("patch",t,i)},delete(t,i){C("delete",t,i)},cancel(){d.current&&d.current.cancel()}}}var ne=require("react");function q(){let r=(0,ne.useContext)(L);if(!r)throw new Error("usePage must be used within the Inertia component");return r}var ge=ae.router;
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/createInertiaApp.ts", "../src/App.ts", "../src/HeadContext.ts", "../src/PageContext.ts", "../src/Head.ts", "../src/Link.ts", "../src/useForm.ts", "../src/useRemember.ts", "../src/usePage.ts"],
|
|
4
4
|
"sourcesContent": ["import { router as Router } from '@inertiajs/core'\n\nexport const router = Router\nexport { default as createInertiaApp } from './createInertiaApp'\nexport { default as Head } from './Head'\nexport { default as Link } from './Link'\nexport { default as useForm } from './useForm'\nexport { default as usePage } from './usePage'\nexport { default as useRemember } from './useRemember'\n", "import { Page, PageProps, PageResolver, setupProgress } from '@inertiajs/core'\nimport { ComponentType, createElement, FunctionComponent, Key, ReactElement, ReactNode } from 'react'\nimport { renderToString } from 'react-dom/server'\nimport App from './App'\n\ntype ReactInstance = ReactElement\ntype ReactComponent = ReactNode\n\ntype HeadManagerOnUpdate = (elements: string[]) => void // TODO: When shipped, replace with: Inertia.HeadManagerOnUpdate\ntype HeadManagerTitleCallback = (title: string) => string // TODO: When shipped, replace with: Inertia.HeadManagerTitleCallback\n\ntype AppType<SharedProps = PageProps> = FunctionComponent<\n {\n children?: (props: { Component: ComponentType; key: Key; props: Page<SharedProps>['props'] }) => ReactNode\n } & SetupOptions<unknown, SharedProps>['props']\n>\n\nexport type SetupOptions<ElementType, SharedProps> = {\n el: ElementType\n App: AppType\n props: {\n initialPage: Page<SharedProps>\n initialComponent: ReactComponent\n resolveComponent: PageResolver\n titleCallback?: HeadManagerTitleCallback\n onHeadUpdate?: HeadManagerOnUpdate\n }\n}\n\ntype BaseInertiaAppOptions = {\n title?: HeadManagerTitleCallback\n resolve: PageResolver\n}\n\ntype CreateInertiaAppSetupReturnType = ReactInstance | void\ntype InertiaAppOptionsForCSR<SharedProps> = BaseInertiaAppOptions & {\n id?: string\n page?: Page | string\n render?: undefined\n progress?:\n | false\n | {\n delay?: number\n color?: string\n includeCSS?: boolean\n showSpinner?: boolean\n }\n setup(options: SetupOptions<HTMLElement, SharedProps>): CreateInertiaAppSetupReturnType\n}\n\ntype CreateInertiaAppSSRContent = { head: string[]; body: string }\ntype InertiaAppOptionsForSSR<SharedProps> = BaseInertiaAppOptions & {\n id?: undefined\n page: Page | string\n render: typeof renderToString\n progress: undefined\n setup(options: SetupOptions<null, SharedProps>): ReactInstance\n}\n\nexport default async function createInertiaApp<SharedProps = PageProps>(\n options: InertiaAppOptionsForCSR<SharedProps>,\n): Promise<CreateInertiaAppSetupReturnType>\nexport default async function createInertiaApp<SharedProps = PageProps>(\n options: InertiaAppOptionsForSSR<SharedProps>,\n): Promise<CreateInertiaAppSSRContent>\nexport default async function createInertiaApp<SharedProps = PageProps>({\n id = 'app',\n resolve,\n setup,\n title,\n progress = {},\n page,\n render,\n}: InertiaAppOptionsForCSR<SharedProps> | InertiaAppOptionsForSSR<SharedProps>): Promise<\n CreateInertiaAppSetupReturnType | CreateInertiaAppSSRContent\n> {\n const isServer = typeof window === 'undefined'\n const el = isServer ? null : document.getElementById(id)\n const initialPage = page || JSON.parse(el.dataset.page)\n // @ts-expect-error\n const resolveComponent = (name) => Promise.resolve(resolve(name)).then((module) => module.default || module)\n\n let head = []\n\n const reactApp = await resolveComponent(initialPage.component).then((initialComponent) => {\n return setup({\n // @ts-expect-error\n el,\n App,\n props: {\n initialPage,\n initialComponent,\n resolveComponent,\n titleCallback: title,\n onHeadUpdate: isServer ? (elements) => (head = elements) : null,\n },\n })\n })\n\n if (!isServer && progress) {\n setupProgress(progress)\n }\n\n if (isServer) {\n const body = await render(\n createElement(\n 'div',\n {\n id,\n 'data-page': JSON.stringify(initialPage),\n },\n // @ts-expect-error\n reactApp,\n ),\n )\n\n return { head, body }\n }\n}\n", "import { createHeadManager, router } from '@inertiajs/core'\nimport { createElement, useEffect, useMemo, useState } from 'react'\nimport HeadContext from './HeadContext'\nimport PageContext from './PageContext'\n\nexport default function App({\n children,\n initialPage,\n initialComponent,\n resolveComponent,\n titleCallback,\n onHeadUpdate,\n}) {\n const [current, setCurrent] = useState({\n component: initialComponent || null,\n page: initialPage,\n key: null,\n })\n\n const headManager = useMemo(() => {\n return createHeadManager(\n typeof window === 'undefined',\n titleCallback || ((title) => title),\n onHeadUpdate || (() => {}),\n )\n }, [])\n\n useEffect(() => {\n router.init({\n initialPage,\n resolveComponent,\n swapComponent: async ({ component, page, preserveState }) => {\n setCurrent((current) => ({\n component,\n page,\n key: preserveState ? current.key : Date.now(),\n }))\n },\n })\n\n router.on('navigate', () => headManager.forceUpdate())\n }, [])\n\n if (!current.component) {\n return createElement(\n HeadContext.Provider,\n { value: headManager },\n createElement(PageContext.Provider, { value: current.page }, null),\n )\n }\n\n const renderChildren =\n children ||\n (({ Component, props, key }) => {\n const child = createElement(Component, { key, ...props })\n\n if (typeof Component.layout === 'function') {\n return Component.layout(child)\n }\n\n if (Array.isArray(Component.layout)) {\n return Component.layout\n .concat(child)\n .reverse()\n .reduce((children, Layout) => createElement(Layout, { children, ...props }))\n }\n\n return child\n })\n\n return createElement(\n HeadContext.Provider,\n { value: headManager },\n createElement(\n PageContext.Provider,\n { value: current.page },\n renderChildren({\n Component: current.component,\n key: current.key,\n props: current.page.props,\n }),\n ),\n )\n}\n\nApp.displayName = 'Inertia'\n", "import { createContext } from 'react'\n\nconst headContext = createContext(undefined)\nheadContext.displayName = 'InertiaHeadContext'\n\nexport default headContext\n", "import { createContext } from 'react'\n\nconst pageContext = createContext(undefined)\npageContext.displayName = 'InertiaPageContext'\n\nexport default pageContext\n", "import React, { FunctionComponent, useContext, useEffect, useMemo } from 'react'\nimport HeadContext from './HeadContext'\n\ntype InertiaHeadProps = {\n title?: string\n}\n\ntype InertiaHead = FunctionComponent<InertiaHeadProps>\n\nconst Head: InertiaHead = function ({ children, title }) {\n const headManager = useContext(HeadContext)\n const provider = useMemo(() => headManager.createProvider(), [headManager])\n\n useEffect(() => {\n return () => {\n provider.disconnect()\n }\n }, [provider])\n\n function isUnaryTag(node) {\n return (\n [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ].indexOf(node.type) > -1\n )\n }\n\n function renderTagStart(node) {\n const attrs = Object.keys(node.props).reduce((carry, name) => {\n if (['head-key', 'children', 'dangerouslySetInnerHTML'].includes(name)) {\n return carry\n }\n const value = node.props[name]\n if (value === '') {\n return carry + ` ${name}`\n } else {\n return carry + ` ${name}=\"${value}\"`\n }\n }, '')\n return `<${node.type}${attrs}>`\n }\n\n function renderTagChildren(node) {\n return typeof node.props.children === 'string'\n ? node.props.children\n : node.props.children.reduce((html, child) => html + renderTag(child), '')\n }\n\n function renderTag(node) {\n let html = renderTagStart(node)\n if (node.props.children) {\n html += renderTagChildren(node)\n }\n if (node.props.dangerouslySetInnerHTML) {\n html += node.props.dangerouslySetInnerHTML.__html\n }\n if (!isUnaryTag(node)) {\n html += `</${node.type}>`\n }\n return html\n }\n\n function ensureNodeHasInertiaProp(node) {\n return React.cloneElement(node, {\n inertia: node.props['head-key'] !== undefined ? node.props['head-key'] : '',\n })\n }\n\n function renderNode(node) {\n return renderTag(ensureNodeHasInertiaProp(node))\n }\n\n function renderNodes(nodes) {\n const computed = (Array.isArray(nodes) ? nodes : [nodes]).filter((node) => node).map((node) => renderNode(node))\n if (title && !computed.find((tag) => tag.startsWith('<title'))) {\n computed.push(`<title inertia>${title}</title>`)\n }\n return computed\n }\n\n provider.update(renderNodes(children))\n\n return null\n}\nexport default Head\n", "import {\n FormDataConvertible,\n mergeDataIntoQueryString,\n Method,\n PreserveStateOption,\n Progress,\n router,\n shouldIntercept,\n} from '@inertiajs/core'\nimport { createElement, forwardRef, useCallback } from 'react'\n\nconst noop = () => undefined\n\ninterface BaseInertiaLinkProps {\n as?: string\n data?: Record<string, FormDataConvertible>\n href: string\n method?: Method\n headers?: Record<string, string>\n onClick?: (event: React.MouseEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLAnchorElement>) => void\n preserveScroll?: PreserveStateOption\n preserveState?: PreserveStateOption\n replace?: boolean\n only?: string[]\n onCancelToken?: (cancelToken: import('axios').CancelTokenSource) => void\n onBefore?: () => void\n onStart?: () => void\n onProgress?: (progress: Progress) => void\n onFinish?: () => void\n onCancel?: () => void\n onSuccess?: () => void\n onError?: () => void\n queryStringArrayFormat?: 'indices' | 'brackets'\n}\n\ntype InertiaLinkProps = BaseInertiaLinkProps &\n Omit<React.HTMLAttributes<HTMLElement>, keyof BaseInertiaLinkProps> &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof BaseInertiaLinkProps>\n\ntype InertiaLink = React.FunctionComponent<InertiaLinkProps>\n\nconst Link: InertiaLink = forwardRef<unknown, InertiaLinkProps>(\n (\n {\n children,\n as = 'a',\n data = {},\n href,\n method = Method.GET,\n preserveScroll = false,\n preserveState = null,\n replace = false,\n only = [],\n headers = {},\n queryStringArrayFormat = 'brackets',\n onClick = noop,\n onCancelToken = noop,\n onBefore = noop,\n onStart = noop,\n onProgress = noop,\n onFinish = noop,\n onCancel = noop,\n onSuccess = noop,\n onError = noop,\n ...props\n },\n ref,\n ) => {\n const visit = useCallback(\n (event) => {\n onClick(event)\n\n if (shouldIntercept(event)) {\n event.preventDefault()\n\n router.visit(href, {\n data,\n method,\n preserveScroll,\n preserveState: preserveState ?? method !== 'get',\n replace,\n only,\n headers,\n onCancelToken,\n onBefore,\n onStart,\n onProgress,\n onFinish,\n onCancel,\n onSuccess,\n onError,\n })\n }\n },\n [\n data,\n href,\n method,\n preserveScroll,\n preserveState,\n replace,\n only,\n headers,\n onClick,\n onCancelToken,\n onBefore,\n onStart,\n onProgress,\n onFinish,\n onCancel,\n onSuccess,\n onError,\n ],\n )\n\n as = as.toLowerCase()\n method = method.toLowerCase() as Method\n const [_href, _data] = mergeDataIntoQueryString(method, href || '', data, queryStringArrayFormat)\n href = _href\n data = _data\n\n if (as === 'a' && method !== 'get') {\n console.warn(\n `Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes \"Open Link in New Tab/Window\" accessibility issues.\\n\\nPlease specify a more appropriate element using the \"as\" attribute. For example:\\n\\n<Link href=\"${href}\" method=\"${method}\" as=\"button\">...</Link>`,\n )\n }\n\n return createElement(\n as,\n {\n ...props,\n ...(as === 'a' ? { href } : {}),\n ref,\n onClick: visit,\n },\n children,\n )\n },\n)\n\nexport default Link\n", "import { Method, Progress, router, VisitOptions } from '@inertiajs/core'\nimport isEqual from 'lodash.isequal'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport useRemember from './useRemember'\n\ntype setDataByObject<TForm> = (data: TForm) => void\ntype setDataByMethod<TForm> = (data: (previousData: TForm) => TForm) => void\ntype setDataByKeyValuePair<TForm> = <K extends keyof TForm>(key: K, value: TForm[K]) => void\n\nexport interface InertiaFormProps<TForm extends Record<string, unknown>> {\n data: TForm\n isDirty: boolean\n errors: Partial<Record<keyof TForm, string>>\n hasErrors: boolean\n processing: boolean\n progress: Progress | null\n wasSuccessful: boolean\n recentlySuccessful: boolean\n setData: setDataByObject<TForm> & setDataByMethod<TForm> & setDataByKeyValuePair<TForm>\n transform: (callback: (data: TForm) => TForm) => void\n setDefaults(): void\n setDefaults(field: keyof TForm, value: string): void\n setDefaults(fields: Record<keyof TForm, string>): void\n reset: (...fields: (keyof TForm)[]) => void\n clearErrors: (...fields: (keyof TForm)[]) => void\n setError(field: keyof TForm, value: string): void\n setError(errors: Record<keyof TForm, string>): void\n submit: (method: Method, url: string, options?: VisitOptions) => void\n get: (url: string, options?: VisitOptions) => void\n patch: (url: string, options?: VisitOptions) => void\n post: (url: string, options?: VisitOptions) => void\n put: (url: string, options?: VisitOptions) => void\n delete: (url: string, options?: VisitOptions) => void\n cancel: () => void\n}\nexport default function useForm<TForm extends Record<string, unknown>>(initialValues?: TForm): InertiaFormProps<TForm>\nexport default function useForm<TForm extends Record<string, unknown>>(\n rememberKey: string,\n initialValues?: TForm,\n): InertiaFormProps<TForm>\nexport default function useForm<TForm extends Record<string, unknown>>(\n rememberKeyOrInitialValues?: string | TForm,\n maybeInitialValues?: TForm,\n): InertiaFormProps<TForm> {\n const isMounted = useRef(null)\n const rememberKey = typeof rememberKeyOrInitialValues === 'string' ? rememberKeyOrInitialValues : null\n const [defaults, setDefaults] = useState(\n (typeof rememberKeyOrInitialValues === 'string' ? maybeInitialValues : rememberKeyOrInitialValues) || ({} as TForm),\n )\n const cancelToken = useRef(null)\n const recentlySuccessfulTimeoutId = useRef(null)\n const [data, setData] = rememberKey ? useRemember(defaults, `${rememberKey}:data`) : useState(defaults)\n const [errors, setErrors] = rememberKey\n ? useRemember({} as Partial<Record<keyof TForm, string>>, `${rememberKey}:errors`)\n : useState({} as Partial<Record<keyof TForm, string>>)\n const [hasErrors, setHasErrors] = useState(false)\n const [processing, setProcessing] = useState(false)\n const [progress, setProgress] = useState(null)\n const [wasSuccessful, setWasSuccessful] = useState(false)\n const [recentlySuccessful, setRecentlySuccessful] = useState(false)\n let transform = (data) => data\n\n useEffect(() => {\n isMounted.current = true\n return () => {\n isMounted.current = false\n }\n }, [])\n\n const submit = useCallback(\n (method, url, options = {}) => {\n const _options = {\n ...options,\n onCancelToken: (token) => {\n cancelToken.current = token\n\n if (options.onCancelToken) {\n return options.onCancelToken(token)\n }\n },\n onBefore: (visit) => {\n setWasSuccessful(false)\n setRecentlySuccessful(false)\n clearTimeout(recentlySuccessfulTimeoutId.current)\n\n if (options.onBefore) {\n return options.onBefore(visit)\n }\n },\n onStart: (visit) => {\n setProcessing(true)\n\n if (options.onStart) {\n return options.onStart(visit)\n }\n },\n onProgress: (event) => {\n setProgress(event)\n\n if (options.onProgress) {\n return options.onProgress(event)\n }\n },\n onSuccess: (page) => {\n if (isMounted.current) {\n setProcessing(false)\n setProgress(null)\n setErrors({})\n setHasErrors(false)\n setWasSuccessful(true)\n setRecentlySuccessful(true)\n recentlySuccessfulTimeoutId.current = setTimeout(() => {\n if (isMounted.current) {\n setRecentlySuccessful(false)\n }\n }, 2000)\n }\n\n if (options.onSuccess) {\n return options.onSuccess(page)\n }\n },\n onError: (errors) => {\n if (isMounted.current) {\n setProcessing(false)\n setProgress(null)\n setErrors(errors)\n setHasErrors(true)\n }\n\n if (options.onError) {\n return options.onError(errors)\n }\n },\n onCancel: () => {\n if (isMounted.current) {\n setProcessing(false)\n setProgress(null)\n }\n\n if (options.onCancel) {\n return options.onCancel()\n }\n },\n onFinish: () => {\n if (isMounted.current) {\n setProcessing(false)\n setProgress(null)\n }\n\n cancelToken.current = null\n\n if (options.onFinish) {\n return options.onFinish()\n }\n },\n }\n\n if (method === 'delete') {\n router.delete(url, { ..._options, data: transform(data) })\n } else {\n router[method](url, transform(data), _options)\n }\n },\n [data, setErrors],\n )\n\n return {\n data,\n setData(keyOrData: keyof TForm | Function | TForm, maybeValue?: TForm[keyof TForm]) {\n if (typeof keyOrData === 'string') {\n setData({ ...data, [keyOrData]: maybeValue })\n } else if (typeof keyOrData === 'function') {\n setData((data) => keyOrData(data))\n } else {\n setData(keyOrData as TForm)\n }\n },\n isDirty: !isEqual(data, defaults),\n errors,\n hasErrors,\n processing,\n progress,\n wasSuccessful,\n recentlySuccessful,\n transform(callback) {\n transform = callback\n },\n setDefaults(fieldOrFields?: keyof TForm | Record<keyof TForm, string>, maybeValue?: string) {\n if (typeof fieldOrFields === 'undefined') {\n setDefaults(() => data)\n } else {\n setDefaults((defaults) => ({\n ...defaults,\n ...(typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : (fieldOrFields as TForm)),\n }))\n }\n },\n reset(...fields) {\n if (fields.length === 0) {\n setData(defaults)\n } else {\n setData(\n (Object.keys(defaults) as Array<keyof TForm>)\n .filter((key) => fields.includes(key))\n .reduce(\n (carry, key) => {\n carry[key] = defaults[key]\n return carry\n },\n { ...data },\n ),\n )\n }\n },\n setError(fieldOrFields: keyof TForm | Record<keyof TForm, string>, maybeValue?: string) {\n setErrors((errors) => {\n const newErrors = {\n ...errors,\n ...(typeof fieldOrFields === 'string'\n ? { [fieldOrFields]: maybeValue }\n : (fieldOrFields as Record<keyof TForm, string>)),\n }\n setHasErrors(Object.keys(newErrors).length > 0)\n return newErrors\n })\n },\n clearErrors(...fields) {\n setErrors((errors) => {\n const newErrors = (Object.keys(errors) as Array<keyof TForm>).reduce(\n (carry, field) => ({\n ...carry,\n ...(fields.length > 0 && !fields.includes(field) ? { [field]: errors[field] } : {}),\n }),\n {},\n )\n setHasErrors(Object.keys(newErrors).length > 0)\n return newErrors\n })\n },\n submit,\n get(url, options) {\n submit('get', url, options)\n },\n post(url, options) {\n submit('post', url, options)\n },\n put(url, options) {\n submit('put', url, options)\n },\n patch(url, options) {\n submit('patch', url, options)\n },\n delete(url, options) {\n submit('delete', url, options)\n },\n cancel() {\n if (cancelToken.current) {\n cancelToken.current.cancel()\n }\n },\n }\n}\n", "import { router } from '@inertiajs/core'\nimport { Dispatch, SetStateAction, useEffect, useState } from 'react'\n\nexport default function useRemember<State>(\n initialState: State,\n key?: string,\n): [State, Dispatch<SetStateAction<State>>] {\n const [state, setState] = useState(() => {\n const restored = router.restore(key) as State\n\n return restored !== undefined ? restored : initialState\n })\n\n useEffect(() => {\n router.remember(state, key)\n }, [state, key])\n\n return [state, setState]\n}\n\n/** @deprecated use `useRemember` instead */\nexport function useRememberedState<State>(initialState: State, key?: string): [State, Dispatch<SetStateAction<State>>] {\n console.warn(\n 'The \"useRememberedState\" hook has been deprecated and will be removed in a future release. Use \"useRemember\" instead.',\n )\n return useRemember(initialState, key)\n}\n", "import { Page } from '@inertiajs/core'\nimport { useContext } from 'react'\nimport PageContext from './PageContext'\n\nexport default function usePage(): Page {\n const page = useContext(PageContext)\n\n if (!page) {\n throw new Error('usePage must be used within the Inertia component')\n }\n\n return page\n}\n"],
|
|
5
|
-
"mappings": "yjBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,UAAAE,GAAA,SAAAC,GAAA,qBAAAC,EAAA,WAAAC,GAAA,YAAAC,EAAA,YAAAC,EAAA,gBAAAC,IAAA,eAAAC,GAAAT,IAAA,IAAAU,GAAiC,2BCAjC,IAAAC,EAA6D,2BAC7DC,GAA8F,iBCD9F,IAAAC,EAA0C,2BAC1CC,EAA4D,iBCD5D,IAAAC,EAA8B,iBAExBC,KAAc,iBAAc,MAAS,EAC3CA,EAAY,YAAc,qBAE1B,IAAOC,EAAQD,ECLf,IAAAE,EAA8B,iBAExBC,KAAc,iBAAc,MAAS,EAC3CA,EAAY,YAAc,qBAE1B,IAAOC,EAAQD,EFAA,SAARE,EAAqB,CAC1B,SAAAC,EACA,YAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,cAAAC,E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AKC,CAAO,CAC9B,EACA,OAAOD,EAAKC,EAAS,CACnBH,EAAO,SAAUE,EAAKC,CAAO,CAC/B,EACA,QAAS,CACHrB,EAAY,SACdA,EAAY,QAAQ,OAAO,CAE/B,CACF,CACF,CErQA,IAAAqC,GAA2B,iBAGZ,SAARC,GAAiC,CACtC,IAAMC,KAAO,eAAWC,CAAW,EAEnC,GAAI,CAACD,EACH,MAAM,IAAI,MAAM,mDAAmD,EAGrE,OAAOA,CACT,CTVO,IAAME,GAAS,GAAAC",
|
|
6
6
|
"names": ["src_exports", "__export", "Head_default", "Link_default", "createInertiaApp", "router", "useForm", "usePage", "useRemember", "__toCommonJS", "import_core", "import_core", "import_react", "import_core", "import_react", "import_react", "headContext", "HeadContext_default", "import_react", "pageContext", "PageContext_default", "App", "children", "initialPage", "initialComponent", "resolveComponent", "titleCallback", "onHeadUpdate", "current", "setCurrent", "headManager", "title", "component", "page", "preserveState", "HeadContext_default", "PageContext_default", "renderChildren", "Component", "props", "key", "child", "Layout", "createInertiaApp", "id", "resolve", "setup", "title", "progress", "page", "render", "isServer", "el", "initialPage", "resolveComponent", "name", "module", "head", "reactApp", "initialComponent", "App", "elements", "body", "import_react", "Head", "children", "title", "headManager", "HeadContext_default", "provider", "isUnaryTag", "node", "renderTagStart", "attrs", "carry", "name", "value", "renderTagChildren", "html", "child", "renderTag", "ensureNodeHasInertiaProp", "React", "renderNode", "renderNodes", "nodes", "computed", "tag", "Head_default", "import_core", "import_react", "noop", "Link", "children", "as", "data", "href", "method", "preserveScroll", "preserveState", "replace", "only", "headers", "queryStringArrayFormat", "onClick", "onCancelToken", "onBefore", "onStart", "onProgress", "onFinish", "onCancel", "onSuccess", "onError", "props", "ref", "visit", "event", "_href", "_data", "Link_default", "import_core", "import_lodash", "import_react", "import_core", "import_react", "useRemember", "initialState", "key", "state", "setState", "restored", "useForm", "rememberKeyOrInitialValues", "maybeInitialValues", "isMounted", "rememberKey", "defaults", "setDefaults", "cancelToken", "recentlySuccessfulTimeoutId", "data", "setData", "useRemember", "errors", "setErrors", "hasErrors", "setHasErrors", "processing", "setProcessing", "progress", "setProgress", "wasSuccessful", "setWasSuccessful", "recentlySuccessful", "setRecentlySuccessful", "transform", "submit", "method", "url", "options", "_options", "token", "visit", "event", "page", "keyOrData", "maybeValue", "isEqual", "callback", "fieldOrFields", "fields", "key", "carry", "newErrors", "field", "import_react", "usePage", "page", "PageContext_default", "router", "Router"]
|
|
7
7
|
}
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var u=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var b=(a,e)=>{for(var f in e)d(a,f,{get:e[f],enumerable:!0})},o=(a,e,f,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!x.call(a,t)&&t!==f&&d(a,t,{get:()=>e[t],enumerable:!(l=m(e,t))||l.enumerable});return a};var c=(a,e,f)=>(f=a!=null?u(s(a)):{},o(e||!a||!a.__esModule?d(f,"default",{value:a,enumerable:!0}):f,a)),g=a=>o(d({},"__esModule",{value:!0}),a);var h={};b(h,{default:()=>r.default});module.exports=g(h);var r=c(require("@inertiajs/core/server"));0&&(module.exports={});
|
|
1
|
+
var u=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var b=(a,e)=>{for(var f in e)d(a,f,{get:e[f],enumerable:!0})},o=(a,e,f,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!x.call(a,t)&&t!==f&&d(a,t,{get:()=>e[t],enumerable:!(l=m(e,t))||l.enumerable});return a};var c=(a,e,f)=>(f=a!=null?u(s(a)):{},o(e||!a||!a.__esModule?d(f,"default",{value:a,enumerable:!0}):f,a)),g=a=>o(d({},"__esModule",{value:!0}),a);var h={};b(h,{default:()=>r.default});module.exports=g(h);var r=c(require("@inertiajs/core/server"),1);0&&(module.exports={});
|
|
2
2
|
//# sourceMappingURL=server.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The React adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/inertiajs/inertia/issues"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"types"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
19
24
|
"source": "src/index.ts",
|
|
20
25
|
"main": "dist/index.js",
|
|
21
26
|
"types": "types/index.d.ts",
|
|
@@ -48,7 +53,7 @@
|
|
|
48
53
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0"
|
|
49
54
|
},
|
|
50
55
|
"dependencies": {
|
|
51
|
-
"@inertiajs/core": "1.0.0-beta.
|
|
56
|
+
"@inertiajs/core": "1.0.0-beta.6",
|
|
52
57
|
"lodash.isequal": "^4.5.0"
|
|
53
58
|
}
|
|
54
59
|
}
|
package/types/App.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function App({ children, initialPage, initialComponent, resolveComponent, titleCallback, onHeadUpdate, }: {
|
|
2
|
+
children: any;
|
|
3
|
+
initialPage: any;
|
|
4
|
+
initialComponent: any;
|
|
5
|
+
resolveComponent: any;
|
|
6
|
+
titleCallback: any;
|
|
7
|
+
onHeadUpdate: any;
|
|
8
|
+
}): import("react").FunctionComponentElement<import("react").ProviderProps<any>>;
|
|
9
|
+
declare namespace App {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export default App;
|
package/types/Head.d.ts
ADDED
package/types/Link.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FormDataConvertible, Method, PreserveStateOption, Progress } from '@inertiajs/core';
|
|
2
|
+
interface BaseInertiaLinkProps {
|
|
3
|
+
as?: string;
|
|
4
|
+
data?: Record<string, FormDataConvertible>;
|
|
5
|
+
href: string;
|
|
6
|
+
method?: Method;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLAnchorElement>) => void;
|
|
9
|
+
preserveScroll?: PreserveStateOption;
|
|
10
|
+
preserveState?: PreserveStateOption;
|
|
11
|
+
replace?: boolean;
|
|
12
|
+
only?: string[];
|
|
13
|
+
onCancelToken?: (cancelToken: import('axios').CancelTokenSource) => void;
|
|
14
|
+
onBefore?: () => void;
|
|
15
|
+
onStart?: () => void;
|
|
16
|
+
onProgress?: (progress: Progress) => void;
|
|
17
|
+
onFinish?: () => void;
|
|
18
|
+
onCancel?: () => void;
|
|
19
|
+
onSuccess?: () => void;
|
|
20
|
+
onError?: () => void;
|
|
21
|
+
queryStringArrayFormat?: 'indices' | 'brackets';
|
|
22
|
+
}
|
|
23
|
+
type InertiaLinkProps = BaseInertiaLinkProps & Omit<React.HTMLAttributes<HTMLElement>, keyof BaseInertiaLinkProps> & Omit<React.AllHTMLAttributes<HTMLElement>, keyof BaseInertiaLinkProps>;
|
|
24
|
+
type InertiaLink = React.FunctionComponent<InertiaLinkProps>;
|
|
25
|
+
declare const Link: InertiaLink;
|
|
26
|
+
export default Link;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Page, PageProps, PageResolver } from '@inertiajs/core';
|
|
2
|
+
import { ComponentType, FunctionComponent, Key, ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { renderToString } from 'react-dom/server';
|
|
4
|
+
type ReactInstance = ReactElement;
|
|
5
|
+
type ReactComponent = ReactNode;
|
|
6
|
+
type HeadManagerOnUpdate = (elements: string[]) => void;
|
|
7
|
+
type HeadManagerTitleCallback = (title: string) => string;
|
|
8
|
+
type AppType<SharedProps = PageProps> = FunctionComponent<{
|
|
9
|
+
children?: (props: {
|
|
10
|
+
Component: ComponentType;
|
|
11
|
+
key: Key;
|
|
12
|
+
props: Page<SharedProps>['props'];
|
|
13
|
+
}) => ReactNode;
|
|
14
|
+
} & SetupOptions<unknown, SharedProps>['props']>;
|
|
15
|
+
export type SetupOptions<ElementType, SharedProps> = {
|
|
16
|
+
el: ElementType;
|
|
17
|
+
App: AppType;
|
|
18
|
+
props: {
|
|
19
|
+
initialPage: Page<SharedProps>;
|
|
20
|
+
initialComponent: ReactComponent;
|
|
21
|
+
resolveComponent: PageResolver;
|
|
22
|
+
titleCallback?: HeadManagerTitleCallback;
|
|
23
|
+
onHeadUpdate?: HeadManagerOnUpdate;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type BaseInertiaAppOptions = {
|
|
27
|
+
title?: HeadManagerTitleCallback;
|
|
28
|
+
resolve: PageResolver;
|
|
29
|
+
};
|
|
30
|
+
type CreateInertiaAppSetupReturnType = ReactInstance | void;
|
|
31
|
+
type InertiaAppOptionsForCSR<SharedProps> = BaseInertiaAppOptions & {
|
|
32
|
+
id?: string;
|
|
33
|
+
page?: Page | string;
|
|
34
|
+
render?: undefined;
|
|
35
|
+
progress?: false | {
|
|
36
|
+
delay?: number;
|
|
37
|
+
color?: string;
|
|
38
|
+
includeCSS?: boolean;
|
|
39
|
+
showSpinner?: boolean;
|
|
40
|
+
};
|
|
41
|
+
setup(options: SetupOptions<HTMLElement, SharedProps>): CreateInertiaAppSetupReturnType;
|
|
42
|
+
};
|
|
43
|
+
type CreateInertiaAppSSRContent = {
|
|
44
|
+
head: string[];
|
|
45
|
+
body: string;
|
|
46
|
+
};
|
|
47
|
+
type InertiaAppOptionsForSSR<SharedProps> = BaseInertiaAppOptions & {
|
|
48
|
+
id?: undefined;
|
|
49
|
+
page: Page | string;
|
|
50
|
+
render: typeof renderToString;
|
|
51
|
+
progress: undefined;
|
|
52
|
+
setup(options: SetupOptions<null, SharedProps>): ReactInstance;
|
|
53
|
+
};
|
|
54
|
+
export default function createInertiaApp<SharedProps = PageProps>(options: InertiaAppOptionsForCSR<SharedProps>): Promise<CreateInertiaAppSetupReturnType>;
|
|
55
|
+
export default function createInertiaApp<SharedProps = PageProps>(options: InertiaAppOptionsForSSR<SharedProps>): Promise<CreateInertiaAppSSRContent>;
|
|
56
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const router: import("@inertiajs/core").Router;
|
|
2
|
+
export { default as createInertiaApp } from './createInertiaApp';
|
|
3
|
+
export { default as Head } from './Head';
|
|
4
|
+
export { default as Link } from './Link';
|
|
5
|
+
export { default as useForm } from './useForm';
|
|
6
|
+
export { default as usePage } from './usePage';
|
|
7
|
+
export { default as useRemember } from './useRemember';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Method, Progress, VisitOptions } from '@inertiajs/core';
|
|
2
|
+
type setDataByObject<TForm> = (data: TForm) => void;
|
|
3
|
+
type setDataByMethod<TForm> = (data: (previousData: TForm) => TForm) => void;
|
|
4
|
+
type setDataByKeyValuePair<TForm> = <K extends keyof TForm>(key: K, value: TForm[K]) => void;
|
|
5
|
+
export interface InertiaFormProps<TForm extends Record<string, unknown>> {
|
|
6
|
+
data: TForm;
|
|
7
|
+
isDirty: boolean;
|
|
8
|
+
errors: Partial<Record<keyof TForm, string>>;
|
|
9
|
+
hasErrors: boolean;
|
|
10
|
+
processing: boolean;
|
|
11
|
+
progress: Progress | null;
|
|
12
|
+
wasSuccessful: boolean;
|
|
13
|
+
recentlySuccessful: boolean;
|
|
14
|
+
setData: setDataByObject<TForm> & setDataByMethod<TForm> & setDataByKeyValuePair<TForm>;
|
|
15
|
+
transform: (callback: (data: TForm) => TForm) => void;
|
|
16
|
+
setDefaults(): void;
|
|
17
|
+
setDefaults(field: keyof TForm, value: string): void;
|
|
18
|
+
setDefaults(fields: Record<keyof TForm, string>): void;
|
|
19
|
+
reset: (...fields: (keyof TForm)[]) => void;
|
|
20
|
+
clearErrors: (...fields: (keyof TForm)[]) => void;
|
|
21
|
+
setError(field: keyof TForm, value: string): void;
|
|
22
|
+
setError(errors: Record<keyof TForm, string>): void;
|
|
23
|
+
submit: (method: Method, url: string, options?: VisitOptions) => void;
|
|
24
|
+
get: (url: string, options?: VisitOptions) => void;
|
|
25
|
+
patch: (url: string, options?: VisitOptions) => void;
|
|
26
|
+
post: (url: string, options?: VisitOptions) => void;
|
|
27
|
+
put: (url: string, options?: VisitOptions) => void;
|
|
28
|
+
delete: (url: string, options?: VisitOptions) => void;
|
|
29
|
+
cancel: () => void;
|
|
30
|
+
}
|
|
31
|
+
export default function useForm<TForm extends Record<string, unknown>>(initialValues?: TForm): InertiaFormProps<TForm>;
|
|
32
|
+
export default function useForm<TForm extends Record<string, unknown>>(rememberKey: string, initialValues?: TForm): InertiaFormProps<TForm>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export default function useRemember<State>(initialState: State, key?: string): [State, Dispatch<SetStateAction<State>>];
|
|
3
|
+
export declare function useRememberedState<State>(initialState: State, key?: string): [State, Dispatch<SetStateAction<State>>];
|
package/build.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const esbuild = require('esbuild')
|
|
3
|
-
const { nodeExternalsPlugin } = require('esbuild-node-externals')
|
|
4
|
-
|
|
5
|
-
const watch = process.argv.slice(1).includes('--watch')
|
|
6
|
-
|
|
7
|
-
const config = {
|
|
8
|
-
bundle: true,
|
|
9
|
-
minify: true,
|
|
10
|
-
sourcemap: true,
|
|
11
|
-
target: 'es2020',
|
|
12
|
-
plugins: [nodeExternalsPlugin()],
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const builds = [
|
|
16
|
-
{ entryPoints: ['src/index.ts'], format: 'esm', outfile: 'dist/index.esm.js', platform: 'browser' },
|
|
17
|
-
{ entryPoints: ['src/index.ts'], format: 'cjs', outfile: 'dist/index.js', platform: 'browser' },
|
|
18
|
-
{ entryPoints: ['src/server.ts'], format: 'esm', outfile: 'dist/server.esm.js', platform: 'node' },
|
|
19
|
-
{ entryPoints: ['src/server.ts'], format: 'cjs', outfile: 'dist/server.js', platform: 'node' },
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
builds.forEach((build) => {
|
|
23
|
-
esbuild
|
|
24
|
-
.build({ ...config, ...build, ...watcher(build) })
|
|
25
|
-
.then(() => console.log(`${watch ? 'Watching' : 'Built'} ${build.entryPoints} (${build.format})…`))
|
|
26
|
-
.catch(() => process.exit(1))
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
function watcher(build) {
|
|
30
|
-
return watch
|
|
31
|
-
? {
|
|
32
|
-
watch: {
|
|
33
|
-
onRebuild: (error) =>
|
|
34
|
-
error
|
|
35
|
-
? console.error('Watch failed:', error)
|
|
36
|
-
: console.log(`Rebuilding ${build.entryPoints} (${build.format})…`),
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
: {}
|
|
40
|
-
}
|
package/src/App.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createHeadManager, router } from '@inertiajs/core'
|
|
2
|
-
import { createElement, useEffect, useMemo, useState } from 'react'
|
|
3
|
-
import HeadContext from './HeadContext'
|
|
4
|
-
import PageContext from './PageContext'
|
|
5
|
-
|
|
6
|
-
export default function App({
|
|
7
|
-
children,
|
|
8
|
-
initialPage,
|
|
9
|
-
initialComponent,
|
|
10
|
-
resolveComponent,
|
|
11
|
-
titleCallback,
|
|
12
|
-
onHeadUpdate,
|
|
13
|
-
}) {
|
|
14
|
-
const [current, setCurrent] = useState({
|
|
15
|
-
component: initialComponent || null,
|
|
16
|
-
page: initialPage,
|
|
17
|
-
key: null,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const headManager = useMemo(() => {
|
|
21
|
-
return createHeadManager(
|
|
22
|
-
typeof window === 'undefined',
|
|
23
|
-
titleCallback || ((title) => title),
|
|
24
|
-
onHeadUpdate || (() => {}),
|
|
25
|
-
)
|
|
26
|
-
}, [])
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
router.init({
|
|
30
|
-
initialPage,
|
|
31
|
-
resolveComponent,
|
|
32
|
-
swapComponent: async ({ component, page, preserveState }) => {
|
|
33
|
-
setCurrent((current) => ({
|
|
34
|
-
component,
|
|
35
|
-
page,
|
|
36
|
-
key: preserveState ? current.key : Date.now(),
|
|
37
|
-
}))
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
router.on('navigate', () => headManager.forceUpdate())
|
|
42
|
-
}, [])
|
|
43
|
-
|
|
44
|
-
if (!current.component) {
|
|
45
|
-
return createElement(
|
|
46
|
-
HeadContext.Provider,
|
|
47
|
-
{ value: headManager },
|
|
48
|
-
createElement(PageContext.Provider, { value: current.page }, null),
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const renderChildren =
|
|
53
|
-
children ||
|
|
54
|
-
(({ Component, props, key }) => {
|
|
55
|
-
const child = createElement(Component, { key, ...props })
|
|
56
|
-
|
|
57
|
-
if (typeof Component.layout === 'function') {
|
|
58
|
-
return Component.layout(child)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (Array.isArray(Component.layout)) {
|
|
62
|
-
return Component.layout
|
|
63
|
-
.concat(child)
|
|
64
|
-
.reverse()
|
|
65
|
-
.reduce((children, Layout) => createElement(Layout, { children, ...props }))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return child
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
return createElement(
|
|
72
|
-
HeadContext.Provider,
|
|
73
|
-
{ value: headManager },
|
|
74
|
-
createElement(
|
|
75
|
-
PageContext.Provider,
|
|
76
|
-
{ value: current.page },
|
|
77
|
-
renderChildren({
|
|
78
|
-
Component: current.component,
|
|
79
|
-
key: current.key,
|
|
80
|
-
props: current.page.props,
|
|
81
|
-
}),
|
|
82
|
-
),
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
App.displayName = 'Inertia'
|
package/src/Head.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React, { FunctionComponent, useContext, useEffect, useMemo } from 'react'
|
|
2
|
-
import HeadContext from './HeadContext'
|
|
3
|
-
|
|
4
|
-
type InertiaHeadProps = {
|
|
5
|
-
title?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
type InertiaHead = FunctionComponent<InertiaHeadProps>
|
|
9
|
-
|
|
10
|
-
const Head: InertiaHead = function ({ children, title }) {
|
|
11
|
-
const headManager = useContext(HeadContext)
|
|
12
|
-
const provider = useMemo(() => headManager.createProvider(), [headManager])
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
return () => {
|
|
16
|
-
provider.disconnect()
|
|
17
|
-
}
|
|
18
|
-
}, [provider])
|
|
19
|
-
|
|
20
|
-
function isUnaryTag(node) {
|
|
21
|
-
return (
|
|
22
|
-
[
|
|
23
|
-
'area',
|
|
24
|
-
'base',
|
|
25
|
-
'br',
|
|
26
|
-
'col',
|
|
27
|
-
'embed',
|
|
28
|
-
'hr',
|
|
29
|
-
'img',
|
|
30
|
-
'input',
|
|
31
|
-
'keygen',
|
|
32
|
-
'link',
|
|
33
|
-
'meta',
|
|
34
|
-
'param',
|
|
35
|
-
'source',
|
|
36
|
-
'track',
|
|
37
|
-
'wbr',
|
|
38
|
-
].indexOf(node.type) > -1
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function renderTagStart(node) {
|
|
43
|
-
const attrs = Object.keys(node.props).reduce((carry, name) => {
|
|
44
|
-
if (['head-key', 'children', 'dangerouslySetInnerHTML'].includes(name)) {
|
|
45
|
-
return carry
|
|
46
|
-
}
|
|
47
|
-
const value = node.props[name]
|
|
48
|
-
if (value === '') {
|
|
49
|
-
return carry + ` ${name}`
|
|
50
|
-
} else {
|
|
51
|
-
return carry + ` ${name}="${value}"`
|
|
52
|
-
}
|
|
53
|
-
}, '')
|
|
54
|
-
return `<${node.type}${attrs}>`
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function renderTagChildren(node) {
|
|
58
|
-
return typeof node.props.children === 'string'
|
|
59
|
-
? node.props.children
|
|
60
|
-
: node.props.children.reduce((html, child) => html + renderTag(child), '')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function renderTag(node) {
|
|
64
|
-
let html = renderTagStart(node)
|
|
65
|
-
if (node.props.children) {
|
|
66
|
-
html += renderTagChildren(node)
|
|
67
|
-
}
|
|
68
|
-
if (node.props.dangerouslySetInnerHTML) {
|
|
69
|
-
html += node.props.dangerouslySetInnerHTML.__html
|
|
70
|
-
}
|
|
71
|
-
if (!isUnaryTag(node)) {
|
|
72
|
-
html += `</${node.type}>`
|
|
73
|
-
}
|
|
74
|
-
return html
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function ensureNodeHasInertiaProp(node) {
|
|
78
|
-
return React.cloneElement(node, {
|
|
79
|
-
inertia: node.props['head-key'] !== undefined ? node.props['head-key'] : '',
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function renderNode(node) {
|
|
84
|
-
return renderTag(ensureNodeHasInertiaProp(node))
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function renderNodes(nodes) {
|
|
88
|
-
const computed = (Array.isArray(nodes) ? nodes : [nodes]).filter((node) => node).map((node) => renderNode(node))
|
|
89
|
-
if (title && !computed.find((tag) => tag.startsWith('<title'))) {
|
|
90
|
-
computed.push(`<title inertia>${title}</title>`)
|
|
91
|
-
}
|
|
92
|
-
return computed
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
provider.update(renderNodes(children))
|
|
96
|
-
|
|
97
|
-
return null
|
|
98
|
-
}
|
|
99
|
-
export default Head
|
package/src/HeadContext.ts
DELETED
package/src/Link.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FormDataConvertible,
|
|
3
|
-
mergeDataIntoQueryString,
|
|
4
|
-
Method,
|
|
5
|
-
PreserveStateOption,
|
|
6
|
-
Progress,
|
|
7
|
-
router,
|
|
8
|
-
shouldIntercept,
|
|
9
|
-
} from '@inertiajs/core'
|
|
10
|
-
import { createElement, forwardRef, useCallback } from 'react'
|
|
11
|
-
|
|
12
|
-
const noop = () => undefined
|
|
13
|
-
|
|
14
|
-
interface BaseInertiaLinkProps {
|
|
15
|
-
as?: string
|
|
16
|
-
data?: Record<string, FormDataConvertible>
|
|
17
|
-
href: string
|
|
18
|
-
method?: Method
|
|
19
|
-
headers?: Record<string, string>
|
|
20
|
-
onClick?: (event: React.MouseEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLAnchorElement>) => void
|
|
21
|
-
preserveScroll?: PreserveStateOption
|
|
22
|
-
preserveState?: PreserveStateOption
|
|
23
|
-
replace?: boolean
|
|
24
|
-
only?: string[]
|
|
25
|
-
onCancelToken?: (cancelToken: import('axios').CancelTokenSource) => void
|
|
26
|
-
onBefore?: () => void
|
|
27
|
-
onStart?: () => void
|
|
28
|
-
onProgress?: (progress: Progress) => void
|
|
29
|
-
onFinish?: () => void
|
|
30
|
-
onCancel?: () => void
|
|
31
|
-
onSuccess?: () => void
|
|
32
|
-
onError?: () => void
|
|
33
|
-
queryStringArrayFormat?: 'indices' | 'brackets'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type InertiaLinkProps = BaseInertiaLinkProps &
|
|
37
|
-
Omit<React.HTMLAttributes<HTMLElement>, keyof BaseInertiaLinkProps> &
|
|
38
|
-
Omit<React.AllHTMLAttributes<HTMLElement>, keyof BaseInertiaLinkProps>
|
|
39
|
-
|
|
40
|
-
type InertiaLink = React.FunctionComponent<InertiaLinkProps>
|
|
41
|
-
|
|
42
|
-
const Link: InertiaLink = forwardRef<unknown, InertiaLinkProps>(
|
|
43
|
-
(
|
|
44
|
-
{
|
|
45
|
-
children,
|
|
46
|
-
as = 'a',
|
|
47
|
-
data = {},
|
|
48
|
-
href,
|
|
49
|
-
method = Method.GET,
|
|
50
|
-
preserveScroll = false,
|
|
51
|
-
preserveState = null,
|
|
52
|
-
replace = false,
|
|
53
|
-
only = [],
|
|
54
|
-
headers = {},
|
|
55
|
-
queryStringArrayFormat = 'brackets',
|
|
56
|
-
onClick = noop,
|
|
57
|
-
onCancelToken = noop,
|
|
58
|
-
onBefore = noop,
|
|
59
|
-
onStart = noop,
|
|
60
|
-
onProgress = noop,
|
|
61
|
-
onFinish = noop,
|
|
62
|
-
onCancel = noop,
|
|
63
|
-
onSuccess = noop,
|
|
64
|
-
onError = noop,
|
|
65
|
-
...props
|
|
66
|
-
},
|
|
67
|
-
ref,
|
|
68
|
-
) => {
|
|
69
|
-
const visit = useCallback(
|
|
70
|
-
(event) => {
|
|
71
|
-
onClick(event)
|
|
72
|
-
|
|
73
|
-
if (shouldIntercept(event)) {
|
|
74
|
-
event.preventDefault()
|
|
75
|
-
|
|
76
|
-
router.visit(href, {
|
|
77
|
-
data,
|
|
78
|
-
method,
|
|
79
|
-
preserveScroll,
|
|
80
|
-
preserveState: preserveState ?? method !== 'get',
|
|
81
|
-
replace,
|
|
82
|
-
only,
|
|
83
|
-
headers,
|
|
84
|
-
onCancelToken,
|
|
85
|
-
onBefore,
|
|
86
|
-
onStart,
|
|
87
|
-
onProgress,
|
|
88
|
-
onFinish,
|
|
89
|
-
onCancel,
|
|
90
|
-
onSuccess,
|
|
91
|
-
onError,
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
[
|
|
96
|
-
data,
|
|
97
|
-
href,
|
|
98
|
-
method,
|
|
99
|
-
preserveScroll,
|
|
100
|
-
preserveState,
|
|
101
|
-
replace,
|
|
102
|
-
only,
|
|
103
|
-
headers,
|
|
104
|
-
onClick,
|
|
105
|
-
onCancelToken,
|
|
106
|
-
onBefore,
|
|
107
|
-
onStart,
|
|
108
|
-
onProgress,
|
|
109
|
-
onFinish,
|
|
110
|
-
onCancel,
|
|
111
|
-
onSuccess,
|
|
112
|
-
onError,
|
|
113
|
-
],
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
as = as.toLowerCase()
|
|
117
|
-
method = method.toLowerCase() as Method
|
|
118
|
-
const [_href, _data] = mergeDataIntoQueryString(method, href || '', data, queryStringArrayFormat)
|
|
119
|
-
href = _href
|
|
120
|
-
data = _data
|
|
121
|
-
|
|
122
|
-
if (as === 'a' && method !== 'get') {
|
|
123
|
-
console.warn(
|
|
124
|
-
`Creating POST/PUT/PATCH/DELETE <a> links is discouraged as it causes "Open Link in New Tab/Window" accessibility issues.\n\nPlease specify a more appropriate element using the "as" attribute. For example:\n\n<Link href="${href}" method="${method}" as="button">...</Link>`,
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return createElement(
|
|
129
|
-
as,
|
|
130
|
-
{
|
|
131
|
-
...props,
|
|
132
|
-
...(as === 'a' ? { href } : {}),
|
|
133
|
-
ref,
|
|
134
|
-
onClick: visit,
|
|
135
|
-
},
|
|
136
|
-
children,
|
|
137
|
-
)
|
|
138
|
-
},
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
export default Link
|
package/src/PageContext.ts
DELETED
package/src/createInertiaApp.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Page, PageProps, PageResolver, setupProgress } from '@inertiajs/core'
|
|
2
|
-
import { ComponentType, createElement, FunctionComponent, Key, ReactElement, ReactNode } from 'react'
|
|
3
|
-
import { renderToString } from 'react-dom/server'
|
|
4
|
-
import App from './App'
|
|
5
|
-
|
|
6
|
-
type ReactInstance = ReactElement
|
|
7
|
-
type ReactComponent = ReactNode
|
|
8
|
-
|
|
9
|
-
type HeadManagerOnUpdate = (elements: string[]) => void // TODO: When shipped, replace with: Inertia.HeadManagerOnUpdate
|
|
10
|
-
type HeadManagerTitleCallback = (title: string) => string // TODO: When shipped, replace with: Inertia.HeadManagerTitleCallback
|
|
11
|
-
|
|
12
|
-
type AppType<SharedProps = PageProps> = FunctionComponent<
|
|
13
|
-
{
|
|
14
|
-
children?: (props: { Component: ComponentType; key: Key; props: Page<SharedProps>['props'] }) => ReactNode
|
|
15
|
-
} & SetupOptions<unknown, SharedProps>['props']
|
|
16
|
-
>
|
|
17
|
-
|
|
18
|
-
export type SetupOptions<ElementType, SharedProps> = {
|
|
19
|
-
el: ElementType
|
|
20
|
-
App: AppType
|
|
21
|
-
props: {
|
|
22
|
-
initialPage: Page<SharedProps>
|
|
23
|
-
initialComponent: ReactComponent
|
|
24
|
-
resolveComponent: PageResolver
|
|
25
|
-
titleCallback?: HeadManagerTitleCallback
|
|
26
|
-
onHeadUpdate?: HeadManagerOnUpdate
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type BaseInertiaAppOptions = {
|
|
31
|
-
title?: HeadManagerTitleCallback
|
|
32
|
-
resolve: PageResolver
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type CreateInertiaAppSetupReturnType = ReactInstance | void
|
|
36
|
-
type InertiaAppOptionsForCSR<SharedProps> = BaseInertiaAppOptions & {
|
|
37
|
-
id?: string
|
|
38
|
-
page?: Page | string
|
|
39
|
-
render?: undefined
|
|
40
|
-
progress?:
|
|
41
|
-
| false
|
|
42
|
-
| {
|
|
43
|
-
delay?: number
|
|
44
|
-
color?: string
|
|
45
|
-
includeCSS?: boolean
|
|
46
|
-
showSpinner?: boolean
|
|
47
|
-
}
|
|
48
|
-
setup(options: SetupOptions<HTMLElement, SharedProps>): CreateInertiaAppSetupReturnType
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type CreateInertiaAppSSRContent = { head: string[]; body: string }
|
|
52
|
-
type InertiaAppOptionsForSSR<SharedProps> = BaseInertiaAppOptions & {
|
|
53
|
-
id?: undefined
|
|
54
|
-
page: Page | string
|
|
55
|
-
render: typeof renderToString
|
|
56
|
-
progress: undefined
|
|
57
|
-
setup(options: SetupOptions<null, SharedProps>): ReactInstance
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default async function createInertiaApp<SharedProps = PageProps>(
|
|
61
|
-
options: InertiaAppOptionsForCSR<SharedProps>,
|
|
62
|
-
): Promise<CreateInertiaAppSetupReturnType>
|
|
63
|
-
export default async function createInertiaApp<SharedProps = PageProps>(
|
|
64
|
-
options: InertiaAppOptionsForSSR<SharedProps>,
|
|
65
|
-
): Promise<CreateInertiaAppSSRContent>
|
|
66
|
-
export default async function createInertiaApp<SharedProps = PageProps>({
|
|
67
|
-
id = 'app',
|
|
68
|
-
resolve,
|
|
69
|
-
setup,
|
|
70
|
-
title,
|
|
71
|
-
progress = {},
|
|
72
|
-
page,
|
|
73
|
-
render,
|
|
74
|
-
}: InertiaAppOptionsForCSR<SharedProps> | InertiaAppOptionsForSSR<SharedProps>): Promise<
|
|
75
|
-
CreateInertiaAppSetupReturnType | CreateInertiaAppSSRContent
|
|
76
|
-
> {
|
|
77
|
-
const isServer = typeof window === 'undefined'
|
|
78
|
-
const el = isServer ? null : document.getElementById(id)
|
|
79
|
-
const initialPage = page || JSON.parse(el.dataset.page)
|
|
80
|
-
// @ts-expect-error
|
|
81
|
-
const resolveComponent = (name) => Promise.resolve(resolve(name)).then((module) => module.default || module)
|
|
82
|
-
|
|
83
|
-
let head = []
|
|
84
|
-
|
|
85
|
-
const reactApp = await resolveComponent(initialPage.component).then((initialComponent) => {
|
|
86
|
-
return setup({
|
|
87
|
-
// @ts-expect-error
|
|
88
|
-
el,
|
|
89
|
-
App,
|
|
90
|
-
props: {
|
|
91
|
-
initialPage,
|
|
92
|
-
initialComponent,
|
|
93
|
-
resolveComponent,
|
|
94
|
-
titleCallback: title,
|
|
95
|
-
onHeadUpdate: isServer ? (elements) => (head = elements) : null,
|
|
96
|
-
},
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
if (!isServer && progress) {
|
|
101
|
-
setupProgress(progress)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (isServer) {
|
|
105
|
-
const body = await render(
|
|
106
|
-
createElement(
|
|
107
|
-
'div',
|
|
108
|
-
{
|
|
109
|
-
id,
|
|
110
|
-
'data-page': JSON.stringify(initialPage),
|
|
111
|
-
},
|
|
112
|
-
// @ts-expect-error
|
|
113
|
-
reactApp,
|
|
114
|
-
),
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
return { head, body }
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { router as Router } from '@inertiajs/core'
|
|
2
|
-
|
|
3
|
-
export const router = Router
|
|
4
|
-
export { default as createInertiaApp } from './createInertiaApp'
|
|
5
|
-
export { default as Head } from './Head'
|
|
6
|
-
export { default as Link } from './Link'
|
|
7
|
-
export { default as useForm } from './useForm'
|
|
8
|
-
export { default as usePage } from './usePage'
|
|
9
|
-
export { default as useRemember } from './useRemember'
|
package/src/server.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as default } from '@inertiajs/core/server'
|
package/src/useForm.ts
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { Method, Progress, router, VisitOptions } from '@inertiajs/core'
|
|
2
|
-
import isEqual from 'lodash.isequal'
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
4
|
-
import useRemember from './useRemember'
|
|
5
|
-
|
|
6
|
-
type setDataByObject<TForm> = (data: TForm) => void
|
|
7
|
-
type setDataByMethod<TForm> = (data: (previousData: TForm) => TForm) => void
|
|
8
|
-
type setDataByKeyValuePair<TForm> = <K extends keyof TForm>(key: K, value: TForm[K]) => void
|
|
9
|
-
|
|
10
|
-
export interface InertiaFormProps<TForm extends Record<string, unknown>> {
|
|
11
|
-
data: TForm
|
|
12
|
-
isDirty: boolean
|
|
13
|
-
errors: Partial<Record<keyof TForm, string>>
|
|
14
|
-
hasErrors: boolean
|
|
15
|
-
processing: boolean
|
|
16
|
-
progress: Progress | null
|
|
17
|
-
wasSuccessful: boolean
|
|
18
|
-
recentlySuccessful: boolean
|
|
19
|
-
setData: setDataByObject<TForm> & setDataByMethod<TForm> & setDataByKeyValuePair<TForm>
|
|
20
|
-
transform: (callback: (data: TForm) => TForm) => void
|
|
21
|
-
setDefaults(): void
|
|
22
|
-
setDefaults(field: keyof TForm, value: string): void
|
|
23
|
-
setDefaults(fields: Record<keyof TForm, string>): void
|
|
24
|
-
reset: (...fields: (keyof TForm)[]) => void
|
|
25
|
-
clearErrors: (...fields: (keyof TForm)[]) => void
|
|
26
|
-
setError(field: keyof TForm, value: string): void
|
|
27
|
-
setError(errors: Record<keyof TForm, string>): void
|
|
28
|
-
submit: (method: Method, url: string, options?: VisitOptions) => void
|
|
29
|
-
get: (url: string, options?: VisitOptions) => void
|
|
30
|
-
patch: (url: string, options?: VisitOptions) => void
|
|
31
|
-
post: (url: string, options?: VisitOptions) => void
|
|
32
|
-
put: (url: string, options?: VisitOptions) => void
|
|
33
|
-
delete: (url: string, options?: VisitOptions) => void
|
|
34
|
-
cancel: () => void
|
|
35
|
-
}
|
|
36
|
-
export default function useForm<TForm extends Record<string, unknown>>(initialValues?: TForm): InertiaFormProps<TForm>
|
|
37
|
-
export default function useForm<TForm extends Record<string, unknown>>(
|
|
38
|
-
rememberKey: string,
|
|
39
|
-
initialValues?: TForm,
|
|
40
|
-
): InertiaFormProps<TForm>
|
|
41
|
-
export default function useForm<TForm extends Record<string, unknown>>(
|
|
42
|
-
rememberKeyOrInitialValues?: string | TForm,
|
|
43
|
-
maybeInitialValues?: TForm,
|
|
44
|
-
): InertiaFormProps<TForm> {
|
|
45
|
-
const isMounted = useRef(null)
|
|
46
|
-
const rememberKey = typeof rememberKeyOrInitialValues === 'string' ? rememberKeyOrInitialValues : null
|
|
47
|
-
const [defaults, setDefaults] = useState(
|
|
48
|
-
(typeof rememberKeyOrInitialValues === 'string' ? maybeInitialValues : rememberKeyOrInitialValues) || ({} as TForm),
|
|
49
|
-
)
|
|
50
|
-
const cancelToken = useRef(null)
|
|
51
|
-
const recentlySuccessfulTimeoutId = useRef(null)
|
|
52
|
-
const [data, setData] = rememberKey ? useRemember(defaults, `${rememberKey}:data`) : useState(defaults)
|
|
53
|
-
const [errors, setErrors] = rememberKey
|
|
54
|
-
? useRemember({} as Partial<Record<keyof TForm, string>>, `${rememberKey}:errors`)
|
|
55
|
-
: useState({} as Partial<Record<keyof TForm, string>>)
|
|
56
|
-
const [hasErrors, setHasErrors] = useState(false)
|
|
57
|
-
const [processing, setProcessing] = useState(false)
|
|
58
|
-
const [progress, setProgress] = useState(null)
|
|
59
|
-
const [wasSuccessful, setWasSuccessful] = useState(false)
|
|
60
|
-
const [recentlySuccessful, setRecentlySuccessful] = useState(false)
|
|
61
|
-
let transform = (data) => data
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
isMounted.current = true
|
|
65
|
-
return () => {
|
|
66
|
-
isMounted.current = false
|
|
67
|
-
}
|
|
68
|
-
}, [])
|
|
69
|
-
|
|
70
|
-
const submit = useCallback(
|
|
71
|
-
(method, url, options = {}) => {
|
|
72
|
-
const _options = {
|
|
73
|
-
...options,
|
|
74
|
-
onCancelToken: (token) => {
|
|
75
|
-
cancelToken.current = token
|
|
76
|
-
|
|
77
|
-
if (options.onCancelToken) {
|
|
78
|
-
return options.onCancelToken(token)
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
onBefore: (visit) => {
|
|
82
|
-
setWasSuccessful(false)
|
|
83
|
-
setRecentlySuccessful(false)
|
|
84
|
-
clearTimeout(recentlySuccessfulTimeoutId.current)
|
|
85
|
-
|
|
86
|
-
if (options.onBefore) {
|
|
87
|
-
return options.onBefore(visit)
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
onStart: (visit) => {
|
|
91
|
-
setProcessing(true)
|
|
92
|
-
|
|
93
|
-
if (options.onStart) {
|
|
94
|
-
return options.onStart(visit)
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
onProgress: (event) => {
|
|
98
|
-
setProgress(event)
|
|
99
|
-
|
|
100
|
-
if (options.onProgress) {
|
|
101
|
-
return options.onProgress(event)
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
onSuccess: (page) => {
|
|
105
|
-
if (isMounted.current) {
|
|
106
|
-
setProcessing(false)
|
|
107
|
-
setProgress(null)
|
|
108
|
-
setErrors({})
|
|
109
|
-
setHasErrors(false)
|
|
110
|
-
setWasSuccessful(true)
|
|
111
|
-
setRecentlySuccessful(true)
|
|
112
|
-
recentlySuccessfulTimeoutId.current = setTimeout(() => {
|
|
113
|
-
if (isMounted.current) {
|
|
114
|
-
setRecentlySuccessful(false)
|
|
115
|
-
}
|
|
116
|
-
}, 2000)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (options.onSuccess) {
|
|
120
|
-
return options.onSuccess(page)
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
onError: (errors) => {
|
|
124
|
-
if (isMounted.current) {
|
|
125
|
-
setProcessing(false)
|
|
126
|
-
setProgress(null)
|
|
127
|
-
setErrors(errors)
|
|
128
|
-
setHasErrors(true)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (options.onError) {
|
|
132
|
-
return options.onError(errors)
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
onCancel: () => {
|
|
136
|
-
if (isMounted.current) {
|
|
137
|
-
setProcessing(false)
|
|
138
|
-
setProgress(null)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (options.onCancel) {
|
|
142
|
-
return options.onCancel()
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
onFinish: () => {
|
|
146
|
-
if (isMounted.current) {
|
|
147
|
-
setProcessing(false)
|
|
148
|
-
setProgress(null)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
cancelToken.current = null
|
|
152
|
-
|
|
153
|
-
if (options.onFinish) {
|
|
154
|
-
return options.onFinish()
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (method === 'delete') {
|
|
160
|
-
router.delete(url, { ..._options, data: transform(data) })
|
|
161
|
-
} else {
|
|
162
|
-
router[method](url, transform(data), _options)
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
[data, setErrors],
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
data,
|
|
170
|
-
setData(keyOrData: keyof TForm | Function | TForm, maybeValue?: TForm[keyof TForm]) {
|
|
171
|
-
if (typeof keyOrData === 'string') {
|
|
172
|
-
setData({ ...data, [keyOrData]: maybeValue })
|
|
173
|
-
} else if (typeof keyOrData === 'function') {
|
|
174
|
-
setData((data) => keyOrData(data))
|
|
175
|
-
} else {
|
|
176
|
-
setData(keyOrData as TForm)
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
isDirty: !isEqual(data, defaults),
|
|
180
|
-
errors,
|
|
181
|
-
hasErrors,
|
|
182
|
-
processing,
|
|
183
|
-
progress,
|
|
184
|
-
wasSuccessful,
|
|
185
|
-
recentlySuccessful,
|
|
186
|
-
transform(callback) {
|
|
187
|
-
transform = callback
|
|
188
|
-
},
|
|
189
|
-
setDefaults(fieldOrFields?: keyof TForm | Record<keyof TForm, string>, maybeValue?: string) {
|
|
190
|
-
if (typeof fieldOrFields === 'undefined') {
|
|
191
|
-
setDefaults(() => data)
|
|
192
|
-
} else {
|
|
193
|
-
setDefaults((defaults) => ({
|
|
194
|
-
...defaults,
|
|
195
|
-
...(typeof fieldOrFields === 'string' ? { [fieldOrFields]: maybeValue } : (fieldOrFields as TForm)),
|
|
196
|
-
}))
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
reset(...fields) {
|
|
200
|
-
if (fields.length === 0) {
|
|
201
|
-
setData(defaults)
|
|
202
|
-
} else {
|
|
203
|
-
setData(
|
|
204
|
-
(Object.keys(defaults) as Array<keyof TForm>)
|
|
205
|
-
.filter((key) => fields.includes(key))
|
|
206
|
-
.reduce(
|
|
207
|
-
(carry, key) => {
|
|
208
|
-
carry[key] = defaults[key]
|
|
209
|
-
return carry
|
|
210
|
-
},
|
|
211
|
-
{ ...data },
|
|
212
|
-
),
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
setError(fieldOrFields: keyof TForm | Record<keyof TForm, string>, maybeValue?: string) {
|
|
217
|
-
setErrors((errors) => {
|
|
218
|
-
const newErrors = {
|
|
219
|
-
...errors,
|
|
220
|
-
...(typeof fieldOrFields === 'string'
|
|
221
|
-
? { [fieldOrFields]: maybeValue }
|
|
222
|
-
: (fieldOrFields as Record<keyof TForm, string>)),
|
|
223
|
-
}
|
|
224
|
-
setHasErrors(Object.keys(newErrors).length > 0)
|
|
225
|
-
return newErrors
|
|
226
|
-
})
|
|
227
|
-
},
|
|
228
|
-
clearErrors(...fields) {
|
|
229
|
-
setErrors((errors) => {
|
|
230
|
-
const newErrors = (Object.keys(errors) as Array<keyof TForm>).reduce(
|
|
231
|
-
(carry, field) => ({
|
|
232
|
-
...carry,
|
|
233
|
-
...(fields.length > 0 && !fields.includes(field) ? { [field]: errors[field] } : {}),
|
|
234
|
-
}),
|
|
235
|
-
{},
|
|
236
|
-
)
|
|
237
|
-
setHasErrors(Object.keys(newErrors).length > 0)
|
|
238
|
-
return newErrors
|
|
239
|
-
})
|
|
240
|
-
},
|
|
241
|
-
submit,
|
|
242
|
-
get(url, options) {
|
|
243
|
-
submit('get', url, options)
|
|
244
|
-
},
|
|
245
|
-
post(url, options) {
|
|
246
|
-
submit('post', url, options)
|
|
247
|
-
},
|
|
248
|
-
put(url, options) {
|
|
249
|
-
submit('put', url, options)
|
|
250
|
-
},
|
|
251
|
-
patch(url, options) {
|
|
252
|
-
submit('patch', url, options)
|
|
253
|
-
},
|
|
254
|
-
delete(url, options) {
|
|
255
|
-
submit('delete', url, options)
|
|
256
|
-
},
|
|
257
|
-
cancel() {
|
|
258
|
-
if (cancelToken.current) {
|
|
259
|
-
cancelToken.current.cancel()
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
}
|
|
263
|
-
}
|
package/src/usePage.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Page } from '@inertiajs/core'
|
|
2
|
-
import { useContext } from 'react'
|
|
3
|
-
import PageContext from './PageContext'
|
|
4
|
-
|
|
5
|
-
export default function usePage(): Page {
|
|
6
|
-
const page = useContext(PageContext)
|
|
7
|
-
|
|
8
|
-
if (!page) {
|
|
9
|
-
throw new Error('usePage must be used within the Inertia component')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return page
|
|
13
|
-
}
|
package/src/useRemember.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { router } from '@inertiajs/core'
|
|
2
|
-
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
export default function useRemember<State>(
|
|
5
|
-
initialState: State,
|
|
6
|
-
key?: string,
|
|
7
|
-
): [State, Dispatch<SetStateAction<State>>] {
|
|
8
|
-
const [state, setState] = useState(() => {
|
|
9
|
-
const restored = router.restore(key) as State
|
|
10
|
-
|
|
11
|
-
return restored !== undefined ? restored : initialState
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
router.remember(state, key)
|
|
16
|
-
}, [state, key])
|
|
17
|
-
|
|
18
|
-
return [state, setState]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** @deprecated use `useRemember` instead */
|
|
22
|
-
export function useRememberedState<State>(initialState: State, key?: string): [State, Dispatch<SetStateAction<State>>] {
|
|
23
|
-
console.warn(
|
|
24
|
-
'The "useRememberedState" hook has been deprecated and will be removed in a future release. Use "useRemember" instead.',
|
|
25
|
-
)
|
|
26
|
-
return useRemember(initialState, key)
|
|
27
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["src/index.ts"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"noEmitOnError": true,
|
|
6
|
-
|
|
7
|
-
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
|
8
|
-
"target": "ES2020",
|
|
9
|
-
"types": ["node"],
|
|
10
|
-
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"declarationDir": "types",
|
|
13
|
-
|
|
14
|
-
"module": "ES2020",
|
|
15
|
-
"moduleResolution": "Node",
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"allowSyntheticDefaultImports": true,
|
|
18
|
-
|
|
19
|
-
"noImplicitThis": false,
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
"preserveConstEnums": true,
|
|
23
|
-
"removeComments": true,
|
|
24
|
-
"typeRoots": ["./node_modules/@types"]
|
|
25
|
-
// "strict": true
|
|
26
|
-
}
|
|
27
|
-
}
|