-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathinterface.ts
More file actions
119 lines (113 loc) · 2.63 KB
/
interface.ts
File metadata and controls
119 lines (113 loc) · 2.63 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import type {
CSSProperties,
InputHTMLAttributes,
KeyboardEventHandler,
MouseEventHandler,
ReactElement,
ReactNode,
} from 'react';
import type { InputFocusOptions } from './utils/commonUtils';
import type { LiteralUnion } from './utils/types';
export interface CommonInputProps {
allowCopy?: ReactNode | boolean;
copyCallback?: (
v: InputHTMLAttributes<HTMLInputElement>['value'],
ele: ReactElement<any, string | React.JSXElementConstructor<any>>,
) => void;
prefix?: ReactNode;
suffix?: ReactNode;
addonBefore?: ReactNode;
addonAfter?: ReactNode;
classes?: {
affixWrapper?: string;
group?: string;
wrapper?: string;
};
classNames?: {
prefix?: string;
suffix?: string;
};
styles?: {
prefix?: CSSProperties;
suffix?: CSSProperties;
};
allowClear?: boolean | { clearIcon?: ReactNode };
}
type DataAttr = Record<`data-${string}`, string>;
export interface BaseInputProps extends CommonInputProps {
value?: InputHTMLAttributes<HTMLInputElement>['value'];
inputElement: ReactElement;
prefixCls?: string;
className?: string;
style?: CSSProperties;
disabled?: boolean;
focused?: boolean;
triggerFocus?: () => void;
readOnly?: boolean;
handleReset?: MouseEventHandler;
hidden?: boolean;
dataAttrs?: {
affixWrapper?: DataAttr;
};
}
export interface ShowCountProps {
formatter: (args: {
value: string;
count: number;
maxLength?: number;
}) => ReactNode;
}
export interface InputProps
extends CommonInputProps,
Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'type'> {
prefixCls?: string;
// ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#%3Cinput%3E_types
type?: LiteralUnion<
| 'button'
| 'checkbox'
| 'color'
| 'date'
| 'datetime-local'
| 'email'
| 'file'
| 'hidden'
| 'image'
| 'month'
| 'number'
| 'password'
| 'radio'
| 'range'
| 'reset'
| 'search'
| 'submit'
| 'tel'
| 'text'
| 'time'
| 'url'
| 'week',
string
>;
onPressEnter?: KeyboardEventHandler<HTMLInputElement>;
showCount?: boolean | ShowCountProps;
autoComplete?: string;
htmlSize?: number;
classNames?: CommonInputProps['classNames'] & {
input?: string;
count?: string;
};
styles?: CommonInputProps['styles'] & {
input?: CSSProperties;
count?: CSSProperties;
};
}
export interface InputRef {
focus: (options?: InputFocusOptions) => void;
blur: () => void;
setSelectionRange: (
start: number,
end: number,
direction?: 'forward' | 'backward' | 'none',
) => void;
select: () => void;
input: HTMLInputElement | null;
}