@@ -2,7 +2,9 @@ import * as React from 'react';
22import classNames from 'classnames' ;
33import { composeRef } from '@rc-component/util/lib/ref' ;
44import { warning } from '@rc-component/util/lib/warning' ;
5+ import composeProps from '@rc-component/util/lib/composeProps' ;
56import useBaseProps from '../hooks/useBaseProps' ;
7+
68type InputRef = HTMLInputElement | HTMLTextAreaElement ;
79
810interface InputProps {
@@ -39,23 +41,13 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
3941 prefixCls,
4042 id,
4143 inputElement,
42- disabled,
43- tabIndex,
44- 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 const { classNames : contextClassNames , styles : contextStyles } = useBaseProps ( ) || { } ;
@@ -64,35 +56,23 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
6456
6557 const { ref : originRef , props : originProps } = inputNode ;
6658
67- const {
68- onKeyDown : onOriginKeyDown ,
69- onChange : onOriginChange ,
70- onMouseDown : onOriginMouseDown ,
71- onCompositionStart : onOriginCompositionStart ,
72- onCompositionEnd : onOriginCompositionEnd ,
73- onBlur : onOriginBlur ,
74- style,
75- } = originProps ;
76-
7759 warning (
7860 ! ( 'maxLength' in inputNode . props ) ,
7961 `Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.` ,
8062 ) ;
8163
8264 inputNode = React . cloneElement ( inputNode , {
8365 type : 'search' ,
84- ...originProps ,
66+ ...composeProps ( restProps , originProps , true ) ,
67+
8568 // Override over origin props
8669 id,
8770 ref : composeRef ( ref , originRef as any ) ,
88- disabled,
89- tabIndex,
9071 autoComplete : autoComplete || 'off' ,
9172
92- autoFocus,
9373 className : classNames (
9474 `${ prefixCls } -selection-search-input` ,
95- inputNode ?. props ? .className ,
75+ originProps . className ,
9676 contextClassNames ?. input ,
9777 ) ,
9878
@@ -105,48 +85,13 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
10585 'aria-activedescendant' : open ? activeDescendantId : undefined ,
10686 ...attrs ,
10787 value : editable ? value : '' ,
108- maxLength,
10988 readOnly : ! editable ,
11089 unselectable : ! editable ? 'on' : null ,
11190
112- style : { ...style , opacity : editable ? null : 0 , ...contextStyles ?. input } ,
113-
114- onKeyDown : ( event : React . KeyboardEvent < HTMLElement > ) => {
115- onKeyDown ( event ) ;
116- if ( onOriginKeyDown ) {
117- onOriginKeyDown ( event ) ;
118- }
119- } ,
120- onMouseDown : ( event : React . MouseEvent < HTMLElement > ) => {
121- onMouseDown ( event ) ;
122- if ( onOriginMouseDown ) {
123- onOriginMouseDown ( event ) ;
124- }
125- } ,
126- onChange : ( event : React . ChangeEvent < HTMLElement > ) => {
127- onChange ( event ) ;
128- if ( onOriginChange ) {
129- onOriginChange ( event ) ;
130- }
131- } ,
132- onCompositionStart ( event : React . CompositionEvent < HTMLElement > ) {
133- onCompositionStart ( event ) ;
134- if ( onOriginCompositionStart ) {
135- onOriginCompositionStart ( event ) ;
136- }
137- } ,
138- onCompositionEnd ( event : React . CompositionEvent < HTMLElement > ) {
139- onCompositionEnd ( event ) ;
140- if ( onOriginCompositionEnd ) {
141- onOriginCompositionEnd ( event ) ;
142- }
143- } ,
144- onPaste,
145- onBlur ( event : React . FocusEvent < HTMLElement > ) {
146- onBlur ( event ) ;
147- if ( onOriginBlur ) {
148- onOriginBlur ( event ) ;
149- }
91+ style : {
92+ ...originProps . style ,
93+ opacity : editable ? null : 0 ,
94+ ...contextStyles ?. input ,
15095 } ,
15196 } ) ;
15297
0 commit comments