saas-js / saas-ui

The React component library for startups, built with Chakra UI.
https://saas-ui.dev
MIT License
1.32k stars 128 forks source link

Feature Request: Date (Range) Pickers | Add prop(s) to easily enable/disable dates and weekdays #184

Open ds-clearago opened 9 months ago

ds-clearago commented 9 months ago

So that holidays and weekends can be disabled etc.) not only maxValue/minValue

If on top of that certain weekdays can be disabled in general, that would be great (we almost never need Saturdays and Sundays to be selectable)

See

linear[bot] commented 9 months ago

SUI-341 Feature Request: Date (Range) Pickers | Add prop(s) to easily enable/disable dates and weekdays

Pagebakers commented 9 months ago

I'm not sure yet if I'm in favor of adding properties for all these specific use cases, but it's actually already possible to achieve the same with the isDateUnavailable property.

Adding more docs and perhaps some helpers could be a great start. Something like this for example:

const daysOfWeekUnavailable = (date, days) => {
  return days.includes(date.toDate().getDay())
}
const isDateUnavailable = (date) =>
    return daysOfWeekUnavailable(date, [0, 6])
)

<DatePicker isDateUnavailable={isDateUnavailable} />