datetimepicker
datetimepicker copied to clipboard
Option to prevent selection of dates in the past
(Split off from #25)
We need to disable selection of dates in the past.
- Style disabled dates differently, and remove the hover highlight and cursor: pointer
- Prevent clicking on disabled dates
- Prevent selection of disabled dates when typing directly in the text input (this looks like it will require some refactoring of the current code to be able to implement cleanly)
- I think it's better to have the API a bit more generic and instead let the user optional provide an "earliest" date rather than just having a way to disallow dates in the past. (This is also in line with a future need of ours, where we'd like to limit the selection to a date range (with both a min and a max date)
- possible future enhancement: disable the month/year back buttons when going back would go to a month that has no enabled dates in it
I have a PR in progress that mostly implements this already.
I think there are values in allowing users to just disable certain dates regardless they're in the future the past. One use case I can think of is if you want to black out some specific dates. So maybe we can provide these options of disabling date.
- A range of dates (this includes before a date, or after a date, or between a date)
- A specific list of dates.
- Some kind of pattern/rule. (e.g: Every second Monday of every month). Not sure how the API will look like yet, but I think it's worth mentioning right now.
I think, for now, we can implement the 1st option, and then add the other options later on.
Sounds good-- the range is nice because it's easy to determine when/if the month/year nav buttons can be disabled. So just doing (1) for now sounds good.
Should have a PR for this later this week.