@@ -15,6 +15,7 @@ import * as React from 'react';
1515import useCursor from './hooks/useCursor' ;
1616import StepHandler from './StepHandler' ;
1717import { getDecupleSteps } from './utils/numberUtil' ;
18+ import SemanticContext from './SemanticContext' ;
1819
1920import type { HolderRef } from '@rc-component/input/lib/BaseInput' ;
2021import { BaseInputProps } from '@rc-component/input/lib/interface' ;
@@ -53,6 +54,7 @@ const getDecimalIfValidate = (value: ValueType) => {
5354 return decimal . isInvalidate ( ) ? null : decimal ;
5455} ;
5556
57+ type SemanticName = 'actions' | 'input' ;
5658export interface InputNumberProps < T extends ValueType = ValueType >
5759 extends Omit <
5860 React . InputHTMLAttributes < HTMLInputElement > ,
@@ -76,9 +78,8 @@ export interface InputNumberProps<T extends ValueType = ValueType>
7678 suffix ?: React . ReactNode ;
7779 addonBefore ?: React . ReactNode ;
7880 addonAfter ?: React . ReactNode ;
79- classNames ?: BaseInputProps [ 'classNames' ] & {
80- input ?: string ;
81- } ;
81+ classNames ?: BaseInputProps [ 'classNames' ] & Partial < Record < SemanticName , string > > ;
82+ styles ?: BaseInputProps [ 'styles' ] & Partial < Record < SemanticName , React . CSSProperties > > ;
8283
8384 // Customize handler node
8485 upHandler ?: React . ReactNode ;
@@ -99,7 +100,10 @@ export interface InputNumberProps<T extends ValueType = ValueType>
99100 onChange ?: ( value : T | null ) => void ;
100101 onPressEnter ?: React . KeyboardEventHandler < HTMLInputElement > ;
101102
102- onStep ?: ( value : T , info : { offset : ValueType ; type : 'up' | 'down' , emitter : 'handler' | 'keyboard' | 'wheel' } ) => void ;
103+ onStep ?: (
104+ value : T ,
105+ info : { offset : ValueType ; type : 'up' | 'down' ; emitter : 'handler' | 'keyboard' | 'wheel' } ,
106+ ) => void ;
103107
104108 /**
105109 * Trigger change onBlur event.
@@ -131,7 +135,6 @@ const InternalInputNumber = React.forwardRef(
131135 changeOnWheel = false ,
132136 controls = true ,
133137
134- classNames,
135138 stringMode,
136139
137140 parser,
@@ -151,6 +154,8 @@ const InternalInputNumber = React.forwardRef(
151154 ...inputProps
152155 } = props ;
153156
157+ const { classNames, styles } = React . useContext ( SemanticContext ) || { } ;
158+
154159 const inputClassName = `${ prefixCls } -input` ;
155160
156161 const inputRef = React . useRef < HTMLInputElement > ( null ) ;
@@ -614,7 +619,10 @@ const InternalInputNumber = React.forwardRef(
614619 onStep = { onInternalStep }
615620 />
616621 ) }
617- < div className = { `${ inputClassName } -wrap` } >
622+ < div
623+ className = { clsx ( `${ inputClassName } -wrap` , classNames ?. actions ) }
624+ style = { styles ?. actions }
625+ >
618626 < input
619627 autoComplete = "off"
620628 role = "spinbutton"
@@ -648,6 +656,7 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
648656 addonAfter,
649657 className,
650658 classNames,
659+ styles,
651660 ...rest
652661 } = props ;
653662
@@ -667,37 +676,41 @@ const InputNumber = React.forwardRef<InputNumberRef, InputNumberProps>((props, r
667676 nativeElement : holderRef . current . nativeElement || inputNumberDomRef . current ,
668677 } ) ,
669678 ) ;
670-
679+ const memoizedValue = React . useMemo ( ( ) => ( { classNames , styles } ) , [ classNames , styles ] ) ;
671680 return (
672- < BaseInput
673- className = { className }
674- triggerFocus = { focus }
675- prefixCls = { prefixCls }
676- value = { value }
677- disabled = { disabled }
678- style = { style }
679- prefix = { prefix }
680- suffix = { suffix }
681- addonAfter = { addonAfter }
682- addonBefore = { addonBefore }
683- classNames = { classNames }
684- components = { {
685- affixWrapper : 'div' ,
686- groupWrapper : 'div' ,
687- wrapper : 'div' ,
688- groupAddon : 'div' ,
689- } }
690- ref = { holderRef }
691- >
692- < InternalInputNumber
681+ < SemanticContext . Provider value = { memoizedValue } >
682+ < BaseInput
683+ className = { className }
684+ triggerFocus = { focus }
693685 prefixCls = { prefixCls }
686+ value = { value }
694687 disabled = { disabled }
695- ref = { inputFocusRef }
696- domRef = { inputNumberDomRef }
697- className = { classNames ?. input }
698- { ...rest }
699- />
700- </ BaseInput >
688+ style = { style }
689+ prefix = { prefix }
690+ suffix = { suffix }
691+ addonAfter = { addonAfter }
692+ addonBefore = { addonBefore }
693+ classNames = { classNames }
694+ styles = { styles }
695+ components = { {
696+ affixWrapper : 'div' ,
697+ groupWrapper : 'div' ,
698+ wrapper : 'div' ,
699+ groupAddon : 'div' ,
700+ } }
701+ ref = { holderRef }
702+ >
703+ < InternalInputNumber
704+ prefixCls = { prefixCls }
705+ disabled = { disabled }
706+ ref = { inputFocusRef }
707+ domRef = { inputNumberDomRef }
708+ className = { classNames ?. input }
709+ style = { styles ?. input }
710+ { ...rest }
711+ />
712+ </ BaseInput >
713+ </ SemanticContext . Provider >
701714 ) ;
702715} ) as ( < T extends ValueType = ValueType > (
703716 props : React . PropsWithChildren < InputNumberProps < T > > & {
0 commit comments