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

laravel-precognition-react-inertia

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

laravel-precognition-react-inertia - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

4

dist/index.d.ts
import { RequestMethod, ValidationConfig } from 'laravel-precognition';
export declare const useForm: <Data extends Record<string, unknown>>(method: RequestMethod, url: string, inputs: Data, config?: ValidationConfig) => any;
import { client } from 'laravel-precognition-react';
export { client };
export declare const useForm: <Data extends Record<string, unknown>>(method: RequestMethod | (() => RequestMethod), url: string | (() => string), inputs: Data, config?: ValidationConfig) => any;

@@ -1,8 +0,7 @@

import { toSimpleValidationErrors } from 'laravel-precognition';
import { useForm as usePrecognitiveForm } from 'laravel-precognition-react';
import { toSimpleValidationErrors, resolveUrl, resolveMethod } from 'laravel-precognition';
import { useForm as usePrecognitiveForm, client } from 'laravel-precognition-react';
import { useForm as useInertiaForm } from '@inertiajs/react';
import { useRef } from 'react';
export { client };
export const useForm = (method, url, inputs, config = {}) => {
// @ts-expect-error
method = method.toLowerCase();
const booted = useRef(false);

@@ -52,5 +51,9 @@ /**

*/
return Object.assign(inertiaForm, {
const form = Object.assign(inertiaForm, {
validating: precognitiveForm.validating,
touched: precognitiveForm.touched,
touch(name) {
precognitiveForm.touch(name);
return form;
},
valid: precognitiveForm.valid,

@@ -61,3 +64,3 @@ invalid: precognitiveForm.invalid,

precognitiveForm.setData(key, value);
return this;
return form;
},

@@ -72,3 +75,3 @@ clearErrors(...names) {

}
return this;
return form;
},

@@ -82,6 +85,6 @@ reset(...names) {

precognitiveForm.setErrors(errors);
return this;
return form;
},
setError(key, value) {
this.setErrors({
form.setErrors({
...inertiaForm.errors,

@@ -92,7 +95,7 @@ ...typeof value === 'undefined'

});
return this;
return form;
},
forgetError(name) {
precognitiveForm.forgetError(name);
return this;
return form;
},

@@ -102,32 +105,36 @@ validate(name) {

precognitiveForm.validate(name);
return this;
return form;
},
setValidationTimeout(duration) {
precognitiveForm.setValidationTimeout(duration);
return this;
return form;
},
validateFiles() {
precognitiveForm.validateFiles();
return this;
return form;
},
submit(submitMethod = {}, submitUrl, submitOptions) {
const isPatchedCall = typeof submitMethod !== 'string';
const userOptions = isPatchedCall
submitOptions = isPatchedCall
? submitMethod
: submitOptions;
const options = {
...userOptions,
submitUrl = isPatchedCall
? resolveUrl(url)
: submitUrl;
submitMethod = isPatchedCall
? resolveMethod(method)
: submitMethod;
inertiaSubmit(submitMethod, submitUrl, {
...submitOptions,
onError: (errors) => {
precognitiveForm.validator().setErrors(errors);
if (userOptions.onError) {
return userOptions.onError(errors);
if (submitOptions.onError) {
return submitOptions.onError(errors);
}
},
};
inertiaSubmit(isPatchedCall ? method : submitMethod,
// @ts-expect-error
(isPatchedCall ? url : submitUrl), options);
});
},
validator: precognitiveForm.validator,
});
return form;
};
{
"name": "laravel-precognition-react-inertia",
"version": "0.3.2",
"version": "0.4.0",
"description": "Laravel Precognition (React w/ Inertia).",

@@ -36,4 +36,4 @@ "keywords": [

"dependencies": {
"laravel-precognition": "0.3.2",
"laravel-precognition-react": "0.3.2"
"laravel-precognition": "0.4.0",
"laravel-precognition-react": "0.4.0"
},

@@ -40,0 +40,0 @@ "devDependencies": {

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