@inertiajs/vue3 2.2.21 → 2.3.1

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.
@@ -1,7 +1,5 @@
1
- import { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, Progress, UrlMethodPair, VisitOptions } from '@inertiajs/core';
2
- type FormOptions = Omit<VisitOptions, 'data'>;
3
- type SubmitArgs = [Method, string, FormOptions?] | [UrlMethodPair, FormOptions?];
4
- type TransformCallback<TForm> = (data: TForm) => object;
1
+ import { ErrorValue, FormDataErrors, FormDataKeys, FormDataType, FormDataValues, Method, Progress, UrlMethodPair, UseFormSubmitArguments, UseFormSubmitOptions, UseFormTransformCallback, UseFormWithPrecognitionArguments } from '@inertiajs/core';
2
+ import { NamedInputEvent, ValidationConfig, Validator } from 'laravel-precognition';
5
3
  export interface InertiaFormProps<TForm extends object> {
6
4
  isDirty: boolean;
7
5
  errors: FormDataErrors<TForm>;
@@ -11,7 +9,7 @@ export interface InertiaFormProps<TForm extends object> {
11
9
  wasSuccessful: boolean;
12
10
  recentlySuccessful: boolean;
13
11
  data(): TForm;
14
- transform(callback: TransformCallback<TForm>): this;
12
+ transform(callback: UseFormTransformCallback<TForm>): this;
15
13
  defaults(): this;
16
14
  defaults<T extends FormDataKeys<TForm>>(field: T, value: FormDataValues<TForm, T>): this;
17
15
  defaults(fields: Partial<TForm>): this;
@@ -20,15 +18,41 @@ export interface InertiaFormProps<TForm extends object> {
20
18
  resetAndClearErrors<K extends FormDataKeys<TForm>>(...fields: K[]): this;
21
19
  setError<K extends FormDataKeys<TForm>>(field: K, value: ErrorValue): this;
22
20
  setError(errors: FormDataErrors<TForm>): this;
23
- submit: (...args: SubmitArgs) => void;
24
- get(url: string, options?: FormOptions): void;
25
- post(url: string, options?: FormOptions): void;
26
- put(url: string, options?: FormOptions): void;
27
- patch(url: string, options?: FormOptions): void;
28
- delete(url: string, options?: FormOptions): void;
21
+ submit: (...args: UseFormSubmitArguments) => void;
22
+ get(url: string, options?: UseFormSubmitOptions): void;
23
+ post(url: string, options?: UseFormSubmitOptions): void;
24
+ put(url: string, options?: UseFormSubmitOptions): void;
25
+ patch(url: string, options?: UseFormSubmitOptions): void;
26
+ delete(url: string, options?: UseFormSubmitOptions): void;
29
27
  cancel(): void;
28
+ withPrecognition(...args: UseFormWithPrecognitionArguments): InertiaPrecognitiveForm<TForm>;
29
+ }
30
+ type PrecognitionValidationConfig<TKeys> = ValidationConfig & {
31
+ only?: TKeys[] | Iterable<TKeys> | ArrayLike<TKeys>;
32
+ };
33
+ export interface InertiaFormValidationProps<TForm extends object> {
34
+ invalid<K extends FormDataKeys<TForm>>(field: K): boolean;
35
+ setValidationTimeout(duration: number): this;
36
+ touch<K extends FormDataKeys<TForm>>(field: K | NamedInputEvent | Array<K>, ...fields: K[]): this;
37
+ touched<K extends FormDataKeys<TForm>>(field?: K): boolean;
38
+ valid<K extends FormDataKeys<TForm>>(field: K): boolean;
39
+ validate<K extends FormDataKeys<TForm>>(field?: K | NamedInputEvent | PrecognitionValidationConfig<K>, config?: PrecognitionValidationConfig<K>): this;
40
+ validateFiles(): this;
41
+ validating: boolean;
42
+ validator: () => Validator;
43
+ withAllErrors(): this;
44
+ withoutFileValidation(): this;
45
+ setErrors(errors: FormDataErrors<TForm> | Record<string, string | string[]>): this;
46
+ forgetError<K extends FormDataKeys<TForm> | NamedInputEvent>(field: K): this;
47
+ }
48
+ interface InternalPrecognitionState {
49
+ __touched: string[];
50
+ __valid: string[];
30
51
  }
31
52
  export type InertiaForm<TForm extends object> = TForm & InertiaFormProps<TForm>;
32
- export default function useForm<TForm extends FormDataType<TForm>>(data: TForm | (() => TForm)): InertiaForm<TForm>;
53
+ export type InertiaPrecognitiveForm<TForm extends object> = InertiaForm<TForm> & InertiaFormValidationProps<TForm> & InternalPrecognitionState;
54
+ export default function useForm<TForm extends FormDataType<TForm>>(method: Method | (() => Method), url: string | (() => string), data: TForm | (() => TForm)): InertiaPrecognitiveForm<TForm>;
55
+ export default function useForm<TForm extends FormDataType<TForm>>(urlMethodPair: UrlMethodPair | (() => UrlMethodPair), data: TForm | (() => TForm)): InertiaPrecognitiveForm<TForm>;
33
56
  export default function useForm<TForm extends FormDataType<TForm>>(rememberKey: string, data: TForm | (() => TForm)): InertiaForm<TForm>;
57
+ export default function useForm<TForm extends FormDataType<TForm>>(data: TForm | (() => TForm)): InertiaForm<TForm>;
34
58
  export {};
@@ -36,7 +36,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
36
36
  loaded: boolean;
37
37
  fetching: boolean;
38
38
  observer: IntersectionObserver | null;
39
- }, {}, {
39
+ }, {
40
+ keys(): string[];
41
+ }, {
40
42
  registerObserver(): void;
41
43
  getReloadParams(): Partial<ReloadOptions>;
42
44
  }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{