vue3-datepicker icon indicating copy to clipboard operation
vue3-datepicker copied to clipboard

Add disabled dates pattern and predicate

Open icehaunter opened this issue 4 years ago • 2 comments

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.

icehaunter avatar Jan 23 '21 15:01 icehaunter

predicate: Filtering function, which should accept a date and a currently displayed level and return a boolean.

What do you mean by level?

thrugl avatar Jul 23 '21 15:07 thrugl

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.

thrugl avatar Jul 23 '21 16:07 thrugl

Closing since people can add custom predicates and implement any level of complexity

icehaunter avatar Jun 04 '23 14:06 icehaunter