@@ -6,6 +6,7 @@ import React, {
66 useEffect ,
77 useContext ,
88 Ref ,
9+ useRef ,
910} from 'react' ;
1011import classnames from 'classnames' ;
1112import keycoder from 'keycoder' ;
@@ -91,7 +92,7 @@ export type InputProps = {
9192 addonRight ?: string ;
9293 elementRef ?: Ref < HTMLDivElement > ;
9394 inputRef ?: Ref < HTMLInputElement > ;
94- onValueChange ?: ( value : string ) => void ;
95+ onValueChange ?: ( value : string , prevValue ?: string ) => void ;
9596} & Omit < InputHTMLAttributes < HTMLInputElement > , 'value' | 'defaultValue' > ;
9697
9798/**
@@ -108,6 +109,8 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
108109
109110 useInitComponentStyle ( ) ;
110111
112+ const prevValueRef = useRef < string > ( ) ;
113+
111114 const onKeyDown = useEventCallback ( ( e : KeyboardEvent < HTMLInputElement > ) => {
112115 if ( symbolPattern ) {
113116 const { keyCode, shiftKey } = e ;
@@ -122,7 +125,8 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
122125
123126 const onChange = useEventCallback ( ( e : ChangeEvent < HTMLInputElement > ) => {
124127 onChange_ ?.( e ) ;
125- onValueChange ?.( e . target . value ) ;
128+ onValueChange ?.( e . target . value , prevValueRef . current ) ;
129+ prevValueRef . current = e . target . value ;
126130 } ) ;
127131
128132 const {
@@ -162,6 +166,16 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
162166 value,
163167 defaultValue,
164168 htmlReadOnly,
169+ iconLeft,
170+ iconRight,
171+ addonLeft,
172+ addonRight,
173+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
174+ onChange : _unused_1 ,
175+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
176+ onValueChange : _unused_2 ,
177+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
178+ onKeyDown : _unused_3 ,
165179 ...rprops2
166180 } = rprops ;
167181 const inputClassNames = classnames (
@@ -192,7 +206,6 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
192206 />
193207 ) ;
194208
195- const { iconLeft, iconRight, addonLeft, addonRight } = props ;
196209 if ( iconLeft || iconRight || addonLeft || addonRight ) {
197210 const wrapperClassName = classnames (
198211 'slds-form-element__control' ,
0 commit comments