rememberCalendarSelectionState

fun rememberCalendarSelectionState(mode: SelectionMode = SelectionMode.Single(), initialSelection: Selection = Selection.Empty, bounds: ClosedRange<LocalDate>? = null, disabled: DisabledDates = DisabledDates.None, onEvent: (SelectionEvent) -> Unit = {}): CalendarSelectionState

Creates and remembers a CalendarSelectionState that survives configuration changes; changing mode or bounds resets it.

A SelectionMode.Week with a null firstDayOfWeek (the default) is resolved to the locale's first day of week, the same default rememberCalendarState and rememberWeekCalendarState use, so a tapped week matches the visible row. CalendarSelectionState.mode exposes the resolved value. Pass an explicit firstDayOfWeek when the calendar overrides its own.

initialSelection is used as-is, except in SelectionMode.Week and SelectionMode.Month where it goes through CalendarSelectionState.set's snapping and validation: it becomes the whole period containing its rangeStart, or Selection.Empty when that period is out of bounds or contains a disabled day (no event fires).