-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.ts
49 lines (43 loc) · 1.23 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
export interface FieldProps {
name: string;
type: string;
label: string;
options?: OptionsObject;
selected?: string;
required?: boolean;
checked?: boolean;
value?: string;
valid?: boolean;
normalize?: (value: string) => string;
validate?: (value: string) => [boolean, string];
onValidate?: (value: boolean) => void;
onValid?: () => void;
onInvalid?: (error: string) => void;
}
export interface OptionsObject {
[key: string]: {
label: string;
name?: string;
value?: string | number;
};
}
export interface RadioFieldProps extends FieldProps {
type: 'toggle' | 'group' | 'tabs';
onChange: (e: React.SyntheticEvent<HTMLInputElement>) => void;
}
export interface SelectFieldProps extends FieldProps {
type: 'select';
multiple?: boolean;
searchable?: boolean;
onChange?: (e: React.SyntheticEvent<HTMLSelectElement>) => void;
selectHandler?: (v: string[]) => void;
selectedValues?: string[];
}
export interface TextAreaFieldProps extends FieldProps {
type: 'textarea';
onChange: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
}
export interface TextFieldProps extends FieldProps {
type: 'text' | 'email' | 'password';
onChange: (e: React.SyntheticEvent<HTMLInputElement>) => void;
}