-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathinterface.ts
More file actions
159 lines (149 loc) · 3.53 KB
/
interface.ts
File metadata and controls
159 lines (149 loc) · 3.53 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import type {
CSSProperties,
InputHTMLAttributes,
KeyboardEventHandler,
MouseEventHandler,
ReactElement,
ReactNode,
} from 'react';
import type { LiteralUnion } from './utils/types';
import type { InputFocusOptions } from '@rc-component/util/lib/Dom/focus';
export interface CommonInputProps {
prefix?: ReactNode;
suffix?: ReactNode;
addonBefore?: ReactNode;
addonAfter?: ReactNode;
/** @deprecated Use `classNames` instead */
classes?: {
affixWrapper?: string;
group?: string;
wrapper?: string;
};
classNames?: {
affixWrapper?: string;
prefix?: string;
suffix?: string;
groupWrapper?: string;
wrapper?: string;
variant?: string;
};
styles?: {
affixWrapper?: CSSProperties;
prefix?: CSSProperties;
suffix?: CSSProperties;
};
allowClear?: boolean | { disabled?: boolean; clearIcon?: ReactNode };
}
type DataAttr = Record<`data-${string}`, string>;
export type ValueType = InputHTMLAttributes<HTMLInputElement>['value'] | bigint;
export interface BaseInputProps extends CommonInputProps {
value?: ValueType;
/** @deprecated Use `children` instead */
inputElement?: ReactElement;
prefixCls?: string;
className?: string;
style?: CSSProperties;
disabled?: boolean;
focused?: boolean;
triggerFocus?: () => void;
readOnly?: boolean;
handleReset?: MouseEventHandler;
onClear?: () => void;
hidden?: boolean;
dataAttrs?: {
affixWrapper?: DataAttr;
};
components?: {
affixWrapper?: 'span' | 'div';
groupWrapper?: 'span' | 'div';
wrapper?: 'span' | 'div';
groupAddon?: 'span' | 'div';
};
children: ReactElement;
}
export type ShowCountFormatter = (args: {
value: string;
count: number;
maxLength?: number;
}) => ReactNode;
export type ExceedFormatter = (
value: string,
config: { max: number },
) => string;
export interface CountConfig {
max?: number;
strategy?: (value: string) => number;
show?: boolean | ShowCountFormatter;
/** Trigger when content larger than the `max` limitation */
exceedFormatter?: ExceedFormatter;
}
export interface InputProps
extends
CommonInputProps,
Omit<
InputHTMLAttributes<HTMLInputElement>,
'size' | 'prefix' | 'type' | 'value'
> {
value?: ValueType;
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>;
/** It's better to use `count.show` instead */
showCount?:
| boolean
| {
formatter: ShowCountFormatter;
};
autoComplete?: string;
htmlSize?: number;
classNames?: CommonInputProps['classNames'] & {
input?: string;
count?: string;
};
styles?: CommonInputProps['styles'] & {
input?: CSSProperties;
count?: CSSProperties;
};
count?: CountConfig;
onClear?: () => void;
}
export interface InputRef {
focus: (options?: InputFocusOptions) => void;
blur: () => void;
setSelectionRange: (
start: number,
end: number,
direction?: 'forward' | 'backward' | 'none',
) => void;
select: () => void;
input: HTMLInputElement | null;
nativeElement: HTMLElement | null;
}
export interface ChangeEventInfo {
source: 'compositionEnd' | 'change';
}