@inertiajs/react 2.3.17 → 3.0.0-beta.2
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 +986 -532
- package/dist/index.js.map +4 -4
- package/dist/server.js +4 -35
- package/dist/server.js.map +2 -2
- package/package.json +9 -11
- package/resources/boost/skills/inertia-react-development/SKILL.blade.php +128 -8
- package/types/App.d.ts +3 -2
- package/types/Deferred.d.ts +4 -1
- package/types/Form.d.ts +10 -19
- package/types/InfiniteScroll.d.ts +2 -1
- package/types/createInertiaApp.d.ts +15 -4
- package/types/index.d.ts +6 -15
- package/types/layoutProps.d.ts +8 -0
- package/types/react.d.ts +0 -1
- package/types/types.d.ts +3 -1
- package/types/useForm.d.ts +10 -12
- package/types/useFormState.d.ts +79 -0
- package/types/useHttp.d.ts +65 -0
- package/dist/index.esm.js +0 -1651
- package/dist/index.esm.js.map +0 -7
- package/dist/server.esm.js +0 -6
- package/dist/server.esm.js.map +0 -7
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, Progress, UrlMethodPair, UseFormTransformCallback, UseFormWithPrecognitionArguments, UseHttpSubmitArguments, UseHttpSubmitOptions } from '@inertiajs/core';
|
|
2
|
+
import { NamedInputEvent, ValidationConfig, Validator } from 'laravel-precognition';
|
|
3
|
+
import { SetDataAction } from './useFormState';
|
|
4
|
+
type PrecognitionValidationConfig<TKeys> = ValidationConfig & {
|
|
5
|
+
only?: TKeys[] | Iterable<TKeys> | ArrayLike<TKeys>;
|
|
6
|
+
};
|
|
7
|
+
export interface UseHttpProps<TForm extends object, TResponse = unknown> {
|
|
8
|
+
data: TForm;
|
|
9
|
+
isDirty: boolean;
|
|
10
|
+
errors: FormDataErrors<TForm>;
|
|
11
|
+
hasErrors: boolean;
|
|
12
|
+
processing: boolean;
|
|
13
|
+
progress: Progress | null;
|
|
14
|
+
wasSuccessful: boolean;
|
|
15
|
+
recentlySuccessful: boolean;
|
|
16
|
+
response: TResponse | null;
|
|
17
|
+
setData: SetDataAction<TForm>;
|
|
18
|
+
transform: (callback: UseFormTransformCallback<TForm>) => void;
|
|
19
|
+
setDefaults: {
|
|
20
|
+
(): void;
|
|
21
|
+
<T extends FormDataKeys<TForm>>(field: T, value: FormDataValues<TForm, T>): void;
|
|
22
|
+
(fields: Partial<TForm>): void;
|
|
23
|
+
};
|
|
24
|
+
reset: <K extends FormDataKeys<TForm>>(...fields: K[]) => void;
|
|
25
|
+
clearErrors: <K extends FormDataKeys<TForm>>(...fields: K[]) => void;
|
|
26
|
+
resetAndClearErrors: <K extends FormDataKeys<TForm>>(...fields: K[]) => void;
|
|
27
|
+
setError: {
|
|
28
|
+
<K extends FormDataKeys<TForm>>(field: K, value: ErrorValue): void;
|
|
29
|
+
(errors: FormDataErrors<TForm>): void;
|
|
30
|
+
};
|
|
31
|
+
submit: (...args: UseHttpSubmitArguments<TResponse, TForm>) => Promise<TResponse>;
|
|
32
|
+
get: (url: string, options?: UseHttpSubmitOptions<TResponse, TForm>) => Promise<TResponse>;
|
|
33
|
+
post: (url: string, options?: UseHttpSubmitOptions<TResponse, TForm>) => Promise<TResponse>;
|
|
34
|
+
put: (url: string, options?: UseHttpSubmitOptions<TResponse, TForm>) => Promise<TResponse>;
|
|
35
|
+
patch: (url: string, options?: UseHttpSubmitOptions<TResponse, TForm>) => Promise<TResponse>;
|
|
36
|
+
delete: (url: string, options?: UseHttpSubmitOptions<TResponse, TForm>) => Promise<TResponse>;
|
|
37
|
+
cancel: () => void;
|
|
38
|
+
dontRemember: <K extends FormDataKeys<TForm>>(...fields: K[]) => UseHttpProps<TForm, TResponse>;
|
|
39
|
+
optimistic: (callback: (currentData: TForm) => Partial<TForm>) => UseHttpProps<TForm, TResponse>;
|
|
40
|
+
withAllErrors: () => UseHttpProps<TForm, TResponse>;
|
|
41
|
+
withPrecognition: (...args: UseFormWithPrecognitionArguments) => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
42
|
+
}
|
|
43
|
+
export interface UseHttpValidationProps<TForm extends object, TResponse = unknown> {
|
|
44
|
+
invalid: <K extends FormDataKeys<TForm>>(field: K) => boolean;
|
|
45
|
+
setValidationTimeout: (duration: number) => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
46
|
+
touch: <K extends FormDataKeys<TForm>>(field: K | NamedInputEvent | Array<K>, ...fields: K[]) => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
47
|
+
touched: <K extends FormDataKeys<TForm>>(field?: K) => boolean;
|
|
48
|
+
valid: <K extends FormDataKeys<TForm>>(field: K) => boolean;
|
|
49
|
+
validate: <K extends FormDataKeys<TForm>>(field?: K | NamedInputEvent | PrecognitionValidationConfig<K>, config?: PrecognitionValidationConfig<K>) => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
50
|
+
validateFiles: () => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
51
|
+
validating: boolean;
|
|
52
|
+
validator: () => Validator;
|
|
53
|
+
withAllErrors: () => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
54
|
+
withoutFileValidation: () => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
55
|
+
setErrors: (errors: FormDataErrors<TForm>) => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
56
|
+
forgetError: <K extends FormDataKeys<TForm> | NamedInputEvent>(field: K) => UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
57
|
+
}
|
|
58
|
+
export type UseHttp<TForm extends object, TResponse = unknown> = UseHttpProps<TForm, TResponse>;
|
|
59
|
+
export type UseHttpPrecognitiveProps<TForm extends object, TResponse = unknown> = UseHttpProps<TForm, TResponse> & UseHttpValidationProps<TForm, TResponse>;
|
|
60
|
+
export default function useHttp<TForm extends FormDataType<TForm>, TResponse = unknown>(method: Method | (() => Method), url: string | (() => string), data: TForm | (() => TForm)): UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
61
|
+
export default function useHttp<TForm extends FormDataType<TForm>, TResponse = unknown>(urlMethodPair: UrlMethodPair | (() => UrlMethodPair), data: TForm | (() => TForm)): UseHttpPrecognitiveProps<TForm, TResponse>;
|
|
62
|
+
export default function useHttp<TForm extends FormDataType<TForm>, TResponse = unknown>(rememberKey: string, data: TForm | (() => TForm)): UseHttp<TForm, TResponse>;
|
|
63
|
+
export default function useHttp<TForm extends FormDataType<TForm>, TResponse = unknown>(data: TForm | (() => TForm)): UseHttp<TForm, TResponse>;
|
|
64
|
+
export default function useHttp<TForm extends FormDataType<TForm>, TResponse = unknown>(): UseHttp<TForm, TResponse>;
|
|
65
|
+
export {};
|