rzkhosroshahi / zaman

It's a lightweight React component for creating a Jalali/Georgian datepicker
https://rzkhosroshahi.github.io/zaman-landing
MIT License
259 stars 46 forks source link

onChange event on CalendarProvider range #114

Closed mrmf0 closed 8 months ago

mrmf0 commented 1 year ago

hi, thanks a lot for stunning jalali date picker library. CalendarProvider range is more beautiful than select range by click on input so we preffered to use your CalendarProvider instead of DatePicker range, by the way you also provide an example like what i said on codesandbox :

<CalendarProvider locale="fa" round="x4" accentColor="#6374ae">
  <Calendar
    defaultValue={new Date()}
    onChange={(d) => console.log(d)}
    weekends={[6]}
    from={new Date()}
    to={new Date().setDate(new Date().getDate() + 7)}
    range
  />
</CalendarProvider>

but i think there is an issue that onChange event only returns first selected date but i hope when we proped range, onChange returns both date started and date ends, some thing like usual way that select date ranges works

<DatePicker onChange={(e) => console.log(e.from, e.to)} range />

how we can use CalendarProvider to get full range dates?

by the way is it possible to use this as one date click then select date range from clicked date till today?

SalehMehrabani commented 11 months ago

The calendar is better for some applications however in range mode the component only returns the start date. It would be better to return both values in range mode.

rzkhosroshahi commented 11 months ago

Hi @mrmf0

I hope you guys are doing well. I've looked at your codesandbox example. There is no problem with the package when you are using range datepicker/calendar you can just simply receive from and to dates by two parameters like this: onChange={(from, to) => console.log(from, to)}. have you tried this before?

cc: @SalehMehrabani

mrmf0 commented 11 months ago

hi @rzkhosroshahi I don't know why I feel that I tried this method before and it didn't work, when maybe I didn't try it.

thanks a lot

mrmf0 commented 10 months ago

hi @rzkhosroshahi

Is there any difference between mobile/tablet mode with desktop mode to select range? I do last solution to get both start and end range in calendar. In my tests I found that in desktop mode all things works correctly but by selecting range in mobile device with same code, it returns both from & to as equal value to start date value. How can solve this?

rzkhosroshahi commented 9 months ago

114

rzkhosroshahi commented 8 months ago

v2.1.0 just released this issue should be fixed by upgrading zaman.