@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
import classNames from 'classnames' ;
3
3
import { composeRef } from 'rc-util/lib/ref' ;
4
4
import { warning } from 'rc-util/lib/warning' ;
5
+ import composeProps from 'rc-util/lib/composeProps' ;
5
6
6
7
type InputRef = HTMLInputElement | HTMLTextAreaElement ;
7
8
@@ -39,57 +40,36 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
39
40
prefixCls,
40
41
id,
41
42
inputElement,
42
- disabled,
43
- tabIndex,
44
43
autoFocus,
45
44
autoComplete,
46
45
editable,
47
46
activeDescendantId,
48
47
value,
49
- maxLength,
50
- onKeyDown,
51
- onMouseDown,
52
- onChange,
53
- onPaste,
54
- onCompositionStart,
55
- onCompositionEnd,
56
- onBlur,
57
48
open,
58
49
attrs,
50
+ ...restProps
59
51
} = props ;
60
52
61
53
let inputNode : React . ComponentElement < any , any > = inputElement || < input /> ;
62
54
63
55
const { ref : originRef , props : originProps } = inputNode ;
64
56
65
- const {
66
- onKeyDown : onOriginKeyDown ,
67
- onChange : onOriginChange ,
68
- onMouseDown : onOriginMouseDown ,
69
- onCompositionStart : onOriginCompositionStart ,
70
- onCompositionEnd : onOriginCompositionEnd ,
71
- onBlur : onOriginBlur ,
72
- style,
73
- } = originProps ;
74
-
75
57
warning (
76
58
! ( 'maxLength' in inputNode . props ) ,
77
59
`Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.` ,
78
60
) ;
79
61
80
62
inputNode = React . cloneElement ( inputNode , {
81
63
type : 'search' ,
82
- ...originProps ,
64
+ ...composeProps ( restProps , originProps , true ) ,
83
65
84
66
// Override over origin props
85
67
id,
86
68
ref : composeRef ( ref , originRef as any ) ,
87
- disabled,
88
- tabIndex,
89
69
autoComplete : autoComplete || 'off' ,
90
70
91
71
autoFocus,
92
- className : classNames ( `${ prefixCls } -selection-search-input` , inputNode ?. props ?. className ) ,
72
+ className : classNames ( `${ prefixCls } -selection-search-input` , originProps ?. className ) ,
93
73
94
74
role : 'combobox' ,
95
75
'aria-expanded' : open || false ,
@@ -100,49 +80,10 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
100
80
'aria-activedescendant' : open ? activeDescendantId : undefined ,
101
81
...attrs ,
102
82
value : editable ? value : '' ,
103
- maxLength,
104
83
readOnly : ! editable ,
105
84
unselectable : ! editable ? 'on' : null ,
106
85
107
- style : { ...style , opacity : editable ? null : 0 } ,
108
-
109
- onKeyDown : ( event : React . KeyboardEvent < HTMLElement > ) => {
110
- onKeyDown ( event ) ;
111
- if ( onOriginKeyDown ) {
112
- onOriginKeyDown ( event ) ;
113
- }
114
- } ,
115
- onMouseDown : ( event : React . MouseEvent < HTMLElement > ) => {
116
- onMouseDown ( event ) ;
117
- if ( onOriginMouseDown ) {
118
- onOriginMouseDown ( event ) ;
119
- }
120
- } ,
121
- onChange : ( event : React . ChangeEvent < HTMLElement > ) => {
122
- onChange ( event ) ;
123
- if ( onOriginChange ) {
124
- onOriginChange ( event ) ;
125
- }
126
- } ,
127
- onCompositionStart ( event : React . CompositionEvent < HTMLElement > ) {
128
- onCompositionStart ( event ) ;
129
- if ( onOriginCompositionStart ) {
130
- onOriginCompositionStart ( event ) ;
131
- }
132
- } ,
133
- onCompositionEnd ( event : React . CompositionEvent < HTMLElement > ) {
134
- onCompositionEnd ( event ) ;
135
- if ( onOriginCompositionEnd ) {
136
- onOriginCompositionEnd ( event ) ;
137
- }
138
- } ,
139
- onPaste,
140
- onBlur ( event : React . FocusEvent < HTMLElement > ) {
141
- onBlur ( event ) ;
142
- if ( onOriginBlur ) {
143
- onOriginBlur ( event ) ;
144
- }
145
- } ,
86
+ style : { ...originProps . style , opacity : editable ? null : 0 } ,
146
87
} ) ;
147
88
148
89
return inputNode ;
0 commit comments