@react-aria/calendar 3.0.5 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@ export {useRangeCalendar} from './useRangeCalendar';
15
15
  export {useCalendarGrid} from './useCalendarGrid';
16
16
  export {useCalendarCell} from './useCalendarCell';
17
17
 
18
- export type {AriaCalendarProps, AriaRangeCalendarProps, CalendarProps, RangeCalendarProps} from '@react-types/calendar';
18
+ export type {AriaCalendarProps, AriaRangeCalendarProps, CalendarProps, DateValue, RangeCalendarProps} from '@react-types/calendar';
19
19
  export type {CalendarAria} from './useCalendarBase';
20
20
  export type {AriaCalendarGridProps, CalendarGridAria} from './useCalendarGrid';
21
21
  export type {AriaCalendarCellProps, CalendarCellAria} from './useCalendarCell';
@@ -13,7 +13,7 @@
13
13
  import {CalendarDate, isEqualDay, isSameDay, isToday} from '@internationalized/date';
14
14
  import {CalendarState, RangeCalendarState} from '@react-stately/calendar';
15
15
  import {DOMAttributes} from '@react-types/shared';
16
- import {focusWithoutScrolling, getScrollParent, scrollIntoView, useDescription} from '@react-aria/utils';
16
+ import {focusWithoutScrolling, getScrollParent, scrollIntoViewport, useDescription} from '@react-aria/utils';
17
17
  import {getEraFormat, hookData} from './utils';
18
18
  import {getInteractionModality, usePress} from '@react-aria/interactions';
19
19
  // @ts-ignore
@@ -172,7 +172,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
172
172
  // again to trigger onPressStart. Cancel presses immediately when the pointer exits.
173
173
  shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,
174
174
  preventFocusOnPress: true,
175
- isDisabled: !isSelectable,
175
+ isDisabled: !isSelectable || state.isReadOnly,
176
176
  onPressStart(e) {
177
177
  if (state.isReadOnly) {
178
178
  state.setFocusedDate(date);
@@ -288,10 +288,10 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
288
288
 
289
289
  // Scroll into view if navigating with a keyboard, otherwise
290
290
  // try not to shift the view under the user's mouse/finger.
291
- // Only scroll the direct scroll parent, not the whole page, so
292
- // we don't scroll to the bottom when opening date picker popover.
291
+ // If in a overlay, scrollIntoViewport will only cause scrolling
292
+ // up to the overlay scroll body to prevent overlay shifting
293
293
  if (getInteractionModality() !== 'pointer') {
294
- scrollIntoView(getScrollParent(ref.current) as HTMLElement, ref.current);
294
+ scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});
295
295
  }
296
296
  }
297
297
  }, [isFocused, ref]);
@@ -302,7 +302,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
302
302
  calendar: date.calendar.identifier
303
303
  });
304
304
 
305
- let formattedDate = useMemo(() => cellDateFormatter.format(nativeDate), [cellDateFormatter, nativeDate]);
305
+ let formattedDate = useMemo(() => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day').value, [cellDateFormatter, nativeDate]);
306
306
 
307
307
  return {
308
308
  cellProps: {