-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
45 lines (38 loc) · 1.25 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
import React from 'react';
import {
Control,
RegisterOptions,
} from 'react-hook-form'
import { Any } from 'src/types/share';
type BaseProps = {
onChange: React.ChangeEventHandler<HTMLInputElement> | React.ChangeEventHandler<HTMLTextAreaElement>;
rules: Omit<
RegisterOptions<Any, Any>,
'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'
>;
required: boolean;
}
export type OptionalProps<T = unknown> =
Partial<React.InputHTMLAttributes<HTMLElement> |
React.TextareaHTMLAttributes<HTMLElement>> &
Partial<BaseProps> &
Partial<React.MutableRefObject<T>>
export type InputBaseProps<T = HTMLInputElement | HTMLTextAreaElement> = OptionalProps<T> & {
// React hook form
name: string;
control: Control<Any, Any>;
shouldUnregister?: boolean;
// Base
color?: "primary" | "secondary" | "success" | "error" | "info"
variant?: "outlined" | "filled" | "standard"
inputComponent?: string;
sx?: React.CSSProperties | { [p: string]: Any }
// Errors
isError?: boolean
errors?: { [x: string]: Any }
errorMessage?: string;
// Icon
activeIconOnChange?: boolean;
// Multiline/textarea
multiline?: boolean
}