@@ -3,8 +3,14 @@ import PropTypes from '../_util/vue-types';
3
3
import type { SizeType } from '../config-provider' ;
4
4
import omit from '../_util/omit' ;
5
5
import type { LiteralUnion , VueNode } from '../_util/type' ;
6
+ import type {
7
+ ChangeEventHandler ,
8
+ CompositionEventHandler ,
9
+ FocusEventHandler ,
10
+ KeyboardEventHandler ,
11
+ } from '../_util/EventInterface' ;
6
12
export const inputDefaultValue = Symbol ( ) as unknown as string ;
7
- const inputProps = {
13
+ const inputProps = ( ) => ( {
8
14
id : String ,
9
15
prefixCls : String ,
10
16
inputPrefixCls : String ,
@@ -63,19 +69,19 @@ const inputProps = {
63
69
bordered : { type : Boolean , default : undefined } ,
64
70
showCount : { type : [ Boolean , Object ] as PropType < boolean | ShowCountProps > } ,
65
71
htmlSize : Number ,
66
- onPressEnter : Function ,
67
- onKeydown : Function ,
68
- onKeyup : Function ,
69
- onFocus : Function ,
70
- onBlur : Function ,
71
- onChange : Function ,
72
- onInput : Function ,
73
- 'onUpdate:value' : Function ,
72
+ onPressEnter : Function as PropType < KeyboardEventHandler > ,
73
+ onKeydown : Function as PropType < KeyboardEventHandler > ,
74
+ onKeyup : Function as PropType < KeyboardEventHandler > ,
75
+ onFocus : Function as PropType < FocusEventHandler > ,
76
+ onBlur : Function as PropType < FocusEventHandler > ,
77
+ onChange : Function as PropType < ChangeEventHandler > ,
78
+ onInput : Function as PropType < ChangeEventHandler > ,
79
+ 'onUpdate:value' : Function as PropType < ( val : string ) => void > ,
74
80
valueModifiers : Object ,
75
81
hidden : Boolean ,
76
- } ;
82
+ } ) ;
77
83
export default inputProps ;
78
- export type InputProps = Partial < ExtractPropTypes < typeof inputProps > > ;
84
+ export type InputProps = Partial < ExtractPropTypes < ReturnType < typeof inputProps > > > ;
79
85
80
86
export interface AutoSizeType {
81
87
minRows ?: number ;
@@ -84,17 +90,17 @@ export interface AutoSizeType {
84
90
export interface ShowCountProps {
85
91
formatter : ( args : { count : number ; maxlength ?: number } ) => VueNode ;
86
92
}
87
- const textAreaProps = {
88
- ...omit ( inputProps , [ 'prefix' , 'addonBefore' , 'addonAfter' , 'suffix' ] ) ,
93
+ const textAreaProps = ( ) => ( {
94
+ ...omit ( inputProps ( ) , [ 'prefix' , 'addonBefore' , 'addonAfter' , 'suffix' ] ) ,
89
95
rows : Number ,
90
96
autosize : { type : [ Boolean , Object ] as PropType < AutoSizeType > , default : undefined } ,
91
97
autoSize : { type : [ Boolean , Object ] as PropType < AutoSizeType > , default : undefined } ,
92
98
onResize : { type : Function as PropType < ( size : { width : number ; height : number } ) => void > } ,
93
- onCompositionstart : Function ,
94
- onCompositionend : Function ,
99
+ onCompositionstart : Function as PropType < CompositionEventHandler > ,
100
+ onCompositionend : Function as PropType < CompositionEventHandler > ,
95
101
valueModifiers : Object ,
96
- } ;
102
+ } ) ;
97
103
98
104
export { textAreaProps } ;
99
105
100
- export type TextAreaProps = Partial < ExtractPropTypes < typeof textAreaProps > > ;
106
+ export type TextAreaProps = Partial < ExtractPropTypes < ReturnType < typeof textAreaProps > > > ;
0 commit comments