Skip to content

Commit 30e5207

Browse files
authored
Creating AriaCalendarProps/AriaRangeCalendarProps (#3444)
1 parent ff5b0a6 commit 30e5207

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

packages/@react-aria/calendar/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export {useRangeCalendar} from './useRangeCalendar';
1515
export {useCalendarGrid} from './useCalendarGrid';
1616
export {useCalendarCell} from './useCalendarCell';
1717

18-
export type {CalendarProps, RangeCalendarProps} from '@react-types/calendar';
18+
export type {AriaCalendarProps, AriaRangeCalendarProps, CalendarProps, RangeCalendarProps} from '@react-types/calendar';
1919
export type {CalendarAria} from './useCalendarBase';
2020
export type {AriaCalendarGridProps, CalendarGridAria} from './useCalendarGrid';
2121
export type {AriaCalendarCellProps, CalendarCellAria} from './useCalendarCell';

packages/@react-aria/calendar/src/useCalendar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13+
import {AriaCalendarProps, DateValue} from '@react-types/calendar';
1314
import {CalendarAria, useCalendarBase} from './useCalendarBase';
14-
import {CalendarProps, DateValue} from '@react-types/calendar';
1515
import {CalendarState} from '@react-stately/calendar';
1616

1717
/**
1818
* Provides the behavior and accessibility implementation for a calendar component.
1919
* A calendar displays one or more date grids and allows users to select a single date.
2020
*/
21-
export function useCalendar<T extends DateValue>(props: CalendarProps<T>, state: CalendarState): CalendarAria {
21+
export function useCalendar<T extends DateValue>(props: AriaCalendarProps<T>, state: CalendarState): CalendarAria {
2222
return useCalendarBase(props, state);
2323
}

packages/@react-aria/calendar/src/useCalendarBase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import {announce} from '@react-aria/live-announcer';
1414
import {AriaButtonProps} from '@react-types/button';
15+
import {AriaLabelingProps, DOMAttributes} from '@react-types/shared';
1516
import {CalendarPropsBase} from '@react-types/calendar';
1617
import {CalendarState, RangeCalendarState} from '@react-stately/calendar';
17-
import {DOMAttributes} from '@react-types/shared';
1818
import {DOMProps} from '@react-types/shared';
1919
import {filterDOMProps, mergeProps, useLabels, useSlotId, useUpdateEffect} from '@react-aria/utils';
2020
import {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';
@@ -36,7 +36,7 @@ export interface CalendarAria {
3636
title: string
3737
}
3838

39-
export function useCalendarBase(props: CalendarPropsBase & DOMProps, state: CalendarState | RangeCalendarState): CalendarAria {
39+
export function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabelingProps, state: CalendarState | RangeCalendarState): CalendarAria {
4040
let stringFormatter = useLocalizedStringFormatter(intlMessages);
4141
let domProps = filterDOMProps(props);
4242

packages/@react-aria/calendar/src/useRangeCalendar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13+
import {AriaRangeCalendarProps, DateValue} from '@react-types/calendar';
1314
import {CalendarAria, useCalendarBase} from './useCalendarBase';
14-
import {DateValue, RangeCalendarProps} from '@react-types/calendar';
1515
import {FocusableElement} from '@react-types/shared';
1616
import {RangeCalendarState} from '@react-stately/calendar';
1717
import {RefObject, useRef} from 'react';
@@ -21,7 +21,7 @@ import {useEvent} from '@react-aria/utils';
2121
* Provides the behavior and accessibility implementation for a range calendar component.
2222
* A range calendar displays one or more date grids and allows users to select a contiguous range of dates.
2323
*/
24-
export function useRangeCalendar<T extends DateValue>(props: RangeCalendarProps<T>, state: RangeCalendarState, ref: RefObject<FocusableElement>): CalendarAria {
24+
export function useRangeCalendar<T extends DateValue>(props: AriaRangeCalendarProps<T>, state: RangeCalendarState, ref: RefObject<FocusableElement>): CalendarAria {
2525
let res = useCalendarBase(props, state);
2626

2727
// We need to ignore virtual pointer events from VoiceOver due to these bugs.

packages/@react-types/calendar/src/index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,19 @@ export interface CalendarPropsBase {
5656
}
5757

5858
export type DateRange = RangeValue<DateValue>;
59-
export interface CalendarProps<T extends DateValue> extends CalendarPropsBase, ValueBase<T, MappedDateValue<T>>, DOMProps, AriaLabelingProps {}
60-
export interface RangeCalendarProps<T extends DateValue> extends CalendarPropsBase, ValueBase<RangeValue<T>, RangeValue<MappedDateValue<T>>>, DOMProps, AriaLabelingProps {
59+
export interface CalendarProps<T extends DateValue> extends CalendarPropsBase, ValueBase<T, MappedDateValue<T>> {}
60+
export interface RangeCalendarProps<T extends DateValue> extends CalendarPropsBase, ValueBase<RangeValue<T>, RangeValue<MappedDateValue<T>>> {
6161
/**
6262
* When combined with `isDateUnavailable`, determines whether non-contiguous ranges,
6363
* i.e. ranges containing unavailable dates, may be selected.
6464
*/
6565
allowsNonContiguousRanges?: boolean
6666
}
6767

68+
export interface AriaCalendarProps<T extends DateValue> extends CalendarProps<T>, DOMProps, AriaLabelingProps {}
69+
70+
export interface AriaRangeCalendarProps<T extends DateValue> extends RangeCalendarProps<T>, DOMProps, AriaLabelingProps {}
71+
6872
export interface SpectrumCalendarProps<T extends DateValue> extends CalendarProps<T>, StyleProps {
6973
/**
7074
* The number of months to display at once. Up to 3 months are supported.

packages/react-aria/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export {VisuallyHidden, useVisuallyHidden} from '@react-aria/visually-hidden';
4444

4545
export type {AriaBreadcrumbItemProps, AriaBreadcrumbsProps, BreadcrumbItemAria, BreadcrumbsAria} from '@react-aria/breadcrumbs';
4646
export type {AriaButtonProps, AriaToggleButtonProps, ButtonAria} from '@react-aria/button';
47-
export type {AriaCalendarCellProps, AriaCalendarGridProps, CalendarAria, CalendarCellAria, CalendarGridAria, CalendarProps, RangeCalendarProps} from '@react-aria/calendar';
47+
export type {AriaCalendarCellProps, AriaCalendarGridProps, AriaCalendarProps, AriaRangeCalendarProps, CalendarAria, CalendarCellAria, CalendarGridAria, CalendarProps, RangeCalendarProps} from '@react-aria/calendar';
4848
export type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps, CheckboxAria, CheckboxGroupAria} from '@react-aria/checkbox';
4949
export type {AriaComboBoxOptions, ComboBoxAria} from '@react-aria/combobox';
5050
export type {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, AriaTimeFieldProps, DateFieldAria, DatePickerAria, DateRangePickerAria, DateSegmentAria} from '@react-aria/datepicker';

0 commit comments

Comments
 (0)