@react-aria/datepicker 3.1.1 → 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.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AC0BA,oCAAoC,CAAC,SAAS,SAAS,CAAE,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,kBAAkB,CAAC;CAAG;AAEtL;IACG,2DAA2D;IAC5D,UAAU,EAAE,aAAa,CAAC;IACzB,4CAA4C;IAC7C,UAAU,EAAE,aAAa,CAAC;IAC1B,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAiBD;;;;GAIG;AACH,6BAA6B,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,OAAO,CAAC,GAAG,aAAa,CAyE7I;AAED;;;;GAIG;AACH,6BAA6B,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,OAAO,CAAC,GAAG,aAAa,CAE7I;ACjHD;IACE,iEAAiE;IACjE,UAAU,EAAE,aAAa,CAAC;IAC1B,2EAA2E;IAC3E,UAAU,EAAE,aAAa,CAAC;IAC1B,gCAAgC;IAChC,UAAU,EAAE,oBAAoB,SAAS,CAAC,CAAC;IAC3C,4CAA4C;IAC5C,WAAW,EAAE,eAAe,CAAC;IAC7B,iDAAiD;IACjD,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAC;IACjC,oCAAoC;IACpC,WAAW,EAAE,eAAe,CAAC;IAC7B,wDAAwD;IACxD,aAAa,EAAE,cAAc,SAAS,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AmB,CA4GrK;AChJD,YAAY,EAAC,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,yBAAyB,CAAC;AAK3F,YAAY,EAAC,kBAAkB,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';\nexport type {AriaTimeFieldProps} from '@react-types/datepicker';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":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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.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -21,18 +21,18 @@
21
21
  "@internationalized/date": "^3.0.1",
22
22
  "@internationalized/number": "^3.1.1",
23
23
  "@internationalized/string": "^3.0.0",
24
- "@react-aria/focus": "^3.8.0",
25
- "@react-aria/i18n": "^3.6.0",
26
- "@react-aria/interactions": "^3.11.0",
27
- "@react-aria/label": "^3.4.1",
28
- "@react-aria/spinbutton": "^3.1.3",
29
- "@react-aria/utils": "^3.13.3",
30
- "@react-stately/datepicker": "^3.0.2",
31
- "@react-types/button": "^3.6.1",
32
- "@react-types/calendar": "^3.0.2",
33
- "@react-types/datepicker": "^3.1.1",
34
- "@react-types/dialog": "^3.4.3",
35
- "@react-types/shared": "^3.14.1"
24
+ "@react-aria/focus": "^3.10.0",
25
+ "@react-aria/i18n": "^3.6.2",
26
+ "@react-aria/interactions": "^3.13.0",
27
+ "@react-aria/label": "^3.4.3",
28
+ "@react-aria/spinbutton": "^3.2.0",
29
+ "@react-aria/utils": "^3.14.1",
30
+ "@react-stately/datepicker": "^3.2.0",
31
+ "@react-types/button": "^3.7.0",
32
+ "@react-types/calendar": "^3.0.4",
33
+ "@react-types/datepicker": "^3.1.3",
34
+ "@react-types/dialog": "^3.4.5",
35
+ "@react-types/shared": "^3.16.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "b03ef51e6317547dd0a840f151e59d039b1e1fd3"
44
+ "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
45
45
  }
@@ -13,11 +13,11 @@
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
+ import {DOMAttributes, KeyboardEvent} from '@react-types/shared';
17
17
  import {filterDOMProps, mergeProps, useDescription} from '@react-aria/utils';
18
+ import {FocusEvent, RefObject, useEffect, useMemo, useRef} from 'react';
18
19
  // @ts-ignore
19
20
  import intlMessages from '../intl/*.json';
20
- 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';
@@ -64,9 +64,16 @@ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>,
64
64
  });
65
65
 
66
66
  let {focusWithinProps} = useFocusWithin({
67
- onBlurWithin() {
67
+ ...props,
68
+ onBlurWithin: (e: FocusEvent) => {
68
69
  state.confirmPlaceholder();
69
- }
70
+
71
+ if (props.onBlur) {
72
+ props.onBlur(e);
73
+ }
74
+ },
75
+ onFocusWithin: props.onFocus,
76
+ onFocusWithinChange: props.onFocusChange
70
77
  });
71
78
 
72
79
  let stringFormatter = useLocalizedStringFormatter(intlMessages);
@@ -126,7 +133,18 @@ export function useDateField<T extends DateValue>(props: AriaDateFieldProps<T>,
126
133
  focusManager.focusFirst();
127
134
  }
128
135
  },
129
- fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps),
136
+ fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps, {
137
+ onKeyDown(e: KeyboardEvent) {
138
+ if (props.onKeyDown) {
139
+ props.onKeyDown(e);
140
+ }
141
+ },
142
+ onKeyUp(e: KeyboardEvent) {
143
+ if (props.onKeyUp) {
144
+ props.onKeyUp(e);
145
+ }
146
+ }
147
+ }),
130
148
  descriptionProps,
131
149
  errorMessageProps
132
150
  };
@@ -16,7 +16,7 @@ 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
+ import {DOMAttributes, KeyboardEvent} from '@react-types/shared';
20
20
  import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
21
21
  // @ts-ignore
22
22
  import intlMessages from '../intl/*.json';
@@ -24,6 +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 {useFocusWithin} from '@react-aria/interactions';
27
28
  import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
28
29
 
29
30
  export interface DatePickerAria {
@@ -71,12 +72,38 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
71
72
  let domProps = filterDOMProps(props);
72
73
  let focusManager = useMemo(() => createFocusManager(ref), [ref]);
73
74
 
75
+ let {focusWithinProps} = useFocusWithin({
76
+ ...props,
77
+ isDisabled: state.isOpen,
78
+ onBlurWithin: props.onBlur,
79
+ onFocusWithin: props.onFocus,
80
+ onFocusWithinChange: props.onFocusChange
81
+ });
82
+
74
83
  return {
75
- groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, {
84
+ groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
76
85
  role: 'group',
77
86
  'aria-disabled': props.isDisabled || null,
78
87
  'aria-labelledby': labelledBy,
79
- 'aria-describedby': ariaDescribedBy
88
+ 'aria-describedby': ariaDescribedBy,
89
+ onKeyDown(e: KeyboardEvent) {
90
+ if (state.isOpen) {
91
+ return;
92
+ }
93
+
94
+ if (props.onKeyDown) {
95
+ props.onKeyDown(e);
96
+ }
97
+ },
98
+ onKeyUp(e: KeyboardEvent) {
99
+ if (state.isOpen) {
100
+ return;
101
+ }
102
+
103
+ if (props.onKeyUp) {
104
+ props.onKeyUp(e);
105
+ }
106
+ }
80
107
  }),
81
108
  labelProps: {
82
109
  ...labelProps,
@@ -15,7 +15,7 @@ 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
+ import {DOMAttributes, KeyboardEvent} from '@react-types/shared';
19
19
  import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
20
20
  import {focusManagerSymbol, roleSymbol} from './useDateField';
21
21
  // @ts-ignore
@@ -24,6 +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 {useFocusWithin} from '@react-aria/interactions';
27
28
  import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
28
29
 
29
30
  export interface DateRangePickerAria {
@@ -105,11 +106,37 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
105
106
 
106
107
  let domProps = filterDOMProps(props);
107
108
 
109
+ let {focusWithinProps} = useFocusWithin({
110
+ ...props,
111
+ isDisabled: state.isOpen,
112
+ onBlurWithin: props.onBlur,
113
+ onFocusWithin: props.onFocus,
114
+ onFocusWithinChange: props.onFocusChange
115
+ });
116
+
108
117
  return {
109
- groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, {
118
+ groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
110
119
  role: 'group',
111
120
  'aria-disabled': props.isDisabled || null,
112
- 'aria-describedby': ariaDescribedBy
121
+ 'aria-describedby': ariaDescribedBy,
122
+ onKeyDown(e: KeyboardEvent) {
123
+ if (state.isOpen) {
124
+ return;
125
+ }
126
+
127
+ if (props.onKeyDown) {
128
+ props.onKeyDown(e);
129
+ }
130
+ },
131
+ onKeyUp(e: KeyboardEvent) {
132
+ if (state.isOpen) {
133
+ return;
134
+ }
135
+
136
+ if (props.onKeyUp) {
137
+ props.onKeyUp(e);
138
+ }
139
+ }
113
140
  }),
114
141
  labelProps: {
115
142
  ...labelProps,