1
- import { forwardRef , RefObject , useRef } from 'react' ;
1
+ import { ForwardedRef , forwardRef , RefObject , useRef } from 'react' ;
2
2
import { useLocale , useNumberField , AriaNumberFieldProps } from 'react-aria' ;
3
3
import { useNumberFieldState } from 'react-stately' ;
4
4
@@ -36,7 +36,10 @@ const StepperContainer = tasty({
36
36
} ,
37
37
} ) ;
38
38
39
- function NumberInput ( props : WithNullableValue < CubeNumberInputProps > , ref ) {
39
+ function NumberInput (
40
+ props : WithNullableValue < CubeNumberInputProps > ,
41
+ ref : ForwardedRef < HTMLElement > ,
42
+ ) {
40
43
props = castNullableNumberValue ( props ) ;
41
44
props = useProviderProps ( props ) ;
42
45
props = useFieldProps ( props ) ;
@@ -53,9 +56,9 @@ function NumberInput(props: WithNullableValue<CubeNumberInputProps>, ref) {
53
56
let showStepper = ! hideStepper ;
54
57
let { locale } = useLocale ( ) ;
55
58
let state = useNumberFieldState ( { ...props , locale } ) ;
56
- let defaultInputRef = useRef ( null ) ;
59
+ let localInputRef = useRef < HTMLInputElement > ( null ) ;
57
60
58
- inputRef = inputRef || defaultInputRef ;
61
+ inputRef = inputRef ?? localInputRef ;
59
62
60
63
let {
61
64
groupProps,
@@ -113,7 +116,7 @@ function NumberInput(props: WithNullableValue<CubeNumberInputProps>, ref) {
113
116
}
114
117
115
118
/**
116
- * NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.
119
+ * NumberFields allow users to enter a number and increment or decrement the value using stepper buttons.
117
120
*/
118
121
const _NumberInput = forwardRef ( NumberInput ) ;
119
122
0 commit comments