duetds / date-picker

Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
https://www.duetds.com
MIT License
1.73k stars 68 forks source link

Provide a way to disable days per week or dates. #15

Closed cdvillard closed 3 years ago

cdvillard commented 4 years ago

Is your feature request related to a problem? Please describe. Using our current date picker doesn't offer a fully disabled state, which makes this one attractive, but we need to be able to disable specific days per week and dates as well.

Describe the solution you'd like It'd be helpful to be able to select specific days of the week to disable, as well as pass in an array of dates to disable.

Describe alternatives you've considered N/A

Additional context The calendar we're currently using is flatpickr, which allows us to disable entire days from each week (i.e.: Mondays, Wednesdays, Fridays) and specific dates (i.e.: Dates that have already been booked, or closed holidays)

WickyNilliams commented 4 years ago

We were already planning on this, but it's good to have it in the issue tracker. Thanks :)

Our plan was to allow passing a basic function isDateEnabled (or maybe it should be isDateDisabled?) that accepts a date as returns a boolean.

Would this fit your needs? You can have arbitrary logic that way

matthewmnewman commented 4 years ago

I agree that this is a must-have implementation.

Adding a function such as isDateDisabled would be ideal as it would add flexibility to use any arbitrary logic to disable dates.

// return true to disable
return (date.getDay() === 0 || date.getDay() === 7);
taromorimoto commented 3 years ago

@WickyNilliams what do you think about the suggested implementation? https://github.com/duetds/date-picker/pull/52

WickyNilliams commented 3 years ago

@taromorimoto see my comment on the PR. I'll try to look at it later this week.