@react-aria/datepicker 3.0.0-nightly.1662 → 3.0.0-nightly.1673

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.
@@ -21,7 +21,7 @@ import {RefObject, useEffect, useMemo, useRef} from 'react';
21
21
  import {useDatePickerGroup} from './useDatePickerGroup';
22
22
  import {useField} from '@react-aria/label';
23
23
  import {useFocusWithin} from '@react-aria/interactions';
24
- import {useMessageFormatter} from '@react-aria/i18n';
24
+ import {useLocalizedStringFormatter} from '@react-aria/i18n';
25
25
 
26
26
  // Allows this hook to also be used with TimeField
27
27
  export interface AriaDateFieldProps<T extends DateValue> extends Omit<AriaDatePickerProps<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue'> {}
@@ -69,10 +69,10 @@ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>,
69
69
  }
70
70
  });
71
71
 
72
- let formatMessage = useMessageFormatter(intlMessages);
72
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
73
73
  let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';
74
74
  let field = state.maxGranularity === 'hour' ? 'time' : 'date';
75
- let description = state.value ? formatMessage(message, {[field]: state.formatValue({month: 'long'})}) : '';
75
+ let description = state.value ? stringFormatter.format(message, {[field]: state.formatValue({month: 'long'})}) : '';
76
76
  let descProps = useDescription(description);
77
77
 
78
78
  // If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
@@ -24,7 +24,7 @@ import {RefObject, useMemo} from 'react';
24
24
  import {roleSymbol} from './useDateField';
25
25
  import {useDatePickerGroup} from './useDatePickerGroup';
26
26
  import {useField} from '@react-aria/label';
27
- import {useLocale, useMessageFormatter} from '@react-aria/i18n';
27
+ import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
28
28
 
29
29
  export interface DatePickerAria {
30
30
  /** Props for the date picker's visible label element, if any. */
@@ -52,7 +52,7 @@ export interface DatePickerAria {
52
52
  export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria {
53
53
  let buttonId = useId();
54
54
  let dialogId = useId();
55
- let formatMessage = useMessageFormatter(intlMessages);
55
+ let stringFormatter = useLocalizedStringFormatter(intlMessages);
56
56
 
57
57
  let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
58
58
  ...props,
@@ -65,7 +65,7 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
65
65
 
66
66
  let {locale} = useLocale();
67
67
  let date = state.formatValue(locale, {month: 'long'});
68
- let description = date ? formatMessage('selectedDateDescription', {date}) : '';
68
+ let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';
69
69
  let descProps = useDescription(description);
70
70
  let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;
71
71
  let domProps = filterDOMProps(props);
@@ -108,7 +108,7 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
108
108
  ...descProps,
109
109
  id: buttonId,
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)
@@ -24,7 +24,7 @@ import {RangeCalendarProps} from '@react-types/calendar';
24
24
  import {RefObject, useMemo} from 'react';
25
25
  import {useDatePickerGroup} from './useDatePickerGroup';
26
26
  import {useField} from '@react-aria/label';
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. */
@@ -53,7 +53,7 @@ export interface DateRangePickerAria {
53
53
  * users to enter or select a date and time range.
54
54
  */
55
55
  export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element>): DateRangePickerAria {
56
- let formatMessage = useMessageFormatter(intlMessages);
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
 
@@ -121,7 +121,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
121
121
  ...descProps,
122
122
  id: buttonId,
123
123
  'aria-haspopup': 'dialog',
124
- 'aria-label': formatMessage('calendar'),
124
+ 'aria-label': stringFormatter.format('calendar'),
125
125
  'aria-labelledby': `${labelledBy} ${buttonId}`,
126
126
  'aria-describedby': ariaDescribedBy,
127
127
  onPress: () => state.setOpen(true)
@@ -12,7 +12,7 @@
12
12
 
13
13
  // @ts-ignore
14
14
  import intlMessages from '../intl/*.json';
15
- import {MessageDictionary} from '@internationalized/message';
15
+ import {LocalizedStringDictionary} from '@internationalized/string';
16
16
  import {useLocale} from '@react-aria/i18n';
17
17
  import {useMemo} from 'react';
18
18
 
@@ -38,11 +38,11 @@ export function useDisplayNames(): DisplayNames {
38
38
 
39
39
  class DisplayNamesPolyfill implements DisplayNames {
40
40
  private locale: string;
41
- private dictionary: MessageDictionary;
41
+ private dictionary: LocalizedStringDictionary<Field, string>;
42
42
 
43
43
  constructor(locale: string) {
44
44
  this.locale = locale;
45
- this.dictionary = new MessageDictionary(intlMessages);
45
+ this.dictionary = new LocalizedStringDictionary<Field, string>(intlMessages);
46
46
  }
47
47
 
48
48
  of(field: Field): string {