@@ -86,7 +86,7 @@ type DateTimePickerProps = {
8686 nativeInputAriaLabel ?: string ;
8787 onCalendarClose ?: ( ) => void ;
8888 onCalendarOpen ?: ( ) => void ;
89- onChange ?: ( value : Date | null ) => void ;
89+ onChange ?: ( value : Value ) => void ;
9090 onClockClose ?: ( ) => void ;
9191 onClockOpen ?: ( ) => void ;
9292 onFocus ?: ( event : React . FocusEvent < HTMLDivElement > ) => void ;
@@ -212,7 +212,7 @@ export default function DateTimePicker(props: DateTimePickerProps) {
212212 closeClock ( ) ;
213213 } , [ closeCalendar , closeClock ] ) ;
214214
215- function onChange ( value : Date | null , shouldCloseWidgets : boolean = shouldCloseWidgetsProps ) {
215+ function onChange ( value : Value , shouldCloseWidgets : boolean = shouldCloseWidgetsProps ) {
216216 if ( shouldCloseWidgets ) {
217217 closeWidgets ( ) ;
218218 }
@@ -222,7 +222,13 @@ export default function DateTimePicker(props: DateTimePickerProps) {
222222 }
223223 }
224224
225- function onDateChange ( nextValue : Value , shouldCloseWidgets ?: boolean ) {
225+ type DatePiece = Date | null ;
226+
227+ function onDateChange (
228+ nextValue : DatePiece | [ DatePiece , DatePiece ] ,
229+ shouldCloseWidgets ?: boolean ,
230+ ) {
231+ // React-Calendar passes an array of values when selectRange is enabled
226232 const [ nextValueFrom ] = Array . isArray ( nextValue ) ? nextValue : [ nextValue ] ;
227233 const [ valueFrom ] = Array . isArray ( value ) ? value : [ value ] ;
228234
0 commit comments