remix-validated-form 3.2.0 → 3.2.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.
@@ -14,15 +14,8 @@ export declare type CreateGetInputPropsOptions = {
|
|
14
14
|
validationBehavior?: Partial<ValidationBehaviorOptions>;
|
15
15
|
name: string;
|
16
16
|
};
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
};
|
21
|
-
export declare type MinimalResult = {
|
22
|
-
name: string;
|
23
|
-
onChange: (...args: any[]) => void;
|
24
|
-
onBlur: (...args: any[]) => void;
|
25
|
-
defaultValue?: any;
|
26
|
-
};
|
27
|
-
export declare type GetInputProps = <T extends {}>(props?: T & MinimalInputProps) => T & MinimalResult;
|
17
|
+
declare type HandledProps = "name" | "defaultValue";
|
18
|
+
declare type Callbacks = "onChange" | "onBlur";
|
19
|
+
export declare type GetInputProps = <T extends Record<string, any>>(props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>) => T;
|
28
20
|
export declare const createGetInputProps: ({ clearError, validate, defaultValue, touched, setTouched, hasBeenSubmitted, validationBehavior, name, }: CreateGetInputPropsOptions) => GetInputProps;
|
21
|
+
export {};
|
@@ -14,7 +14,7 @@ export const createGetInputProps = ({ clearError, validate, defaultValue, touche
|
|
14
14
|
: touched
|
15
15
|
? validationBehaviors.whenTouched
|
16
16
|
: validationBehaviors.initial;
|
17
|
-
|
17
|
+
const result = {
|
18
18
|
...props,
|
19
19
|
onChange: (...args) => {
|
20
20
|
var _a;
|
@@ -34,5 +34,6 @@ export const createGetInputProps = ({ clearError, validate, defaultValue, touche
|
|
34
34
|
defaultValue,
|
35
35
|
name,
|
36
36
|
};
|
37
|
+
return result;
|
37
38
|
};
|
38
39
|
};
|
@@ -14,15 +14,8 @@ export declare type CreateGetInputPropsOptions = {
|
|
14
14
|
validationBehavior?: Partial<ValidationBehaviorOptions>;
|
15
15
|
name: string;
|
16
16
|
};
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
};
|
21
|
-
export declare type MinimalResult = {
|
22
|
-
name: string;
|
23
|
-
onChange: (...args: any[]) => void;
|
24
|
-
onBlur: (...args: any[]) => void;
|
25
|
-
defaultValue?: any;
|
26
|
-
};
|
27
|
-
export declare type GetInputProps = <T extends {}>(props?: T & MinimalInputProps) => T & MinimalResult;
|
17
|
+
declare type HandledProps = "name" | "defaultValue";
|
18
|
+
declare type Callbacks = "onChange" | "onBlur";
|
19
|
+
export declare type GetInputProps = <T extends Record<string, any>>(props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>) => T;
|
28
20
|
export declare const createGetInputProps: ({ clearError, validate, defaultValue, touched, setTouched, hasBeenSubmitted, validationBehavior, name, }: CreateGetInputPropsOptions) => GetInputProps;
|
21
|
+
export {};
|
@@ -17,7 +17,7 @@ const createGetInputProps = ({ clearError, validate, defaultValue, touched, setT
|
|
17
17
|
: touched
|
18
18
|
? validationBehaviors.whenTouched
|
19
19
|
: validationBehaviors.initial;
|
20
|
-
|
20
|
+
const result = {
|
21
21
|
...props,
|
22
22
|
onChange: (...args) => {
|
23
23
|
var _a;
|
@@ -37,6 +37,7 @@ const createGetInputProps = ({ clearError, validate, defaultValue, touched, setT
|
|
37
37
|
defaultValue,
|
38
38
|
name,
|
39
39
|
};
|
40
|
+
return result;
|
40
41
|
};
|
41
42
|
};
|
42
43
|
exports.createGetInputProps = createGetInputProps;
|
package/package.json
CHANGED
@@ -17,21 +17,12 @@ export type CreateGetInputPropsOptions = {
|
|
17
17
|
name: string;
|
18
18
|
};
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
onBlur?: (...args: any[]) => void;
|
23
|
-
};
|
20
|
+
type HandledProps = "name" | "defaultValue";
|
21
|
+
type Callbacks = "onChange" | "onBlur";
|
24
22
|
|
25
|
-
export type
|
26
|
-
|
27
|
-
|
28
|
-
onBlur: (...args: any[]) => void;
|
29
|
-
defaultValue?: any;
|
30
|
-
};
|
31
|
-
|
32
|
-
export type GetInputProps = <T extends {}>(
|
33
|
-
props?: T & MinimalInputProps
|
34
|
-
) => T & MinimalResult;
|
23
|
+
export type GetInputProps = <T extends Record<string, any>>(
|
24
|
+
props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>
|
25
|
+
) => T;
|
35
26
|
|
36
27
|
const defaultValidationBehavior: ValidationBehaviorOptions = {
|
37
28
|
initial: "onBlur",
|
@@ -54,20 +45,21 @@ export const createGetInputProps = ({
|
|
54
45
|
...validationBehavior,
|
55
46
|
};
|
56
47
|
|
57
|
-
return (props = {} as any) => {
|
48
|
+
return <T extends Record<string, any>>(props = {} as any) => {
|
58
49
|
const behavior = hasBeenSubmitted
|
59
50
|
? validationBehaviors.whenSubmitted
|
60
51
|
: touched
|
61
52
|
? validationBehaviors.whenTouched
|
62
53
|
: validationBehaviors.initial;
|
63
|
-
|
54
|
+
|
55
|
+
const result: T = {
|
64
56
|
...props,
|
65
|
-
onChange: (...args) => {
|
57
|
+
onChange: (...args: unknown[]) => {
|
66
58
|
if (behavior === "onChange") validate();
|
67
59
|
else clearError();
|
68
60
|
return props?.onChange?.(...args);
|
69
61
|
},
|
70
|
-
onBlur: (...args) => {
|
62
|
+
onBlur: (...args: unknown[]) => {
|
71
63
|
if (behavior === "onBlur") validate();
|
72
64
|
setTouched(true);
|
73
65
|
return props?.onBlur?.(...args);
|
@@ -75,5 +67,7 @@ export const createGetInputProps = ({
|
|
75
67
|
defaultValue,
|
76
68
|
name,
|
77
69
|
};
|
70
|
+
|
71
|
+
return result;
|
78
72
|
};
|
79
73
|
};
|