replace

fun replace(current: Selection, proposed: Selection): SelectionResult

Validates proposed the way clicks are validated and returns either the proposed selection (no events) or current plus the first violation. The proposal's shape must match the mode (Selection.Empty matches every mode); a mismatch throws IllegalArgumentException.

In SelectionMode.Week and SelectionMode.Month the proposal is first snapped to the whole period containing Selection.rangeStart, clamped to the bounds (its Selection.rangeEnd is ignored), so the result is always a period a tap could produce. The snapped period is then validated, so a disabled day anywhere in it rejects the proposal with SelectionEvent.Intercepted, and a Selection.rangeStart outside the bounds is rejected with SelectionEvent.OutOfRange.