docs(calendar): update examples to use useSelection hook#446
Merged
Conversation
added 7 commits
March 25, 2026 00:03
Add comprehensive API documentation for the useSelection hook covering all three selection modes (single, range, multiple), the Matcher type for date disabling, and type exports. Add sidebar navigation entry.
Replace manual useState + isSameDay selection logic with
useSelection({ mode: "single" }) across all 6 date-picker examples
(vanilla, bootstrap, tailwind × basic, calendar variants).
Replace manual DateRange state, handleDateSelect, isInRange, isSelected
with useSelection({ mode: "range" }) across all 9 date-range-picker
examples. Hover preview preserved via isInRangeWithHover wrapper.
Popover variants sync selection to parent via useEffect callback.
Add Selection section with brief usage example and link to the useSelection API reference page.
selection.isSelected() in range mode returns true for ALL dates in range (start, end, and in-between). Replace with isRangeStart/isRangeEnd for the selected style, and remove || isSelected from isInRangeWithHover so in-range dates get the lighter connected background instead of the dark selected appearance.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Remove all manual useState (hoverDate), isInRangeWithHover wrappers, onMouseEnter/onMouseLeave handlers from date-range-picker examples. Examples now use only useCalendar + useSelection with zero user-side state for selection logic, making them simpler and more typical.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Update docs/calendar examples to use the
useSelectionhook added in #442, replacing all manual selection logic.Changes
useSelectionreference page covering single/range/multiple modes, Matcher type, and type exportsuseState+isSameDaywithuseSelection({ mode: "single" })DateRangestate, hover logic, and helper functions withuseSelection({ mode: "range" })