@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/dist/import.mjs +1307 -0
- package/dist/main.js +7 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -6
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -11
- package/src/index.ts +1 -1
- package/src/useCalendarCell.ts +6 -6
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';
|
package/src/useCalendarCell.ts
CHANGED
|
@@ -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,
|
|
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
|
-
//
|
|
292
|
-
//
|
|
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
|
-
|
|
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.
|
|
305
|
+
let formattedDate = useMemo(() => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day').value, [cellDateFormatter, nativeDate]);
|
|
306
306
|
|
|
307
307
|
return {
|
|
308
308
|
cellProps: {
|