@@ -2,7 +2,9 @@ import * as React from 'react';
2
2
import classNames from 'classnames' ;
3
3
import { composeRef } from '@rc-component/util/lib/ref' ;
4
4
import { warning } from '@rc-component/util/lib/warning' ;
5
+ import composeProps from '@rc-component/util/lib/composeProps' ;
5
6
import useBaseProps from '../hooks/useBaseProps' ;
7
+
6
8
type InputRef = HTMLInputElement | HTMLTextAreaElement ;
7
9
8
10
interface InputProps {
@@ -39,23 +41,13 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
39
41
prefixCls,
40
42
id,
41
43
inputElement,
42
- disabled,
43
- tabIndex,
44
- 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
const { classNames : contextClassNames , styles : contextStyles } = useBaseProps ( ) || { } ;
@@ -64,35 +56,23 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
64
56
65
57
const { ref : originRef , props : originProps } = inputNode ;
66
58
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
-
77
59
warning (
78
60
! ( 'maxLength' in inputNode . props ) ,
79
61
`Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.` ,
80
62
) ;
81
63
82
64
inputNode = React . cloneElement ( inputNode , {
83
65
type : 'search' ,
84
- ...originProps ,
66
+ ...composeProps ( restProps , originProps , true ) ,
67
+
85
68
// Override over origin props
86
69
id,
87
70
ref : composeRef ( ref , originRef as any ) ,
88
- disabled,
89
- tabIndex,
90
71
autoComplete : autoComplete || 'off' ,
91
72
92
- autoFocus,
93
73
className : classNames (
94
74
`${ prefixCls } -selection-search-input` ,
95
- inputNode ?. props ? .className ,
75
+ originProps . className ,
96
76
contextClassNames ?. input ,
97
77
) ,
98
78
@@ -105,48 +85,13 @@ const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (props, ref)
105
85
'aria-activedescendant' : open ? activeDescendantId : undefined ,
106
86
...attrs ,
107
87
value : editable ? value : '' ,
108
- maxLength,
109
88
readOnly : ! editable ,
110
89
unselectable : ! editable ? 'on' : null ,
111
90
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 ,
150
95
} ,
151
96
} ) ;
152
97
0 commit comments