Skip to content

docs(calendar): update examples to use useSelection hook#446

Merged
moraeso merged 9 commits into
mainfrom
surf-failing
Mar 25, 2026
Merged

docs(calendar): update examples to use useSelection hook#446
moraeso merged 9 commits into
mainfrom
surf-failing

Conversation

@moraeso
Copy link
Copy Markdown
Member

@moraeso moraeso commented Mar 24, 2026

Summary

Update docs/calendar examples to use the useSelection hook added in #442, replacing all manual selection logic.

Changes

  • API docs: Add useSelection reference page covering single/range/multiple modes, Matcher type, and type exports
  • date-picker examples (6 files): Replace useState + isSameDay with useSelection({ mode: "single" })
  • date-range-picker examples (9 files): Replace manual DateRange state, hover logic, and helper functions with useSelection({ mode: "range" })
  • getting-started guide: Add Selection section with usage example

songsang 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.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
h6s Ready Ready Preview, Comment Mar 24, 2026 4:16pm

Request Review

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.
@moraeso moraeso merged commit c583402 into main Mar 25, 2026
9 checks passed
@moraeso moraeso deleted the surf-failing branch March 25, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant