@inertiajs/core 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.
- package/dist/index.esm.js +114 -9
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +114 -9
- package/dist/index.js.map +4 -4
- package/package.json +2 -1
- package/types/index.d.ts +1 -0
- package/types/scroll.d.ts +1 -0
- package/types/types.d.ts +18 -0
- package/types/useFormUtils.d.ts +47 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A framework for creating server-driven single page apps.",
|
|
6
6
|
"contributors": [
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@types/lodash-es": "^4.17.12",
|
|
48
|
+
"laravel-precognition": "^1.0.0",
|
|
48
49
|
"axios": "^1.13.2",
|
|
49
50
|
"lodash-es": "^4.17.21",
|
|
50
51
|
"qs": "^6.14.0"
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
2
|
import { Router } from './router';
|
|
3
|
+
export { UseFormUtils } from './useFormUtils';
|
|
3
4
|
export { config } from './config';
|
|
4
5
|
export { getInitialPageFromDOM, getScrollableParent } from './domUtils';
|
|
5
6
|
export { objectToFormData } from './formData';
|
package/types/scroll.d.ts
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosProgressEvent, AxiosResponse } from 'axios';
|
|
2
|
+
import { NamedInputEvent, ValidationConfig, Validator } from 'laravel-precognition';
|
|
2
3
|
import { Response } from './response';
|
|
3
4
|
declare module 'axios' {
|
|
4
5
|
interface AxiosProgressEvent {
|
|
@@ -415,6 +416,13 @@ export type UrlMethodPair = {
|
|
|
415
416
|
url: string;
|
|
416
417
|
method: Method;
|
|
417
418
|
};
|
|
419
|
+
export type UseFormTransformCallback<TForm> = (data: TForm) => object;
|
|
420
|
+
export type UseFormWithPrecognitionArguments = [Method | (() => Method), string | (() => string)] | [UrlMethodPair | (() => UrlMethodPair)];
|
|
421
|
+
type UseFormInertiaArguments<TForm> = [data: TForm | (() => TForm)] | [rememberKey: string, data: TForm | (() => TForm)];
|
|
422
|
+
type UseFormPrecognitionArguments<TForm> = [urlMethodPair: UrlMethodPair | (() => UrlMethodPair), data: TForm | (() => TForm)] | [method: Method | (() => Method), url: string | (() => string), data: TForm | (() => TForm)];
|
|
423
|
+
export type UseFormArguments<TForm> = UseFormInertiaArguments<TForm> | UseFormPrecognitionArguments<TForm>;
|
|
424
|
+
export type UseFormSubmitOptions = Omit<VisitOptions, 'data'>;
|
|
425
|
+
export type UseFormSubmitArguments = [Method, string, UseFormSubmitOptions?] | [UrlMethodPair, UseFormSubmitOptions?] | [UseFormSubmitOptions?];
|
|
418
426
|
export type FormComponentOptions = Pick<VisitOptions, 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'replace' | 'only' | 'except' | 'reset' | 'viewTransition'>;
|
|
419
427
|
export type FormComponentProps = Partial<Pick<Visit, 'headers' | 'queryStringArrayFormat' | 'errorBag' | 'showProgress' | 'invalidateCacheTags'> & Omit<VisitCallbacks, 'onPrefetched' | 'onPrefetching'>> & {
|
|
420
428
|
method?: Method | Uppercase<Method>;
|
|
@@ -426,6 +434,9 @@ export type FormComponentProps = Partial<Pick<Visit, 'headers' | 'queryStringArr
|
|
|
426
434
|
resetOnSuccess?: boolean | string[];
|
|
427
435
|
resetOnError?: boolean | string[];
|
|
428
436
|
setDefaultsOnSuccess?: boolean;
|
|
437
|
+
validateFiles?: boolean;
|
|
438
|
+
validationTimeout?: number;
|
|
439
|
+
withAllErrors?: boolean;
|
|
429
440
|
};
|
|
430
441
|
export type FormComponentMethods = {
|
|
431
442
|
clearErrors: (...fields: string[]) => void;
|
|
@@ -437,6 +448,12 @@ export type FormComponentMethods = {
|
|
|
437
448
|
defaults: () => void;
|
|
438
449
|
getData: () => Record<string, FormDataConvertible>;
|
|
439
450
|
getFormData: () => FormData;
|
|
451
|
+
valid: (field: string) => boolean;
|
|
452
|
+
invalid: (field: string) => boolean;
|
|
453
|
+
validate(field?: string | NamedInputEvent | ValidationConfig, config?: ValidationConfig): void;
|
|
454
|
+
touch: (...fields: string[]) => void;
|
|
455
|
+
touched(field?: string): boolean;
|
|
456
|
+
validator: () => Validator;
|
|
440
457
|
};
|
|
441
458
|
export type FormComponentonSubmitCompleteArguments = Pick<FormComponentMethods, 'reset' | 'defaults'>;
|
|
442
459
|
export type FormComponentState = {
|
|
@@ -447,6 +464,7 @@ export type FormComponentState = {
|
|
|
447
464
|
wasSuccessful: boolean;
|
|
448
465
|
recentlySuccessful: boolean;
|
|
449
466
|
isDirty: boolean;
|
|
467
|
+
validating: boolean;
|
|
450
468
|
};
|
|
451
469
|
export type FormComponentSlotProps = FormComponentMethods & FormComponentState;
|
|
452
470
|
export type FormComponentRef = FormComponentSlotProps;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { NamedInputEvent, ValidationConfig } from 'laravel-precognition';
|
|
2
|
+
import { FormDataType, Method, UrlMethodPair, UseFormArguments, UseFormSubmitArguments, UseFormSubmitOptions } from './types';
|
|
3
|
+
export declare class UseFormUtils {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a callback that returns a UrlMethodPair.
|
|
6
|
+
*
|
|
7
|
+
* createWayfinderCallback(urlMethodPair)
|
|
8
|
+
* createWayfinderCallback(method, url)
|
|
9
|
+
* createWayfinderCallback(() => urlMethodPair)
|
|
10
|
+
* createWayfinderCallback(() => method, () => url)
|
|
11
|
+
*/
|
|
12
|
+
static createWayfinderCallback(...args: [UrlMethodPair | (() => UrlMethodPair)] | [Method | (() => Method), string | (() => string)]): () => UrlMethodPair;
|
|
13
|
+
/**
|
|
14
|
+
* Parses all useForm() arguments into { rememberKey, data, precognitionEndpoint }.
|
|
15
|
+
*
|
|
16
|
+
* useForm(data)
|
|
17
|
+
* useForm(rememberKey, data)
|
|
18
|
+
* useForm(method, url, data)
|
|
19
|
+
* useForm(urlMethodPair, data)
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
static parseUseFormArguments<TForm extends FormDataType<TForm>>(...args: UseFormArguments<TForm>): {
|
|
23
|
+
rememberKey: string | null;
|
|
24
|
+
data: TForm | (() => TForm);
|
|
25
|
+
precognitionEndpoint: (() => UrlMethodPair) | null;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Parses all submission arguments into { method, url, options }.
|
|
29
|
+
* It uses the Precognition endpoint if no explicit method/url are provided.
|
|
30
|
+
*
|
|
31
|
+
* form.submit(method, url)
|
|
32
|
+
* form.submit(method, url, options)
|
|
33
|
+
* form.submit(urlMethodPair)
|
|
34
|
+
* form.submit(urlMethodPair, options)
|
|
35
|
+
* form.submit()
|
|
36
|
+
* form.submit(options)
|
|
37
|
+
*/
|
|
38
|
+
static parseSubmitArguments(args: UseFormSubmitArguments, precognitionEndpoint: (() => UrlMethodPair) | null): {
|
|
39
|
+
method: Method;
|
|
40
|
+
url: string;
|
|
41
|
+
options: UseFormSubmitOptions;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Merges headers into the Precognition validate() arguments.
|
|
45
|
+
*/
|
|
46
|
+
static mergeHeadersForValidation(field?: string | NamedInputEvent | ValidationConfig, config?: ValidationConfig, headers?: Record<string, string>): [string | NamedInputEvent | ValidationConfig | undefined, ValidationConfig | undefined];
|
|
47
|
+
}
|