@react-aria/datepicker 3.0.0-rc.0 → 3.1.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/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AriaDatePickerProps, AriaTimeFieldProps, DateValue, TimeValue, AriaDateRangePickerProps } from "@react-types/datepicker";
2
2
  import { DateFieldState, DatePickerState, DateSegment, DateRangePickerState } from "@react-stately/datepicker";
3
- import { HTMLAttributes, RefObject } from "react";
3
+ import { DOMAttributes } from "@react-types/shared";
4
+ import { RefObject } from "react";
4
5
  import { AriaButtonProps } from "@react-types/button";
5
6
  import { AriaDialogProps } from "@react-types/dialog";
6
7
  import { CalendarProps, RangeCalendarProps } from "@react-types/calendar";
@@ -8,39 +9,39 @@ export interface AriaDateFieldProps<T extends DateValue> extends Omit<AriaDatePi
8
9
  }
9
10
  export interface DateFieldAria {
10
11
  /** Props for the field's visible label element, if any. */
11
- labelProps: HTMLAttributes<HTMLElement>;
12
+ labelProps: DOMAttributes;
12
13
  /** Props for the field grouping element. */
13
- fieldProps: HTMLAttributes<HTMLElement>;
14
+ fieldProps: DOMAttributes;
14
15
  /** Props for the description element, if any. */
15
- descriptionProps: HTMLAttributes<HTMLElement>;
16
+ descriptionProps: DOMAttributes;
16
17
  /** Props for the error message element, if any. */
17
- errorMessageProps: HTMLAttributes<HTMLElement>;
18
+ errorMessageProps: DOMAttributes;
18
19
  }
19
20
  /**
20
21
  * Provides the behavior and accessibility implementation for a date field component.
21
22
  * A date field allows users to enter and edit date and time values using a keyboard.
22
23
  * Each part of a date value is displayed in an individually editable segment.
23
24
  */
24
- export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>, state: DateFieldState, ref: RefObject<HTMLElement>): DateFieldAria;
25
+ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria;
25
26
  /**
26
27
  * Provides the behavior and accessibility implementation for a time field component.
27
28
  * A time field allows users to enter and edit time values using a keyboard.
28
29
  * Each part of a time value is displayed in an individually editable segment.
29
30
  */
30
- export function useTimeField<T extends TimeValue>(props: AriaTimeFieldProps<T>, state: DateFieldState, ref: RefObject<HTMLElement>): DateFieldAria;
31
+ export function useTimeField<T extends TimeValue>(props: AriaTimeFieldProps<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria;
31
32
  export interface DatePickerAria {
32
33
  /** Props for the date picker's visible label element, if any. */
33
- labelProps: HTMLAttributes<HTMLElement>;
34
+ labelProps: DOMAttributes;
34
35
  /** Props for the grouping element containing the date field and button. */
35
- groupProps: HTMLAttributes<HTMLElement>;
36
+ groupProps: DOMAttributes;
36
37
  /** Props for the date field. */
37
38
  fieldProps: AriaDatePickerProps<DateValue>;
38
39
  /** Props for the popover trigger button. */
39
40
  buttonProps: AriaButtonProps;
40
41
  /** Props for the description element, if any. */
41
- descriptionProps: HTMLAttributes<HTMLElement>;
42
+ descriptionProps: DOMAttributes;
42
43
  /** Props for the error message element, if any. */
43
- errorMessageProps: HTMLAttributes<HTMLElement>;
44
+ errorMessageProps: DOMAttributes;
44
45
  /** Props for the popover dialog. */
45
46
  dialogProps: AriaDialogProps;
46
47
  /** Props for the calendar within the popover dialog. */
@@ -50,7 +51,7 @@ export interface DatePickerAria {
50
51
  * Provides the behavior and accessibility implementation for a date picker component.
51
52
  * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.
52
53
  */
53
- export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<HTMLElement>): DatePickerAria;
54
+ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria;
54
55
  type Field = 'era' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod' | 'timeZoneName' | 'weekday';
55
56
  interface DisplayNames {
56
57
  of(field: Field): string;
@@ -59,7 +60,7 @@ interface DisplayNames {
59
60
  export function useDisplayNames(): DisplayNames;
60
61
  export interface DateSegmentAria {
61
62
  /** Props for the segment element. */
62
- segmentProps: HTMLAttributes<HTMLDivElement>;
63
+ segmentProps: DOMAttributes;
63
64
  }
64
65
  /**
65
66
  * Provides the behavior and accessibility implementation for a segment in a date field.
@@ -69,9 +70,9 @@ export interface DateSegmentAria {
69
70
  export function useDateSegment(segment: DateSegment, state: DateFieldState, ref: RefObject<HTMLElement>): DateSegmentAria;
70
71
  export interface DateRangePickerAria {
71
72
  /** Props for the date range picker's visible label element, if any. */
72
- labelProps: HTMLAttributes<HTMLElement>;
73
+ labelProps: DOMAttributes;
73
74
  /** Props for the grouping element containing the date fields and button. */
74
- groupProps: HTMLAttributes<HTMLElement>;
75
+ groupProps: DOMAttributes;
75
76
  /** Props for the start date field. */
76
77
  startFieldProps: AriaDatePickerProps<DateValue>;
77
78
  /** Props for the end date field. */
@@ -79,9 +80,9 @@ export interface DateRangePickerAria {
79
80
  /** Props for the popover trigger button. */
80
81
  buttonProps: AriaButtonProps;
81
82
  /** Props for the description element, if any. */
82
- descriptionProps: HTMLAttributes<HTMLElement>;
83
+ descriptionProps: DOMAttributes;
83
84
  /** Props for the error message element, if any. */
84
- errorMessageProps: HTMLAttributes<HTMLElement>;
85
+ errorMessageProps: DOMAttributes;
85
86
  /** Props for the popover dialog. */
86
87
  dialogProps: AriaDialogProps;
87
88
  /** Props for the range calendar within the popover dialog. */
@@ -92,7 +93,8 @@ export interface DateRangePickerAria {
92
93
  * A date range picker combines two DateFields and a RangeCalendar popover to allow
93
94
  * users to enter or select a date and time range.
94
95
  */
95
- export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<HTMLElement>): DateRangePickerAria;
96
+ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element>): DateRangePickerAria;
96
97
  export type { AriaDatePickerProps, AriaDateRangePickerProps } from '@react-types/datepicker';
98
+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SAAS,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,mBAAmB,CA8GzK;AClJD,YAAY,EAAC,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,yBAAyB,CAAC","sources":["packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePickerGroup.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateField.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDisplayNames.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateSegment.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateRangePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/index.ts","packages/@react-aria/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useDatePicker} from './useDatePicker';\nexport {useDateSegment} from './useDateSegment';\nexport {useDateField, useTimeField} from './useDateField';\nexport {useDateRangePicker} from './useDateRangePicker';\nexport {useDisplayNames} from './useDisplayNames';\n\nexport type {AriaDatePickerProps, AriaDateRangePickerProps} from '@react-types/datepicker';\nexport type {AriaDateFieldProps, DateFieldAria} from './useDateField';\nexport type {DatePickerAria} from './useDatePicker';\nexport type {DateRangePickerAria} from './useDateRangePicker';\nexport type {DateSegmentAria} from './useDateSegment';\n"],"names":[],"version":3,"file":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C,MAAM,yBAAyB,CAAC","sources":["packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePickerGroup.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateField.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDatePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDisplayNames.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateSegment.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/useDateRangePicker.ts","packages/@react-aria/datepicker/src/packages/@react-aria/datepicker/src/index.ts","packages/@react-aria/datepicker/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useDatePicker} from './useDatePicker';\nexport {useDateSegment} from './useDateSegment';\nexport {useDateField, useTimeField} from './useDateField';\nexport {useDateRangePicker} from './useDateRangePicker';\nexport {useDisplayNames} from './useDisplayNames';\n\nexport type {AriaDatePickerProps, AriaDateRangePickerProps} from '@react-types/datepicker';\nexport type {AriaDateFieldProps, DateFieldAria} from './useDateField';\nexport type {DatePickerAria} from './useDatePicker';\nexport type {DateRangePickerAria} from './useDateRangePicker';\nexport type {DateSegmentAria} from './useDateSegment';\nexport type {AriaTimeFieldProps} from '@react-types/datepicker';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/datepicker",
3
- "version": "3.0.0-rc.0",
3
+ "version": "3.1.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,27 +18,28 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@internationalized/message": "^3.0.6",
22
- "@internationalized/number": "^3.1.0",
23
- "@react-aria/focus": "^3.5.5",
24
- "@react-aria/i18n": "^3.3.9",
25
- "@react-aria/interactions": "^3.8.4",
26
- "@react-aria/label": "^3.2.5",
27
- "@react-aria/spinbutton": "^3.0.6",
28
- "@react-aria/utils": "^3.12.0",
29
- "@react-stately/datepicker": "3.0.0-rc.0",
30
- "@react-types/button": "^3.4.5",
31
- "@react-types/calendar": "3.0.0-rc.0",
32
- "@react-types/datepicker": "3.0.0-rc.0",
33
- "@react-types/dialog": "^3.3.5",
34
- "@react-types/shared": "^3.12.0"
21
+ "@internationalized/date": "^3.0.1",
22
+ "@internationalized/number": "^3.1.1",
23
+ "@internationalized/string": "^3.0.0",
24
+ "@react-aria/focus": "^3.7.0",
25
+ "@react-aria/i18n": "^3.5.0",
26
+ "@react-aria/interactions": "^3.10.0",
27
+ "@react-aria/label": "^3.4.0",
28
+ "@react-aria/spinbutton": "^3.1.2",
29
+ "@react-aria/utils": "^3.13.2",
30
+ "@react-stately/datepicker": "^3.0.1",
31
+ "@react-types/button": "^3.6.0",
32
+ "@react-types/calendar": "^3.0.1",
33
+ "@react-types/datepicker": "^3.1.0",
34
+ "@react-types/dialog": "^3.4.2",
35
+ "@react-types/shared": "^3.14.0"
35
36
  },
36
37
  "peerDependencies": {
37
- "react": "^16.8.0 || ^17.0.0-rc.1",
38
- "react-dom": "^16.8.0 || ^17.0.0-rc.1"
38
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
39
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
- "gitHead": "6a503b715e0dbbf92038cd7f08b1bcdde4c78e82"
44
+ "gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
44
45
  }
package/src/index.ts CHANGED
@@ -21,3 +21,4 @@ export type {AriaDateFieldProps, DateFieldAria} from './useDateField';
21
21
  export type {DatePickerAria} from './useDatePicker';
22
22
  export type {DateRangePickerAria} from './useDateRangePicker';
23
23
  export type {DateSegmentAria} from './useDateSegment';
24
+ export type {AriaTimeFieldProps} from '@react-types/datepicker';
@@ -13,27 +13,28 @@
13
13
  import {AriaDatePickerProps, AriaTimeFieldProps, DateValue, TimeValue} from '@react-types/datepicker';
14
14
  import {createFocusManager, FocusManager} from '@react-aria/focus';
15
15
  import {DateFieldState} from '@react-stately/datepicker';
16
+ import {DOMAttributes} from '@react-types/shared';
16
17
  import {filterDOMProps, mergeProps, useDescription} from '@react-aria/utils';
17
- import {HTMLAttributes, RefObject, useEffect, useMemo, useRef} from 'react';
18
18
  // @ts-ignore
19
19
  import intlMessages from '../intl/*.json';
20
+ import {RefObject, useEffect, useMemo, useRef} from 'react';
20
21
  import {useDatePickerGroup} from './useDatePickerGroup';
21
22
  import {useField} from '@react-aria/label';
22
23
  import {useFocusWithin} from '@react-aria/interactions';
23
- import {useMessageFormatter} from '@react-aria/i18n';
24
+ import {useLocalizedStringFormatter} from '@react-aria/i18n';
24
25
 
25
26
  // Allows this hook to also be used with TimeField
26
27
  export interface AriaDateFieldProps<T extends DateValue> extends Omit<AriaDatePickerProps<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue'> {}
27
28
 
28
29
  export interface DateFieldAria {
29
30
  /** Props for the field's visible label element, if any. */
30
- labelProps: HTMLAttributes<HTMLElement>,
31
+ labelProps: DOMAttributes,
31
32
  /** Props for the field grouping element. */
32
- fieldProps: HTMLAttributes<HTMLElement>,
33
+ fieldProps: DOMAttributes,
33
34
  /** Props for the description element, if any. */
34
- descriptionProps: HTMLAttributes<HTMLElement>,
35
+ descriptionProps: DOMAttributes,
35
36
  /** Props for the error message element, if any. */
36
- errorMessageProps: HTMLAttributes<HTMLElement>
37
+ errorMessageProps: DOMAttributes
37
38
  }
38
39
 
39
40
  // Data that is passed between useDateField and useDateSegment.
@@ -56,24 +57,22 @@ export const focusManagerSymbol = '__focusManager_' + Date.now();
56
57
  * A date field allows users to enter and edit date and time values using a keyboard.
57
58
  * Each part of a date value is displayed in an individually editable segment.
58
59
  */
59
- export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>, state: DateFieldState, ref: RefObject<HTMLElement>): DateFieldAria {
60
+ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria {
60
61
  let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
61
62
  ...props,
62
63
  labelElementType: 'span'
63
64
  });
64
65
 
65
- let groupProps = useDatePickerGroup(state, ref);
66
-
67
66
  let {focusWithinProps} = useFocusWithin({
68
67
  onBlurWithin() {
69
68
  state.confirmPlaceholder();
70
69
  }
71
70
  });
72
71
 
73
- let formatMessage = useMessageFormatter(intlMessages);
72
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
74
73
  let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';
75
74
  let field = state.maxGranularity === 'hour' ? 'time' : 'date';
76
- let description = state.value ? formatMessage(message, {[field]: state.formatValue({month: 'long'})}) : '';
75
+ let description = state.value ? stringFormatter.format(message, {[field]: state.formatValue({month: 'long'})}) : '';
77
76
  let descProps = useDescription(description);
78
77
 
79
78
  // If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
@@ -83,6 +82,7 @@ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>,
83
82
  : [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;
84
83
  let propsFocusManager = props[focusManagerSymbol];
85
84
  let focusManager = useMemo(() => propsFocusManager || createFocusManager(ref), [propsFocusManager, ref]);
85
+ let groupProps = useDatePickerGroup(state, ref, props[roleSymbol] === 'presentation');
86
86
 
87
87
  // Pass labels and other information to segments.
88
88
  hookData.set(state, {
@@ -98,7 +98,7 @@ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>,
98
98
  // rather than role="group". Since the date picker/date range picker already has a role="group"
99
99
  // with a label and description, and the segments are already labeled by this as well, this
100
100
  // avoids very verbose duplicate announcements.
101
- let fieldDOMProps: HTMLAttributes<HTMLElement>;
101
+ let fieldDOMProps: DOMAttributes;
102
102
  if (props[roleSymbol] === 'presentation') {
103
103
  fieldDOMProps = {
104
104
  role: 'presentation'
@@ -137,6 +137,6 @@ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>,
137
137
  * A time field allows users to enter and edit time values using a keyboard.
138
138
  * Each part of a time value is displayed in an individually editable segment.
139
139
  */
140
- export function useTimeField<T extends TimeValue>(props: AriaTimeFieldProps<T>, state: DateFieldState, ref: RefObject<HTMLElement>): DateFieldAria {
140
+ export function useTimeField<T extends TimeValue>(props: AriaTimeFieldProps<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria {
141
141
  return useDateField(props, state, ref);
142
142
  }
@@ -16,28 +16,29 @@ import {AriaDialogProps} from '@react-types/dialog';
16
16
  import {CalendarProps} from '@react-types/calendar';
17
17
  import {createFocusManager} from '@react-aria/focus';
18
18
  import {DatePickerState} from '@react-stately/datepicker';
19
+ import {DOMAttributes} from '@react-types/shared';
19
20
  import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
20
- import {HTMLAttributes, RefObject} from 'react';
21
21
  // @ts-ignore
22
22
  import intlMessages from '../intl/*.json';
23
+ import {RefObject, useMemo} from 'react';
23
24
  import {roleSymbol} from './useDateField';
24
25
  import {useDatePickerGroup} from './useDatePickerGroup';
25
26
  import {useField} from '@react-aria/label';
26
- import {useLocale, useMessageFormatter} from '@react-aria/i18n';
27
+ import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
27
28
 
28
29
  export interface DatePickerAria {
29
30
  /** Props for the date picker's visible label element, if any. */
30
- labelProps: HTMLAttributes<HTMLElement>,
31
+ labelProps: DOMAttributes,
31
32
  /** Props for the grouping element containing the date field and button. */
32
- groupProps: HTMLAttributes<HTMLElement>,
33
+ groupProps: DOMAttributes,
33
34
  /** Props for the date field. */
34
35
  fieldProps: AriaDatePickerProps<DateValue>,
35
36
  /** Props for the popover trigger button. */
36
37
  buttonProps: AriaButtonProps,
37
38
  /** Props for the description element, if any. */
38
- descriptionProps: HTMLAttributes<HTMLElement>,
39
+ descriptionProps: DOMAttributes,
39
40
  /** Props for the error message element, if any. */
40
- errorMessageProps: HTMLAttributes<HTMLElement>,
41
+ errorMessageProps: DOMAttributes,
41
42
  /** Props for the popover dialog. */
42
43
  dialogProps: AriaDialogProps,
43
44
  /** Props for the calendar within the popover dialog. */
@@ -48,10 +49,10 @@ export interface DatePickerAria {
48
49
  * Provides the behavior and accessibility implementation for a date picker component.
49
50
  * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.
50
51
  */
51
- export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<HTMLElement>): DatePickerAria {
52
+ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria {
52
53
  let buttonId = useId();
53
54
  let dialogId = useId();
54
- let formatMessage = useMessageFormatter(intlMessages);
55
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
55
56
 
56
57
  let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
57
58
  ...props,
@@ -64,10 +65,11 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
64
65
 
65
66
  let {locale} = useLocale();
66
67
  let date = state.formatValue(locale, {month: 'long'});
67
- let description = date ? formatMessage('selectedDateDescription', {date}) : '';
68
+ let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';
68
69
  let descProps = useDescription(description);
69
70
  let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;
70
71
  let domProps = filterDOMProps(props);
72
+ let focusManager = useMemo(() => createFocusManager(ref), [ref]);
71
73
 
72
74
  return {
73
75
  groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, {
@@ -79,7 +81,6 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
79
81
  labelProps: {
80
82
  ...labelProps,
81
83
  onClick: () => {
82
- let focusManager = createFocusManager(ref);
83
84
  focusManager.focusFirst();
84
85
  }
85
86
  },
@@ -106,9 +107,8 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
106
107
  buttonProps: {
107
108
  ...descProps,
108
109
  id: buttonId,
109
- excludeFromTabOrder: true,
110
110
  'aria-haspopup': 'dialog',
111
- 'aria-label': formatMessage('calendar'),
111
+ 'aria-label': stringFormatter.format('calendar'),
112
112
  'aria-labelledby': `${labelledBy} ${buttonId}`,
113
113
  'aria-describedby': ariaDescribedBy,
114
114
  onPress: () => state.setOpen(true)
@@ -1,11 +1,15 @@
1
+ import {createFocusManager, getFocusableTreeWalker} from '@react-aria/focus';
1
2
  import {DateFieldState, DatePickerState, DateRangePickerState} from '@react-stately/datepicker';
2
- import {getFocusableTreeWalker} from '@react-aria/focus';
3
- import {KeyboardEvent} from '@react-types/shared';
3
+ import {FocusableElement, KeyboardEvent} from '@react-types/shared';
4
4
  import {mergeProps} from '@react-aria/utils';
5
- import {RefObject} from 'react';
5
+ import {RefObject, useMemo} from 'react';
6
+ import {useLocale} from '@react-aria/i18n';
6
7
  import {usePress} from '@react-aria/interactions';
7
8
 
8
- export function useDatePickerGroup(state: DatePickerState | DateRangePickerState | DateFieldState, ref: RefObject<HTMLElement>) {
9
+ export function useDatePickerGroup(state: DatePickerState | DateRangePickerState | DateFieldState, ref: RefObject<Element>, disableArrowNavigation?: boolean) {
10
+ let {direction} = useLocale();
11
+ let focusManager = useMemo(() => createFocusManager(ref), [ref]);
12
+
9
13
  // Open the popover on alt + arrow down
10
14
  let onKeyDown = (e: KeyboardEvent) => {
11
15
  if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {
@@ -13,23 +17,48 @@ export function useDatePickerGroup(state: DatePickerState | DateRangePickerState
13
17
  e.stopPropagation();
14
18
  state.setOpen(true);
15
19
  }
20
+
21
+ if (disableArrowNavigation) {
22
+ return;
23
+ }
24
+
25
+ switch (e.key) {
26
+ case 'ArrowLeft':
27
+ e.preventDefault();
28
+ e.stopPropagation();
29
+ if (direction === 'rtl') {
30
+ focusManager.focusNext();
31
+ } else {
32
+ focusManager.focusPrevious();
33
+ }
34
+ break;
35
+ case 'ArrowRight':
36
+ e.preventDefault();
37
+ e.stopPropagation();
38
+ if (direction === 'rtl') {
39
+ focusManager.focusPrevious();
40
+ } else {
41
+ focusManager.focusNext();
42
+ }
43
+ break;
44
+ }
16
45
  };
17
46
 
18
47
  // Focus the first placeholder segment from the end on mouse down/touch up in the field.
19
48
  let focusLast = () => {
20
49
  // Try to find the segment prior to the element that was clicked on.
21
- let target = window.event?.target as HTMLElement;
50
+ let target = window.event?.target as FocusableElement;
22
51
  let walker = getFocusableTreeWalker(ref.current, {tabbable: true});
23
52
  if (target) {
24
53
  walker.currentNode = target;
25
- target = walker.previousNode() as HTMLElement;
54
+ target = walker.previousNode() as FocusableElement;
26
55
  }
27
56
 
28
57
  // If no target found, find the last element from the end.
29
58
  if (!target) {
30
- let last: HTMLElement;
59
+ let last: FocusableElement;
31
60
  do {
32
- last = walker.lastChild() as HTMLElement;
61
+ last = walker.lastChild() as FocusableElement;
33
62
  if (last) {
34
63
  target = last;
35
64
  }
@@ -37,9 +66,9 @@ export function useDatePickerGroup(state: DatePickerState | DateRangePickerState
37
66
  }
38
67
 
39
68
  // Now go backwards until we find an element that is not a placeholder.
40
- while (target?.getAttribute('aria-placeholder')) {
41
- let prev = walker.previousNode() as HTMLElement;
42
- if (prev && prev.getAttribute('aria-placeholder')) {
69
+ while (target?.hasAttribute('data-placeholder')) {
70
+ let prev = walker.previousNode() as FocusableElement;
71
+ if (prev && prev.hasAttribute('data-placeholder')) {
43
72
  target = prev;
44
73
  } else {
45
74
  break;
@@ -52,6 +81,8 @@ export function useDatePickerGroup(state: DatePickerState | DateRangePickerState
52
81
  };
53
82
 
54
83
  let {pressProps} = usePress({
84
+ preventFocusOnPress: true,
85
+ allowTextSelectionOnPress: true,
55
86
  onPressStart(e) {
56
87
  if (e.pointerType === 'mouse') {
57
88
  focusLast();
@@ -15,22 +15,22 @@ import {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-t
15
15
  import {AriaDialogProps} from '@react-types/dialog';
16
16
  import {createFocusManager} from '@react-aria/focus';
17
17
  import {DateRangePickerState} from '@react-stately/datepicker';
18
+ import {DOMAttributes} from '@react-types/shared';
18
19
  import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
19
20
  import {focusManagerSymbol, roleSymbol} from './useDateField';
20
- import {HTMLAttributes, RefObject, useMemo} from 'react';
21
21
  // @ts-ignore
22
22
  import intlMessages from '../intl/*.json';
23
23
  import {RangeCalendarProps} from '@react-types/calendar';
24
+ import {RefObject, useMemo} from 'react';
24
25
  import {useDatePickerGroup} from './useDatePickerGroup';
25
26
  import {useField} from '@react-aria/label';
26
- import {useFocusWithin} from '@react-aria/interactions';
27
- import {useLocale, useMessageFormatter} from '@react-aria/i18n';
27
+ import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
28
28
 
29
29
  export interface DateRangePickerAria {
30
30
  /** Props for the date range picker's visible label element, if any. */
31
- labelProps: HTMLAttributes<HTMLElement>,
31
+ labelProps: DOMAttributes,
32
32
  /** Props for the grouping element containing the date fields and button. */
33
- groupProps: HTMLAttributes<HTMLElement>,
33
+ groupProps: DOMAttributes,
34
34
  /** Props for the start date field. */
35
35
  startFieldProps: AriaDatePickerProps<DateValue>,
36
36
  /** Props for the end date field. */
@@ -38,9 +38,9 @@ export interface DateRangePickerAria {
38
38
  /** Props for the popover trigger button. */
39
39
  buttonProps: AriaButtonProps,
40
40
  /** Props for the description element, if any. */
41
- descriptionProps: HTMLAttributes<HTMLElement>,
41
+ descriptionProps: DOMAttributes,
42
42
  /** Props for the error message element, if any. */
43
- errorMessageProps: HTMLAttributes<HTMLElement>,
43
+ errorMessageProps: DOMAttributes,
44
44
  /** Props for the popover dialog. */
45
45
  dialogProps: AriaDialogProps,
46
46
  /** Props for the range calendar within the popover dialog. */
@@ -52,8 +52,8 @@ export interface DateRangePickerAria {
52
52
  * A date range picker combines two DateFields and a RangeCalendar popover to allow
53
53
  * users to enter or select a date and time range.
54
54
  */
55
- export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<HTMLElement>): DateRangePickerAria {
56
- let formatMessage = useMessageFormatter(intlMessages);
55
+ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element>): DateRangePickerAria {
56
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
57
57
  let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
58
58
  ...props,
59
59
  labelElementType: 'span'
@@ -63,16 +63,16 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
63
63
 
64
64
  let {locale} = useLocale();
65
65
  let range = state.formatValue(locale, {month: 'long'});
66
- let description = range ? formatMessage('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';
66
+ let description = range ? stringFormatter.format('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';
67
67
  let descProps = useDescription(description);
68
68
 
69
69
  let startFieldProps = {
70
- 'aria-label': formatMessage('startDate'),
70
+ 'aria-label': stringFormatter.format('startDate'),
71
71
  'aria-labelledby': labelledBy
72
72
  };
73
73
 
74
74
  let endFieldProps = {
75
- 'aria-label': formatMessage('endDate'),
75
+ 'aria-label': stringFormatter.format('endDate'),
76
76
  'aria-labelledby': labelledBy
77
77
  };
78
78
 
@@ -80,14 +80,13 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
80
80
  let dialogId = useId();
81
81
 
82
82
  let groupProps = useDatePickerGroup(state, ref);
83
- let {focusWithinProps} = useFocusWithin({
84
- onBlurWithin() {
85
- state.confirmPlaceholder();
86
- }
87
- });
88
83
 
89
84
  let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;
90
- let focusManager = useMemo(() => createFocusManager(ref), [ref]);
85
+ let focusManager = useMemo(() => createFocusManager(ref, {
86
+ // Exclude the button from the focus manager.
87
+ accept: element => element.id !== buttonId
88
+ }), [ref, buttonId]);
89
+
91
90
  let commonFieldProps = {
92
91
  [focusManagerSymbol]: focusManager,
93
92
  [roleSymbol]: 'presentation',
@@ -107,7 +106,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
107
106
  let domProps = filterDOMProps(props);
108
107
 
109
108
  return {
110
- groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
109
+ groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, {
111
110
  role: 'group',
112
111
  'aria-disabled': props.isDisabled || null,
113
112
  'aria-describedby': ariaDescribedBy
@@ -121,9 +120,8 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
121
120
  buttonProps: {
122
121
  ...descProps,
123
122
  id: buttonId,
124
- excludeFromTabOrder: true,
125
123
  'aria-haspopup': 'dialog',
126
- 'aria-label': formatMessage('calendar'),
124
+ 'aria-label': stringFormatter.format('calendar'),
127
125
  'aria-labelledby': `${labelledBy} ${buttonId}`,
128
126
  'aria-describedby': ariaDescribedBy,
129
127
  onPress: () => state.setOpen(true)