@react-aria/calendar 3.8.0 → 3.8.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.
|
@@ -87,6 +87,7 @@ function $02ef492a56b91cb2$export$d652b3ea2d672d5b(props, state) {
|
|
|
87
87
|
return {
|
|
88
88
|
calendarProps: (0, $dPWPO$reactariautils.mergeProps)(domProps, labelProps, {
|
|
89
89
|
role: 'application',
|
|
90
|
+
'aria-details': props['aria-details'] || undefined,
|
|
90
91
|
'aria-describedby': props['aria-describedby'] || undefined
|
|
91
92
|
}),
|
|
92
93
|
nextButtonProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA2BM,SAAS,0CAAgB,KAAuD,EAAE,KAAyC;IAChI,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE;IAE9B,IAAI,QAAQ,CAAA,GAAA,oDAAyB,EAAE,MAAM,YAAY,CAAC,KAAK,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,QAAQ,EAAE;IACzG,IAAI,0BAA0B,CAAA,GAAA,oDAAyB,EAAE,MAAM,YAAY,CAAC,KAAK,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,QAAQ,EAAE;IAE3H,+CAA+C;IAC/C,CAAA,GAAA,qCAAc,EAAE;QACd,iDAAiD;QACjD,IAAI,CAAC,MAAM,SAAS,EAClB,CAAA,GAAA,sCAAO,EAAE;IAEb,GAAG;QAAC;KAAwB;IAE5B,2CAA2C;IAC3C,IAAI,0BAA0B,CAAA,GAAA,oDAAyB,EAAE;IACzD,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,yBACF,CAAA,GAAA,sCAAO,EAAE,yBAAyB,UAAU;IAE9C,yGAAyG;IAC3G,GAAG;QAAC;KAAwB;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","sources":["packages/@react-aria/calendar/src/useCalendarBase.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 */\n\nimport {announce} from '@react-aria/live-announcer';\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {CalendarPropsBase} from '@react-types/calendar';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {filterDOMProps, mergeProps, useLabels, useSlotId, useUpdateEffect} from '@react-aria/utils';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useState} from 'react';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes,\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps,\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** A description of the visible date range, for use in the calendar title. */\n title: string\n}\n\nexport function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabelingProps, state: CalendarState | RangeCalendarState): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);\n let visibleRangeDescription = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([Boolean(props.errorMessage), props.isInvalid, props.validationState]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA2BM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iB,mBAAmB,GAAG,CAAA,GAAA,qBAAO,EAAE;IACrD,IAAI,mBAAmB,MAAM,UAAU,IAAI,MAAM,6BAA6B;IAC9E,IAAI,oBAAoB,iBAAiB;QACvC,mBAAmB;QACnB,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,aAAa,CAAA,GAAA,+BAAQ,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK;QACf,cAAc;YAAC,KAAK,CAAC,aAAa;YAAE;SAAwB,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,gCAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarBase.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 */\n\nimport {announce} from '@react-aria/live-announcer';\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {CalendarPropsBase} from '@react-types/calendar';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {filterDOMProps, mergeProps, useLabels, useSlotId, useUpdateEffect} from '@react-aria/utils';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useState} from 'react';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes,\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps,\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** A description of the visible date range, for use in the calendar title. */\n title: string\n}\n\nexport function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabelingProps, state: CalendarState | RangeCalendarState): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);\n let visibleRangeDescription = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([Boolean(props.errorMessage), props.isInvalid, props.validationState]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.main.js.map"}
|
package/dist/useCalendarBase.mjs
CHANGED
|
@@ -81,6 +81,7 @@ function $c4acc1de3ab169cf$export$d652b3ea2d672d5b(props, state) {
|
|
|
81
81
|
return {
|
|
82
82
|
calendarProps: (0, $g2t6q$mergeProps)(domProps, labelProps, {
|
|
83
83
|
role: 'application',
|
|
84
|
+
'aria-details': props['aria-details'] || undefined,
|
|
84
85
|
'aria-describedby': props['aria-describedby'] || undefined
|
|
85
86
|
}),
|
|
86
87
|
nextButtonProps: {
|
|
@@ -81,6 +81,7 @@ function $c4acc1de3ab169cf$export$d652b3ea2d672d5b(props, state) {
|
|
|
81
81
|
return {
|
|
82
82
|
calendarProps: (0, $g2t6q$mergeProps)(domProps, labelProps, {
|
|
83
83
|
role: 'application',
|
|
84
|
+
'aria-details': props['aria-details'] || undefined,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AAA,GAAA,eAAO,EAAE;IAC7C,IAAI,eAAe,MAAM,UAAU,IAAI,MAAM,yBAAyB;IACtE,IAAI,gBAAgB,aAAa;QAC/B,eAAe;QACf,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,CAAC,iBAAiB,mBAAmB,GAAG,CAAA,GAAA,eAAO,EAAE;IACrD,IAAI,mBAAmB,MAAM,UAAU,IAAI,MAAM,6BAA6B;IAC9E,IAAI,oBAAoB,iBAAiB;QACvC,mBAAmB;QACnB,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,aAAa,CAAA,GAAA,gBAAQ,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK;QACf,cAAc;YAAC,KAAK,CAAC,aAAa;YAAE;SAAwB,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarBase.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 */\n\nimport {announce} from '@react-aria/live-announcer';\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {CalendarPropsBase} from '@react-types/calendar';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {filterDOMProps, mergeProps, useLabels, useSlotId, useUpdateEffect} from '@react-aria/utils';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useState} from 'react';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes,\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps,\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** A description of the visible date range, for use in the calendar title. */\n title: string\n}\n\nexport function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabelingProps, state: CalendarState | RangeCalendarState): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);\n let visibleRangeDescription = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([Boolean(props.errorMessage), props.isInvalid, props.validationState]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA2BM,SAAS,0CAAgB,KAAuD,EAAE,KAAyC;IAChI,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE;IAE9B,IAAI,QAAQ,CAAA,GAAA,wCAAyB,EAAE,MAAM,YAAY,CAAC,KAAK,EAAE,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,QAAQ,EAAE;IACzG,IAAI,0BAA0B,CAAA,GAAA,wCAAyB,EAAE,MAA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F,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarBase.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 */\n\nimport {announce} from '@react-aria/live-announcer';\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {CalendarPropsBase} from '@react-types/calendar';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {filterDOMProps, mergeProps, useLabels, useSlotId, useUpdateEffect} from '@react-aria/utils';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useState} from 'react';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes,\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps,\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** A description of the visible date range, for use in the calendar title. */\n title: string\n}\n\nexport function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabelingProps, state: CalendarState | RangeCalendarState): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);\n let visibleRangeDescription = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([Boolean(props.errorMessage), props.isInvalid, props.validationState]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/calendar",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@internationalized/date": "^3.8.
|
|
26
|
-
"@react-aria/i18n": "^3.12.
|
|
27
|
-
"@react-aria/interactions": "^3.25.
|
|
25
|
+
"@internationalized/date": "^3.8.1",
|
|
26
|
+
"@react-aria/i18n": "^3.12.9",
|
|
27
|
+
"@react-aria/interactions": "^3.25.1",
|
|
28
28
|
"@react-aria/live-announcer": "^3.4.2",
|
|
29
|
-
"@react-aria/utils": "^3.
|
|
30
|
-
"@react-stately/calendar": "^3.8.
|
|
31
|
-
"@react-types/button": "^3.12.
|
|
32
|
-
"@react-types/calendar": "^3.7.
|
|
33
|
-
"@react-types/shared": "^3.29.
|
|
29
|
+
"@react-aria/utils": "^3.29.0",
|
|
30
|
+
"@react-stately/calendar": "^3.8.1",
|
|
31
|
+
"@react-types/button": "^3.12.1",
|
|
32
|
+
"@react-types/calendar": "^3.7.1",
|
|
33
|
+
"@react-types/shared": "^3.29.1",
|
|
34
34
|
"@swc/helpers": "^0.5.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "9c77d4e8267ed39469c65f65da94ece7be509874"
|
|
44
44
|
}
|
package/src/useCalendarBase.ts
CHANGED
|
@@ -93,6 +93,7 @@ export function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabeli
|
|
|
93
93
|
return {
|
|
94
94
|
calendarProps: mergeProps(domProps, labelProps, {
|
|
95
95
|
role: 'application',
|
|
96
|
+
'aria-details': props['aria-details'] || undefined,
|
|
96
97
|
'aria-describedby': props['aria-describedby'] || undefined
|
|
97
98
|
}),
|
|
98
99
|
nextButtonProps: {
|