vue3-datepicker
vue3-datepicker copied to clipboard
Add disabled dates pattern and predicate
Thanks to #12, this component now supports disabling specific dates. It would be nice to be able to use everything else from the original filtering object. I think it is a good idea to start at predicate-based filtering, as it allows for the implementation of everything else at the usage point. It might not be the most convenient thing, but it is a good start.
Overall, we might support the following object keys:
daysOfWeek: Indices of days of the week, which are disabled. E.g.[0, 6]to disable Saturday and Sunday.daysOfMonth: Actual dates in any month to be disabled. E.g.[25, 31]to disable 31st and 25th.ranges: Ranges of dates (both ends excluded) that should be disabled. E.g. `[{ from: new Date('2021-01-01'), to: new Date('2021-01-05') }]predicate: Filtering function, which should accept a date and a currently displayed level and return a boolean. It should be run on every date which will be presented in the current view of the calendar.
predicate: Filtering function, which should accept a date and a currently displayed level and return a boolean.
What do you mean by level?
In any case, I have submitted a pull request for a simple implementation of the predicate function. It only takes in the current date as param, but other params could be easily added.
Closing since people can add custom predicates and implement any level of complexity