|
1 | | -import { |
2 | | - Config, |
3 | | - RequestMethods, |
4 | | - Timeout, |
5 | | - Validator, |
6 | | -} from 'laravel-precognition/dist/types'; |
7 | | -import React from 'react'; |
8 | | -import { InertiaFormProps } from '@inertiajs/inertia-react'; |
9 | | - |
10 | | -export type UsePrecognitionFormOptions<TForm = Record<string, any>> = { |
11 | | - precognition: { |
12 | | - method: RequestMethods; |
13 | | - url: string; |
14 | | - config?: Config; |
15 | | - }; |
16 | | - |
17 | | - form: { |
18 | | - initialValues: TForm; |
19 | | - }; |
20 | | -}; |
21 | | - |
22 | | -export type UsePrecognition<TForm = Record<string, any>> = { |
23 | | - validator: Validator; |
24 | | - validate(name: keyof TForm): UsePrecognition<TForm>; |
25 | | - isValidating: string | null; |
26 | | - isProcessingValidation: boolean; |
27 | | - lastTouched: keyof TForm | null; |
28 | | - setLastTouched: React.Dispatch<React.SetStateAction<keyof TForm | null>>; |
29 | | - touched: Array<keyof TForm>; |
30 | | - |
31 | | - setValidatorTimeout(duration: Timeout): UsePrecognition<TForm>; |
32 | | -}; |
33 | | - |
34 | | -export type InertiaPrecognitionFormProps<TForm = Record<string, any>> = |
35 | | - InertiaFormProps<TForm> & UsePrecognition<TForm>; |
36 | | - |
37 | | -export interface UseInertiaPrecognitionForm<TForm = Record<string, any>> |
38 | | - extends InertiaPrecognitionFormProps<TForm> { |
39 | | - validateAndSetDataByKeyValuePair( |
40 | | - name: keyof TForm, |
41 | | - value: any |
42 | | - ): UsePrecognition<TForm>; |
43 | | - passed: Array<keyof TForm>; |
44 | | -} |
45 | | - |
46 | | -export type UsePrecognitionForm<TForm = Record<string, any>> = |
47 | | - UsePrecognition<TForm> & { |
48 | | - data: TForm; |
49 | | - setData: React.Dispatch<React.SetStateAction<TForm>>; |
50 | | - errors: Record<keyof TForm, string> | null; |
51 | | - setErrors: React.Dispatch< |
52 | | - React.SetStateAction<Record<keyof TForm, string> | null> |
53 | | - >; |
54 | | - clearErrors: () => void; |
55 | | - validateAndSetDataByKeyValuePair( |
56 | | - key: keyof TForm, |
57 | | - value: any |
58 | | - ): UsePrecognitionForm<TForm>; |
59 | | - passed: Array<keyof TForm>; |
60 | | - }; |
| 1 | +export * from './hooks'; |
0 commit comments