@react-spectrum/datepicker 3.10.2 → 3.11.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/LICENSE +201 -0
- package/dist/DateField.main.js +2 -2
- package/dist/DateField.main.js.map +1 -1
- package/dist/DateField.mjs +2 -2
- package/dist/DateField.module.js +2 -2
- package/dist/DateField.module.js.map +1 -1
- package/dist/DatePicker.main.js +2 -2
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +2 -2
- package/dist/DatePicker.module.js +2 -2
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/DatePickerField.main.js +2 -2
- package/dist/DatePickerField.main.js.map +1 -1
- package/dist/DatePickerField.mjs +2 -2
- package/dist/DatePickerField.module.js +2 -2
- package/dist/DatePickerField.module.js.map +1 -1
- package/dist/DatePickerSegment.main.js +1 -1
- package/dist/DatePickerSegment.main.js.map +1 -1
- package/dist/DatePickerSegment.mjs +1 -1
- package/dist/DatePickerSegment.module.js +1 -1
- package/dist/DatePickerSegment.module.js.map +1 -1
- package/dist/DateRangePicker.main.js +2 -2
- package/dist/DateRangePicker.main.js.map +1 -1
- package/dist/DateRangePicker.mjs +2 -2
- package/dist/DateRangePicker.module.js +2 -2
- package/dist/DateRangePicker.module.js.map +1 -1
- package/dist/Input.main.js +1 -1
- package/dist/Input.main.js.map +1 -1
- package/dist/Input.mjs +1 -1
- package/dist/Input.module.js +1 -1
- package/dist/Input.module.js.map +1 -1
- package/dist/TimeField.main.js +1 -1
- package/dist/TimeField.main.js.map +1 -1
- package/dist/TimeField.mjs +1 -1
- package/dist/TimeField.module.js +1 -1
- package/dist/TimeField.module.js.map +1 -1
- package/dist/inputgroup_vars_css.main.js.map +1 -1
- package/dist/inputgroup_vars_css.module.js.map +1 -1
- package/dist/textfield_vars_css.main.js.map +1 -1
- package/dist/textfield_vars_css.module.js.map +1 -1
- package/dist/utils.main.js +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +1 -1
- package/dist/utils.module.js +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +25 -24
- package/src/DateField.tsx +4 -4
- package/src/DatePicker.tsx +3 -3
- package/src/DatePickerField.tsx +2 -2
- package/src/DatePickerSegment.tsx +1 -1
- package/src/DateRangePicker.tsx +3 -3
- package/src/Input.tsx +4 -4
- package/src/TimeField.tsx +3 -3
- package/src/utils.ts +2 -2
package/dist/utils.module.js
CHANGED
|
@@ -65,7 +65,7 @@ function $04e96200274b03de$var$getVisibleMonths(scale) {
|
|
|
65
65
|
return Math.floor((window.innerWidth - popoverPadding * 2) / (monthWidth + gap));
|
|
66
66
|
}
|
|
67
67
|
function $04e96200274b03de$export$71a23a36270e4bf0(ref) {
|
|
68
|
-
let domRef = (0, $d7JPl$useRef)(
|
|
68
|
+
let domRef = (0, $d7JPl$useRef)(null);
|
|
69
69
|
(0, $d7JPl$useImperativeHandle)(ref, ()=>({
|
|
70
70
|
...(0, $d7JPl$createDOMRef)(domRef),
|
|
71
71
|
focus () {
|
package/dist/utils.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAWM,SAAS,0CAAkB,KAA8E;IAC9G,IAAI,YAAY,CAAA,GAAA,uBAAe,EAAE;QAAC,WAAW;IAAO;IACpD,IAAI,eAAe,CAAA,GAAA,sBAAc;IACjC,OAAO,CAAA,GAAA,cAAM,EAAE;QACb,IAAI,MAAM,WAAW,EACnB,OAAO,MAAM,WAAW;QAG1B,IAAI,MAAM,kBAAkB,EAC1B,OAAO,UAAU,aAAa,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAA;YAC7C,IAAI,EAAE,IAAI,KAAK,WACb,OAAO,EAAE,KAAK;YAGhB,OAAO,aAAa,EAAE,CAAC,EAAE,IAAI;QAC/B,GAAG,IAAI,CAAC;QAGV,OAAO;IACT,GAAG;QAAC,MAAM,WAAW;QAAE,MAAM,kBAAkB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AAI,eAAe,MAAM,gBAAgB,CAAC,QAAQ;QAAC,yBAAyB;IAAI,GAAG,MAAM,CAAC,aAAa;IACvG,IAAI,kBAAmB,aAAa,MAAM;IAE1C,+CAA+C;IAC/C,8EAA8E;IAC9E,mFAAmF;IACnF,iEAAiE;IACjE,OAAQ,kBAAkB,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,kBAAkB,IAAI;AACtE","sources":["packages/@react-spectrum/datepicker/src/utils.ts"],"sourcesContent":["/*\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 */\nimport {createDOMRef} from '@react-spectrum/utils';\nimport {createFocusManager} from '@react-aria/focus';\nimport {FocusableRef} from '@react-types/shared';\nimport {SpectrumDatePickerBase} from '@react-types/datepicker';\nimport {useDateFormatter, useLocale} from '@react-aria/i18n';\nimport {useDisplayNames} from '@react-aria/datepicker';\nimport {useImperativeHandle, useMemo, useRef, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useProvider} from '@react-spectrum/provider';\n\nexport function useFormatHelpText(props: Pick<SpectrumDatePickerBase<any>, 'description' | 'showFormatHelpText'>) {\n let formatter = useDateFormatter({dateStyle: 'short'});\n let displayNames = useDisplayNames();\n return useMemo(() => {\n if (props.description) {\n return props.description;\n }\n\n if (props.showFormatHelpText) {\n return formatter.formatToParts(new Date()).map(s => {\n if (s.type === 'literal') {\n return s.value;\n }\n\n return displayNames.of(s.type);\n }).join(' ');\n }\n\n return '';\n }, [props.description, props.showFormatHelpText, formatter, displayNames]);\n}\n\nexport function useVisibleMonths(maxVisibleMonths: number) {\n let {scale} = useProvider()!;\n let [visibleMonths, setVisibleMonths] = useState(getVisibleMonths(scale));\n useLayoutEffect(() => {\n let onResize = () => setVisibleMonths(getVisibleMonths(scale));\n onResize();\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [scale]);\n\n return Math.max(1, Math.min(visibleMonths, maxVisibleMonths, 3));\n}\n\nfunction getVisibleMonths(scale) {\n if (typeof window === 'undefined') {\n return 1;\n }\n let monthWidth = scale === 'large' ? 336 : 280;\n let gap = scale === 'large' ? 30 : 24;\n let popoverPadding = scale === 'large' ? 32 : 48;\n return Math.floor((window.innerWidth - popoverPadding * 2) / (monthWidth + gap));\n}\n\nexport function useFocusManagerRef(ref: FocusableRef<HTMLElement>) {\n let domRef = useRef<HTMLElement | null>(null);\n useImperativeHandle(ref, () => ({\n ...createDOMRef(domRef),\n focus() {\n createFocusManager(domRef).focusFirst({tabbable: true});\n }\n }));\n return domRef;\n}\n\nexport function useFormattedDateWidth(state) {\n let locale = useLocale()?.locale;\n let currentDate = new Date();\n let formatedDate = state.getDateFormatter(locale, {shouldForceLeadingZeros: true}).format(currentDate, locale);\n let totalCharacters = formatedDate.length;\n\n // The max of two is for times with only hours.\n // As the length of a date grows we need to proportionally increase the width.\n // We use the character count with 'ch' units and add extra padding to accomate for\n // dates with months and time dashes, which are wider characters.\n return (totalCharacters + Math.max(Math.floor(totalCharacters / 5), 2));\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/datepicker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,25 +36,25 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@internationalized/date": "^3.
|
|
40
|
-
"@react-aria/datepicker": "^3.
|
|
41
|
-
"@react-aria/focus": "^3.
|
|
42
|
-
"@react-aria/i18n": "^3.12.
|
|
43
|
-
"@react-aria/interactions": "^3.22.
|
|
44
|
-
"@react-aria/utils": "^3.
|
|
45
|
-
"@react-spectrum/button": "^3.16.
|
|
46
|
-
"@react-spectrum/calendar": "^3.
|
|
47
|
-
"@react-spectrum/dialog": "^3.8.
|
|
48
|
-
"@react-spectrum/form": "^3.7.
|
|
49
|
-
"@react-spectrum/label": "^3.16.
|
|
50
|
-
"@react-spectrum/layout": "^3.6.
|
|
51
|
-
"@react-spectrum/utils": "^3.
|
|
52
|
-
"@react-spectrum/view": "^3.6.
|
|
53
|
-
"@react-stately/datepicker": "^3.
|
|
54
|
-
"@react-types/datepicker": "^3.
|
|
55
|
-
"@react-types/shared": "^3.
|
|
56
|
-
"@spectrum-icons/ui": "^3.6.
|
|
57
|
-
"@spectrum-icons/workflow": "^4.2.
|
|
39
|
+
"@internationalized/date": "^3.6.0",
|
|
40
|
+
"@react-aria/datepicker": "^3.12.0",
|
|
41
|
+
"@react-aria/focus": "^3.19.0",
|
|
42
|
+
"@react-aria/i18n": "^3.12.4",
|
|
43
|
+
"@react-aria/interactions": "^3.22.5",
|
|
44
|
+
"@react-aria/utils": "^3.26.0",
|
|
45
|
+
"@react-spectrum/button": "^3.16.9",
|
|
46
|
+
"@react-spectrum/calendar": "^3.5.0",
|
|
47
|
+
"@react-spectrum/dialog": "^3.8.16",
|
|
48
|
+
"@react-spectrum/form": "^3.7.10",
|
|
49
|
+
"@react-spectrum/label": "^3.16.10",
|
|
50
|
+
"@react-spectrum/layout": "^3.6.10",
|
|
51
|
+
"@react-spectrum/utils": "^3.12.0",
|
|
52
|
+
"@react-spectrum/view": "^3.6.14",
|
|
53
|
+
"@react-stately/datepicker": "^3.11.0",
|
|
54
|
+
"@react-types/datepicker": "^3.9.0",
|
|
55
|
+
"@react-types/shared": "^3.26.0",
|
|
56
|
+
"@spectrum-icons/ui": "^3.6.11",
|
|
57
|
+
"@spectrum-icons/workflow": "^4.2.16",
|
|
58
58
|
"@swc/helpers": "^0.5.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
@@ -63,10 +63,11 @@
|
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@react-spectrum/provider": "^3.0.0",
|
|
66
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
67
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
66
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
67
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
|
-
}
|
|
72
|
-
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
73
|
+
}
|
package/src/DateField.tsx
CHANGED
|
@@ -45,8 +45,8 @@ function DateField<T extends DateValue>(props: SpectrumDateFieldProps<T>, ref: F
|
|
|
45
45
|
createCalendar
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
let fieldRef = useRef(null);
|
|
49
|
-
let inputRef = useRef(null);
|
|
48
|
+
let fieldRef = useRef<HTMLElement | null>(null);
|
|
49
|
+
let inputRef = useRef<HTMLInputElement | null>(null);
|
|
50
50
|
let {labelProps, fieldProps, inputProps, descriptionProps, errorMessageProps, isInvalid, validationErrors, validationDetails} = useDateField({
|
|
51
51
|
...props,
|
|
52
52
|
inputRef
|
|
@@ -56,7 +56,7 @@ function DateField<T extends DateValue>(props: SpectrumDateFieldProps<T>, ref: F
|
|
|
56
56
|
// The format help text is unnecessary for screen reader users because each segment already has a label.
|
|
57
57
|
let description = useFormatHelpText(props);
|
|
58
58
|
if (description && !props.description) {
|
|
59
|
-
descriptionProps.id =
|
|
59
|
+
descriptionProps.id = undefined;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
let validationState = state.validationState || (isInvalid ? 'invalid' : null);
|
|
@@ -72,7 +72,7 @@ function DateField<T extends DateValue>(props: SpectrumDateFieldProps<T>, ref: F
|
|
|
72
72
|
labelProps={labelProps}
|
|
73
73
|
descriptionProps={descriptionProps}
|
|
74
74
|
errorMessageProps={errorMessageProps}
|
|
75
|
-
validationState={validationState}
|
|
75
|
+
validationState={validationState ?? undefined}
|
|
76
76
|
isInvalid={isInvalid}
|
|
77
77
|
validationErrors={validationErrors}
|
|
78
78
|
validationDetails={validationDetails}
|
package/src/DatePicker.tsx
CHANGED
|
@@ -50,7 +50,7 @@ function DatePicker<T extends DateValue>(props: SpectrumDatePickerProps<T>, ref:
|
|
|
50
50
|
pageBehavior
|
|
51
51
|
} = props;
|
|
52
52
|
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
53
|
-
let targetRef = useRef<HTMLDivElement>(
|
|
53
|
+
let targetRef = useRef<HTMLDivElement | null>(null);
|
|
54
54
|
let state = useDatePickerState({
|
|
55
55
|
...props,
|
|
56
56
|
shouldCloseOnSelect: () => !state.hasTime
|
|
@@ -99,10 +99,10 @@ function DatePicker<T extends DateValue>(props: SpectrumDatePickerProps<T>, ref:
|
|
|
99
99
|
// The format help text is unnecessary for screen reader users because each segment already has a label.
|
|
100
100
|
let description = useFormatHelpText(props);
|
|
101
101
|
if (description && !props.description) {
|
|
102
|
-
descriptionProps.id =
|
|
102
|
+
descriptionProps.id = undefined;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
let placeholder: DateValue = placeholderValue;
|
|
105
|
+
let placeholder: DateValue | null | undefined = placeholderValue;
|
|
106
106
|
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
|
|
107
107
|
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
|
|
108
108
|
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
|
package/src/DatePickerField.tsx
CHANGED
|
@@ -33,7 +33,7 @@ export function DatePickerField<T extends DateValue>(props: DatePickerFieldProps
|
|
|
33
33
|
isRequired,
|
|
34
34
|
inputClassName
|
|
35
35
|
} = props;
|
|
36
|
-
let ref = useRef(
|
|
36
|
+
let ref = useRef<HTMLDivElement | null>(null);
|
|
37
37
|
let {locale} = useLocale();
|
|
38
38
|
let state = useDateFieldState({
|
|
39
39
|
...props,
|
|
@@ -41,7 +41,7 @@ export function DatePickerField<T extends DateValue>(props: DatePickerFieldProps
|
|
|
41
41
|
createCalendar
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
let inputRef = useRef(
|
|
44
|
+
let inputRef = useRef<HTMLInputElement | null>(null);
|
|
45
45
|
let {fieldProps, inputProps} = useDateField({...props, inputRef}, state, ref);
|
|
46
46
|
|
|
47
47
|
return (
|
|
@@ -50,7 +50,7 @@ function LiteralSegment({segment}: LiteralSegmentProps) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function EditableSegment({segment, state}: DatePickerSegmentProps) {
|
|
53
|
-
let ref = useRef(
|
|
53
|
+
let ref = useRef<HTMLDivElement | null>(null);
|
|
54
54
|
let {segmentProps} = useDateSegment(segment, state, ref);
|
|
55
55
|
|
|
56
56
|
return (
|
package/src/DateRangePicker.tsx
CHANGED
|
@@ -50,7 +50,7 @@ function DateRangePicker<T extends DateValue>(props: SpectrumDateRangePickerProp
|
|
|
50
50
|
pageBehavior
|
|
51
51
|
} = props;
|
|
52
52
|
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
53
|
-
let targetRef = useRef<HTMLDivElement>(
|
|
53
|
+
let targetRef = useRef<HTMLDivElement | null>(null);
|
|
54
54
|
let state = useDateRangePickerState({
|
|
55
55
|
...props,
|
|
56
56
|
shouldCloseOnSelect: () => !state.hasTime
|
|
@@ -99,10 +99,10 @@ function DateRangePicker<T extends DateValue>(props: SpectrumDateRangePickerProp
|
|
|
99
99
|
// The format help text is unnecessary for screen reader users because each segment already has a label.
|
|
100
100
|
let description = useFormatHelpText(props);
|
|
101
101
|
if (description && !props.description) {
|
|
102
|
-
descriptionProps.id =
|
|
102
|
+
descriptionProps.id = undefined;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
let placeholder: DateValue = placeholderValue;
|
|
105
|
+
let placeholder: DateValue | null | undefined = placeholderValue;
|
|
106
106
|
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
|
|
107
107
|
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
|
|
108
108
|
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
|
package/src/Input.tsx
CHANGED
|
@@ -15,12 +15,12 @@ import Checkmark from '@spectrum-icons/ui/CheckmarkMedium';
|
|
|
15
15
|
import {classNames, useValueEffect} from '@react-spectrum/utils';
|
|
16
16
|
import datepickerStyles from './styles.css';
|
|
17
17
|
import {mergeProps, mergeRefs, useEvent, useLayoutEffect, useResizeObserver} from '@react-aria/utils';
|
|
18
|
-
import React, {useCallback, useRef} from 'react';
|
|
18
|
+
import React, {ReactElement, useCallback, useRef} from 'react';
|
|
19
19
|
import textfieldStyles from '@adobe/spectrum-css-temp/components/textfield/vars.css';
|
|
20
20
|
import {useFocusRing} from '@react-aria/focus';
|
|
21
21
|
|
|
22
22
|
function Input(props, ref) {
|
|
23
|
-
let inputRef = useRef(null);
|
|
23
|
+
let inputRef = useRef<HTMLInputElement | null>(null);
|
|
24
24
|
let {
|
|
25
25
|
isDisabled,
|
|
26
26
|
isQuiet,
|
|
@@ -38,7 +38,7 @@ function Input(props, ref) {
|
|
|
38
38
|
// not cause a layout shift.
|
|
39
39
|
let [reservePadding, setReservePadding] = useValueEffect(false);
|
|
40
40
|
let onResize = useCallback(() => setReservePadding(function *(reservePadding) {
|
|
41
|
-
if (inputRef.current) {
|
|
41
|
+
if (inputRef.current && inputRef.current.parentElement) {
|
|
42
42
|
if (reservePadding) {
|
|
43
43
|
// Try to collapse padding if the content is clipped.
|
|
44
44
|
if (inputRef.current.scrollWidth > inputRef.current.offsetWidth) {
|
|
@@ -114,7 +114,7 @@ function Input(props, ref) {
|
|
|
114
114
|
'spectrum-Textfield-validationIcon'
|
|
115
115
|
);
|
|
116
116
|
|
|
117
|
-
let validationIcon = null;
|
|
117
|
+
let validationIcon: ReactElement | null = null;
|
|
118
118
|
if (validationState === 'invalid' && !isDisabled) {
|
|
119
119
|
validationIcon = <Alert data-testid="invalid-icon" UNSAFE_className={iconClass} />;
|
|
120
120
|
} else if (validationState === 'valid' && !isDisabled) {
|
package/src/TimeField.tsx
CHANGED
|
@@ -43,8 +43,8 @@ function TimeField<T extends TimeValue>(props: SpectrumTimeFieldProps<T>, ref: F
|
|
|
43
43
|
locale
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
let fieldRef = useRef(null);
|
|
47
|
-
let inputRef = useRef(null);
|
|
46
|
+
let fieldRef = useRef<HTMLDivElement | null>(null);
|
|
47
|
+
let inputRef = useRef<HTMLInputElement | null>(null);
|
|
48
48
|
let {labelProps, fieldProps, inputProps, descriptionProps, errorMessageProps, isInvalid, validationErrors, validationDetails} = useTimeField({
|
|
49
49
|
...props,
|
|
50
50
|
inputRef
|
|
@@ -62,7 +62,7 @@ function TimeField<T extends TimeValue>(props: SpectrumTimeFieldProps<T>, ref: F
|
|
|
62
62
|
labelProps={labelProps}
|
|
63
63
|
descriptionProps={descriptionProps}
|
|
64
64
|
errorMessageProps={errorMessageProps}
|
|
65
|
-
validationState={validationState}
|
|
65
|
+
validationState={validationState ?? undefined}
|
|
66
66
|
isInvalid={isInvalid}
|
|
67
67
|
validationErrors={validationErrors}
|
|
68
68
|
validationDetails={validationDetails}
|
package/src/utils.ts
CHANGED
|
@@ -42,7 +42,7 @@ export function useFormatHelpText(props: Pick<SpectrumDatePickerBase<any>, 'desc
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function useVisibleMonths(maxVisibleMonths: number) {
|
|
45
|
-
let {scale} = useProvider()
|
|
45
|
+
let {scale} = useProvider()!;
|
|
46
46
|
let [visibleMonths, setVisibleMonths] = useState(getVisibleMonths(scale));
|
|
47
47
|
useLayoutEffect(() => {
|
|
48
48
|
let onResize = () => setVisibleMonths(getVisibleMonths(scale));
|
|
@@ -68,7 +68,7 @@ function getVisibleMonths(scale) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export function useFocusManagerRef(ref: FocusableRef<HTMLElement>) {
|
|
71
|
-
let domRef = useRef(
|
|
71
|
+
let domRef = useRef<HTMLElement | null>(null);
|
|
72
72
|
useImperativeHandle(ref, () => ({
|
|
73
73
|
...createDOMRef(domRef),
|
|
74
74
|
focus() {
|