@@ -49,20 +49,12 @@ export default function Story() {
4949 ) ;
5050}
5151
52- interface InputStepperProps {
53- value : number | "" ;
54- onChange : ( e : ChangeEvent < HTMLInputElement > ) => void ;
52+ type InputStepperProps = JSX . IntrinsicElements [ "input" ] & {
5553 step ?: number ;
5654 min ?: number ;
5755 max ?: number ;
5856 round ?: boolean ;
59- name ?: string ;
60- id ?: string ;
61- disabled ?: boolean ;
62- readOnly ?: boolean ;
63- className ?: string ;
64- placeholder ?: string ;
65- }
57+ } ;
6658
6759function InputStepper ( {
6860 value,
@@ -128,7 +120,6 @@ function InputStepper({
128120
129121 function roundToStep ( val : number ) : number {
130122 if ( step <= 0 ) return val ;
131- // HTML number input uses min as the step base when provided, otherwise 0
132123 const base = min ?? 0 ;
133124 const shifted = val - base ;
134125 const quotient = shifted / step ;
@@ -138,7 +129,6 @@ function InputStepper({
138129 const up = base + ceiled * step ;
139130 const distDown = Math . abs ( val - down ) ;
140131 const distUp = Math . abs ( up - val ) ;
141- // Ties go down
142132 return distUp < distDown ? up : down ;
143133 }
144134
@@ -154,7 +144,7 @@ function InputStepper({
154144 // Update the real input's value for immediate UI feedback
155145 el . value = String ( rounded ) ;
156146 // Invoke consumer onChange with the real element as target/currentTarget
157- onChange ( {
147+ onChange ?. ( {
158148 target : el ,
159149 currentTarget : el ,
160150 } as unknown as ChangeEvent < HTMLInputElement > ) ;
@@ -181,13 +171,13 @@ function InputStepper({
181171 if ( e . currentTarget . value === "" ) {
182172 // reflect emptiness in the input and notify consumer as empty
183173 if ( inputRef . current ) inputRef . current . value = "" ;
184- onChange ( {
174+ onChange ?. ( {
185175 target : e . currentTarget ,
186176 currentTarget : e . currentTarget ,
187177 } as ChangeEvent < HTMLInputElement > ) ;
188178 return ;
189179 }
190- onChange ( e ) ;
180+ onChange ?. ( e ) ;
191181 } }
192182 onBlur = { ( e ) => {
193183 // If blur is caused by clicking our step buttons, we prevent pointerdown
@@ -213,7 +203,6 @@ function InputStepper({
213203 />
214204
215205 < div className = "flex items-center gap-1 pr-1.5" >
216- { /* Minus Button */ }
217206 < button
218207 type = "button"
219208 onClick = { handleStepDown }
0 commit comments