Skip to content

Commit 26faa7c

Browse files
committed
Update index.d.ts
1 parent 631af30 commit 26faa7c

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

src/index.d.ts

+23-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for react-use-form-state 0.1
1+
// Type definitions for react-use-form-state 0.2
22
// Project: https://github.com/wsmd/react-use-form-state
33
// Definitions by: Waseem Dahman <https://github.com/wsmd>
44

@@ -7,47 +7,43 @@ export function useFormState<
77
>(initialState?: T): [FormState<T>, Inputs];
88

99
interface FormState<T> {
10-
values: FormStateValues<T>;
11-
validity: FormStateValidations<T>;
12-
touched: FormStateValidations<T>;
10+
values: InputValues<T>;
11+
validity: InputValuesValidity<T>;
12+
touched: InputValuesValidity<T>;
1313
}
1414

1515
interface Inputs {
16-
select(name: string): Omit<SharedInputProps, 'type'>;
17-
email(name: string): SharedInputProps;
18-
color(name: string): SharedInputProps;
19-
password(name: string): SharedInputProps;
20-
text(name: string): SharedInputProps;
21-
url(name: string): SharedInputProps;
22-
search(name: string): SharedInputProps;
23-
number(name: string): SharedInputProps;
24-
range(name: string): SharedInputProps;
25-
tel(name: string): SharedInputProps;
26-
radio(name: string, value: string): SharedInputProps & CheckedProp;
27-
checkbox(name: string, value: string): SharedInputProps & CheckedProp;
28-
date(name: string): SharedInputProps;
29-
month(name: string): SharedInputProps;
30-
week(name: string): SharedInputProps;
31-
time(name: string): SharedInputProps;
16+
select(name: string): Omit<InputProps, 'type'>;
17+
email(name: string): InputProps;
18+
color(name: string): InputProps;
19+
password(name: string): InputProps;
20+
text(name: string): InputProps;
21+
url(name: string): InputProps;
22+
search(name: string): InputProps;
23+
number(name: string): InputProps;
24+
range(name: string): InputProps;
25+
tel(name: string): InputProps;
26+
radio(name: string, value: string): InputProps & CheckedProp;
27+
checkbox(name: string, value: string): InputProps & CheckedProp;
28+
date(name: string): InputProps;
29+
month(name: string): InputProps;
30+
week(name: string): InputProps;
31+
time(name: string): InputProps;
3232
}
3333

3434
type Maybe<T> = T | void;
3535

3636
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
3737

38-
type FormStateValues<T> = { readonly [A in keyof T]: T[A] } & {
38+
type InputValues<T> = { readonly [A in keyof T]: T[A] } & {
3939
readonly [key: string]: Maybe<string | string[]>;
4040
};
4141

42-
type FormStateValidations<T> = { readonly [A in keyof T]: Maybe<boolean> } & {
42+
type InputValuesValidity<T> = { readonly [A in keyof T]: Maybe<boolean> } & {
4343
readonly [key: string]: Maybe<boolean>;
4444
};
4545

46-
interface TypeProp {
47-
type: string;
48-
}
49-
50-
interface SharedInputProps {
46+
interface InputProps {
5147
onChange(e: any): void;
5248
onBlur(e: any): void;
5349
value: string;

0 commit comments

Comments
 (0)