@react-aria/calendar 3.0.0-nightly.2235 → 3.0.0-nightly.2241
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 +11 -15
- package/dist/main.js +9 -13
- package/dist/main.js.map +1 -1
- package/dist/module.js +11 -15
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/useCalendarBase.ts +9 -11
- package/src/useCalendarCell.ts +2 -8
package/src/useCalendarBase.ts
CHANGED
|
@@ -21,7 +21,7 @@ import {hookData, useSelectedDateDescription, useVisibleRangeDescription} from '
|
|
|
21
21
|
// @ts-ignore
|
|
22
22
|
import intlMessages from '../intl/*.json';
|
|
23
23
|
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
24
|
-
import {
|
|
24
|
+
import {useState} from 'react';
|
|
25
25
|
|
|
26
26
|
export interface CalendarAria {
|
|
27
27
|
/** Props for the calendar grouping element. */
|
|
@@ -71,17 +71,17 @@ export function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabeli
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
// If the next or previous buttons become disabled while they are focused, move focus to the calendar body.
|
|
74
|
-
let nextFocused =
|
|
74
|
+
let [nextFocused, setNextFocused] = useState(false);
|
|
75
75
|
let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();
|
|
76
|
-
if (nextDisabled && nextFocused
|
|
77
|
-
|
|
76
|
+
if (nextDisabled && nextFocused) {
|
|
77
|
+
setNextFocused(false);
|
|
78
78
|
state.setFocused(true);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
let previousFocused =
|
|
81
|
+
let [previousFocused, setPreviousFocused] = useState(false);
|
|
82
82
|
let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();
|
|
83
|
-
if (previousDisabled && previousFocused
|
|
84
|
-
|
|
83
|
+
if (previousDisabled && previousFocused) {
|
|
84
|
+
setPreviousFocused(false);
|
|
85
85
|
state.setFocused(true);
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -100,15 +100,13 @@ export function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabeli
|
|
|
100
100
|
onPress: () => state.focusNextPage(),
|
|
101
101
|
'aria-label': stringFormatter.format('next'),
|
|
102
102
|
isDisabled: nextDisabled,
|
|
103
|
-
|
|
104
|
-
onBlur: () => nextFocused.current = false
|
|
103
|
+
onFocusChange: setNextFocused
|
|
105
104
|
},
|
|
106
105
|
prevButtonProps: {
|
|
107
106
|
onPress: () => state.focusPreviousPage(),
|
|
108
107
|
'aria-label': stringFormatter.format('previous'),
|
|
109
108
|
isDisabled: previousDisabled,
|
|
110
|
-
|
|
111
|
-
onBlur: () => previousFocused.current = false
|
|
109
|
+
onFocusChange: setPreviousFocused
|
|
112
110
|
},
|
|
113
111
|
errorMessageProps: {
|
|
114
112
|
id: errorMessageId
|
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, scrollIntoViewport, useDescription} from '@react-aria/utils';
|
|
16
|
+
import {focusWithoutScrolling, getScrollParent, scrollIntoViewport, useDeepMemo, 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
|
|
@@ -102,13 +102,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
|
|
|
102
102
|
|
|
103
103
|
// For performance, reuse the same date object as before if the new date prop is the same.
|
|
104
104
|
// This allows subsequent useMemo results to be reused.
|
|
105
|
-
|
|
106
|
-
if (lastDate.current && isEqualDay(date, lastDate.current)) {
|
|
107
|
-
date = lastDate.current;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
lastDate.current = date;
|
|
111
|
-
|
|
105
|
+
date = useDeepMemo<CalendarDate>(date, isEqualDay);
|
|
112
106
|
let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);
|
|
113
107
|
|
|
114
108
|
// aria-label should be localize Day of week, Month, Day and Year without Time.
|