@@ -2,6 +2,7 @@ import * as React from 'react';
22import classNames from 'classnames' ;
33import { composeRef } from 'rc-util/lib/ref' ;
44import { warning } from 'rc-util/lib/warning' ;
5+ import composeProps from 'rc-util/lib/composeProps' ;
56
67type InputRef = HTMLInputElement | HTMLTextAreaElement ;
78
@@ -39,57 +40,36 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
3940 prefixCls,
4041 id,
4142 inputElement,
42- disabled,
43- tabIndex,
4443 autoFocus,
4544 autoComplete,
4645 editable,
4746 activeDescendantId,
4847 value,
49- maxLength,
50- onKeyDown,
51- onMouseDown,
52- onChange,
53- onPaste,
54- onCompositionStart,
55- onCompositionEnd,
56- onBlur,
5748 open,
5849 attrs,
50+ ...restProps
5951 } = props ;
6052
6153 let inputNode : React . ComponentElement < any , any > = inputElement || < input /> ;
6254
6355 const { ref : originRef , props : originProps } = inputNode ;
6456
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-
7557 warning (
7658 ! ( 'maxLength' in inputNode . props ) ,
7759 `Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.` ,
7860 ) ;
7961
8062 inputNode = React . cloneElement ( inputNode , {
8163 type : 'search' ,
82- ...originProps ,
64+ ...composeProps ( restProps , originProps , true ) ,
8365
8466 // Override over origin props
8567 id,
8668 ref : composeRef ( ref , originRef as any ) ,
87- disabled,
88- tabIndex,
8969 autoComplete : autoComplete || 'off' ,
9070
9171 autoFocus,
92- className : classNames ( `${ prefixCls } -selection-search-input` , inputNode ?. props ?. className ) ,
72+ className : classNames ( `${ prefixCls } -selection-search-input` , originProps ?. className ) ,
9373
9474 role : 'combobox' ,
9575 'aria-expanded' : open || false ,
@@ -100,49 +80,10 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
10080 'aria-activedescendant' : open ? activeDescendantId : undefined ,
10181 ...attrs ,
10282 value : editable ? value : '' ,
103- maxLength,
10483 readOnly : ! editable ,
10584 unselectable : ! editable ? 'on' : null ,
10685
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 } ,
14687 } ) ;
14788
14889 return inputNode ;
0 commit comments