@inertiajs/react
Advanced tools
+16
-9
@@ -256,4 +256,6 @@ // src/index.ts | ||
| import React2, { | ||
| createContext as createContext3, | ||
| createElement as createElement3, | ||
| forwardRef, | ||
| useContext, | ||
| useEffect as useEffect6, | ||
@@ -398,4 +400,3 @@ useImperativeHandle, | ||
| setProgress(null); | ||
| setErrors(errors2); | ||
| setHasErrors(true); | ||
| setError(errors2); | ||
| } | ||
@@ -674,2 +675,3 @@ if (options.onError) { | ||
| var noop = () => void 0; | ||
| var FormContext = createContext3(void 0); | ||
| var Form = forwardRef( | ||
@@ -821,3 +823,3 @@ ({ | ||
| }; | ||
| const exposed = () => ({ | ||
| const exposed = { | ||
| errors: form.errors, | ||
@@ -846,5 +848,5 @@ hasErrors: form.hasErrors, | ||
| touched: form.touched | ||
| }); | ||
| useImperativeHandle(ref, exposed, [form, isDirty, submit]); | ||
| return createElement3( | ||
| }; | ||
| useImperativeHandle(ref, () => exposed, [form, isDirty, submit]); | ||
| const formNode = createElement3( | ||
| "form", | ||
@@ -866,7 +868,11 @@ { | ||
| }, | ||
| typeof children === "function" ? children(exposed()) : children | ||
| typeof children === "function" ? children(exposed) : children | ||
| ); | ||
| return createElement3(FormContext.Provider, { value: exposed }, formNode); | ||
| } | ||
| ); | ||
| Form.displayName = "InertiaForm"; | ||
| function useFormContext() { | ||
| return useContext(FormContext); | ||
| } | ||
| var Form_default = Form; | ||
@@ -876,5 +882,5 @@ | ||
| import { escape } from "lodash-es"; | ||
| import React3, { useContext, useEffect as useEffect7, useMemo as useMemo5 } from "react"; | ||
| import React3, { useContext as useContext2, useEffect as useEffect7, useMemo as useMemo5 } from "react"; | ||
| var Head = function({ children, title }) { | ||
| const headManager = useContext(HeadContext_default); | ||
| const headManager = useContext2(HeadContext_default); | ||
| const provider = useMemo5(() => headManager.createProvider(), [headManager]); | ||
@@ -1629,2 +1635,3 @@ const isServer = typeof window === "undefined"; | ||
| useForm, | ||
| useFormContext, | ||
| usePage, | ||
@@ -1631,0 +1638,0 @@ usePoll, |
+12
-7
@@ -45,2 +45,3 @@ "use strict"; | ||
| useForm: () => useForm, | ||
| useFormContext: () => useFormContext, | ||
| usePage: () => usePage, | ||
@@ -419,4 +420,3 @@ usePoll: () => usePoll, | ||
| setProgress(null); | ||
| setErrors(errors2); | ||
| setHasErrors(true); | ||
| setError(errors2); | ||
| } | ||
@@ -695,2 +695,3 @@ if (options.onError) { | ||
| var noop = () => void 0; | ||
| var FormContext = (0, import_react11.createContext)(void 0); | ||
| var Form = (0, import_react11.forwardRef)( | ||
@@ -842,3 +843,3 @@ ({ | ||
| }; | ||
| const exposed = () => ({ | ||
| const exposed = { | ||
| errors: form.errors, | ||
@@ -867,5 +868,5 @@ hasErrors: form.hasErrors, | ||
| touched: form.touched | ||
| }); | ||
| (0, import_react11.useImperativeHandle)(ref, exposed, [form, isDirty, submit]); | ||
| return (0, import_react11.createElement)( | ||
| }; | ||
| (0, import_react11.useImperativeHandle)(ref, () => exposed, [form, isDirty, submit]); | ||
| const formNode = (0, import_react11.createElement)( | ||
| "form", | ||
@@ -887,7 +888,11 @@ { | ||
| }, | ||
| typeof children === "function" ? children(exposed()) : children | ||
| typeof children === "function" ? children(exposed) : children | ||
| ); | ||
| return (0, import_react11.createElement)(FormContext.Provider, { value: exposed }, formNode); | ||
| } | ||
| ); | ||
| Form.displayName = "InertiaForm"; | ||
| function useFormContext() { | ||
| return (0, import_react11.useContext)(FormContext); | ||
| } | ||
| var Form_default = Form; | ||
@@ -894,0 +899,0 @@ |
+2
-2
| { | ||
| "name": "@inertiajs/react", | ||
| "version": "2.3.8", | ||
| "version": "2.3.9", | ||
| "license": "MIT", | ||
@@ -64,3 +64,3 @@ "description": "The React adapter for Inertia.js", | ||
| "lodash-es": "^4.17.21", | ||
| "@inertiajs/core": "2.3.8" | ||
| "@inertiajs/core": "2.3.9" | ||
| }, | ||
@@ -67,0 +67,0 @@ "scripts": { |
+2
-1
@@ -1,2 +0,2 @@ | ||
| import { FormComponentSlotProps, FormDataConvertible, Method } from '@inertiajs/core'; | ||
| import { FormComponentRef, FormComponentSlotProps, FormDataConvertible, Method } from '@inertiajs/core'; | ||
| import React, { ReactNode } from 'react'; | ||
@@ -19,2 +19,3 @@ declare const Form: React.ForwardRefExoticComponent<Partial<Pick<import("@inertiajs/core").Visit<import("@inertiajs/core").RequestPayload>, "headers" | "errorBag" | "queryStringArrayFormat" | "showProgress" | "invalidateCacheTags"> & Omit<import("@inertiajs/core").VisitCallbacks<import("@inertiajs/core").RequestPayload>, "onPrefetched" | "onPrefetching">> & { | ||
| } & React.RefAttributes<FormComponentSlotProps>>; | ||
| export declare function useFormContext(): FormComponentRef | undefined; | ||
| export default Form; |
+1
-1
@@ -17,3 +17,3 @@ export declare const progress: { | ||
| export { default as Deferred } from './Deferred'; | ||
| export { default as Form } from './Form'; | ||
| export { default as Form, useFormContext } from './Form'; | ||
| export { default as Head } from './Head'; | ||
@@ -20,0 +20,0 @@ export { default as InfiniteScroll } from './InfiniteScroll'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
336974
0.44%3507
0.37%+ Added
- Removed
Updated