Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.18k stars 517 forks source link

Disabled Days #5543

Closed chris-parker-bliss closed 2 weeks ago

chris-parker-bliss commented 1 month ago

I'm looking for a Blazor date-time picker to use for selecting delivery date on an eCommerce site. The problem is that as well as disabling particular dates we also need to the ability to disable days of the week (no post on Sundays).

Ideally I'd imagine this would work almost exactly the same as the existing DisabledDates attribute, but instead of an array of DateTime values it could take an array of DayOfWeek values.

chris-parker-bliss commented 1 month ago

It looks like the Blazorise picker is built on flatpickr, which has the ability to disable based on a function (see https://flatpickr.js.org/examples/#disabling-dates-by-a-function) so perhaps this could be leveraged?

stsrki commented 1 month ago

The problem with this function is that it is a JavaScript function. There is no easy way to translate C# function into JS. Or to invoke asyncrounous function from synchronous function in JS.

Back to your problem. We could add DisabledDays which would handle it internally by making use of flatpickr function. That could work easily.

chris-parker-bliss commented 1 month ago

That makes sense @stsrki, thanks for your response, sounds promising!

stsrki commented 2 weeks ago

https://github.com/Megabit/Blazorise/pull/5578