react-hook-form 7.28.1 → 8.0.0-alpha.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/__typetests__/__fixtures__/index.d.ts +2 -0
- package/dist/__typetests__/__fixtures__/index.d.ts.map +1 -0
- package/dist/__typetests__/__fixtures__/type.d.ts +12 -0
- package/dist/__typetests__/__fixtures__/type.d.ts.map +1 -0
- package/dist/__typetests__/types/__fixtures__/index.d.ts +4 -0
- package/dist/__typetests__/types/__fixtures__/index.d.ts.map +1 -0
- package/dist/__typetests__/types/__fixtures__/pathString.d.ts +4 -0
- package/dist/__typetests__/types/__fixtures__/pathString.d.ts.map +1 -0
- package/dist/__typetests__/types/__fixtures__/traversable.d.ts +14 -0
- package/dist/__typetests__/types/__fixtures__/traversable.d.ts.map +1 -0
- package/dist/__typetests__/types/__fixtures__/tuple.d.ts +15 -0
- package/dist/__typetests__/types/__fixtures__/tuple.d.ts.map +1 -0
- package/dist/__typetests__/types/form.test-d.d.ts +2 -0
- package/dist/__typetests__/types/form.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/auto.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/auto.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/autoCompletePath.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/autoCompletePath.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/hasPath.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/hasPath.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/keys.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/keys.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/pathGetValue.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/pathGetValue.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/pathSetValue.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/pathSetValue.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/pathTuple.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/pathTuple.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/internal/utils.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/internal/utils.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/lazy.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/lazy.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/path/value.test-d.d.ts +2 -0
- package/dist/__typetests__/types/path/value.test-d.d.ts.map +1 -0
- package/dist/__typetests__/types/util.test-d.d.ts +2 -0
- package/dist/__typetests__/types/util.test-d.d.ts.map +1 -0
- package/dist/__typetests__/utils/join.test-d.d.ts +2 -0
- package/dist/__typetests__/utils/join.test-d.d.ts.map +1 -0
- package/dist/__typetests__/utils/of.test-d.d.ts +2 -0
- package/dist/__typetests__/utils/of.test-d.d.ts.map +1 -0
- package/dist/controller.d.ts +1 -1
- package/dist/controller.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +210 -109
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/logic/createFormControl.d.ts.map +1 -1
- package/dist/logic/focusFieldBy.d.ts.map +1 -1
- package/dist/logic/getResolverOptions.d.ts +2 -2
- package/dist/logic/hasValidation.d.ts +1 -1
- package/dist/logic/shouldRenderFormState.d.ts.map +1 -1
- package/dist/types/controller.d.ts +8 -8
- package/dist/types/controller.d.ts.map +1 -1
- package/dist/types/errors.d.ts +8 -2
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/fieldArray.d.ts +14 -14
- package/dist/types/fieldArray.d.ts.map +1 -1
- package/dist/types/form.d.ts +34 -44
- package/dist/types/form.d.ts.map +1 -1
- package/dist/types/path/auto.d.ts +76 -0
- package/dist/types/path/auto.d.ts.map +1 -0
- package/dist/types/path/branded.d.ts +61 -0
- package/dist/types/path/branded.d.ts.map +1 -0
- package/dist/types/path/index.d.ts +7 -3
- package/dist/types/path/index.d.ts.map +1 -1
- package/dist/types/path/internal/autoCompletePath.d.ts +173 -0
- package/dist/types/path/internal/autoCompletePath.d.ts.map +1 -0
- package/dist/types/path/internal/hasPath.d.ts +56 -0
- package/dist/types/path/internal/hasPath.d.ts.map +1 -0
- package/dist/types/path/internal/keys.d.ts +103 -0
- package/dist/types/path/internal/keys.d.ts.map +1 -0
- package/dist/types/path/internal/pathGetValue.d.ts +76 -0
- package/dist/types/path/internal/pathGetValue.d.ts.map +1 -0
- package/dist/types/path/internal/pathSetValue.d.ts +96 -0
- package/dist/types/path/internal/pathSetValue.d.ts.map +1 -0
- package/dist/types/path/internal/pathTuple.d.ts +73 -0
- package/dist/types/path/internal/pathTuple.d.ts.map +1 -0
- package/dist/types/path/internal/utils.d.ts +84 -0
- package/dist/types/path/internal/utils.d.ts.map +1 -0
- package/dist/types/path/lazy.d.ts +62 -0
- package/dist/types/path/lazy.d.ts.map +1 -0
- package/dist/types/path/pathString.d.ts +6 -0
- package/dist/types/path/pathString.d.ts.map +1 -0
- package/dist/types/path/value.d.ts +49 -0
- package/dist/types/path/value.d.ts.map +1 -0
- package/dist/types/resolvers.d.ts +3 -3
- package/dist/types/resolvers.d.ts.map +1 -1
- package/dist/types/utils.d.ts +15 -7
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/validator.d.ts +2 -2
- package/dist/types/validator.d.ts.map +1 -1
- package/dist/useController.d.ts +2 -2
- package/dist/useController.d.ts.map +1 -1
- package/dist/useFieldArray.d.ts +2 -2
- package/dist/useFieldArray.d.ts.map +1 -1
- package/dist/useForm.d.ts.map +1 -1
- package/dist/useFormContext.d.ts.map +1 -1
- package/dist/useFormState.d.ts +2 -2
- package/dist/useFormState.d.ts.map +1 -1
- package/dist/useWatch.d.ts +9 -23
- package/dist/useWatch.d.ts.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/join.d.ts +16 -0
- package/dist/utils/join.d.ts.map +1 -0
- package/dist/utils/of.d.ts +13 -0
- package/dist/utils/of.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/types/path/common.d.ts +0 -316
- package/dist/types/path/common.d.ts.map +0 -1
- package/dist/types/path/eager.d.ts +0 -82
- package/dist/types/path/eager.d.ts.map +0 -1
- package/dist/utils/omitKeys.d.ts +0 -3
- package/dist/utils/omitKeys.d.ts.map +0 -1
@@ -0,0 +1,96 @@
|
|
1
|
+
import { IsAny } from '../../utils';
|
2
|
+
import { AsPathTuple, PathTuple } from './pathTuple';
|
3
|
+
import { ArrayKey, AsKey, IsTuple, Key, MapKeys, UnionToIntersection } from './utils';
|
4
|
+
/**
|
5
|
+
* Type to access a type by a key. Returns never
|
6
|
+
* - if it can't be indexed by that key.
|
7
|
+
* - if the type is not traversable.
|
8
|
+
* @typeParam T - type which is indexed by the key
|
9
|
+
* @typeParam K - key into the type
|
10
|
+
* ```
|
11
|
+
* TrySet<{foo: string}, 'foo'> = string
|
12
|
+
* TrySet<{foo: string}, 'bar'> = never
|
13
|
+
* TrySet<null, 'foo'> = never
|
14
|
+
* TrySet<string, 'foo'> = never
|
15
|
+
* ```
|
16
|
+
* @internal
|
17
|
+
*/
|
18
|
+
declare type TrySet<T, K> = K extends keyof T ? T[K] : never;
|
19
|
+
/**
|
20
|
+
* Type to access an array type by a key.
|
21
|
+
* @typeParam T - type which is indexed by the key
|
22
|
+
* @typeParam K - key into the type
|
23
|
+
* ```
|
24
|
+
* TrySetArray<string[], '0'> = string
|
25
|
+
* TrySetArray<string[], 'foo'> = never
|
26
|
+
* ```
|
27
|
+
* @internal
|
28
|
+
*/
|
29
|
+
declare type TrySetArray<T extends ReadonlyArray<any>, K extends Key> = K extends `${ArrayKey}` ? T[number] : TrySet<T, K>;
|
30
|
+
/**
|
31
|
+
* Type to implement {@link KeySetValue}. Wraps everything into a tuple.
|
32
|
+
* @typeParam T - non-nullable type which is indexed by the key
|
33
|
+
* @typeParam K - key into the type, mustn't be a union of keys
|
34
|
+
* @internal
|
35
|
+
*/
|
36
|
+
declare type KeySetValueImpl<T, K extends Key> = T extends ReadonlyArray<any> ? IsTuple<T> extends true ? [TrySet<T, K>] : [TrySetArray<T, K>] : [TrySet<MapKeys<T>, K>];
|
37
|
+
/**
|
38
|
+
* Type to evaluate the type which is required for setting the property which
|
39
|
+
* the given key points to.
|
40
|
+
* - If either T or K is union, it will evaluate to the intersection of the
|
41
|
+
* types at the given key(s).
|
42
|
+
* - If T can be null or undefined, the resulting type won't include null or
|
43
|
+
* undefined.
|
44
|
+
* - If a key doesn't exist,the resulting type will be never.
|
45
|
+
* - If a key may be optional, the resulting type will include undefined.
|
46
|
+
* @typeParam T - type which is indexed by the key
|
47
|
+
* @typeParam K - key into the type
|
48
|
+
* @example
|
49
|
+
* ```
|
50
|
+
* KeySetValue<{foo: string}, 'foo'> = string
|
51
|
+
* KeySetValue<{foo: string, bar: number}, 'foo' | 'bar'> = string & number
|
52
|
+
* KeySetValue<{foo: string} | {foo: number}, 'foo'> = string & number
|
53
|
+
* KeySetValue<null | {foo: string}, 'foo'> = string
|
54
|
+
* KeySetValue<{bar: string}, 'foo'> = never
|
55
|
+
* KeySetValue<{foo?: string}, 'foo'> = undefined | string
|
56
|
+
* ```
|
57
|
+
* @internal
|
58
|
+
*/
|
59
|
+
export declare type KeySetValue<T, K extends Key> = UnionToIntersection<K extends any ? KeySetValueImpl<NonNullable<T>, K> : never>[never];
|
60
|
+
/**
|
61
|
+
* Type to implement {@link PathSetValue} tail-recursively.
|
62
|
+
* Wraps everything into a tuple.
|
63
|
+
* @typeParam T - deeply nested type which is indexed by the path
|
64
|
+
* @typeParam PT - path into the deeply nested type
|
65
|
+
* @internal
|
66
|
+
*/
|
67
|
+
declare type PathSetValueImpl<T, PT extends PathTuple> = PT extends [
|
68
|
+
infer K,
|
69
|
+
...infer R
|
70
|
+
] ? PathSetValueImpl<KeySetValue<T, AsKey<K>>, AsPathTuple<R>> : [T];
|
71
|
+
/**
|
72
|
+
* Type to evaluate the type which is required for setting the property which
|
73
|
+
* the given path points to.
|
74
|
+
* - If either T or PT is union, it will evaluate to the intersection of the
|
75
|
+
* types at the given paths(s).
|
76
|
+
* - If T can be null or undefined, the resulting type won't include null or
|
77
|
+
* undefined.
|
78
|
+
* - If a path doesn't exist, the resulting type will be never.
|
79
|
+
* - Only if last kay is optional, the resulting type will include undefined.
|
80
|
+
* @typeParam T - deeply nested type which is indexed by the path
|
81
|
+
* @typeParam PT - path into the deeply nested type
|
82
|
+
* @example
|
83
|
+
* ```
|
84
|
+
* PathSetValue<{foo: {bar: string}}, ['foo', 'bar']> = string
|
85
|
+
* PathSetValue<{foo: string, bar: number}, ['foo'] | ['bar']> = string & number
|
86
|
+
* PathSetValue<{foo: string} | {foo: number}, ['foo']> = string & number
|
87
|
+
* PathSetValue<null | {foo: string}, ['foo']> = string
|
88
|
+
* PathSetValue<{bar: string}, ['foo']> = never
|
89
|
+
* PathSetValue<{foo?: string}, ['foo']> = undefined | string
|
90
|
+
* PathSetValue<{foo?: {bar: string}}, ['foo', 'bar']> = string
|
91
|
+
* ```
|
92
|
+
* @internal
|
93
|
+
*/
|
94
|
+
export declare type PathSetValue<T, PT extends PathTuple> = IsAny<PT> extends true ? any : UnionToIntersection<PathSetValueImpl<T, PT>>[never];
|
95
|
+
export {};
|
96
|
+
//# sourceMappingURL=pathSetValue.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pathSetValue.d.ts","sourceRoot":"","sources":["../../../../src/types/path/internal/pathSetValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,GAAG,EACH,OAAO,EACP,mBAAmB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CAAC,CAAC;AAER;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,oBAAY,YAAY,CAAC,CAAC,EAAE,EAAE,SAAS,SAAS,IAAI,KAAK,CAAC,EAAE,CAAC,SAAS,IAAI,GACtE,GAAG,GACH,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC"}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { IsAny } from '../../utils';
|
2
|
+
import { PathString } from '../pathString';
|
3
|
+
import { AsKey, Key } from './utils';
|
4
|
+
/**
|
5
|
+
* Type which describes a path through an object as a list of individual keys.
|
6
|
+
* @internal
|
7
|
+
*/
|
8
|
+
export declare type PathTuple = Key[];
|
9
|
+
/**
|
10
|
+
* Type to assert that a type is a path tuple.
|
11
|
+
* @typeParam T - type which may be a path tuple
|
12
|
+
* @internal
|
13
|
+
*/
|
14
|
+
export declare type AsPathTuple<T> = Extract<T, PathTuple>;
|
15
|
+
/**
|
16
|
+
* Type which appends a key to the path tuple only if it is not blank,
|
17
|
+
* i.e. not the empty string.
|
18
|
+
* @typeParam PT - path
|
19
|
+
* @typeParam K - key
|
20
|
+
* @example
|
21
|
+
* ```
|
22
|
+
* AppendNonBlankKey<['foo'], 'bar'> = ['foo', 'bar']
|
23
|
+
* AppendNonBlankKey<['foo'], ''> = ['foo']
|
24
|
+
* ```
|
25
|
+
* @internal
|
26
|
+
*/
|
27
|
+
declare type AppendNonBlankKey<PT extends PathTuple, K extends Key> = K extends '' ? PT : [...PT, K];
|
28
|
+
/**
|
29
|
+
* Type to implement {@link SplitPathString} tail recursively.
|
30
|
+
* @typeParam PS - remaining path string which should be split into its
|
31
|
+
* individual keys
|
32
|
+
* @typeParam PT - accumulator of the keys which have been split from
|
33
|
+
* the original path string already
|
34
|
+
* @internal
|
35
|
+
*/
|
36
|
+
declare type SplitPathStringImpl<PS extends PathString, PT extends PathTuple> = PS extends `${infer K}.${infer R}` ? SplitPathStringImpl<R, AppendNonBlankKey<PT, K>> : AppendNonBlankKey<PT, PS>;
|
37
|
+
/**
|
38
|
+
* Type to split a path string into a path tuple.
|
39
|
+
* The individual keys may be empty strings.
|
40
|
+
* @typeParam PS - path string which should be split into its individual keys
|
41
|
+
* @example
|
42
|
+
* ```
|
43
|
+
* SplitPathString<'foo'> = ['foo']
|
44
|
+
* SplitPathString<'foo.bar.0.baz'> = ['foo', 'bar', '0', 'baz']
|
45
|
+
* SplitPathString<'.'> = []
|
46
|
+
* ```
|
47
|
+
* @internal
|
48
|
+
*/
|
49
|
+
export declare type SplitPathString<PS extends PathString> = IsAny<PS> extends true ? any : SplitPathStringImpl<PS, []>;
|
50
|
+
/**
|
51
|
+
* Type to implement {@link JoinPathTuple} tail-recursively.
|
52
|
+
* @typeParam PT - remaining keys which needs to be joined
|
53
|
+
* @typeParam PS - accumulator of the already joined keys
|
54
|
+
* @internal
|
55
|
+
*/
|
56
|
+
declare type JoinPathTupleImpl<PT extends PathTuple, PS extends PathString> = PT extends [infer K, ...infer R] ? JoinPathTupleImpl<AsPathTuple<R>, `${PS}.${AsKey<K>}`> : PS;
|
57
|
+
/**
|
58
|
+
* Type to join a path tuple to a path string.
|
59
|
+
* @typeParam PT - path tuple which should be joined.
|
60
|
+
* @example
|
61
|
+
* ```
|
62
|
+
* JoinPathTuple<['foo']> = 'foo'
|
63
|
+
* JoinPathTuple<['foo', 'bar', '0', 'baz']> = 'foo.bar.0.baz'
|
64
|
+
* JoinPathTuple<[]> = never
|
65
|
+
* ```
|
66
|
+
* @internal
|
67
|
+
*/
|
68
|
+
export declare type JoinPathTuple<PT extends PathTuple> = PT extends [
|
69
|
+
infer K,
|
70
|
+
...infer R
|
71
|
+
] ? JoinPathTupleImpl<AsPathTuple<R>, AsKey<K>> : never;
|
72
|
+
export {};
|
73
|
+
//# sourceMappingURL=pathTuple.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pathTuple.d.ts","sourceRoot":"","sources":["../../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AAE,CAAC;AAEP;;;;;;;;;;GAUG;AACH,oBAAY,aAAa,CAAC,EAAE,SAAS,SAAS,IAAI,EAAE,SAAS;IAC3D,MAAM,CAAC;IACP,GAAG,MAAM,CAAC;CACX,GACG,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAC3C,KAAK,CAAC"}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
* Type which can be traversed through with a path string.
|
3
|
+
* I.e. objects, arrays, and tuples
|
4
|
+
* @internal
|
5
|
+
*/
|
6
|
+
export declare type Traversable = object;
|
7
|
+
/**
|
8
|
+
* Type which can be used to index an array or tuple type.
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
export declare type ArrayKey = number;
|
12
|
+
/**
|
13
|
+
* Type which can be used to index an object.
|
14
|
+
* @internal
|
15
|
+
*/
|
16
|
+
export declare type Key = string;
|
17
|
+
/**
|
18
|
+
* Type to assert that a type is a key.
|
19
|
+
* @typeParam T - type which may be a key
|
20
|
+
* @internal
|
21
|
+
*/
|
22
|
+
export declare type AsKey<T> = Extract<T, Key>;
|
23
|
+
/**
|
24
|
+
* Type to convert a type to a key.
|
25
|
+
* @typeParam T - type which may be converted to a key
|
26
|
+
* @internal
|
27
|
+
*/
|
28
|
+
export declare type ToKey<T> = T extends ArrayKey ? `${T}` : AsKey<T>;
|
29
|
+
/**
|
30
|
+
* Type which converts all keys of an object to keys.
|
31
|
+
* @typeParam T - object type
|
32
|
+
* @example
|
33
|
+
* ```
|
34
|
+
* MapKeys<{0: string}> = {'0': string}
|
35
|
+
* ```
|
36
|
+
* @internal
|
37
|
+
*/
|
38
|
+
export declare type MapKeys<T> = {
|
39
|
+
[K in keyof T as ToKey<K>]: T[K];
|
40
|
+
};
|
41
|
+
/**
|
42
|
+
* Type to query whether an array type T is a tuple type.
|
43
|
+
* @typeParam T - type which may be an array or tuple
|
44
|
+
* @example
|
45
|
+
* ```
|
46
|
+
* IsTuple<[number]> = true
|
47
|
+
* IsTuple<number[]> = false
|
48
|
+
* ```
|
49
|
+
* @internal
|
50
|
+
*/
|
51
|
+
export declare type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
|
52
|
+
/**
|
53
|
+
* Type to intersect a union type.
|
54
|
+
* See https://fettblog.eu/typescript-union-to-intersection/
|
55
|
+
* @typeParam U - union
|
56
|
+
* @example
|
57
|
+
* ```
|
58
|
+
* UnionToIntersection<{ foo: string } | { bar: number }>
|
59
|
+
* = { foo: string; bar: number }
|
60
|
+
* ```
|
61
|
+
* @internal
|
62
|
+
*/
|
63
|
+
export declare type UnionToIntersection<U> = (U extends any ? (_: U) => any : never) extends (_: infer I) => any ? I : never;
|
64
|
+
/**
|
65
|
+
* Type which represents a property access.
|
66
|
+
* @typeParam Get - the type when getting the property (covariant)
|
67
|
+
* @typeParam Set - the type required for setting the property (contravariant)
|
68
|
+
* @remarks
|
69
|
+
* See {@link https://dmitripavlutin.com/typescript-covariance-contravariance/}
|
70
|
+
* for an explanation of covariance and contravariance.
|
71
|
+
*
|
72
|
+
* Using it as a constraint:
|
73
|
+
* - `'abcd'` is a subtype of `string`
|
74
|
+
* - `string` is a supertype of `'abcd'`
|
75
|
+
*
|
76
|
+
* Therefore,
|
77
|
+
* - `AccessPattern<'abcd', 'abcd'>` extends `AccessPattern<string, 'abcd'>`
|
78
|
+
* - `AccessPattern<'abcd', string>` extends `AccessPattern<'abcd', 'abcd'>`
|
79
|
+
* - `AccessPattern<string, 'abcd'>` doesn't extend `AccessPattern<'abcd', 'abcd'>`
|
80
|
+
* - `AccessPattern<'abcd', 'abcd'>` doesn't extend `AccessPattern<'abcd', string>`
|
81
|
+
* @internal
|
82
|
+
*/
|
83
|
+
export declare type AccessPattern<Get = unknown, Set = never> = (_: Set) => Get;
|
84
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/types/path/internal/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,WAAW,GAAG,MAAM,CAAC;AAEjC;;;GAGG;AACH,oBAAY,QAAQ,GAAG,MAAM,CAAC;AAE9B;;;GAGG;AACH,oBAAY,GAAG,GAAG,MAAM,CAAC;AAEzB;;;;GAIG;AACH,oBAAY,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAEvC;;;;GAIG;AACH,oBAAY,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAAG,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE9D;;;;;;;;;GASG;AACH,oBAAY,OAAO,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC1E,KAAK,GACL,IAAI,CAAC;AAET;;;;;;;;;;GAUG;AACH,oBAAY,mBAAmB,CAAC,CAAC,IAAI,CACnC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,GAAG,KAAK,CACtC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,GAAG,GACzB,CAAC,GACD,KAAK,CAAC;AAEV;;;;;;;;;;;;;;;;;;GAkBG;AACH,oBAAY,aAAa,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC"}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { FieldValues } from '../fields';
|
2
|
+
import { AutoCompletePath } from './internal/autoCompletePath';
|
3
|
+
import { AccessPattern } from './internal/utils';
|
4
|
+
import * as Branded from './branded';
|
5
|
+
import { PathString } from './pathString';
|
6
|
+
/**
|
7
|
+
* Type which offers autocompletion of paths through a form.
|
8
|
+
* @typeParam TFieldValues - the field values for which this path is valid
|
9
|
+
* @typeParam TPathString - the string representation of the path
|
10
|
+
* @typeParam TValue - the value which may be read from the path
|
11
|
+
* @typeParam TValueSet - the value which can be written to the path
|
12
|
+
* @example
|
13
|
+
* ```
|
14
|
+
* declare function getNumber<T extends FieldValues, P extends PathString>(
|
15
|
+
* obj: T,
|
16
|
+
* path: TypedFieldPath<T, P, number>,
|
17
|
+
* ): number
|
18
|
+
* ```
|
19
|
+
*/
|
20
|
+
export declare type TypedFieldPath<TFieldValues, TPathString extends PathString, TValue, TValueSet = TValue> = TPathString extends Branded.FieldPath<any> ? never : AutoCompletePath<TFieldValues, TPathString, AccessPattern<TValue, TValueSet>>;
|
21
|
+
/**
|
22
|
+
* Type which offers autocompletion of paths through a form.
|
23
|
+
* @typeParam TFieldValues - the field values for which this path is valid
|
24
|
+
* @typeParam TPathString - the string representation of the path
|
25
|
+
* @example
|
26
|
+
* ```
|
27
|
+
* declare function get<T extends FieldValues, P extends PathString>(
|
28
|
+
* obj: T,
|
29
|
+
* path: FieldPath<T, P>,
|
30
|
+
* ): FieldPathValue<T, P>
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
export declare type FieldPath<TFieldValues, TPathString extends PathString> = TypedFieldPath<TFieldValues, TPathString, unknown, never>;
|
34
|
+
/**
|
35
|
+
* Type which offers autocompletion of paths through a form which point to an array.
|
36
|
+
* @typeParam TFieldValues - the field values for which this path is valid
|
37
|
+
* @typeParam TPathString - the string representation of the path
|
38
|
+
* @typeParam TArrayValues - the value which may be read from array at the path
|
39
|
+
* @typeParam TArrayValuesSet - the value which can be written to the array at the path
|
40
|
+
* @example
|
41
|
+
* ```
|
42
|
+
* declare function popNumber<T extends FieldValues, P extends PathString>(
|
43
|
+
* obj: T,
|
44
|
+
* path: TypedFieldArrayPath<T, P, number>,
|
45
|
+
* ): number
|
46
|
+
* ```
|
47
|
+
*/
|
48
|
+
export declare type TypedFieldArrayPath<TFieldValues, TPathString extends PathString, TArrayValues extends FieldValues, TArrayValuesSet extends FieldValues = TArrayValues> = TypedFieldPath<TFieldValues, TPathString, ReadonlyArray<TArrayValues> | null | undefined, TArrayValuesSet[]>;
|
49
|
+
/**
|
50
|
+
* Type which offers autocompletion of paths through a form which point to an array.
|
51
|
+
* @typeParam TFieldValues - the field values for which this path is valid
|
52
|
+
* @typeParam TPathString - the string representation of the path
|
53
|
+
* @example
|
54
|
+
* ```
|
55
|
+
* declare function pop<T extends FieldValues, P extends PathString>(
|
56
|
+
* obj: T,
|
57
|
+
* path: FieldArrayPath<T, P>,
|
58
|
+
* ): FieldPathValue<T, P>[never]
|
59
|
+
* ```
|
60
|
+
*/
|
61
|
+
export declare type FieldArrayPath<TFieldValues, TPathString extends PathString> = TypedFieldArrayPath<TFieldValues, TPathString, FieldValues, never>;
|
62
|
+
//# sourceMappingURL=lazy.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/types/path/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,oBAAY,cAAc,CACxB,YAAY,EACZ,WAAW,SAAS,UAAU,EAC9B,MAAM,EACN,SAAS,GAAG,MAAM,IAChB,WAAW,SAAS,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAC1C,KAAK,GACL,gBAAgB,CACd,YAAY,EACZ,WAAW,EACX,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CACjC,CAAC;AAEN;;;;;;;;;;;GAWG;AACH,oBAAY,SAAS,CACnB,YAAY,EACZ,WAAW,SAAS,UAAU,IAC5B,cAAc,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,oBAAY,mBAAmB,CAC7B,YAAY,EACZ,WAAW,SAAS,UAAU,EAC9B,YAAY,SAAS,WAAW,EAChC,eAAe,SAAS,WAAW,GAAG,YAAY,IAChD,cAAc,CAChB,YAAY,EACZ,WAAW,EACX,aAAa,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAC9C,eAAe,EAAE,CAClB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,oBAAY,cAAc,CACxB,YAAY,EACZ,WAAW,SAAS,UAAU,IAC5B,mBAAmB,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pathString.d.ts","sourceRoot":"","sources":["../../../src/types/path/pathString.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,UAAU,GAAG,MAAM,CAAC"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { IsNever } from '../utils';
|
2
|
+
import { PathGetValue } from './internal/pathGetValue';
|
3
|
+
import { PathSetValue } from './internal/pathSetValue';
|
4
|
+
import { SplitPathString } from './internal/pathTuple';
|
5
|
+
import * as Branded from './branded';
|
6
|
+
import { PathString } from './pathString';
|
7
|
+
/**
|
8
|
+
* Type for getting the value of a path.
|
9
|
+
* @typeParam TFieldValues - the field values for which this path is valid
|
10
|
+
* @typeParam TPathString - the string representation of the path
|
11
|
+
* @example
|
12
|
+
* ```
|
13
|
+
* declare function get<T extends FieldValues, P extends PathString>(
|
14
|
+
* obj: T,
|
15
|
+
* path: Auto.FieldPath<T, P>,
|
16
|
+
* ): FieldPathValue<T, P>
|
17
|
+
* ```
|
18
|
+
*/
|
19
|
+
export declare type FieldPathValue<TFieldValues, TPathString extends PathString> = IsNever<TPathString> extends true ? unknown : TPathString extends Branded.FieldPath<any> ? TPathString extends Branded.TypedFieldPath<TFieldValues, infer Value, never> ? Value : unknown : PathGetValue<TFieldValues, SplitPathString<TPathString>>;
|
20
|
+
/**
|
21
|
+
* Type for getting the value which required for setting a path.
|
22
|
+
* @typeParam TFieldValues - the field values for which this path is valid
|
23
|
+
* @typeParam TPathString - the string representation of the path
|
24
|
+
* @example
|
25
|
+
* ```
|
26
|
+
* declare function set<T extends FieldValues, P extends PathString>(
|
27
|
+
* obj: T,
|
28
|
+
* path: Auto.FieldPath<T, P>,
|
29
|
+
* value: FieldPathSetValue<T, P>
|
30
|
+
* ): void
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
export declare type FieldPathSetValue<TFieldValues, TPathString extends PathString> = TPathString extends Branded.FieldPath<any> ? TPathString extends Branded.TypedFieldPath<TFieldValues, unknown, infer Value> ? Value : never : PathSetValue<TFieldValues, SplitPathString<TPathString>>;
|
34
|
+
/**
|
35
|
+
* Type for getting the values of a tuple of paths.
|
36
|
+
* @typeParam TFieldValues - the field values for which the paths are valid
|
37
|
+
* @typeParam TPathStrings - the string representations of the paths
|
38
|
+
* @example
|
39
|
+
* ```
|
40
|
+
* declare function get<
|
41
|
+
* T extends FieldValues,
|
42
|
+
* P extends ReadonlyArray<PathString>,
|
43
|
+
* >(obj: T, paths: Auto.FieldPaths<T, P>): FieldPathValues<T, P>
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
export declare type FieldPathValues<TFieldValues, TPathStrings extends ReadonlyArray<PathString>> = IsNever<TPathStrings> extends true ? unknown[] : {
|
47
|
+
[Idx in keyof TPathStrings]: FieldPathValue<TFieldValues, Extract<TPathStrings[Idx], PathString>>;
|
48
|
+
};
|
49
|
+
//# sourceMappingURL=value.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"value.d.ts","s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OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CACvC;CACF,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { FieldErrors } from './errors';
|
2
2
|
import { Field, FieldName, FieldValues, InternalFieldName } from './fields';
|
3
|
-
import { CriteriaMode
|
3
|
+
import { CriteriaMode } from './form';
|
4
4
|
export declare type ResolverSuccess<TFieldValues extends FieldValues = FieldValues> = {
|
5
|
-
values:
|
5
|
+
values: TFieldValues;
|
6
6
|
errors: {};
|
7
7
|
};
|
8
8
|
export declare type ResolverError<TFieldValues extends FieldValues = FieldValues> = {
|
@@ -16,5 +16,5 @@ export interface ResolverOptions<TFieldValues> {
|
|
16
16
|
names?: FieldName<TFieldValues>[];
|
17
17
|
shouldUseNativeValidation: boolean | undefined;
|
18
18
|
}
|
19
|
-
export declare type Resolver<TFieldValues extends FieldValues = FieldValues, TContext = any> = (values:
|
19
|
+
export declare type Resolver<TFieldValues extends FieldValues = FieldValues, TContext = any> = (values: TFieldValues, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>> | ResolverResult<TFieldValues>;
|
20
20
|
//# sourceMappingURL=resolvers.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../src/types/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../src/types/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,oBAAY,eAAe,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,IAAI;IAC5E,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,EAAE,CAAC;CACZ,CAAC;AAEF,oBAAY,aAAa,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,IAAI;IAC1E,MAAM,EAAE,EAAE,CAAC;IACX,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;CACnC,CAAC;AAEF,oBAAY,cAAc,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,IACrE,eAAe,CAAC,YAAY,CAAC,GAC7B,aAAa,CAAC,YAAY,CAAC,CAAC;AAEhC,MAAM,WAAW,eAAe,CAAC,YAAY;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;IAClC,yBAAyB,EAAE,OAAO,GAAG,SAAS,CAAC;CAChD;AAED,oBAAY,QAAQ,CAClB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,IACZ,CACF,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,QAAQ,GAAG,SAAS,EAC7B,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,KACnC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC"}
|
package/dist/types/utils.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { NestedValue } from './form';
|
2
1
|
export declare type Noop = () => void;
|
3
2
|
interface File extends Blob {
|
4
3
|
readonly lastModified: number;
|
@@ -17,10 +16,10 @@ export declare type NonUndefined<T> = T extends undefined ? never : T;
|
|
17
16
|
export declare type LiteralUnion<T extends U, U extends Primitive> = T | (U & {
|
18
17
|
_?: never;
|
19
18
|
});
|
20
|
-
export declare type DeepPartial<T> = T extends Date | FileList | File
|
19
|
+
export declare type DeepPartial<T> = T extends Date | FileList | File ? T : {
|
21
20
|
[K in keyof T]?: DeepPartial<T[K]>;
|
22
21
|
};
|
23
|
-
export declare type DeepPartialSkipArrayKey<T> = T extends Date | FileList | File
|
22
|
+
export declare type DeepPartialSkipArrayKey<T> = T extends Date | FileList | File ? T : T extends ReadonlyArray<any> ? {
|
24
23
|
[K in keyof T]: DeepPartialSkipArrayKey<T[K]>;
|
25
24
|
} : {
|
26
25
|
[K in keyof T]?: DeepPartialSkipArrayKey<T[K]>;
|
@@ -39,14 +38,23 @@ export declare type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
39
38
|
* Checks whether the type is never
|
40
39
|
* @typeParam T - type which may be never
|
41
40
|
* ```
|
42
|
-
*
|
43
|
-
*
|
41
|
+
* IsNever<never> = true
|
42
|
+
* IsNever<string> = false
|
44
43
|
* ```
|
45
44
|
*/
|
46
45
|
export declare type IsNever<T> = [T] extends [never] ? true : false;
|
47
|
-
|
46
|
+
/**
|
47
|
+
* Checks whether the type is unknown
|
48
|
+
* @typeParam T - type which may be unknown
|
49
|
+
* ```
|
50
|
+
* IsUnknown<unknown> = true
|
51
|
+
* IsUnknown<string> = false
|
52
|
+
* ```
|
53
|
+
*/
|
54
|
+
export declare type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
|
55
|
+
export declare type DeepMap<T, TValue> = IsAny<T> extends true ? any : T extends Date | FileList | File ? TValue : T extends object ? {
|
48
56
|
[K in keyof T]: DeepMap<NonUndefined<T[K]>, TValue>;
|
49
57
|
} : TValue;
|
50
|
-
export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T],
|
58
|
+
export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T], Date | FileList>, any[] | object> extends never ? true : false;
|
51
59
|
export {};
|
52
60
|
//# sourceMappingURL=utils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"AASA,oBAAY,IAAI,GAAG,MAAM,IAAI,CAAC;AAE9B,UAAU,IAAK,SAAQ,IAAI;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,QAAQ;IAChB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,oBAAY,SAAS,GACjB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AAEX,oBAAY,WAAW,GAAG;KAAG,CAAC,IAAI,MAAM,GAAG,MAAM,GAAG,KAAK;CAAE,CAAC;AAE5D,oBAAY,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAE9D,oBAAY,YAAY,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,SAAS,IACrD,CAAC,GACD,CAAC,CAAC,GAAG;IAAE,CAAC,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAExB,oBAAY,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,GAAG,QAAQ,GAAG,IAAI,GACzD,CAAC,GACD;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE3C,oBAAY,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,GA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,6 @@
|
|
1
1
|
import { Message } from './errors';
|
2
2
|
import { FieldValues, InternalFieldName } from './fields';
|
3
|
-
import {
|
3
|
+
import { FieldPathValue, PathString } from './path';
|
4
4
|
export declare type ValidationValue = boolean | number | string | RegExp;
|
5
5
|
export declare type ValidationRule<TValidationValue extends ValidationValue = ValidationValue> = TValidationValue | ValidationValueMessage<TValidationValue>;
|
6
6
|
export declare type ValidationValueMessage<TValidationValue extends ValidationValue = ValidationValue> = {
|
@@ -9,7 +9,7 @@ export declare type ValidationValueMessage<TValidationValue extends ValidationVa
|
|
9
9
|
};
|
10
10
|
export declare type ValidateResult = Message | Message[] | boolean | undefined;
|
11
11
|
export declare type Validate<TFieldValue> = (value: TFieldValue) => ValidateResult | Promise<ValidateResult>;
|
12
|
-
export declare type RegisterOptions<TFieldValues extends FieldValues = FieldValues, TFieldName extends
|
12
|
+
export declare type RegisterOptions<TFieldValues extends FieldValues = FieldValues, TFieldName extends PathString = never> = Partial<{
|
13
13
|
required: Message | ValidationRule<boolean>;
|
14
14
|
min: ValidationRule<number | string>;
|
15
15
|
max: ValidationRule<number | string>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/types/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/types/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpD,oBAAY,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM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AAG,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;CAC/C,CAAC,CAAC"}
|
package/dist/useController.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { FieldValues, PathString, UseControllerProps, UseControllerReturn } from './types';
|
2
2
|
/**
|
3
3
|
* Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
|
4
4
|
*
|
@@ -23,5 +23,5 @@ import { FieldPath, FieldValues, UseControllerProps, UseControllerReturn } from
|
|
23
23
|
* }
|
24
24
|
* ```
|
25
25
|
*/
|
26
|
-
export declare function useController<TFieldValues extends FieldValues
|
26
|
+
export declare function useController<TFieldValues extends FieldValues, TName extends PathString>(props: UseControllerProps<TFieldValues, TName>): UseControllerReturn<TFieldValues, TName>;
|
27
27
|
//# sourceMappingURL=useController.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useController.d.ts","sourceRoot":"","sources":["../src/useController.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,
|
1
|
+
{"version":3,"file":"useController.d.ts","sourceRoot":"","sources":["../src/useController.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,WAAW,EAEX,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,YAAY,SAAS,WAAW,EAChC,KAAK,SAAS,UAAU,EAExB,KAAK,EAAE,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,GAC7C,mBAAmB,CAAC,YAAY,EAAE,KAAK,CAAC,CA+F1C"}
|
package/dist/useFieldArray.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { FieldValues, PathString, UseFieldArrayProps, UseFieldArrayReturn } from './types';
|
2
2
|
/**
|
3
3
|
* A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc.
|
4
4
|
*
|
@@ -36,5 +36,5 @@ import { FieldArrayPath, FieldValues, UseFieldArrayProps, UseFieldArrayReturn }
|
|
36
36
|
* }
|
37
37
|
* ```
|
38
38
|
*/
|
39
|
-
export declare function useFieldArray<TFieldValues extends FieldValues
|
39
|
+
export declare function useFieldArray<TFieldValues extends FieldValues, TFieldArrayName extends PathString>(props: UseFieldArrayProps<TFieldValues, TFieldArrayName>): UseFieldArrayReturn<TFieldValues, TFieldArrayName>;
|
40
40
|
//# sourceMappingURL=useFieldArray.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFieldArray.d.ts","sourceRoot":"","sources":["../src/useFieldArray.ts"],"names":[],"mappings":"AAkBA,OAAO,
|
1
|
+
{"version":3,"file":"useFieldArray.d.ts","sourceRoot":"","sources":["../src/useFieldArray.ts"],"names":[],"mappings":"AAkBA,OAAO,EAML,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAC3B,YAAY,SAAS,WAAW,EAChC,eAAe,SAAS,UAAU,EAElC,KAAK,EAAE,kBAAkB,CAAC,YAAY,EAAE,eAAe,CAAC,GACvD,mBAAmB,CAAC,YAAY,EAAE,eAAe,CAAC,CAsQpD"}
|
package/dist/useForm.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../src/useForm.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,WAAW,EAEX,YAAY,EACZ,aAAa,EACd,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,OAAO,CACrB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EAEd,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAM,GAC/C,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../src/useForm.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,WAAW,EAEX,YAAY,EACZ,aAAa,EACd,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,OAAO,CACrB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EAEd,KAAK,GAAE,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAM,GAC/C,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAmEvC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFormContext.d.ts","sourceRoot":"","sources":["../src/useFormContext.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useFormContext.d.ts","sourceRoot":"","sources":["../src/useFormContext.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,cAAc,0EAGkD,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,YAAY,qHASxB,CAAC"}
|
package/dist/useFormState.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FieldValues, UseFormStateProps, UseFormStateReturn } from './types';
|
1
|
+
import { FieldValues, PathString, UseFormStateProps, UseFormStateReturn } from './types';
|
2
2
|
/**
|
3
3
|
* This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
|
4
4
|
*
|
@@ -29,6 +29,6 @@ import { FieldValues, UseFormStateProps, UseFormStateReturn } from './types';
|
|
29
29
|
* }
|
30
30
|
* ```
|
31
31
|
*/
|
32
|
-
declare function useFormState<TFieldValues extends FieldValues
|
32
|
+
declare function useFormState<TFieldValues extends FieldValues, TFieldName extends PathString>(props?: UseFormStateProps<TFieldValues, TFieldName>): UseFormStateReturn<TFieldValues>;
|
33
33
|
export { useFormState };
|
34
34
|
//# sourceMappingURL=useFormState.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useFormState.d.ts","sourceRoot":"","sources":["../src/useFormState.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,iBAAS,YAAY,
|
1
|
+
{"version":3,"file":"useFormState.d.ts","sourceRoot":"","sources":["../src/useFormState.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EAEX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,iBAAS,YAAY,CACnB,YAAY,SAAS,WAAW,EAChC,UAAU,SAAS,UAAU,EAE7B,KAAK,CAAC,EAAE,iBAAiB,CAAC,YAAY,EAAE,UAAU,CAAC,GAClD,kBAAkB,CAAC,YAAY,CAAC,CAoDlC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|