@react-aria/calendar 3.1.0 → 3.3.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';
@@ -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);
@@ -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: {
@@ -30,7 +30,13 @@ export interface AriaCalendarGridProps {
30
30
  * Defaults to the last visible date in the calendar.
31
31
  * Override this to display multiple date grids in a calendar.
32
32
  */
33
- endDate?: CalendarDate
33
+ endDate?: CalendarDate,
34
+ /**
35
+ * The style of weekday names to display in the calendar grid header,
36
+ * e.g. single letter, abbreviation, or full day name.
37
+ * @default "narrow"
38
+ */
39
+ weekdayStyle?: 'narrow' | 'short' | 'long'
34
40
  }
35
41
 
36
42
  export interface CalendarGridAria {
@@ -128,7 +134,7 @@ export function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarSta
128
134
  'aria-labelledby': ariaLabelledBy
129
135
  });
130
136
 
131
- let dayFormatter = useDateFormatter({weekday: 'narrow', timeZone: state.timeZone});
137
+ let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});
132
138
  let {locale} = useLocale();
133
139
  let weekDays = useMemo(() => {
134
140
  let weekStart = startOfWeek(today(state.timeZone), locale);