-
Couldn't load subscription status.
- Fork 87
feat(date-picker): Add isDateDisabled functionality #6603
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
Changes from 9 commits
7cc70a1
6a49802
7df3432
e58f796
0c119cf
848efbe
41865b2
8c687f2
2474fe7
efadb48
077d79f
f9b077e
47cd2bb
93c8e1d
e67599d
8bc4cfd
a963bd4
46a33d4
1c103f8
459a783
3b2446d
07e8687
2268b6a
59750ee
1dd26c8
1010d3c
9ab7e8a
4e93815
2143f0e
f0793b9
a1d37c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,9 @@ | |
| <script type="module"> | ||
| import '@vaadin/date-picker'; | ||
| import '@vaadin/tooltip'; | ||
| const isDateDisabled = (date) => !!(date?.getDay() === 0); | ||
|
||
| const picker = document.querySelector('vaadin-date-picker'); | ||
| picker.isDateDisabled = isDateDisabled; | ||
| </script> | ||
| </head> | ||
| <body> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,10 +59,12 @@ export function dateEquals(date1, date2) { | |
| * @param {!Date} date The date to check | ||
| * @param {Date} min Range start | ||
| * @param {Date} max Range end | ||
| * @param {function(!Date): boolean} isDateDisabled Callback to check if the date is disabled | ||
| * @return {boolean} True if the date is in the range | ||
| */ | ||
| export function dateAllowed(date, min, max) { | ||
| return (!min || date >= min) && (!max || date <= max); | ||
| export function dateAllowed(date, min, max, isDateDisabled) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the heavy lifting function that does all the work of deciding a date needs to be disabled. So all the components that need to disable a date end up feeding here. |
||
| const dateIsDisabled = typeof isDateDisabled === 'function' ? isDateDisabled(date) : false; | ||
| return (!min || date >= min) && (!max || date <= max) && !dateIsDisabled; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
This conversation was marked as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.