@@ -53,9 +53,33 @@ const getDecimalIfValidate = (value: ValueType) => {
5353type SemanticName = 'root' | 'actions' | 'input' | 'action' | 'prefix' | 'suffix' ;
5454export interface InputNumberProps < T extends ValueType = ValueType >
5555 extends Omit <
56- React . InputHTMLAttributes < HTMLInputElement > ,
57- 'value' | 'defaultValue' | 'onInput' | 'onChange' | 'prefix' | 'suffix'
58- > {
56+ React . InputHTMLAttributes < HTMLInputElement > ,
57+ | 'value'
58+ | 'defaultValue'
59+ | 'onInput'
60+ | 'onChange'
61+ | 'prefix'
62+ | 'suffix'
63+ | 'onMouseDown'
64+ | 'onClick'
65+ | 'onMouseUp'
66+ | 'onMouseLeave'
67+ | 'onMouseMove'
68+ | 'onMouseEnter'
69+ | 'onMouseOut'
70+ > ,
71+ Pick <
72+ React . HTMLAttributes < HTMLDivElement > ,
73+ | 'onMouseDown'
74+ | 'onClick'
75+ | 'onMouseUp'
76+ | 'onMouseLeave'
77+ | 'onMouseMove'
78+ | 'onMouseEnter'
79+ | 'onMouseOut'
80+ > {
81+ disabled ?: boolean ;
82+ readOnly ?: boolean ;
5983 /** value will show as string */
6084 stringMode ?: boolean ;
6185
@@ -143,9 +167,18 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
143167 onPressEnter,
144168 onStep,
145169
170+ // Mouse Events
171+ onMouseDown,
172+ onClick,
173+ onMouseUp,
174+ onMouseLeave,
175+ onMouseMove,
176+ onMouseEnter,
177+ onMouseOut,
178+
146179 changeOnBlur = true ,
147180
148- ...inputProps
181+ ...restProps
149182 } = props ;
150183
151184 const [ focus , setFocus ] = React . useState ( false ) ;
@@ -561,6 +594,15 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
561594 userTypingRef . current = false ;
562595 } ;
563596
597+ // >>> Mouse events
598+ const onInternalMouseDown : React . MouseEventHandler < HTMLDivElement > = ( event ) => {
599+ if ( inputRef . current && event . target !== inputRef . current ) {
600+ inputRef . current . focus ( ) ;
601+ }
602+
603+ onMouseDown ?.( event ) ;
604+ } ;
605+
564606 // ========================== Controlled ==========================
565607 // Input by precision & formatter
566608 useLayoutUpdateEffect ( ( ) => {
@@ -624,6 +666,13 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
624666 [ `${ prefixCls } -out-of-range` ] : ! decimalValue . isInvalidate ( ) && ! isInRange ( decimalValue ) ,
625667 } ) }
626668 style = { { ...styles ?. root , ...style } }
669+ onMouseDown = { onInternalMouseDown }
670+ onMouseUp = { onMouseUp }
671+ onMouseLeave = { onMouseLeave }
672+ onMouseMove = { onMouseMove }
673+ onMouseEnter = { onMouseEnter }
674+ onMouseOut = { onMouseOut }
675+ onClick = { onClick }
627676 onFocus = { ( ) => {
628677 setFocus ( true ) ;
629678 } }
@@ -649,14 +698,14 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
649698 aria-valuemax = { max as any }
650699 aria-valuenow = { decimalValue . isInvalidate ( ) ? null : ( decimalValue . toString ( ) as any ) }
651700 step = { step }
652- { ...inputProps }
653701 ref = { inputRef }
654702 className = { clsx ( `${ prefixCls } -input` , classNames ?. input ) }
655703 style = { styles ?. input }
656704 value = { inputValue }
657705 onChange = { onInternalInput }
658706 disabled = { disabled }
659707 readOnly = { readOnly }
708+ { ...restProps }
660709 />
661710
662711 { suffix !== undefined && (
0 commit comments