feat(year): add date selection, drag-to-select and drag-to-create - #47
Merged
Conversation
main landed month drag-to-create and drag-to-reschedule (#45) in parallel with this branch. Its implementation is the one kept: core's `monthCreateRange` / `monthDropBounds`, the `MonthDrag` state machine on both renderers, and `data-drop` for the drop target. This branch's own `dayRangeFromDrag` / `shiftEventDays` duplicates are dropped. Re-applied on top, since main does not cover them: - `onSelectDrag` on the month grids and through `Calendar`, so a sweep reports its span live and can drive a selection instead of only firing on release. - The year grid's selection, drag-to-select and drag-to-create, plus its `dayBadge` / `rangeBand` slots. - `Calendar`'s selection props in month and year modes on the native renderer, forwarded through `MonthPager` via `CalendarSelectionProvider` so cached pages repaint. - The dom range band's events-mode geometry, so a selection reads as a strip across the date row rather than a block over the event chips.
- Clear the click guard on every fresh press: a sweep ending over a different cell gets its trailing click on an ancestor, where nothing consumed the guard, so the next plain click was swallowed and onPressDay never fired. - Keep disabled days out of a sweep, which the README promises but extendCreate did not enforce. - Hand only the sideways axis to the sweep (touch-action: pan-y): the year grid is itself the scroll container, so touch-action: none made the later months unreachable on a phone. - Only render a day as a button when onPressDay is set; with just the sweep wired, 365 buttons were tab stops whose click and Enter did nothing. - Hoist getIsToday, which ran three times per cell.
- Scope the tap guard to the web and clear it on every fresh sweep: a pan never leaves a press behind, so the flag outlived its interaction and ate the next unrelated tap. - Reject a hold on a blanked adjacent-month cell or an unselectable day, which MonthView's hitTest already did. - Read the pan's inputs from a ref so a consumer's inline handler cannot rebuild it mid-drag, which cancels the drag running through it. - Freeze the ScrollView only on native, where a hold arms the sweep; on the web a press arms it at once, so freezing there cost every touch scroll.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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
Closes the rest of what issue #41 reports: the year and month views now support selecting dates, creating events, and moving events.
#45 landed the month grid's drag-to-create and drag-to-reschedule while this branch was open, so the merge here keeps that implementation wholesale (core's
monthCreateRange/monthDropBounds, theMonthDragstate machine,data-drop) and drops this branch's near-duplicatedayRangeFromDrag/shiftEventDays. What remains on top is the part #45 doesn't cover:YearViewtakes the same selection model as the month grid and the picker (selectedDates,selectedRange,minDate,maxDate,isDateDisabled), drawn with core'sdaySelectionState/dayBadgeKind/rangeBandKindso it can't disagree with the other grids. Hold a day and drag (press and drag on web) to sweep out a range, withonCreateEventcommitting it as an all-day span. Native runs a pan per mini month; the web drives it from the cells' pointer events, so a sweep can run across months there. The year view has no event bars to pick up, so there's no drag-to-move.onSelectDragon both month grids, both year grids andCalendar.onCreateEventonly fires on release, which is fine for creating but leaves a selection highlight lagging the drag.onSelectDragreports the same sweep live, as the ordered inclusive[start, end]days, so it wires straight touseDateRange'sselectRange. It enables the sweep on its own.Calendar. It had no selection props at all; they're now accepted inmonthandyearmodes and forwarded throughMonthPagerviaCalendarSelectionProvider, so pages LegendList has already cached still repaint.Two fixes fell out of making selection first-class on the month grid: the dom range band was sized from
theme.cellHeight(48px) but applied to a ~100px events cell, so a selection painted a block over the event chips instead of a strip across the dates; and the band's pill cap assumed a centred badge, which events mode doesn't have.Testing
lint,format,typecheck,test(529 passing, +23 over main),build,attw+publintper package, andmint broken-linksare all clean.touch-action, and that a click after a sweep still reachesonPressDay. Screenshots confirmed the year selection band and that the today badge survived the cell restructure.Notes for review
dayBadgeis a newYearViewslot and the today/selected circle moved onto it, fromday(now just the cell), matchingMonthView. A consumer restyling that circle throughclassNames.dayhas to move todayBadge; there's a<Note>in the year-view guide saying so. Flagging it because it's a silent visual change, not a type error.fillCellOnSelectionis month-only. It doesn't map cleanly onto the mini months' full-cell band, soCalendardoesn't forward it in year mode and the docs now say so.MonthList.dayAtContent,MonthView.hitTest,YearView.dayAt), and copying it is what dropped the adjacent-month guard fixed here. A shareddayAtPointin core would carry the guards once, but it means touching two files feat(month): hide the built-in title, and add cell press and drag support #45 just rewrote, so I left it out of this PR.Closes #41