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.2.2 to 0.3.0

37

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

@@ -14,11 +18,2 @@ * The Inertia form.

/**
* Setup event listeners.
*/
precognitiveForm.validator().on('errorsChanged', () => {
inertiaClearErrors();
inertiaSetError(
// @ts-expect-error
toSimpleValidationErrors(precognitiveForm.validator().errors()));
});
/**
* The Inertia submit function.

@@ -43,2 +38,14 @@ */

const inertiaSetData = inertiaForm.setData.bind(inertiaForm);
if (!booted.current) {
/**
* Setup event listeners.
*/
precognitiveForm.validator().on('errorsChanged', () => {
inertiaClearErrors();
inertiaSetError(
// @ts-expect-error
toSimpleValidationErrors(precognitiveForm.validator().errors()));
});
booted.current = true;
}
/**

@@ -58,5 +65,10 @@ * Patch the form.

},
clearErrors() {
inertiaClearErrors();
precognitiveForm.setErrors({});
clearErrors(...names) {
inertiaClearErrors(...names);
if (names.length === 0) {
precognitiveForm.setErrors({});
}
else {
names.forEach(precognitiveForm.forgetError);
}
return this;

@@ -117,3 +129,4 @@ },

},
validator: precognitiveForm.validator,
});
};
{
"name": "laravel-precognition-react-inertia",
"version": "0.2.2",
"version": "0.3.0",
"description": "Laravel Precognition (React w/ Inertia).",

@@ -31,3 +31,4 @@ "keywords": [

"peerDependencies": {
"@inertiajs/react": "^1.0.0"
"@inertiajs/react": "^1.0.0",
"react": "^18.0.0"
},

@@ -34,0 +35,0 @@ "dependencies": {

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