1- import React , { FC , useEffect , useState } from "react"
1+ import React , { useEffect , useState } from "react"
22import dayjs , { Dayjs } from "dayjs"
3- import Calendar from "@atlaskit/calendar"
3+ import Calendar , { ChangeEvent } from "@atlaskit/calendar"
44import { WeekDay } from "@atlaskit/calendar/types"
55
66export class EndDateBeforeStartDateError extends Error { }
@@ -34,7 +34,8 @@ export interface DateRangeProps {
3434
3535 disabled ?: boolean
3636
37- onChange ?: ( start : string , end : string ) => void
37+ onDateRangeSelected : ( start : string , end : string ) => void
38+ onViewChanged ?: ( e : ChangeEvent ) => void
3839 onCollision ?: ( dateString : string ) => void
3940}
4041
@@ -115,10 +116,6 @@ export function DateRangePicker(props: DateRangeProps) {
115116 : [ ]
116117
117118 function onDateSelect ( value : string ) {
118- if ( ! props . onChange ) {
119- console . log ( "DateRangePicker: onChange is not defined" )
120- return
121- }
122119 const pickedDate = dayjs ( value )
123120 const collision = checkCollisions ( pickedDate , disabledDates )
124121 if ( collision ) {
@@ -137,7 +134,7 @@ export function DateRangePicker(props: DateRangeProps) {
137134 setEndDate ( undefined )
138135 } else {
139136 setEndDate ( pickedDate )
140- props . onChange (
137+ props . onDateRangeSelected (
141138 toDateString ( startDate ) ,
142139 toDateString ( pickedDate ) ,
143140 )
@@ -189,6 +186,7 @@ export function DateRangePicker(props: DateRangeProps) {
189186 const selectedDate = event . iso
190187 onDateSelect ( selectedDate )
191188 } }
189+ onChange = { props . onViewChanged }
192190 locale = { props . locale }
193191 weekStartDay = { props . weekStartDate }
194192 />
0 commit comments