Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add disabledDates and enabledDates to DatePicker and DateInput #92

Closed

Conversation

JinIgarashi
Copy link

@JinIgarashi JinIgarashi commented Apr 1, 2024

It would be nice if particular dates can be disabled or enabled while currently only can restrict by using min and max dates.

I added following two props.

  • disabledDates: Date[]. Disable dates in the array.
  • enabledDates: Date[]. Enable only dates in the array. If it is used, disabledDates is ignored.
  • updated documentation for these two props

Please let me know your thought on this PR.

Screenshots

  • for DateInput
image
  • for DatePicker. I added new datepicker for enabledDates.
    image

  • If enabledDates is used, disable year and month on dropdown

image image

@probablykasper
Copy link
Owner

Would you agree that it makes more sense to have a property like this?

isDateDisabled: (date: Date) => boolean | undefined

@JinIgarashi
Copy link
Author

@probablykasper Thank you for your comment. I am very sorry I was not aware there was already closed issue. IsDateDisabled can be a better idea than adding new two properties of this PR. I will try to add a callback function (probably I will create another PR for isDateDisabled).

I just let you know that I published this PR's changes to our NPM since we need this feature for our development. I will switch from ours to yours when it will have the feature to disable particular dates.
https://www.npmjs.com/package/@undp-data/date-picker-svelte

@probablykasper
Copy link
Owner

All good! In that case I'll close this PR, but I appreciate your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants