@react-aria/datepicker 3.1.2 → 3.2.1
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/main.js +430 -442
- package/dist/main.js.map +1 -1
- package/dist/module.js +430 -442
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/useDateField.ts +23 -5
- package/src/useDatePicker.ts +30 -3
- package/src/useDateRangePicker.ts +30 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/datepicker",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -17,22 +17,22 @@
|
|
|
17
17
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@internationalized/
|
|
22
|
-
"@internationalized/
|
|
23
|
-
"@
|
|
24
|
-
"@react-aria/
|
|
25
|
-
"@react-aria/
|
|
26
|
-
"@react-aria/
|
|
27
|
-
"@react-aria/
|
|
28
|
-
"@react-aria/
|
|
29
|
-
"@react-
|
|
30
|
-
"@react-
|
|
31
|
-
"@react-types/
|
|
32
|
-
"@react-types/
|
|
33
|
-
"@react-types/
|
|
34
|
-
"@react-types/
|
|
35
|
-
"@
|
|
20
|
+
"@internationalized/date": "^3.0.2",
|
|
21
|
+
"@internationalized/number": "^3.1.2",
|
|
22
|
+
"@internationalized/string": "^3.0.1",
|
|
23
|
+
"@react-aria/focus": "^3.10.1",
|
|
24
|
+
"@react-aria/i18n": "^3.6.3",
|
|
25
|
+
"@react-aria/interactions": "^3.13.1",
|
|
26
|
+
"@react-aria/label": "^3.4.4",
|
|
27
|
+
"@react-aria/spinbutton": "^3.2.1",
|
|
28
|
+
"@react-aria/utils": "^3.14.2",
|
|
29
|
+
"@react-stately/datepicker": "^3.2.1",
|
|
30
|
+
"@react-types/button": "^3.7.0",
|
|
31
|
+
"@react-types/calendar": "^3.0.5",
|
|
32
|
+
"@react-types/datepicker": "^3.1.4",
|
|
33
|
+
"@react-types/dialog": "^3.4.5",
|
|
34
|
+
"@react-types/shared": "^3.16.0",
|
|
35
|
+
"@swc/helpers": "^0.4.14"
|
|
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": "
|
|
44
|
+
"gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
|
|
45
45
|
}
|
package/src/useDateField.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
};
|
package/src/useDatePicker.ts
CHANGED
|
@@ -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,
|