@react-aria/datepicker 3.2.1 → 3.4.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/import.mjs +1628 -0
- package/dist/main.js +7 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -2
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -17
- package/src/index.ts +2 -2
- package/src/useDateField.ts +3 -3
- package/src/useDatePicker.ts +3 -0
- package/src/useDateRangePicker.ts +1 -0
- package/src/useDateSegment.ts +2 -2
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AC0BA,
|
|
1
|
+
{"mappings":";;;;;;;AC0BA,sCAAsC,CAAC,SAAS,SAAS,CAAE,SAAQ,IAAI,CAAC,mBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,kBAAkB,CAAC;CAAG;AAE3L;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,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,OAAO,CAAC,GAAG,aAAa,CA2F/I;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;AClID;IACE,iEAAiE;IACjE,UAAU,EAAE,aAAa,C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,gBAAgB,EAAE,aAAa,CAAC;IAChC,mDAAmD;IACnD,iBAAiB,EAAE,aAAa,CAAC;IACjC,oCAAoC;IACpC,WAAW,EAAE,eAAe,CAAC;IAC7B,8DAA8D;IAC9D,aAAa,EAAE,mBAAmB,SAAS,CAAC,CAAA;CAC7C;AAED;;;;GAIG;AACH,mCAAmC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,UAAU,OAAO,CAAC,GAAG,mBAAmB,CAuIrK;AC5KD,YAAY,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAKhJ,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 {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, DateRange, DateValue, TimeValue} from '@react-types/datepicker';\nexport type {AriaDateFieldOptions, 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,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/datepicker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -17,21 +22,21 @@
|
|
|
17
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@internationalized/date": "^3.0
|
|
21
|
-
"@internationalized/number": "^3.
|
|
22
|
-
"@internationalized/string": "^3.0
|
|
23
|
-
"@react-aria/focus": "^3.
|
|
24
|
-
"@react-aria/i18n": "^3.
|
|
25
|
-
"@react-aria/interactions": "^3.
|
|
26
|
-
"@react-aria/label": "^3.
|
|
27
|
-
"@react-aria/spinbutton": "^3.
|
|
28
|
-
"@react-aria/utils": "^3.
|
|
29
|
-
"@react-stately/datepicker": "^3.
|
|
30
|
-
"@react-types/button": "^3.7.
|
|
31
|
-
"@react-types/calendar": "^3.0
|
|
32
|
-
"@react-types/datepicker": "^3.
|
|
33
|
-
"@react-types/dialog": "^3.
|
|
34
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@internationalized/date": "^3.2.0",
|
|
26
|
+
"@internationalized/number": "^3.2.0",
|
|
27
|
+
"@internationalized/string": "^3.1.0",
|
|
28
|
+
"@react-aria/focus": "^3.12.0",
|
|
29
|
+
"@react-aria/i18n": "^3.7.1",
|
|
30
|
+
"@react-aria/interactions": "^3.15.0",
|
|
31
|
+
"@react-aria/label": "^3.5.1",
|
|
32
|
+
"@react-aria/spinbutton": "^3.4.0",
|
|
33
|
+
"@react-aria/utils": "^3.16.0",
|
|
34
|
+
"@react-stately/datepicker": "^3.4.0",
|
|
35
|
+
"@react-types/button": "^3.7.2",
|
|
36
|
+
"@react-types/calendar": "^3.2.0",
|
|
37
|
+
"@react-types/datepicker": "^3.3.0",
|
|
38
|
+
"@react-types/dialog": "^3.5.1",
|
|
39
|
+
"@react-types/shared": "^3.18.0",
|
|
35
40
|
"@swc/helpers": "^0.4.14"
|
|
36
41
|
},
|
|
37
42
|
"peerDependencies": {
|
|
@@ -41,5 +46,5 @@
|
|
|
41
46
|
"publishConfig": {
|
|
42
47
|
"access": "public"
|
|
43
48
|
},
|
|
44
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9d1ba9bd8ebcd63bf3495ade16d349bcb71795ce"
|
|
45
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,8 +16,8 @@ export {useDateField, useTimeField} from './useDateField';
|
|
|
16
16
|
export {useDateRangePicker} from './useDateRangePicker';
|
|
17
17
|
export {useDisplayNames} from './useDisplayNames';
|
|
18
18
|
|
|
19
|
-
export type {AriaDatePickerProps, AriaDateRangePickerProps} from '@react-types/datepicker';
|
|
20
|
-
export type {
|
|
19
|
+
export type {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, DateRange, DateValue, TimeValue} from '@react-types/datepicker';
|
|
20
|
+
export type {AriaDateFieldOptions, DateFieldAria} from './useDateField';
|
|
21
21
|
export type {DatePickerAria} from './useDatePicker';
|
|
22
22
|
export type {DateRangePickerAria} from './useDateRangePicker';
|
|
23
23
|
export type {DateSegmentAria} from './useDateSegment';
|
package/src/useDateField.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {AriaDateFieldProps as AriaDateFieldPropsBase, 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
16
|
import {DOMAttributes, KeyboardEvent} from '@react-types/shared';
|
|
@@ -24,7 +24,7 @@ import {useFocusWithin} from '@react-aria/interactions';
|
|
|
24
24
|
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
25
25
|
|
|
26
26
|
// Allows this hook to also be used with TimeField
|
|
27
|
-
export interface
|
|
27
|
+
export interface AriaDateFieldOptions<T extends DateValue> extends Omit<AriaDateFieldPropsBase<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue'> {}
|
|
28
28
|
|
|
29
29
|
export interface DateFieldAria {
|
|
30
30
|
/** Props for the field's visible label element, if any. */
|
|
@@ -57,7 +57,7 @@ export const focusManagerSymbol = '__focusManager_' + Date.now();
|
|
|
57
57
|
* A date field allows users to enter and edit date and time values using a keyboard.
|
|
58
58
|
* Each part of a date value is displayed in an individually editable segment.
|
|
59
59
|
*/
|
|
60
|
-
export function useDateField<T extends DateValue>(props:
|
|
60
|
+
export function useDateField<T extends DateValue>(props: AriaDateFieldOptions<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria {
|
|
61
61
|
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
|
|
62
62
|
...props,
|
|
63
63
|
labelElementType: 'span'
|
package/src/useDatePicker.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface DatePickerAria {
|
|
|
53
53
|
export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria {
|
|
54
54
|
let buttonId = useId();
|
|
55
55
|
let dialogId = useId();
|
|
56
|
+
let fieldId = useId();
|
|
56
57
|
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
57
58
|
|
|
58
59
|
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
|
|
@@ -113,6 +114,7 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
|
|
|
113
114
|
},
|
|
114
115
|
fieldProps: {
|
|
115
116
|
...fieldProps,
|
|
117
|
+
id: fieldId,
|
|
116
118
|
[roleSymbol]: 'presentation',
|
|
117
119
|
'aria-describedby': ariaDescribedBy,
|
|
118
120
|
value: state.value,
|
|
@@ -138,6 +140,7 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
|
|
|
138
140
|
'aria-label': stringFormatter.format('calendar'),
|
|
139
141
|
'aria-labelledby': `${labelledBy} ${buttonId}`,
|
|
140
142
|
'aria-describedby': ariaDescribedBy,
|
|
143
|
+
'aria-expanded': state.isOpen || undefined,
|
|
141
144
|
onPress: () => state.setOpen(true)
|
|
142
145
|
},
|
|
143
146
|
dialogProps: {
|
|
@@ -151,6 +151,7 @@ export function useDateRangePicker<T extends DateValue>(props: AriaDateRangePick
|
|
|
151
151
|
'aria-label': stringFormatter.format('calendar'),
|
|
152
152
|
'aria-labelledby': `${labelledBy} ${buttonId}`,
|
|
153
153
|
'aria-describedby': ariaDescribedBy,
|
|
154
|
+
'aria-expanded': state.isOpen || undefined,
|
|
154
155
|
onPress: () => state.setOpen(true)
|
|
155
156
|
},
|
|
156
157
|
dialogProps: {
|
package/src/useDateSegment.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {CalendarDate, toCalendar} from '@internationalized/date';
|
|
14
14
|
import {DateFieldState, DateSegment} from '@react-stately/datepicker';
|
|
15
15
|
import {DOMAttributes} from '@react-types/shared';
|
|
16
|
-
import {getScrollParent, isIOS, isMac, mergeProps,
|
|
16
|
+
import {getScrollParent, isIOS, isMac, mergeProps, scrollIntoViewport, useEvent, useId, useLabels, useLayoutEffect} from '@react-aria/utils';
|
|
17
17
|
import {hookData} from './useDateField';
|
|
18
18
|
import {NumberParser} from '@internationalized/number';
|
|
19
19
|
import React, {RefObject, useMemo, useRef} from 'react';
|
|
@@ -258,7 +258,7 @@ export function useDateSegment(segment: DateSegment, state: DateFieldState, ref:
|
|
|
258
258
|
|
|
259
259
|
let onFocus = () => {
|
|
260
260
|
enteredKeys.current = '';
|
|
261
|
-
|
|
261
|
+
scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});
|
|
262
262
|
|
|
263
263
|
// Collapse selection to start or Chrome won't fire input events.
|
|
264
264
|
let selection = window.getSelection();
|