-
Notifications
You must be signed in to change notification settings - Fork 78
feat: keyboard navigation in calendar #858
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5245fa7
feat: gridmanager, intial arrow key movement
jacobdevera 9f4eedd
feat: row and col wrapping
jacobdevera f67eac3
fix: enter and space handling
jacobdevera cb4f411
fix: button labels, navigation fixes
jacobdevera 4d97ec7
fix: first focusable element
jacobdevera d3b5341
feat: skip disabled and block dates
jacobdevera e783f40
fix: grid boundary logic
jacobdevera 53e19d4
fix: date labels
jacobdevera e0b8886
fix: focus on init logic
jacobdevera 50803e1
feat: page up, page down, home, end handling
jacobdevera de77452
fix: header option, tests
jacobdevera 59e78b3
chore: remove edit mode references
jacobdevera 0870296
fix: datepicker state
jacobdevera 0cc38fa
chore: cleanup
jacobdevera ba119fe
fix: disabled cells
jacobdevera daacb26
fix: test
jacobdevera 42d1b1d
fix: prevent default
jacobdevera 7bd09ea
fix: default for other keys
jacobdevera 74631bb
Merge branch 'master' into feat/kb-calendar
jacobdevera 44889b7
fix: page keys shouldn't select date
jacobdevera 3dd52d7
fix: six weeks
jacobdevera c7fbf0a
Merge branch 'master' into feat/kb-calendar
jacobdevera 2a2de97
fix: datepicker popover
jacobdevera 0c3620e
fix: visual regression
jacobdevera 0791a01
fix: button label, live area
jacobdevera ec9ce22
Merge branch 'master' into feat/kb-calendar
jacobdevera 3c8d202
fix: merge
jacobdevera 807d405
fix: element.matches check
jacobdevera c4f3840
fix: merge, null checks
jacobdevera 6a466a4
fix: close after selecting
jacobdevera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import moment from 'moment'; | ||
|
||
export const isDateBetween = (date, blockedDates, isRangeEnabled) => { | ||
if (typeof blockedDates === 'undefined' || typeof blockedDates[0] === 'undefined' || typeof blockedDates[1] === 'undefined') { | ||
return false; | ||
} | ||
if (typeof isRangeEnabled !== 'undefined' || isRangeEnabled) { | ||
if (blockedDates[0].isAfter(blockedDates[1])) { | ||
return blockedDates[1].isBefore(date) && blockedDates[0].isAfter(date); | ||
} | ||
} | ||
return blockedDates[0].isBefore(date, 'day') && blockedDates[1].isAfter(date, 'day'); | ||
}; | ||
|
||
export const isDisabledWeekday = (date, weekDays) => { | ||
if (!weekDays) { | ||
return false; | ||
} | ||
|
||
const daysName = moment.weekdays(); | ||
|
||
return weekDays.indexOf(daysName[date.day()]) > -1; | ||
}; | ||
|
||
export const isEnabledDate = (day, dateProps) => { | ||
const { | ||
disableWeekends, | ||
disableAfterDate, | ||
disableBeforeDate, | ||
blockedDates, | ||
disableWeekday, | ||
disablePastDates, | ||
disableFutureDates, | ||
disabledDates | ||
} = dateProps; | ||
return ( | ||
!isDisabledWeekday(day, disableWeekday) && | ||
!(disableWeekends && (day.day() === 0 || day.day() === 6)) && | ||
!(disableBeforeDate && day.isBefore(moment(disableBeforeDate))) && | ||
!(disableAfterDate && day.isAfter(moment(disableAfterDate))) && | ||
!(disablePastDates && day.isBefore(moment(), 'day')) && | ||
!(disableFutureDates && day.isAfter(moment(), 'day')) && | ||
!isDateBetween(day, blockedDates && blockedDates.map(date => moment(date))) && | ||
!isDateBetween(day, disabledDates && disabledDates.map(date => moment(date))) | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These essentially test opening/closing the calendar which should now be covered by using the Popover component itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥