react-aria 3.49.0 → 3.50.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/private/autocomplete/useAutocomplete.cjs +16 -7
- package/dist/private/autocomplete/useAutocomplete.cjs.map +1 -1
- package/dist/private/autocomplete/useAutocomplete.js +16 -7
- package/dist/private/autocomplete/useAutocomplete.js.map +1 -1
- package/dist/private/autocomplete/useAutocomplete.mjs +16 -7
- package/dist/private/autocomplete/useAutocomplete.mjs.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.cjs.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.js.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.mjs.map +1 -1
- package/dist/private/calendar/useCalendarBase.cjs.map +1 -1
- package/dist/private/calendar/useCalendarBase.js.map +1 -1
- package/dist/private/calendar/useCalendarBase.mjs.map +1 -1
- package/dist/private/calendar/useCalendarCell.cjs.map +1 -1
- package/dist/private/calendar/useCalendarCell.js.map +1 -1
- package/dist/private/calendar/useCalendarCell.mjs.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.cjs +4 -4
- package/dist/private/calendar/useCalendarYearPicker.cjs.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.js +4 -4
- package/dist/private/calendar/useCalendarYearPicker.js.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.mjs +4 -4
- package/dist/private/calendar/useCalendarYearPicker.mjs.map +1 -1
- package/dist/private/calendar/utils.cjs.map +1 -1
- package/dist/private/calendar/utils.js.map +1 -1
- package/dist/private/calendar/utils.mjs.map +1 -1
- package/dist/private/color/useColorArea.cjs.map +1 -1
- package/dist/private/color/useColorArea.js.map +1 -1
- package/dist/private/color/useColorArea.mjs.map +1 -1
- package/dist/private/color/useColorSwatch.cjs.map +1 -1
- package/dist/private/color/useColorSwatch.js.map +1 -1
- package/dist/private/color/useColorSwatch.mjs.map +1 -1
- package/dist/private/combobox/useComboBox.cjs +2 -0
- package/dist/private/combobox/useComboBox.cjs.map +1 -1
- package/dist/private/combobox/useComboBox.js +2 -0
- package/dist/private/combobox/useComboBox.js.map +1 -1
- package/dist/private/combobox/useComboBox.mjs +2 -0
- package/dist/private/combobox/useComboBox.mjs.map +1 -1
- package/dist/private/datepicker/useDateField.cjs.map +1 -1
- package/dist/private/datepicker/useDateField.js.map +1 -1
- package/dist/private/datepicker/useDateField.mjs.map +1 -1
- package/dist/private/datepicker/useDatePicker.cjs.map +1 -1
- package/dist/private/datepicker/useDatePicker.js.map +1 -1
- package/dist/private/datepicker/useDatePicker.mjs.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.cjs.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.js.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.mjs.map +1 -1
- package/dist/private/datepicker/useDisplayNames.cjs +1 -2
- package/dist/private/datepicker/useDisplayNames.cjs.map +1 -1
- package/dist/private/datepicker/useDisplayNames.js +1 -2
- package/dist/private/datepicker/useDisplayNames.js.map +1 -1
- package/dist/private/datepicker/useDisplayNames.mjs +1 -2
- package/dist/private/datepicker/useDisplayNames.mjs.map +1 -1
- package/dist/private/dnd/DragManager.cjs +4 -1
- package/dist/private/dnd/DragManager.cjs.map +1 -1
- package/dist/private/dnd/DragManager.js +4 -1
- package/dist/private/dnd/DragManager.js.map +1 -1
- package/dist/private/dnd/DragManager.mjs +4 -1
- package/dist/private/dnd/DragManager.mjs.map +1 -1
- package/dist/private/dnd/useDrag.cjs.map +1 -1
- package/dist/private/dnd/useDrag.js.map +1 -1
- package/dist/private/dnd/useDrag.mjs.map +1 -1
- package/dist/private/dnd/useDraggableItem.cjs.map +1 -1
- package/dist/private/dnd/useDraggableItem.js.map +1 -1
- package/dist/private/dnd/useDraggableItem.mjs.map +1 -1
- package/dist/private/dnd/useDropIndicator.cjs.map +1 -1
- package/dist/private/dnd/useDropIndicator.js.map +1 -1
- package/dist/private/dnd/useDropIndicator.mjs.map +1 -1
- package/dist/private/dnd/useVirtualDrop.cjs.map +1 -1
- package/dist/private/dnd/useVirtualDrop.js.map +1 -1
- package/dist/private/dnd/useVirtualDrop.mjs.map +1 -1
- package/dist/private/dnd/utils.cjs +13 -3
- package/dist/private/dnd/utils.cjs.map +1 -1
- package/dist/private/dnd/utils.js +13 -3
- package/dist/private/dnd/utils.js.map +1 -1
- package/dist/private/dnd/utils.mjs +13 -3
- package/dist/private/dnd/utils.mjs.map +1 -1
- package/dist/private/form/useFormValidation.cjs +1 -1
- package/dist/private/form/useFormValidation.cjs.map +1 -1
- package/dist/private/form/useFormValidation.js +1 -1
- package/dist/private/form/useFormValidation.js.map +1 -1
- package/dist/private/form/useFormValidation.mjs +1 -1
- package/dist/private/form/useFormValidation.mjs.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.cjs.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.js.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.mjs.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.cjs.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.js.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.mjs.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.cjs.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.js.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.mjs.map +1 -1
- package/dist/private/gridlist/useGridList.cjs +2 -1
- package/dist/private/gridlist/useGridList.cjs.map +1 -1
- package/dist/private/gridlist/useGridList.js +2 -1
- package/dist/private/gridlist/useGridList.js.map +1 -1
- package/dist/private/gridlist/useGridList.mjs +2 -1
- package/dist/private/gridlist/useGridList.mjs.map +1 -1
- package/dist/private/gridlist/useGridListItem.cjs +62 -21
- package/dist/private/gridlist/useGridListItem.cjs.map +1 -1
- package/dist/private/gridlist/useGridListItem.js +63 -22
- package/dist/private/gridlist/useGridListItem.js.map +1 -1
- package/dist/private/gridlist/useGridListItem.mjs +62 -21
- package/dist/private/gridlist/useGridListItem.mjs.map +1 -1
- package/dist/private/interactions/createEventHandler.cjs +3 -0
- package/dist/private/interactions/createEventHandler.cjs.map +1 -1
- package/dist/private/interactions/createEventHandler.js +3 -0
- package/dist/private/interactions/createEventHandler.js.map +1 -1
- package/dist/private/interactions/createEventHandler.mjs +3 -0
- package/dist/private/interactions/createEventHandler.mjs.map +1 -1
- package/dist/private/interactions/useFocusVisible.cjs +16 -5
- package/dist/private/interactions/useFocusVisible.cjs.map +1 -1
- package/dist/private/interactions/useFocusVisible.js +16 -5
- package/dist/private/interactions/useFocusVisible.js.map +1 -1
- package/dist/private/interactions/useFocusVisible.mjs +16 -5
- package/dist/private/interactions/useFocusVisible.mjs.map +1 -1
- package/dist/private/menu/useMenu.cjs.map +1 -1
- package/dist/private/menu/useMenu.js.map +1 -1
- package/dist/private/menu/useMenu.mjs.map +1 -1
- package/dist/private/menu/useMenuItem.cjs +1 -1
- package/dist/private/menu/useMenuItem.cjs.map +1 -1
- package/dist/private/menu/useMenuItem.js +1 -1
- package/dist/private/menu/useMenuItem.js.map +1 -1
- package/dist/private/menu/useMenuItem.mjs +1 -1
- package/dist/private/menu/useMenuItem.mjs.map +1 -1
- package/dist/private/menu/useMenuTrigger.cjs.map +1 -1
- package/dist/private/menu/useMenuTrigger.js.map +1 -1
- package/dist/private/menu/useMenuTrigger.mjs.map +1 -1
- package/dist/private/menu/utils.cjs.map +1 -1
- package/dist/private/menu/utils.js.map +1 -1
- package/dist/private/menu/utils.mjs.map +1 -1
- package/dist/private/numberfield/useNumberField.cjs.map +1 -1
- package/dist/private/numberfield/useNumberField.js.map +1 -1
- package/dist/private/numberfield/useNumberField.mjs.map +1 -1
- package/dist/private/overlays/DismissButton.cjs.map +1 -1
- package/dist/private/overlays/DismissButton.js.map +1 -1
- package/dist/private/overlays/DismissButton.mjs.map +1 -1
- package/dist/private/overlays/calculatePosition.cjs +7 -7
- package/dist/private/overlays/calculatePosition.cjs.map +1 -1
- package/dist/private/overlays/calculatePosition.js +7 -7
- package/dist/private/overlays/calculatePosition.js.map +1 -1
- package/dist/private/overlays/calculatePosition.mjs +7 -7
- package/dist/private/overlays/calculatePosition.mjs.map +1 -1
- package/dist/private/overlays/useOverlayPosition.cjs +3 -2
- package/dist/private/overlays/useOverlayPosition.cjs.map +1 -1
- package/dist/private/overlays/useOverlayPosition.js +3 -2
- package/dist/private/overlays/useOverlayPosition.js.map +1 -1
- package/dist/private/overlays/useOverlayPosition.mjs +3 -2
- package/dist/private/overlays/useOverlayPosition.mjs.map +1 -1
- package/dist/private/searchfield/useSearchField.cjs.map +1 -1
- package/dist/private/searchfield/useSearchField.js.map +1 -1
- package/dist/private/searchfield/useSearchField.mjs.map +1 -1
- package/dist/private/select/useSelect.cjs +1 -2
- package/dist/private/select/useSelect.cjs.map +1 -1
- package/dist/private/select/useSelect.js +1 -2
- package/dist/private/select/useSelect.js.map +1 -1
- package/dist/private/select/useSelect.mjs +1 -2
- package/dist/private/select/useSelect.mjs.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.cjs +31 -3
- package/dist/private/selection/ListKeyboardDelegate.cjs.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.js +31 -3
- package/dist/private/selection/ListKeyboardDelegate.js.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.mjs +31 -3
- package/dist/private/selection/ListKeyboardDelegate.mjs.map +1 -1
- package/dist/private/selection/useSelectableCollection.cjs +20 -14
- package/dist/private/selection/useSelectableCollection.cjs.map +1 -1
- package/dist/private/selection/useSelectableCollection.js +26 -19
- package/dist/private/selection/useSelectableCollection.js.map +1 -1
- package/dist/private/selection/useSelectableCollection.mjs +20 -14
- package/dist/private/selection/useSelectableCollection.mjs.map +1 -1
- package/dist/private/selection/useTypeSelect.cjs +50 -18
- package/dist/private/selection/useTypeSelect.cjs.map +1 -1
- package/dist/private/selection/useTypeSelect.js +51 -19
- package/dist/private/selection/useTypeSelect.js.map +1 -1
- package/dist/private/selection/useTypeSelect.mjs +51 -19
- package/dist/private/selection/useTypeSelect.mjs.map +1 -1
- package/dist/private/spinbutton/useSpinButton.cjs.map +1 -1
- package/dist/private/spinbutton/useSpinButton.js.map +1 -1
- package/dist/private/spinbutton/useSpinButton.mjs.map +1 -1
- package/dist/private/steplist/useStepList.cjs.map +1 -1
- package/dist/private/steplist/useStepList.js.map +1 -1
- package/dist/private/steplist/useStepList.mjs.map +1 -1
- package/dist/private/table/useTable.cjs.map +1 -1
- package/dist/private/table/useTable.js.map +1 -1
- package/dist/private/table/useTable.mjs.map +1 -1
- package/dist/private/table/useTableColumnHeader.cjs.map +1 -1
- package/dist/private/table/useTableColumnHeader.js.map +1 -1
- package/dist/private/table/useTableColumnHeader.mjs.map +1 -1
- package/dist/private/table/useTableColumnResize.cjs.map +1 -1
- package/dist/private/table/useTableColumnResize.js.map +1 -1
- package/dist/private/table/useTableColumnResize.mjs.map +1 -1
- package/dist/private/table/useTableRow.cjs.map +1 -1
- package/dist/private/table/useTableRow.js.map +1 -1
- package/dist/private/table/useTableRow.mjs.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.cjs.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.js.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.mjs.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.cjs +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.cjs.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.js +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.js.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.mjs +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.mjs.map +1 -1
- package/dist/private/tag/useTag.cjs.map +1 -1
- package/dist/private/tag/useTag.js.map +1 -1
- package/dist/private/tag/useTag.mjs.map +1 -1
- package/dist/private/toast/useToast.cjs.map +1 -1
- package/dist/private/toast/useToast.js.map +1 -1
- package/dist/private/toast/useToast.mjs.map +1 -1
- package/dist/private/toast/useToastRegion.cjs.map +1 -1
- package/dist/private/toast/useToastRegion.js.map +1 -1
- package/dist/private/toast/useToastRegion.mjs.map +1 -1
- package/dist/private/toolbar/useToolbar.cjs +0 -1
- package/dist/private/toolbar/useToolbar.cjs.map +1 -1
- package/dist/private/toolbar/useToolbar.js +0 -1
- package/dist/private/toolbar/useToolbar.js.map +1 -1
- package/dist/private/toolbar/useToolbar.mjs +0 -1
- package/dist/private/toolbar/useToolbar.mjs.map +1 -1
- package/dist/private/tree/useTree.cjs.map +1 -1
- package/dist/private/tree/useTree.js.map +1 -1
- package/dist/private/tree/useTree.mjs.map +1 -1
- package/dist/private/tree/useTreeItem.cjs.map +1 -1
- package/dist/private/tree/useTreeItem.js.map +1 -1
- package/dist/private/tree/useTreeItem.mjs.map +1 -1
- package/dist/private/utils/isElementVisible.cjs +1 -1
- package/dist/private/utils/isElementVisible.cjs.map +1 -1
- package/dist/private/utils/isElementVisible.js +1 -1
- package/dist/private/utils/isElementVisible.js.map +1 -1
- package/dist/private/utils/isElementVisible.mjs +1 -1
- package/dist/private/utils/isElementVisible.mjs.map +1 -1
- package/dist/private/utils/isFocusable.cjs +3 -1
- package/dist/private/utils/isFocusable.cjs.map +1 -1
- package/dist/private/utils/isFocusable.js +3 -1
- package/dist/private/utils/isFocusable.js.map +1 -1
- package/dist/private/utils/isFocusable.mjs +3 -1
- package/dist/private/utils/isFocusable.mjs.map +1 -1
- package/dist/types/src/dnd/utils.d.ts +2 -2
- package/dist/types/src/gridlist/useGridList.d.ts +7 -0
- package/dist/types/src/menu/useMenu.d.ts +1 -1
- package/dist/types/src/menu/utils.d.ts +1 -1
- package/dist/types/src/overlays/calculatePosition.d.ts +1 -0
- package/dist/types/src/overlays/useOverlayPosition.d.ts +8 -0
- package/dist/types/src/selection/ListKeyboardDelegate.d.ts +1 -0
- package/dist/types/src/selection/useSelectableCollection.d.ts +7 -0
- package/dist/types/src/tree/useTree.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;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AAE;IAE/B,IAAI,gBAAgB,KAAK,GAAG,KAAK,MAAM,gBAAgB,CAAC,UAAU;IAClE,IAAI,YAAY,MAAM,gBAAgB,CAAC,UAAU,IAAI;IACrD,IAAI,WAAW;IACf,IAAI,CAAC,cAAe,CAAA,iBAAiB,CAAC,SAAQ,GAC5C,WAAW;IAGb,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,KAAK,KAAK;IACxC,IAAI,YAAY,CAAA,GAAA,yCAAoB,EAAE,KAAK,KAAK;IAChD,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,yCAAW,EAChC;QACE,GAAG,KAAK,KAAK;oBACb;IACF,GACA;IAGF,OAAO;QACL,mBAAmB;YACjB,cAAc,gBAAgB,MAAM,CAAC;YACrC,mBAAmB,GAAG,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;wBAC/C;YACA,IAAI;YACJ,SAAS,IAAO,WAAW,SAAS,IAAI,IAAI;oBAAC,KAAK,GAAG;iBAAC,KAAK;QAC7D;QACA,UAAU,CAAA,GAAA,yCAAS,EAAE,gBAAgB,UAAU,UAAU,WAAW;sBAClE;YACA,WAAW,WAAW,YAAY;YAClC,oBAAoB,SAAS,CAAC,mBAAmB;QACnD;QACA,eAAe,CAAA,GAAA,yCAAS,EAAE,eAAe;YACvC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,cAAc,KAAK,CAAC,aAAa;QACnC;QACA,GAAG,uBAAuB;QAC1B,gBAAgB,CAAC,CAAC;IACpB;AACF","sources":["packages/react-aria/src/tag/useTag.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 {AriaButtonProps} from '../button/useButton';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData} from './useTagGroup';\nimport intlMessages from '../../intl/tag/*.json';\nimport {KeyboardEvent} from 'react';\nimport type {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {SelectableItemStates} from '../selection/useSelectableItem';\nimport {useDescription} from '../utils/useDescription';\nimport {useFocusable} from '../interactions/useFocusable';\nimport {useGridListItem} from '../gridlist/useGridListItem';\nimport {useId} from '../utils/useId';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSyntheticLinkProps} from '../utils/openLink';\n\nexport interface TagAria extends SelectableItemStates {\n /** Props for the tag row element. */\n rowProps: DOMAttributes;\n /** Props for the tag cell element. */\n gridCellProps: DOMAttributes;\n /** Props for the tag remove button. */\n removeButtonProps: AriaButtonProps;\n /** Whether the tag can be removed. */\n allowsRemoving: boolean;\n}\n\nexport interface AriaTagProps<T> {\n /** An object representing the tag. Contains all the relevant information that makes up the tag. */\n item: Node<T>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag component.\n *\n * @param props - Props to be applied to the tag.\n * @param state - State for the tag group, as returned by `useListState`.\n * @param ref - A ref to a DOM element for the tag.\n */\nexport function useTag<T>(\n props: AriaTagProps<T>,\n state: ListState<T>,\n ref: RefObject<FocusableElement | null>\n): TagAria {\n let {item} = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tag');\n let buttonId = useId();\n\n let {onRemove} = hookData.get(state) || {};\n let {rowProps, gridCellProps, ...states} = useGridListItem(\n {\n node: item\n },\n state,\n ref\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {descriptionProps: _, ...stateWithoutDescription} = states;\n\n let isDisabled = state.disabledKeys.has(item.key) || item.props.isDisabled;\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace') {\n if (isDisabled) {\n return;\n }\n\n e.preventDefault();\n if (state.selectionManager.isSelected(item.key)) {\n onRemove?.(new Set(state.selectionManager.selectedKeys));\n } else {\n onRemove?.(new Set([item.key]));\n }\n }\n };\n\n let modality = useInteractionModality();\n if (modality === 'virtual' && typeof window !== 'undefined' && 'ontouchstart' in window) {\n modality = 'pointer';\n }\n let description =\n onRemove && (modality === 'keyboard' || modality === 'virtual')\n ? stringFormatter.format('removeDescription')\n : '';\n let descProps = useDescription(description);\n\n let isItemFocused = item.key === state.selectionManager.focusedKey;\n let isFocused = state.selectionManager.focusedKey != null;\n let tabIndex = -1;\n if (!isDisabled && (isItemFocused || !isFocused)) {\n tabIndex = 0;\n }\n\n let domProps = filterDOMProps(item.props);\n let linkProps = useSyntheticLinkProps(item.props);\n let {focusableProps} = useFocusable(\n {\n ...item.props,\n isDisabled\n },\n ref\n );\n\n return {\n removeButtonProps: {\n 'aria-label': stringFormatter.format('removeButtonLabel'),\n 'aria-labelledby': `${buttonId} ${rowProps.id}`,\n isDisabled,\n id: buttonId,\n onPress: () => (onRemove ? onRemove(new Set([item.key])) : null)\n },\n rowProps: mergeProps(focusableProps, rowProps, domProps, linkProps, {\n tabIndex,\n onKeyDown: onRemove ? onKeyDown : undefined,\n 'aria-describedby': descProps['aria-describedby']\n }),\n gridCellProps: mergeProps(gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label']\n }),\n ...stateWithoutDescription,\n allowsRemoving: !!onRemove\n };\n}\n"],"names":[],"version":3,"file":"useTag.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AA0CM,SAAS,0CACd,KAA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AAiB,CAAC,SAAQ,GAC5C,WAAW;IAGb,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,KAAK,KAAK;IACxC,IAAI,YAAY,CAAA,GAAA,yCAAoB,EAAE,KAAK,KAAK;IAChD,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,yCAAW,EAChC;QACE,GAAG,KAAK,KAAK;oBACb;IACF,GACA;IAGF,OAAO;QACL,mBAAmB;YACjB,cAAc,gBAAgB,MAAM,CAAC;YACrC,mBAAmB,GAAG,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;wBAC/C;YACA,IAAI;YACJ,SAAS,IAAO,WAAW,SAAS,IAAI,IAAI;oBAAC,KAAK,GAAG;iBAAC,KAAK;QAC7D;QACA,UAAU,CAAA,GAAA,yCAAS,EAAE,gBAAgB,UAAU,UAAU,WAAW;sBAClE;YACA,WAAW,WAAW,YAAY;YAClC,oBAAoB,SAAS,CAAC,mBAAmB;QACnD;QACA,eAAe,CAAA,GAAA,yCAAS,EAAE,eAAe;YACvC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,cAAc,KAAK,CAAC,aAAa;QACnC;QACA,GAAG,uBAAuB;QAC1B,gBAAgB,CAAC,CAAC;IACpB;AACF","sources":["packages/react-aria/src/tag/useTag.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 {AriaButtonProps} from '../button/useButton';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData} from './useTagGroup';\nimport intlMessages from '../../intl/tag/*.json';\nimport {KeyboardEvent} from 'react';\nimport type {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {SelectableItemStates} from '../selection/useSelectableItem';\nimport {useDescription} from '../utils/useDescription';\nimport {useFocusable} from '../interactions/useFocusable';\nimport {useGridListItem} from '../gridlist/useGridListItem';\nimport {useId} from '../utils/useId';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSyntheticLinkProps} from '../utils/openLink';\n\nexport interface TagAria extends SelectableItemStates {\n /** Props for the tag row element. */\n rowProps: DOMAttributes;\n /** Props for the tag cell element. */\n gridCellProps: DOMAttributes;\n /** Props for the tag remove button. */\n removeButtonProps: AriaButtonProps;\n /** Whether the tag can be removed. */\n allowsRemoving: boolean;\n}\n\nexport interface AriaTagProps<T> {\n /** An object representing the tag. Contains all the relevant information that makes up the tag. */\n item: Node<T>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tag component.\n *\n * @param props - Props to be applied to the tag.\n * @param state - State for the tag group, as returned by `useListState`.\n * @param ref - A ref to a DOM element for the tag.\n */\nexport function useTag<T>(\n props: AriaTagProps<T>,\n state: ListState<T>,\n ref: RefObject<FocusableElement | null>\n): TagAria {\n let {item} = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tag');\n let buttonId = useId();\n\n let {onRemove} = hookData.get(state) || {};\n let {rowProps, gridCellProps, ...states} = useGridListItem(\n {\n node: item\n },\n state,\n ref\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {descriptionProps: _, ...stateWithoutDescription} = states;\n\n let isDisabled = state.disabledKeys.has(item.key) || item.props.isDisabled;\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace') {\n if (isDisabled) {\n return;\n }\n\n e.preventDefault();\n if (state.selectionManager.isSelected(item.key)) {\n onRemove?.(new Set(state.selectionManager.selectedKeys));\n } else {\n onRemove?.(new Set([item.key]));\n }\n }\n };\n\n let modality = useInteractionModality();\n if (modality === 'virtual' && typeof window !== 'undefined' && 'ontouchstart' in window) {\n modality = 'pointer';\n }\n let description =\n onRemove && (modality === 'keyboard' || modality === 'virtual')\n ? stringFormatter.format('removeDescription')\n : '';\n let descProps = useDescription(description);\n\n let isItemFocused = item.key === state.selectionManager.focusedKey;\n let isFocused = state.selectionManager.focusedKey != null;\n let tabIndex = -1;\n if (!isDisabled && (isItemFocused || !isFocused)) {\n tabIndex = 0;\n }\n\n let domProps = filterDOMProps(item.props);\n let linkProps = useSyntheticLinkProps(item.props);\n let {focusableProps} = useFocusable(\n {\n ...item.props,\n isDisabled\n },\n ref\n );\n\n return {\n removeButtonProps: {\n 'aria-label': stringFormatter.format('removeButtonLabel'),\n 'aria-labelledby': `${buttonId} ${rowProps.id}`,\n isDisabled,\n id: buttonId,\n onPress: () => (onRemove ? onRemove(new Set([item.key])) : null)\n },\n rowProps: mergeProps(focusableProps, rowProps, domProps, linkProps, {\n tabIndex,\n onKeyDown: onRemove ? onKeyDown : undefined,\n 'aria-describedby': descProps['aria-describedby']\n }),\n gridCellProps: mergeProps(gridCellProps, {\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-label': props['aria-label']\n }),\n ...stateWithoutDescription,\n allowsRemoving: !!onRemove\n };\n}\n"],"names":[],"version":3,"file":"useTag.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAkCM,SAAS,0CACd,KAAwB,EACxB,KAAoB,EACpB,6DAA6D;AAC7D,GAAuC;IAEvC,IAAI,OAAC,GAAG,SAAE,KAAK,WAAE,OAAO,EAAC,GAAG,MAAM,KAAK;IAEvC,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,SAAS,QAAQ,WAAW,MAC9B;QAGF,MAAM,KAAK,CAAC;QACZ,OAAO;YACL,MAAM,KAAK;QACb;IACF,GAAG;QAAC;QAAO;KAAQ;IAEnB,IAAI,UAAU,CAAA,GAAA,+BAAI;IAClB,IAAI,gBAAgB,CAAA,GAAA,mCAAQ;IAC5B,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,wGAAwG;IACxG,mJAAmJ;IACnJ,2CAA2C;IAC3C,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IACzC,CAAA,GAAA,yCAAc,EAAE;QACd,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,aAAa,CAAA,GAAA,wCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAEvD,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,MAAM;YACN,cAAc;YACd,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;YACjD,UAAU;QACZ;QACA,cAAc;YACZ,MAAM;YACN,eAAe;YACf,eAAe,YAAY,YAAY;QACzC;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,SAAS,IAAM,MAAM,KAAK,CAAC;QAC7B;IACF;AACF","sources":["packages/react-aria/src/toast/useToast.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 {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/toast/*.json';\nimport {QueuedToast, ToastState} from 'react-stately/useToastState';\nimport {useEffect, useState} from 'react';\nimport {useId, useSlotId} from '../utils/useId';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastProps<T> extends AriaLabelingProps {\n /** The toast object. */\n toast: QueuedToast<T>;\n}\n\nexport interface ToastAria {\n /** Props for the toast container, non-modal dialog element. */\n toastProps: DOMAttributes;\n /** Props for the toast content alert message. */\n contentProps: DOMAttributes;\n /** Props for the toast title element. */\n titleProps: DOMAttributes;\n /** Props for the toast description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the toast close button. */\n closeButtonProps: AriaButtonProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast component. Toasts display\n * brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToast<T>(\n props: AriaToastProps<T>,\n state: ToastState<T>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ref: RefObject<FocusableElement | null>\n): ToastAria {\n let {key, timer, timeout} = props.toast;\n\n useEffect(() => {\n if (timer == null || timeout == null) {\n return;\n }\n\n timer.reset(timeout);\n return () => {\n timer.pause();\n };\n }, [timer, timeout]);\n\n let titleId = useId();\n let descriptionId = useSlotId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n\n // This is required for NVDA announcements, without it NVDA will NOT announce the toast when it appears.\n // Originally was tied to animationStart/End via https://github.com/adobe/react-spectrum/pull/6223/commits/e22e319df64958e822ab7cd9685e96818cae9ba5\n // but toasts don't always have animations.\n let [isVisible, setIsVisible] = useState(false);\n useLayoutEffect(() => {\n setIsVisible(true);\n }, []);\n\n let toastProps = filterDOMProps(props, {labelable: true});\n\n return {\n toastProps: {\n ...toastProps,\n role: 'alertdialog',\n 'aria-modal': 'false',\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n 'aria-describedby': props['aria-describedby'] || descriptionId,\n tabIndex: 0\n },\n contentProps: {\n role: 'alert',\n 'aria-atomic': 'true',\n 'aria-hidden': isVisible ? undefined : 'true'\n },\n titleProps: {\n id: titleId\n },\n descriptionProps: {\n id: descriptionId\n },\n closeButtonProps: {\n 'aria-label': stringFormatter.format('close'),\n onPress: () => state.close(key)\n }\n };\n}\n"],"names":[],"version":3,"file":"useToast.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAkCM,SAAS,0CACd,KAAwB,EACxB,KAAoB,EACpB,6DAA6D;AAC7D,GAAuC;IAEvC,IAAI,OAAC,GAAG,SAAE,KAAK,WAAE,OAAO,EAAC,GAAG,MAAM,KAAK;IAEvC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,SAAS,QAAQ,WAAW,MAC9B;QAGF,MAAM,KAAK,CAAC;QACZ,OAAO;YACL,MAAM,KAAK;QACb;IACF,GAAG;QAAC;QAAO;KAAQ;IAEnB,IAAI,UAAU,CAAA,GAAA,yCAAI;IAClB,IAAI,gBAAgB,CAAA,GAAA,yCAAQ;IAC5B,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAEhE,wGAAwG;IACxG,mJAAmJ;IACnJ,2CAA2C;IAC3C,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IACzC,CAAA,GAAA,yCAAc,EAAE;QACd,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,aAAa,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAEvD,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,MAAM;YACN,cAAc;YACd,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;YACjD,UAAU;QACZ;QACA,cAAc;YACZ,MAAM;YACN,eAAe;YACf,eAAe,YAAY,YAAY;QACzC;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,SAAS,IAAM,MAAM,KAAK,CAAC;QAC7B;IACF;AACF","sources":["packages/react-aria/src/toast/useToast.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 {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/toast/*.json';\nimport {QueuedToast, ToastState} from 'react-stately/useToastState';\nimport {useEffect, useState} from 'react';\nimport {useId, useSlotId} from '../utils/useId';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastProps<T> extends AriaLabelingProps {\n /** The toast object. */\n toast: QueuedToast<T>;\n}\n\nexport interface ToastAria {\n /** Props for the toast container, non-modal dialog element. */\n toastProps: DOMAttributes;\n /** Props for the toast content alert message. */\n contentProps: DOMAttributes;\n /** Props for the toast title element. */\n titleProps: DOMAttributes;\n /** Props for the toast description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the toast close button. */\n closeButtonProps: AriaButtonProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast component. Toasts display\n * brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToast<T>(\n props: AriaToastProps<T>,\n state: ToastState<T>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ref: RefObject<FocusableElement | null>\n): ToastAria {\n let {key, timer, timeout} = props.toast;\n\n useEffect(() => {\n if (timer == null || timeout == null) {\n return;\n }\n\n timer.reset(timeout);\n return () => {\n timer.pause();\n };\n }, [timer, timeout]);\n\n let titleId = useId();\n let descriptionId = useSlotId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n\n // This is required for NVDA announcements, without it NVDA will NOT announce the toast when it appears.\n // Originally was tied to animationStart/End via https://github.com/adobe/react-spectrum/pull/6223/commits/e22e319df64958e822ab7cd9685e96818cae9ba5\n // but toasts don't always have animations.\n let [isVisible, setIsVisible] = useState(false);\n useLayoutEffect(() => {\n setIsVisible(true);\n }, []);\n\n let toastProps = filterDOMProps(props, {labelable: true});\n\n return {\n toastProps: {\n ...toastProps,\n role: 'alertdialog',\n 'aria-modal': 'false',\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n 'aria-describedby': props['aria-describedby'] || descriptionId,\n tabIndex: 0\n },\n contentProps: {\n role: 'alert',\n 'aria-atomic': 'true',\n 'aria-hidden': isVisible ? undefined : 'true'\n },\n titleProps: {\n id: titleId\n },\n descriptionProps: {\n id: descriptionId\n },\n closeButtonProps: {\n 'aria-label': stringFormatter.format('close'),\n onPress: () => state.close(key)\n }\n };\n}\n"],"names":[],"version":3,"file":"useToast.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAkCM,SAAS,0CACd,KAAwB,EACxB,KAAoB,EACpB,6DAA6D;AAC7D,GAAuC;IAEvC,IAAI,OAAC,GAAG,SAAE,KAAK,WAAE,OAAO,EAAC,GAAG,MAAM,KAAK;IAEvC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,SAAS,QAAQ,WAAW,MAC9B;QAGF,MAAM,KAAK,CAAC;QACZ,OAAO;YACL,MAAM,KAAK;QACb;IACF,GAAG;QAAC;QAAO;KAAQ;IAEnB,IAAI,UAAU,CAAA,GAAA,yCAAI;IAClB,IAAI,gBAAgB,CAAA,GAAA,yCAAQ;IAC5B,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAEhE,wGAAwG;IACxG,mJAAmJ;IACnJ,2CAA2C;IAC3C,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IACzC,CAAA,GAAA,yCAAc,EAAE;QACd,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,aAAa,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAEvD,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,MAAM;YACN,cAAc;YACd,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;YACjD,UAAU;QACZ;QACA,cAAc;YACZ,MAAM;YACN,eAAe;YACf,eAAe,YAAY,YAAY;QACzC;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,SAAS,IAAM,MAAM,KAAK,CAAC;QAC7B;IACF;AACF","sources":["packages/react-aria/src/toast/useToast.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 {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/toast/*.json';\nimport {QueuedToast, ToastState} from 'react-stately/useToastState';\nimport {useEffect, useState} from 'react';\nimport {useId, useSlotId} from '../utils/useId';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastProps<T> extends AriaLabelingProps {\n /** The toast object. */\n toast: QueuedToast<T>;\n}\n\nexport interface ToastAria {\n /** Props for the toast container, non-modal dialog element. */\n toastProps: DOMAttributes;\n /** Props for the toast content alert message. */\n contentProps: DOMAttributes;\n /** Props for the toast title element. */\n titleProps: DOMAttributes;\n /** Props for the toast description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the toast close button. */\n closeButtonProps: AriaButtonProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast component. Toasts display\n * brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToast<T>(\n props: AriaToastProps<T>,\n state: ToastState<T>,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ref: RefObject<FocusableElement | null>\n): ToastAria {\n let {key, timer, timeout} = props.toast;\n\n useEffect(() => {\n if (timer == null || timeout == null) {\n return;\n }\n\n timer.reset(timeout);\n return () => {\n timer.pause();\n };\n }, [timer, timeout]);\n\n let titleId = useId();\n let descriptionId = useSlotId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n\n // This is required for NVDA announcements, without it NVDA will NOT announce the toast when it appears.\n // Originally was tied to animationStart/End via https://github.com/adobe/react-spectrum/pull/6223/commits/e22e319df64958e822ab7cd9685e96818cae9ba5\n // but toasts don't always have animations.\n let [isVisible, setIsVisible] = useState(false);\n useLayoutEffect(() => {\n setIsVisible(true);\n }, []);\n\n let toastProps = filterDOMProps(props, {labelable: true});\n\n return {\n toastProps: {\n ...toastProps,\n role: 'alertdialog',\n 'aria-modal': 'false',\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n 'aria-describedby': props['aria-describedby'] || descriptionId,\n tabIndex: 0\n },\n contentProps: {\n role: 'alert',\n 'aria-atomic': 'true',\n 'aria-hidden': isVisible ? undefined : 'true'\n },\n titleProps: {\n id: titleId\n },\n descriptionProps: {\n id: descriptionId\n },\n closeButtonProps: {\n 'aria-label': stringFormatter.format('close'),\n onPress: () => state.close(key)\n }\n };\n}\n"],"names":[],"version":3,"file":"useToast.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoCM,SAAS,0CACd,KAA2B,EAC3B,KAAoB,EACpB,GAAkC;IAElC,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,qCAAU,EAC9B;QACE,MAAM;QACN,cACE,KAAK,CAAC,aAAa,IACnB,gBAAgB,MAAM,CAAC,iBAAiB;YAAC,OAAO,MAAM,aAAa,CAAC,MAAM;QAAA;IAC9E,GACA;IAGF,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,IAAI,eAAe,CAAA,GAAA,wBAAU,EAAE;QAC7B,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,QAAQ;aAEd,MAAM,SAAS;IAEnB,GAAG;QAAC;KAAM;IAEV,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE;QAC1B,cAAc;YACZ,UAAU,OAAO,GAAG;YACpB;QACF;QACA,YAAY;YACV,UAAU,OAAO,GAAG;YACpB;QACF;IACF;I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BAEzC,YAAY,OAAO,CAAC,KAAK;YAE3B,YAAY,OAAO,GAAG;QACxB;IACF,GAAG;QAAC;QAAK,MAAM,aAAa,CAAC,MAAM;KAAC;IAEpC,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,YAAY,OAAO,EAAE,aAAa;gBACpC,IAAI,CAAA,GAAA,gDAAqB,QAAQ,WAC/B,CAAA,GAAA,+CAAoB,EAAE,YAAY,OAAO;qBAEzC,YAAY,OAAO,CAAC,KAAK;gBAE3B,YAAY,OAAO,GAAG;YACxB;QACF;IACF,GAAG;QAAC;KAAI;IAER,OAAO;QACL,aAAa,CAAA,GAAA,oCAAS,EAAE,eAAe,YAAY,kBAAkB;YACnE,UAAU;YACV,sDAAsD;YACtD,iDAAiD;YACjD,yDAAyD;YACzD,8EAA8E;YAC9E,aAAa;YACb,6BAA6B;YAC7B,oFAAoF;YACpF,0CAA0C;YAC1C,SAAS,CAAA;gBACP,IAAI,SAAS,AAAC,CAAA,GAAA,wCAAa,EAAE,GAAe,OAAO,CAAC;gBACpD,aAAa,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA,IAAK,MAAM;YAC7D;YACA,QAAQ;gBACN,aAAa,OAAO,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/react-aria/src/toast/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport intlMessages from '../../intl/toast/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {ToastState} from 'react-stately/useToastState';\nimport {useCallback, useEffect, useRef} from 'react';\n// @ts-ignore\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useHover} from '../interactions/useHover';\nimport {useLandmark} from '../landmark/useLandmark';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n *\n * @default 'Notifications'\n */\n 'aria-label'?: string;\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more\n * toasts. Toasts display brief, temporary notifications of actions, errors, or other events in an\n * application.\n */\nexport function useToastRegion<T>(\n props: AriaToastRegionProps,\n state: ToastState<T>,\n ref: RefObject<HTMLElement | null>\n): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark(\n {\n role: 'region',\n 'aria-label':\n props['aria-label'] ||\n stringFormatter.format('notifications', {count: state.visibleToasts.length})\n },\n ref\n );\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n let updateTimers = useCallback(() => {\n if (isHovered.current || isFocused.current) {\n state.pauseAll();\n } else {\n state.resumeAll();\n }\n }, [state]);\n\n let {hoverProps} = useHover({\n onHoverStart: () => {\n isHovered.current = true;\n updateTimers();\n },\n onHoverEnd: () => {\n isHovered.current = false;\n updateTimers();\n }\n });\n\n // Manage focus within the toast region.\n // If a focused containing toast is removed, move focus to the next toast, or the previous toast if there is no next toast.\n let toasts = useRef<FocusableElement[]>([]);\n let prevVisibleToasts = useRef(state.visibleToasts);\n let focusedToast = useRef<number | null>(null);\n useLayoutEffect(() => {\n // If no toast has focus, then don't do anything.\n if (focusedToast.current === -1 || state.visibleToasts.length === 0 || !ref.current) {\n toasts.current = [];\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n toasts.current = [\n ...ref.current.querySelectorAll('[role=\"alertdialog\"]')\n ] as FocusableElement[];\n // If the visible toasts haven't changed, we don't need to do anything.\n if (\n prevVisibleToasts.current.length === state.visibleToasts.length &&\n state.visibleToasts.every((t, i) => t.key === prevVisibleToasts.current[i].key)\n ) {\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n // Get a list of all toasts by index and add info if they are removed.\n let allToasts = prevVisibleToasts.current.map((t, i) => ({\n ...t,\n i,\n isRemoved: !state.visibleToasts.some(t2 => t.key === t2.key)\n }));\n\n let removedFocusedToastIndex = allToasts.findIndex(\n t => t.i === focusedToast.current && t.isRemoved\n );\n\n // If the focused toast was removed, focus the next or previous toast.\n if (removedFocusedToastIndex > -1) {\n // In pointer modality, move focus out of the toast region.\n // Otherwise auto-dismiss timers will appear \"stuck\".\n if (getInteractionModality() === 'pointer' && lastFocused.current?.isConnected) {\n focusWithoutScrolling(lastFocused.current);\n } else {\n let i = 0;\n let nextToast;\n let prevToast;\n while (i <= removedFocusedToastIndex) {\n if (!allToasts[i].isRemoved) {\n prevToast = Math.max(0, i - 1);\n }\n i++;\n }\n while (i < allToasts.length) {\n if (!allToasts[i].isRemoved) {\n nextToast = i - 1;\n break;\n }\n i++;\n }\n\n // in the case where it's one toast at a time, both will be undefined, but we know the index must be 0\n if (prevToast === undefined && nextToast === undefined) {\n prevToast = 0;\n }\n\n // prioritize going to newer toasts\n if (prevToast >= 0 && prevToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[prevToast]);\n } else if (nextToast >= 0 && nextToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[nextToast]);\n }\n }\n }\n\n prevVisibleToasts.current = state.visibleToasts;\n }, [state.visibleToasts, ref]);\n\n let lastFocused = useRef<FocusableElement | null>(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: e => {\n isFocused.current = true;\n lastFocused.current = e.relatedTarget as FocusableElement;\n updateTimers();\n },\n onBlurWithin: () => {\n isFocused.current = false;\n lastFocused.current = null;\n updateTimers();\n }\n });\n\n // When the number of visible toasts becomes 0 or the region unmounts,\n // restore focus to the last element that had focus before the user moved focus\n // into the region. FocusScope restore focus doesn't update whenever the focus\n // moves in, it only happens once, so we correct it.\n // Because we're in a hook, we can't control if the user unmounts or not.\n useEffect(() => {\n if (state.visibleToasts.length === 0 && lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n }, [ref, state.visibleToasts.length]);\n\n useEffect(() => {\n return () => {\n if (lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n // listen to focus events separate from focuswithin because that will only fire once\n // and we need to follow all focus changes\n onFocus: e => {\n let target = (getEventTarget(e) as Element).closest('[role=\"alertdialog\"]');\n focusedToast.current = toasts.current.findIndex(t => t === target);\n },\n onBlur: () => {\n focusedToast.current = -1;\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAmCM,SAAS,0CACd,KAA2B,EAC3B,KAAoB,EACpB,GAAkC;IAElC,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW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Ae,OAAO,CAAC;gBACpD,aAAa,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA,IAAK,MAAM;YAC7D;YACA,QAAQ;gBACN,aAAa,OAAO,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/react-aria/src/toast/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport intlMessages from '../../intl/toast/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {ToastState} from 'react-stately/useToastState';\nimport {useCallback, useEffect, useRef} from 'react';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useHover} from '../interactions/useHover';\nimport {useLandmark} from '../landmark/useLandmark';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n *\n * @default 'Notifications'\n */\n 'aria-label'?: string;\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more\n * toasts. Toasts display brief, temporary notifications of actions, errors, or other events in an\n * application.\n */\nexport function useToastRegion<T>(\n props: AriaToastRegionProps,\n state: ToastState<T>,\n ref: RefObject<HTMLElement | null>\n): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark(\n {\n role: 'region',\n 'aria-label':\n props['aria-label'] ||\n stringFormatter.format('notifications', {count: state.visibleToasts.length})\n },\n ref\n );\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n let updateTimers = useCallback(() => {\n if (isHovered.current || isFocused.current) {\n state.pauseAll();\n } else {\n state.resumeAll();\n }\n }, [state]);\n\n let {hoverProps} = useHover({\n onHoverStart: () => {\n isHovered.current = true;\n updateTimers();\n },\n onHoverEnd: () => {\n isHovered.current = false;\n updateTimers();\n }\n });\n\n // Manage focus within the toast region.\n // If a focused containing toast is removed, move focus to the next toast, or the previous toast if there is no next toast.\n let toasts = useRef<FocusableElement[]>([]);\n let prevVisibleToasts = useRef(state.visibleToasts);\n let focusedToast = useRef<number | null>(null);\n useLayoutEffect(() => {\n // If no toast has focus, then don't do anything.\n if (focusedToast.current === -1 || state.visibleToasts.length === 0 || !ref.current) {\n toasts.current = [];\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n toasts.current = [\n ...ref.current.querySelectorAll('[role=\"alertdialog\"]')\n ] as FocusableElement[];\n // If the visible toasts haven't changed, we don't need to do anything.\n if (\n prevVisibleToasts.current.length === state.visibleToasts.length &&\n state.visibleToasts.every((t, i) => t.key === prevVisibleToasts.current[i].key)\n ) {\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n // Get a list of all toasts by index and add info if they are removed.\n let allToasts = prevVisibleToasts.current.map((t, i) => ({\n ...t,\n i,\n isRemoved: !state.visibleToasts.some(t2 => t.key === t2.key)\n }));\n\n let removedFocusedToastIndex = allToasts.findIndex(\n t => t.i === focusedToast.current && t.isRemoved\n );\n\n // If the focused toast was removed, focus the next or previous toast.\n if (removedFocusedToastIndex > -1) {\n // In pointer modality, move focus out of the toast region.\n // Otherwise auto-dismiss timers will appear \"stuck\".\n if (getInteractionModality() === 'pointer' && lastFocused.current?.isConnected) {\n focusWithoutScrolling(lastFocused.current);\n } else {\n let i = 0;\n let nextToast;\n let prevToast;\n while (i <= removedFocusedToastIndex) {\n if (!allToasts[i].isRemoved) {\n prevToast = Math.max(0, i - 1);\n }\n i++;\n }\n while (i < allToasts.length) {\n if (!allToasts[i].isRemoved) {\n nextToast = i - 1;\n break;\n }\n i++;\n }\n\n // in the case where it's one toast at a time, both will be undefined, but we know the index must be 0\n if (prevToast === undefined && nextToast === undefined) {\n prevToast = 0;\n }\n\n // prioritize going to newer toasts\n if (prevToast >= 0 && prevToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[prevToast]);\n } else if (nextToast >= 0 && nextToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[nextToast]);\n }\n }\n }\n\n prevVisibleToasts.current = state.visibleToasts;\n }, [state.visibleToasts, ref]);\n\n let lastFocused = useRef<FocusableElement | null>(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: e => {\n isFocused.current = true;\n lastFocused.current = e.relatedTarget as FocusableElement;\n updateTimers();\n },\n onBlurWithin: () => {\n isFocused.current = false;\n lastFocused.current = null;\n updateTimers();\n }\n });\n\n // When the number of visible toasts becomes 0 or the region unmounts,\n // restore focus to the last element that had focus before the user moved focus\n // into the region. FocusScope restore focus doesn't update whenever the focus\n // moves in, it only happens once, so we correct it.\n // Because we're in a hook, we can't control if the user unmounts or not.\n useEffect(() => {\n if (state.visibleToasts.length === 0 && lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n }, [ref, state.visibleToasts.length]);\n\n useEffect(() => {\n return () => {\n if (lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n // listen to focus events separate from focuswithin because that will only fire once\n // and we need to follow all focus changes\n onFocus: e => {\n let target = (getEventTarget(e) as Element).closest('[role=\"alertdialog\"]');\n focusedToast.current = toasts.current.findIndex(t => t === target);\n },\n onBlur: () => {\n focusedToast.current = -1;\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoCM,SAAS,0CACd,KAA2B,EAC3B,KAAoB,EACpB,GAAkC;IAElC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,yCAAU,EAC9B;QACE,MAAM;QACN,cACE,KAAK,CAAC,aAAa,IACnB,gBAAgB,MAAM,CAAC,iBAAiB;YAAC,OAAO,MAAM,aAAa,CAAC,MAAM;QAAA;IAC9E,GACA;IAGF,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,eAAe,CAAA,GAAA,kBAAU,EAAE;QAC7B,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,QAAQ;aAEd,MAAM,SAAS;IAEnB,GAAG;QAAC;KAAM;IAEV,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE;QAC1B,cAAc;YACZ,UAAU,OAAO,GAAG;YACpB;QACF;QACA,YAAY;YACV,UAAU,OAAO,GAAG;YACpB;QACF;IACF;IAEA,wCAAwC;IACxC,2HAA2H;IAC3H,IAAI,SA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A,yCAAoB,EAAE,YAAY,OAAO;iBAEzC,YAAY,OAAO,CAAC,KAAK;YAE3B,YAAY,OAAO,GAAG;QACxB;IACF,GAAG;QAAC;QAAK,MAAM,aAAa,CAAC,MAAM;KAAC;IAEpC,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;gBACD;YAAJ,KAAI,uBAAA,YAAY,OAAO,cAAnB,2CAAA,qBAAqB,WAAW,EAAE;gBACpC,IAAI,CAAA,GAAA,yCAAqB,QAAQ,WAC/B,CAAA,GAAA,yCAAoB,EAAE,YAAY,OAAO;qBAEzC,YAAY,OAAO,CAAC,KAAK;gBAE3B,YAAY,OAAO,GAAG;YACxB;QACF;IACF,GAAG;QAAC;KAAI;IAER,OAAO;QACL,aAAa,CAAA,GAAA,yCAAS,EAAE,eAAe,YAAY,kBAAkB;YACnE,UAAU;YACV,sDAAsD;YACtD,iDAAiD;YACjD,yDAAyD;YACzD,8EAA8E;YAC9E,aAAa;YACb,6BAA6B;YAC7B,oFAAoF;YACpF,0CAA0C;YAC1C,SAAS,CAAA;gBACP,IAAI,SAAS,AAAC,CAAA,GAAA,yCAAa,EAAE,GAAe,OAAO,CAAC;gBACpD,aAAa,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA,IAAK,MAAM;YAC7D;YACA,QAAQ;gBACN,aAAa,OAAO,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/react-aria/src/toast/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport intlMessages from '../../intl/toast/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {ToastState} from 'react-stately/useToastState';\nimport {useCallback, useEffect, useRef} from 'react';\n// @ts-ignore\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useHover} from '../interactions/useHover';\nimport {useLandmark} from '../landmark/useLandmark';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n *\n * @default 'Notifications'\n */\n 'aria-label'?: string;\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more\n * toasts. Toasts display brief, temporary notifications of actions, errors, or other events in an\n * application.\n */\nexport function useToastRegion<T>(\n props: AriaToastRegionProps,\n state: ToastState<T>,\n ref: RefObject<HTMLElement | null>\n): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark(\n {\n role: 'region',\n 'aria-label':\n props['aria-label'] ||\n stringFormatter.format('notifications', {count: state.visibleToasts.length})\n },\n ref\n );\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n let updateTimers = useCallback(() => {\n if (isHovered.current || isFocused.current) {\n state.pauseAll();\n } else {\n state.resumeAll();\n }\n }, [state]);\n\n let {hoverProps} = useHover({\n onHoverStart: () => {\n isHovered.current = true;\n updateTimers();\n },\n onHoverEnd: () => {\n isHovered.current = false;\n updateTimers();\n }\n });\n\n // Manage focus within the toast region.\n // If a focused containing toast is removed, move focus to the next toast, or the previous toast if there is no next toast.\n let toasts = useRef<FocusableElement[]>([]);\n let prevVisibleToasts = useRef(state.visibleToasts);\n let focusedToast = useRef<number | null>(null);\n useLayoutEffect(() => {\n // If no toast has focus, then don't do anything.\n if (focusedToast.current === -1 || state.visibleToasts.length === 0 || !ref.current) {\n toasts.current = [];\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n toasts.current = [\n ...ref.current.querySelectorAll('[role=\"alertdialog\"]')\n ] as FocusableElement[];\n // If the visible toasts haven't changed, we don't need to do anything.\n if (\n prevVisibleToasts.current.length === state.visibleToasts.length &&\n state.visibleToasts.every((t, i) => t.key === prevVisibleToasts.current[i].key)\n ) {\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n // Get a list of all toasts by index and add info if they are removed.\n let allToasts = prevVisibleToasts.current.map((t, i) => ({\n ...t,\n i,\n isRemoved: !state.visibleToasts.some(t2 => t.key === t2.key)\n }));\n\n let removedFocusedToastIndex = allToasts.findIndex(\n t => t.i === focusedToast.current && t.isRemoved\n );\n\n // If the focused toast was removed, focus the next or previous toast.\n if (removedFocusedToastIndex > -1) {\n // In pointer modality, move focus out of the toast region.\n // Otherwise auto-dismiss timers will appear \"stuck\".\n if (getInteractionModality() === 'pointer' && lastFocused.current?.isConnected) {\n focusWithoutScrolling(lastFocused.current);\n } else {\n let i = 0;\n let nextToast;\n let prevToast;\n while (i <= removedFocusedToastIndex) {\n if (!allToasts[i].isRemoved) {\n prevToast = Math.max(0, i - 1);\n }\n i++;\n }\n while (i < allToasts.length) {\n if (!allToasts[i].isRemoved) {\n nextToast = i - 1;\n break;\n }\n i++;\n }\n\n // in the case where it's one toast at a time, both will be undefined, but we know the index must be 0\n if (prevToast === undefined && nextToast === undefined) {\n prevToast = 0;\n }\n\n // prioritize going to newer toasts\n if (prevToast >= 0 && prevToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[prevToast]);\n } else if (nextToast >= 0 && nextToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[nextToast]);\n }\n }\n }\n\n prevVisibleToasts.current = state.visibleToasts;\n }, [state.visibleToasts, ref]);\n\n let lastFocused = useRef<FocusableElement | null>(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: e => {\n isFocused.current = true;\n lastFocused.current = e.relatedTarget as FocusableElement;\n updateTimers();\n },\n onBlurWithin: () => {\n isFocused.current = false;\n lastFocused.current = null;\n updateTimers();\n }\n });\n\n // When the number of visible toasts becomes 0 or the region unmounts,\n // restore focus to the last element that had focus before the user moved focus\n // into the region. FocusScope restore focus doesn't update whenever the focus\n // moves in, it only happens once, so we correct it.\n // Because we're in a hook, we can't control if the user unmounts or not.\n useEffect(() => {\n if (state.visibleToasts.length === 0 && lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n }, [ref, state.visibleToasts.length]);\n\n useEffect(() => {\n return () => {\n if (lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n // listen to focus events separate from focuswithin because that will only fire once\n // and we need to follow all focus changes\n onFocus: e => {\n let target = (getEventTarget(e) as Element).closest('[role=\"alertdialog\"]');\n focusedToast.current = toasts.current.findIndex(t => t === target);\n },\n onBlur: () => {\n focusedToast.current = -1;\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAmCM,SAAS,0CACd,KAA2B,EAC3B,KAAoB,EACpB,GAAkC;IAElC,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tD,iDAAiD;YACjD,yDAAyD;YACzD,8EAA8E;YAC9E,aAAa;YACb,6BAA6B;YAC7B,oFAAoF;YACpF,0CAA0C;YAC1C,SAAS,CAAA;gBACP,IAAI,SAAS,AAAC,CAAA,GAAA,yCAAa,EAAE,GAAe,OAAO,CAAC;gBACpD,aAAa,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA,IAAK,MAAM;YAC7D;YACA,QAAQ;gBACN,aAAa,OAAO,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/react-aria/src/toast/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport intlMessages from '../../intl/toast/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {ToastState} from 'react-stately/useToastState';\nimport {useCallback, useEffect, useRef} from 'react';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useHover} from '../interactions/useHover';\nimport {useLandmark} from '../landmark/useLandmark';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n *\n * @default 'Notifications'\n */\n 'aria-label'?: string;\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more\n * toasts. Toasts display brief, temporary notifications of actions, errors, or other events in an\n * application.\n */\nexport function useToastRegion<T>(\n props: AriaToastRegionProps,\n state: ToastState<T>,\n ref: RefObject<HTMLElement | null>\n): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark(\n {\n role: 'region',\n 'aria-label':\n props['aria-label'] ||\n stringFormatter.format('notifications', {count: state.visibleToasts.length})\n },\n ref\n );\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n let updateTimers = useCallback(() => {\n if (isHovered.current || isFocused.current) {\n state.pauseAll();\n } else {\n state.resumeAll();\n }\n }, [state]);\n\n let {hoverProps} = useHover({\n onHoverStart: () => {\n isHovered.current = true;\n updateTimers();\n },\n onHoverEnd: () => {\n isHovered.current = false;\n updateTimers();\n }\n });\n\n // Manage focus within the toast region.\n // If a focused containing toast is removed, move focus to the next toast, or the previous toast if there is no next toast.\n let toasts = useRef<FocusableElement[]>([]);\n let prevVisibleToasts = useRef(state.visibleToasts);\n let focusedToast = useRef<number | null>(null);\n useLayoutEffect(() => {\n // If no toast has focus, then don't do anything.\n if (focusedToast.current === -1 || state.visibleToasts.length === 0 || !ref.current) {\n toasts.current = [];\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n toasts.current = [\n ...ref.current.querySelectorAll('[role=\"alertdialog\"]')\n ] as FocusableElement[];\n // If the visible toasts haven't changed, we don't need to do anything.\n if (\n prevVisibleToasts.current.length === state.visibleToasts.length &&\n state.visibleToasts.every((t, i) => t.key === prevVisibleToasts.current[i].key)\n ) {\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n // Get a list of all toasts by index and add info if they are removed.\n let allToasts = prevVisibleToasts.current.map((t, i) => ({\n ...t,\n i,\n isRemoved: !state.visibleToasts.some(t2 => t.key === t2.key)\n }));\n\n let removedFocusedToastIndex = allToasts.findIndex(\n t => t.i === focusedToast.current && t.isRemoved\n );\n\n // If the focused toast was removed, focus the next or previous toast.\n if (removedFocusedToastIndex > -1) {\n // In pointer modality, move focus out of the toast region.\n // Otherwise auto-dismiss timers will appear \"stuck\".\n if (getInteractionModality() === 'pointer' && lastFocused.current?.isConnected) {\n focusWithoutScrolling(lastFocused.current);\n } else {\n let i = 0;\n let nextToast;\n let prevToast;\n while (i <= removedFocusedToastIndex) {\n if (!allToasts[i].isRemoved) {\n prevToast = Math.max(0, i - 1);\n }\n i++;\n }\n while (i < allToasts.length) {\n if (!allToasts[i].isRemoved) {\n nextToast = i - 1;\n break;\n }\n i++;\n }\n\n // in the case where it's one toast at a time, both will be undefined, but we know the index must be 0\n if (prevToast === undefined && nextToast === undefined) {\n prevToast = 0;\n }\n\n // prioritize going to newer toasts\n if (prevToast >= 0 && prevToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[prevToast]);\n } else if (nextToast >= 0 && nextToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[nextToast]);\n }\n }\n }\n\n prevVisibleToasts.current = state.visibleToasts;\n }, [state.visibleToasts, ref]);\n\n let lastFocused = useRef<FocusableElement | null>(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: e => {\n isFocused.current = true;\n lastFocused.current = e.relatedTarget as FocusableElement;\n updateTimers();\n },\n onBlurWithin: () => {\n isFocused.current = false;\n lastFocused.current = null;\n updateTimers();\n }\n });\n\n // When the number of visible toasts becomes 0 or the region unmounts,\n // restore focus to the last element that had focus before the user moved focus\n // into the region. FocusScope restore focus doesn't update whenever the focus\n // moves in, it only happens once, so we correct it.\n // Because we're in a hook, we can't control if the user unmounts or not.\n useEffect(() => {\n if (state.visibleToasts.length === 0 && lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n }, [ref, state.visibleToasts.length]);\n\n useEffect(() => {\n return () => {\n if (lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n // listen to focus events separate from focuswithin because that will only fire once\n // and we need to follow all focus changes\n onFocus: e => {\n let target = (getEventTarget(e) as Element).closest('[role=\"alertdialog\"]');\n focusedToast.current = toasts.current.findIndex(t => t === target);\n },\n onBlur: () => {\n focusedToast.current = -1;\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAoCM,SAAS,0CACd,KAA2B,EAC3B,KAAoB,EACpB,GAAkC;IAElC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,yCAAU,EAC9B;QACE,MAAM;QACN,cACE,KAAK,CAAC,aAAa,IACnB,gBAAgB,MAAM,CAAC,iBAAiB;YAAC,OAAO,MAAM,aAAa,CAAC,MAAM;QAAA;IAC9E,GACA;IAGF,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,eAAe,CAAA,GAAA,kBAAU,EAAE;QAC7B,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,QAAQ;aAEd,MAAM,SAAS;IAEnB,GAAG;QAAC;KAAM;IAEV,IAAI,cAAC,UAAU,EAAC,GAAG,C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,KAAK,YAAY,OAAO,EAAE,aAAa;YACxE,IAAI,CAAA,GAAA,yCAAqB,QAAQ,WAC/B,CAAA,GAAA,yCAAoB,EAAE,YAAY,OAAO;iBAEzC,YAAY,OAAO,CAAC,KAAK;YAE3B,YAAY,OAAO,GAAG;QACxB;IACF,GAAG;QAAC;QAAK,MAAM,aAAa,CAAC,MAAM;KAAC;IAEpC,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,YAAY,OAAO,EAAE,aAAa;gBACpC,IAAI,CAAA,GAAA,yCAAqB,QAAQ,WAC/B,CAAA,GAAA,yCAAoB,EAAE,YAAY,OAAO;qBAEzC,YAAY,OAAO,CAAC,KAAK;gBAE3B,YAAY,OAAO,GAAG;YACxB;QACF;IACF,GAAG;QAAC;KAAI;IAER,OAAO;QACL,aAAa,CAAA,GAAA,yCAAS,EAAE,eAAe,YAAY,kBAAkB;YACnE,UAAU;YACV,sDAAsD;YACtD,iDAAiD;YACjD,yDAAyD;YACzD,8EAA8E;YAC9E,aAAa;YACb,6BAA6B;YAC7B,oFAAoF;YACpF,0CAA0C;YAC1C,SAAS,CAAA;gBACP,IAAI,SAAS,AAAC,CAAA,GAAA,yCAAa,EAAE,GAAe,OAAO,CAAC;gBACpD,aAAa,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA,IAAK,MAAM;YAC7D;YACA,QAAQ;gBACN,aAAa,OAAO,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/react-aria/src/toast/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport intlMessages from '../../intl/toast/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {ToastState} from 'react-stately/useToastState';\nimport {useCallback, useEffect, useRef} from 'react';\n// @ts-ignore\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useHover} from '../interactions/useHover';\nimport {useLandmark} from '../landmark/useLandmark';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n *\n * @default 'Notifications'\n */\n 'aria-label'?: string;\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more\n * toasts. Toasts display brief, temporary notifications of actions, errors, or other events in an\n * application.\n */\nexport function useToastRegion<T>(\n props: AriaToastRegionProps,\n state: ToastState<T>,\n ref: RefObject<HTMLElement | null>\n): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark(\n {\n role: 'region',\n 'aria-label':\n props['aria-label'] ||\n stringFormatter.format('notifications', {count: state.visibleToasts.length})\n },\n ref\n );\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n let updateTimers = useCallback(() => {\n if (isHovered.current || isFocused.current) {\n state.pauseAll();\n } else {\n state.resumeAll();\n }\n }, [state]);\n\n let {hoverProps} = useHover({\n onHoverStart: () => {\n isHovered.current = true;\n updateTimers();\n },\n onHoverEnd: () => {\n isHovered.current = false;\n updateTimers();\n }\n });\n\n // Manage focus within the toast region.\n // If a focused containing toast is removed, move focus to the next toast, or the previous toast if there is no next toast.\n let toasts = useRef<FocusableElement[]>([]);\n let prevVisibleToasts = useRef(state.visibleToasts);\n let focusedToast = useRef<number | null>(null);\n useLayoutEffect(() => {\n // If no toast has focus, then don't do anything.\n if (focusedToast.current === -1 || state.visibleToasts.length === 0 || !ref.current) {\n toasts.current = [];\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n toasts.current = [\n ...ref.current.querySelectorAll('[role=\"alertdialog\"]')\n ] as FocusableElement[];\n // If the visible toasts haven't changed, we don't need to do anything.\n if (\n prevVisibleToasts.current.length === state.visibleToasts.length &&\n state.visibleToasts.every((t, i) => t.key === prevVisibleToasts.current[i].key)\n ) {\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n // Get a list of all toasts by index and add info if they are removed.\n let allToasts = prevVisibleToasts.current.map((t, i) => ({\n ...t,\n i,\n isRemoved: !state.visibleToasts.some(t2 => t.key === t2.key)\n }));\n\n let removedFocusedToastIndex = allToasts.findIndex(\n t => t.i === focusedToast.current && t.isRemoved\n );\n\n // If the focused toast was removed, focus the next or previous toast.\n if (removedFocusedToastIndex > -1) {\n // In pointer modality, move focus out of the toast region.\n // Otherwise auto-dismiss timers will appear \"stuck\".\n if (getInteractionModality() === 'pointer' && lastFocused.current?.isConnected) {\n focusWithoutScrolling(lastFocused.current);\n } else {\n let i = 0;\n let nextToast;\n let prevToast;\n while (i <= removedFocusedToastIndex) {\n if (!allToasts[i].isRemoved) {\n prevToast = Math.max(0, i - 1);\n }\n i++;\n }\n while (i < allToasts.length) {\n if (!allToasts[i].isRemoved) {\n nextToast = i - 1;\n break;\n }\n i++;\n }\n\n // in the case where it's one toast at a time, both will be undefined, but we know the index must be 0\n if (prevToast === undefined && nextToast === undefined) {\n prevToast = 0;\n }\n\n // prioritize going to newer toasts\n if (prevToast >= 0 && prevToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[prevToast]);\n } else if (nextToast >= 0 && nextToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[nextToast]);\n }\n }\n }\n\n prevVisibleToasts.current = state.visibleToasts;\n }, [state.visibleToasts, ref]);\n\n let lastFocused = useRef<FocusableElement | null>(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: e => {\n isFocused.current = true;\n lastFocused.current = e.relatedTarget as FocusableElement;\n updateTimers();\n },\n onBlurWithin: () => {\n isFocused.current = false;\n lastFocused.current = null;\n updateTimers();\n }\n });\n\n // When the number of visible toasts becomes 0 or the region unmounts,\n // restore focus to the last element that had focus before the user moved focus\n // into the region. FocusScope restore focus doesn't update whenever the focus\n // moves in, it only happens once, so we correct it.\n // Because we're in a hook, we can't control if the user unmounts or not.\n useEffect(() => {\n if (state.visibleToasts.length === 0 && lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n }, [ref, state.visibleToasts.length]);\n\n useEffect(() => {\n return () => {\n if (lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n // listen to focus events separate from focuswithin because that will only fire once\n // and we need to follow all focus changes\n onFocus: e => {\n let target = (getEventTarget(e) as Element).closest('[role=\"alertdialog\"]');\n focusedToast.current = toasts.current.findIndex(t => t === target);\n },\n onBlur: () => {\n focusedToast.current = -1;\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAmCM,S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B;YAC7B,oFAAoF;YACpF,0CAA0C;YAC1C,SAAS,CAAA;gBACP,IAAI,SAAS,AAAC,CAAA,GAAA,yCAAa,EAAE,GAAe,OAAO,CAAC;gBACpD,aAAa,OAAO,GAAG,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA,IAAK,MAAM;YAC7D;YACA,QAAQ;gBACN,aAAa,OAAO,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/react-aria/src/toast/useToastRegion.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {AriaLabelingProps, DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport intlMessages from '../../intl/toast/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {ToastState} from 'react-stately/useToastState';\nimport {useCallback, useEffect, useRef} from 'react';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useHover} from '../interactions/useHover';\nimport {useLandmark} from '../landmark/useLandmark';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n *\n * @default 'Notifications'\n */\n 'aria-label'?: string;\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more\n * toasts. Toasts display brief, temporary notifications of actions, errors, or other events in an\n * application.\n */\nexport function useToastRegion<T>(\n props: AriaToastRegionProps,\n state: ToastState<T>,\n ref: RefObject<HTMLElement | null>\n): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark(\n {\n role: 'region',\n 'aria-label':\n props['aria-label'] ||\n stringFormatter.format('notifications', {count: state.visibleToasts.length})\n },\n ref\n );\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n let updateTimers = useCallback(() => {\n if (isHovered.current || isFocused.current) {\n state.pauseAll();\n } else {\n state.resumeAll();\n }\n }, [state]);\n\n let {hoverProps} = useHover({\n onHoverStart: () => {\n isHovered.current = true;\n updateTimers();\n },\n onHoverEnd: () => {\n isHovered.current = false;\n updateTimers();\n }\n });\n\n // Manage focus within the toast region.\n // If a focused containing toast is removed, move focus to the next toast, or the previous toast if there is no next toast.\n let toasts = useRef<FocusableElement[]>([]);\n let prevVisibleToasts = useRef(state.visibleToasts);\n let focusedToast = useRef<number | null>(null);\n useLayoutEffect(() => {\n // If no toast has focus, then don't do anything.\n if (focusedToast.current === -1 || state.visibleToasts.length === 0 || !ref.current) {\n toasts.current = [];\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n toasts.current = [\n ...ref.current.querySelectorAll('[role=\"alertdialog\"]')\n ] as FocusableElement[];\n // If the visible toasts haven't changed, we don't need to do anything.\n if (\n prevVisibleToasts.current.length === state.visibleToasts.length &&\n state.visibleToasts.every((t, i) => t.key === prevVisibleToasts.current[i].key)\n ) {\n prevVisibleToasts.current = state.visibleToasts;\n return;\n }\n // Get a list of all toasts by index and add info if they are removed.\n let allToasts = prevVisibleToasts.current.map((t, i) => ({\n ...t,\n i,\n isRemoved: !state.visibleToasts.some(t2 => t.key === t2.key)\n }));\n\n let removedFocusedToastIndex = allToasts.findIndex(\n t => t.i === focusedToast.current && t.isRemoved\n );\n\n // If the focused toast was removed, focus the next or previous toast.\n if (removedFocusedToastIndex > -1) {\n // In pointer modality, move focus out of the toast region.\n // Otherwise auto-dismiss timers will appear \"stuck\".\n if (getInteractionModality() === 'pointer' && lastFocused.current?.isConnected) {\n focusWithoutScrolling(lastFocused.current);\n } else {\n let i = 0;\n let nextToast;\n let prevToast;\n while (i <= removedFocusedToastIndex) {\n if (!allToasts[i].isRemoved) {\n prevToast = Math.max(0, i - 1);\n }\n i++;\n }\n while (i < allToasts.length) {\n if (!allToasts[i].isRemoved) {\n nextToast = i - 1;\n break;\n }\n i++;\n }\n\n // in the case where it's one toast at a time, both will be undefined, but we know the index must be 0\n if (prevToast === undefined && nextToast === undefined) {\n prevToast = 0;\n }\n\n // prioritize going to newer toasts\n if (prevToast >= 0 && prevToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[prevToast]);\n } else if (nextToast >= 0 && nextToast < toasts.current.length) {\n focusWithoutScrolling(toasts.current[nextToast]);\n }\n }\n }\n\n prevVisibleToasts.current = state.visibleToasts;\n }, [state.visibleToasts, ref]);\n\n let lastFocused = useRef<FocusableElement | null>(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: e => {\n isFocused.current = true;\n lastFocused.current = e.relatedTarget as FocusableElement;\n updateTimers();\n },\n onBlurWithin: () => {\n isFocused.current = false;\n lastFocused.current = null;\n updateTimers();\n }\n });\n\n // When the number of visible toasts becomes 0 or the region unmounts,\n // restore focus to the last element that had focus before the user moved focus\n // into the region. FocusScope restore focus doesn't update whenever the focus\n // moves in, it only happens once, so we correct it.\n // Because we're in a hook, we can't control if the user unmounts or not.\n useEffect(() => {\n if (state.visibleToasts.length === 0 && lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n }, [ref, state.visibleToasts.length]);\n\n useEffect(() => {\n return () => {\n if (lastFocused.current?.isConnected) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n lastFocused.current = null;\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n // listen to focus events separate from focuswithin because that will only fire once\n // and we need to follow all focus changes\n onFocus: e => {\n let target = (getEventTarget(e) as Element).closest('[role=\"alertdialog\"]');\n focusedToast.current = toasts.current.findIndex(t => t === target);\n },\n onBlur: () => {\n focusedToast.current = -1;\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.mjs.map"}
|
|
@@ -53,7 +53,6 @@ function $4be8e70c23134915$export$fa142eb1681c520(props, ref) {
|
|
|
53
53
|
// out of the entire toolbar. To do this, move focus
|
|
54
54
|
// to the first or last focusable child, and let the
|
|
55
55
|
// browser handle the Tab key as usual from there.
|
|
56
|
-
e.stopPropagation();
|
|
57
56
|
lastFocused.current = (0, $da02ee888921bc9e$exports.getActiveElement)();
|
|
58
57
|
if (e.shiftKey) focusManager.focusFirst();
|
|
59
58
|
else focusManager.focusLast();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,yCACd,KAAuB,EACvB,GAAkC;IAElC,MAAM,EACJ,cAAc,SAAS,EACvB,mBAAmB,cAAc,eACjC,cAAc,cACf,GAAG;IACJ,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC3C,4FAA4F;IAC5F,mFAAmF;IACnF,uDAAuD;IACvD,CAAA,GAAA,yCAAc,EAAE;QACd,aAAa,CAAC,CAAE,CAAA,IAAI,OAAO,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,QAAQ,mBAAkB;IACtF;IACA,M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;IACF;IAEA,OAAO;QACL,cAAc;YACZ,GAAG,CAAA,GAAA,wCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;YAC3C,MAAM,CAAC,cAAc,YAAY;YACjC,oBAAoB;YACpB,cAAc;YACd,mBAAmB,aAAa,OAAO,iBAAiB;YACxD,kBAAkB,CAAC,cAAc,YAAY;YAC7C,gBAAgB,CAAC,cAAc,UAAU;YACzC,eAAe,CAAC,cAAc,SAAS;QACzC;IACF;AACF","sources":["packages/react-aria/src/toolbar/useToolbar.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {AriaLabelingProps, Orientation, RefObject} from '@react-types/shared';\nimport {createFocusManager} from '../focus/FocusScope';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEventHandler, HTMLAttributes, KeyboardEventHandler, useRef, useState} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocale} from '../i18n/I18nProvider';\n\nexport interface AriaToolbarProps extends AriaLabelingProps {\n /**\n * The orientation of the entire toolbar.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation;\n}\n\nexport interface ToolbarAria {\n /**\n * Props for the toolbar container.\n */\n toolbarProps: HTMLAttributes<HTMLElement>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toolbar.\n * A toolbar is a container for a set of interactive controls with arrow key navigation.\n *\n * @param props - Props to be applied to the toolbar.\n * @param ref - A ref to a DOM element for the toolbar.\n */\nexport function useToolbar(\n props: AriaToolbarProps,\n ref: RefObject<HTMLElement | null>\n): ToolbarAria {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n orientation = 'horizontal'\n } = props;\n let [isInToolbar, setInToolbar] = useState(false);\n // should be safe because re-calling set state with the same value it already has is a no-op\n // this will allow us to react should a parent re-render and change its role though\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n });\n const {direction} = useLocale();\n const shouldReverse = direction === 'rtl' && orientation === 'horizontal';\n let focusManager = createFocusManager(ref);\n\n const onKeyDown: KeyboardEventHandler = e => {\n // don't handle portalled events\n if (!nodeContains(e.currentTarget, getEventTarget(e) as HTMLElement)) {\n return;\n }\n if (\n (orientation === 'horizontal' && e.key === 'ArrowRight') ||\n (orientation === 'vertical' && e.key === 'ArrowDown')\n ) {\n if (shouldReverse) {\n focusManager.focusPrevious();\n } else {\n focusManager.focusNext();\n }\n } else if (\n (orientation === 'horizontal' && e.key === 'ArrowLeft') ||\n (orientation === 'vertical' && e.key === 'ArrowUp')\n ) {\n if (shouldReverse) {\n focusManager.focusNext();\n } else {\n focusManager.focusPrevious();\n }\n } else if (e.key === 'Tab') {\n // When the tab key is pressed, we want to move focus\n // out of the entire toolbar. To do this, move focus\n // to the first or last focusable child, and let the\n // browser handle the Tab key as usual from there.\n lastFocused.current = getActiveElement() as HTMLElement;\n if (e.shiftKey) {\n focusManager.focusFirst();\n } else {\n focusManager.focusLast();\n }\n return;\n } else {\n // if we didn't handle anything, return early so we don't preventDefault\n return;\n }\n\n // Prevent arrow keys from being handled by nested action groups.\n e.stopPropagation();\n e.preventDefault();\n };\n\n // Record the last focused child when focus moves out of the toolbar.\n const lastFocused = useRef<HTMLElement | null>(null);\n const onBlur: FocusEventHandler<HTMLElement> = e => {\n if (!nodeContains(e.currentTarget, e.relatedTarget) && !lastFocused.current) {\n lastFocused.current = getEventTarget(e);\n }\n };\n\n // Restore focus to the last focused child when focus returns into the toolbar.\n // If the element was removed, do nothing, either the first item in the first group,\n // or the last item in the last group will be focused, depending on direction.\n const onFocus: FocusEventHandler<HTMLElement> = e => {\n if (\n lastFocused.current &&\n !nodeContains(e.currentTarget, e.relatedTarget) &&\n nodeContains(ref.current, getEventTarget(e))\n ) {\n lastFocused.current?.focus();\n lastFocused.current = null;\n }\n };\n\n return {\n toolbarProps: {\n ...filterDOMProps(props, {labelable: true}),\n role: !isInToolbar ? 'toolbar' : 'group',\n 'aria-orientation': orientation,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabel == null ? ariaLabelledBy : undefined,\n onKeyDownCapture: !isInToolbar ? onKeyDown : undefined,\n onFocusCapture: !isInToolbar ? onFocus : undefined,\n onBlurCapture: !isInToolbar ? onBlur : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useToolbar.cjs.map"}
|
|
@@ -48,7 +48,6 @@ function $bfa20c3289e39703$export$fa142eb1681c520(props, ref) {
|
|
|
48
48
|
// out of the entire toolbar. To do this, move focus
|
|
49
49
|
// to the first or last focusable child, and let the
|
|
50
50
|
// browser handle the Tab key as usual from there.
|
|
51
|
-
e.stopPropagation();
|
|
52
51
|
lastFocused.current = (0, $d8ac7ed472840322$export$cd4e5573fbe2b576)();
|
|
53
52
|
if (e.shiftKey) focusManager.focusFirst();
|
|
54
53
|
else focusManager.focusLast();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,yCACd,KAAuB,EACvB,GAAkC;IAElC,MAAM,EACJ,cAAc,SAAS,EACvB,mBAAmB,cAAc,eACjC,cAAc,cACf,GAAG;IACJ,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,4FAA4F;IAC5F,mFAAmF;IACnF,uDAAuD;IACvD,CAAA,GAAA,yCAAc,EAAE;YACiB;QAA/B,aAAa,CAAC,CAAE,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AAa,KAC9C,CAAA,GAAA,yCAAW,EAAE,IAAI,OAAO,EAAE,CAAA,GAAA,yCAAa,EAAE,KACzC;gBACA;aAAA,uBAAA,YAAY,OAAO,cAAnB,2CAAA,qBAAqB,KAAK;YAC1B,YAAY,OAAO,GAAG;QACxB;IACF;IAEA,OAAO;QACL,cAAc;YACZ,GAAG,CAAA,GAAA,yCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;YAC3C,MAAM,CAAC,cAAc,YAAY;YACjC,oBAAoB;YACpB,cAAc;YACd,mBAAmB,aAAa,OAAO,iBAAiB;YACxD,kBAAkB,CAAC,cAAc,YAAY;YAC7C,gBAAgB,CAAC,cAAc,UAAU;YACzC,eAAe,CAAC,cAAc,SAAS;QACzC;IACF;AACF","sources":["packages/react-aria/src/toolbar/useToolbar.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {AriaLabelingProps, Orientation, RefObject} from '@react-types/shared';\nimport {createFocusManager} from '../focus/FocusScope';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEventHandler, HTMLAttributes, KeyboardEventHandler, useRef, useState} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocale} from '../i18n/I18nProvider';\n\nexport interface AriaToolbarProps extends AriaLabelingProps {\n /**\n * The orientation of the entire toolbar.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation;\n}\n\nexport interface ToolbarAria {\n /**\n * Props for the toolbar container.\n */\n toolbarProps: HTMLAttributes<HTMLElement>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toolbar.\n * A toolbar is a container for a set of interactive controls with arrow key navigation.\n *\n * @param props - Props to be applied to the toolbar.\n * @param ref - A ref to a DOM element for the toolbar.\n */\nexport function useToolbar(\n props: AriaToolbarProps,\n ref: RefObject<HTMLElement | null>\n): ToolbarAria {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n orientation = 'horizontal'\n } = props;\n let [isInToolbar, setInToolbar] = useState(false);\n // should be safe because re-calling set state with the same value it already has is a no-op\n // this will allow us to react should a parent re-render and change its role though\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n });\n const {direction} = useLocale();\n const shouldReverse = direction === 'rtl' && orientation === 'horizontal';\n let focusManager = createFocusManager(ref);\n\n const onKeyDown: KeyboardEventHandler = e => {\n // don't handle portalled events\n if (!nodeContains(e.currentTarget, getEventTarget(e) as HTMLElement)) {\n return;\n }\n if (\n (orientation === 'horizontal' && e.key === 'ArrowRight') ||\n (orientation === 'vertical' && e.key === 'ArrowDown')\n ) {\n if (shouldReverse) {\n focusManager.focusPrevious();\n } else {\n focusManager.focusNext();\n }\n } else if (\n (orientation === 'horizontal' && e.key === 'ArrowLeft') ||\n (orientation === 'vertical' && e.key === 'ArrowUp')\n ) {\n if (shouldReverse) {\n focusManager.focusNext();\n } else {\n focusManager.focusPrevious();\n }\n } else if (e.key === 'Tab') {\n // When the tab key is pressed, we want to move focus\n // out of the entire toolbar. To do this, move focus\n // to the first or last focusable child, and let the\n // browser handle the Tab key as usual from there.\n lastFocused.current = getActiveElement() as HTMLElement;\n if (e.shiftKey) {\n focusManager.focusFirst();\n } else {\n focusManager.focusLast();\n }\n return;\n } else {\n // if we didn't handle anything, return early so we don't preventDefault\n return;\n }\n\n // Prevent arrow keys from being handled by nested action groups.\n e.stopPropagation();\n e.preventDefault();\n };\n\n // Record the last focused child when focus moves out of the toolbar.\n const lastFocused = useRef<HTMLElement | null>(null);\n const onBlur: FocusEventHandler<HTMLElement> = e => {\n if (!nodeContains(e.currentTarget, e.relatedTarget) && !lastFocused.current) {\n lastFocused.current = getEventTarget(e);\n }\n };\n\n // Restore focus to the last focused child when focus returns into the toolbar.\n // If the element was removed, do nothing, either the first item in the first group,\n // or the last item in the last group will be focused, depending on direction.\n const onFocus: FocusEventHandler<HTMLElement> = e => {\n if (\n lastFocused.current &&\n !nodeContains(e.currentTarget, e.relatedTarget) &&\n nodeContains(ref.current, getEventTarget(e))\n ) {\n lastFocused.current?.focus();\n lastFocused.current = null;\n }\n };\n\n return {\n toolbarProps: {\n ...filterDOMProps(props, {labelable: true}),\n role: !isInToolbar ? 'toolbar' : 'group',\n 'aria-orientation': orientation,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabel == null ? ariaLabelledBy : undefined,\n onKeyDownCapture: !isInToolbar ? onKeyDown : undefined,\n onFocusCapture: !isInToolbar ? onFocus : undefined,\n onBlurCapture: !isInToolbar ? onBlur : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useToolbar.js.map"}
|
|
@@ -47,7 +47,6 @@ function $afa781ff67c1cd08$export$fa142eb1681c520(props, ref) {
|
|
|
47
47
|
// out of the entire toolbar. To do this, move focus
|
|
48
48
|
// to the first or last focusable child, and let the
|
|
49
49
|
// browser handle the Tab key as usual from there.
|
|
50
|
-
e.stopPropagation();
|
|
51
50
|
lastFocused.current = (0, $23f2114a1b82827e$export$cd4e5573fbe2b576)();
|
|
52
51
|
if (e.shiftKey) focusManager.focusFirst();
|
|
53
52
|
else focusManager.focusLast();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,SAAS,yCACd,KAAuB,EACvB,GAAkC;IAElC,MAAM,EACJ,cAAc,SAAS,EACvB,mBAAmB,cAAc,eACjC,cAAc,cACf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,UAA0C,CAAA;QAC9C,IACE,YAAY,OAAO,IACnB,CAAC,CAAA,GAAA,yCAAW,EAAE,EAAE,aAAa,EAAE,EAAE,aAAa,KAC9C,CAAA,GAAA,yCAAW,EAAE,IAAI,OAAO,EAAE,CAAA,GAAA,yCAAa,EAAE,KACzC;YACA,YAAY,OAAO,EAAE;YACrB,YAAY,OAAO,GAAG;QACxB;IACF;IAEA,OAAO;QACL,cAAc;YACZ,GAAG,CAAA,GAAA,yCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;YAC3C,MAAM,CAAC,cAAc,YAAY;YACjC,oBAAoB;YACpB,cAAc;YACd,mBAAmB,aAAa,OAAO,iBAAiB;YACxD,kBAAkB,CAAC,cAAc,YAAY;YAC7C,gBAAgB,CAAC,cAAc,UAAU;YACzC,eAAe,CAAC,cAAc,SAAS;QACzC;IACF;AACF","sources":["packages/react-aria/src/toolbar/useToolbar.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {AriaLabelingProps, Orientation, RefObject} from '@react-types/shared';\nimport {createFocusManager} from '../focus/FocusScope';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEventHandler, HTMLAttributes, KeyboardEventHandler, useRef, useState} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocale} from '../i18n/I18nProvider';\n\nexport interface AriaToolbarProps extends AriaLabelingProps {\n /**\n * The orientation of the entire toolbar.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation;\n}\n\nexport interface ToolbarAria {\n /**\n * Props for the toolbar container.\n */\n toolbarProps: HTMLAttributes<HTMLElement>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toolbar.\n * A toolbar is a container for a set of interactive controls with arrow key navigation.\n *\n * @param props - Props to be applied to the toolbar.\n * @param ref - A ref to a DOM element for the toolbar.\n */\nexport function useToolbar(\n props: AriaToolbarProps,\n ref: RefObject<HTMLElement | null>\n): ToolbarAria {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n orientation = 'horizontal'\n } = props;\n let [isInToolbar, setInToolbar] = useState(false);\n // should be safe because re-calling set state with the same value it already has is a no-op\n // this will allow us to react should a parent re-render and change its role though\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role=\"toolbar\"]')));\n });\n const {direction} = useLocale();\n const shouldReverse = direction === 'rtl' && orientation === 'horizontal';\n let focusManager = createFocusManager(ref);\n\n const onKeyDown: KeyboardEventHandler = e => {\n // don't handle portalled events\n if (!nodeContains(e.currentTarget, getEventTarget(e) as HTMLElement)) {\n return;\n }\n if (\n (orientation === 'horizontal' && e.key === 'ArrowRight') ||\n (orientation === 'vertical' && e.key === 'ArrowDown')\n ) {\n if (shouldReverse) {\n focusManager.focusPrevious();\n } else {\n focusManager.focusNext();\n }\n } else if (\n (orientation === 'horizontal' && e.key === 'ArrowLeft') ||\n (orientation === 'vertical' && e.key === 'ArrowUp')\n ) {\n if (shouldReverse) {\n focusManager.focusNext();\n } else {\n focusManager.focusPrevious();\n }\n } else if (e.key === 'Tab') {\n // When the tab key is pressed, we want to move focus\n // out of the entire toolbar. To do this, move focus\n // to the first or last focusable child, and let the\n // browser handle the Tab key as usual from there.\n lastFocused.current = getActiveElement() as HTMLElement;\n if (e.shiftKey) {\n focusManager.focusFirst();\n } else {\n focusManager.focusLast();\n }\n return;\n } else {\n // if we didn't handle anything, return early so we don't preventDefault\n return;\n }\n\n // Prevent arrow keys from being handled by nested action groups.\n e.stopPropagation();\n e.preventDefault();\n };\n\n // Record the last focused child when focus moves out of the toolbar.\n const lastFocused = useRef<HTMLElement | null>(null);\n const onBlur: FocusEventHandler<HTMLElement> = e => {\n if (!nodeContains(e.currentTarget, e.relatedTarget) && !lastFocused.current) {\n lastFocused.current = getEventTarget(e);\n }\n };\n\n // Restore focus to the last focused child when focus returns into the toolbar.\n // If the element was removed, do nothing, either the first item in the first group,\n // or the last item in the last group will be focused, depending on direction.\n const onFocus: FocusEventHandler<HTMLElement> = e => {\n if (\n lastFocused.current &&\n !nodeContains(e.currentTarget, e.relatedTarget) &&\n nodeContains(ref.current, getEventTarget(e))\n ) {\n lastFocused.current?.focus();\n lastFocused.current = null;\n }\n };\n\n return {\n toolbarProps: {\n ...filterDOMProps(props, {labelable: true}),\n role: !isInToolbar ? 'toolbar' : 'group',\n 'aria-orientation': orientation,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabel == null ? ariaLabelledBy : undefined,\n onKeyDownCapture: !isInToolbar ? onKeyDown : undefined,\n onFocusCapture: !isInToolbar ? onFocus : undefined,\n onBlurCapture: !isInToolbar ? onBlur : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useToolbar.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAuCM,SAAS,0CACd,KAAyB,EACzB,KAAmB,EACnB,GAAkC;IAElC,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/tree/useTree.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n AriaGridListOptions,\n AriaGridListProps,\n GridListProps,\n useGridList\n} from '../gridlist/useGridList';\nimport {DOMAttributes, KeyboardDelegate, RefObject} from '@react-types/shared';\nimport {TreeState} from 'react-stately/useTreeState';\n\nexport interface TreeProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeProps<T> extends AriaGridListProps<T> {}\nexport interface AriaTreeOptions<T> extends Omit<\n AriaGridListOptions<T>,\n 'children' | 'shouldFocusWrap'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface TreeAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component\n * with interactive children. A tree grid provides users with a way to navigate nested hierarchical\n * information.\n *\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTree<T>(\n props: AriaTreeOptions<T>,\n state: TreeState<T>,\n ref: RefObject<HTMLElement | null>\n): TreeAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTree.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAuCM,SAAS,0CACd,KAAyB,EACzB,KAAmB,EACnB,GAAkC;IAElC,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/tree/useTree.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n AriaGridListOptions,\n AriaGridListProps,\n GridListProps,\n useGridList\n} from '../gridlist/useGridList';\nimport {DOMAttributes, KeyboardDelegate, RefObject} from '@react-types/shared';\nimport {TreeState} from 'react-stately/useTreeState';\n\nexport interface TreeProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeProps<T> extends AriaGridListProps<T> {}\nexport interface AriaTreeOptions<T> extends Omit<\n AriaGridListOptions<T>,\n 'children' | 'shouldFocusWrap'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface TreeAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component\n * with interactive children. A tree grid provides users with a way to navigate nested hierarchical\n * information.\n *\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTree<T>(\n props: AriaTreeOptions<T>,\n state: TreeState<T>,\n ref: RefObject<HTMLElement | null>\n): TreeAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTree.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAuCM,SAAS,0CACd,KAAyB,EACzB,KAAmB,EACnB,GAAkC;IAElC,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/tree/useTree.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n AriaGridListOptions,\n AriaGridListProps,\n GridListProps,\n useGridList\n} from '../gridlist/useGridList';\nimport {DOMAttributes, KeyboardDelegate, RefObject} from '@react-types/shared';\nimport {TreeState} from 'react-stately/useTreeState';\n\nexport interface TreeProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeProps<T> extends AriaGridListProps<T> {}\nexport interface AriaTreeOptions<T> extends Omit<\n AriaGridListOptions<T>,\n 'children' | 'shouldFocusWrap'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface TreeAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component\n * with interactive children. A tree grid provides users with a way to navigate nested hierarchical\n * information.\n *\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTree<T>(\n props: AriaTreeOptions<T>,\n state: TreeState<T>,\n ref: RefObject<HTMLElement | null>\n): TreeAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTree.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAwCM,SAAS,0CACd,KAA0B,EAC1B,KAAmB,EACnB,GAAuC;IAEvC,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE,OAAO,OAAO;IACjD,IAAI,aAAa,aAAa,QAAQ,CAAC,gBAAgB,KAAK;IAC5D,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,aAAa,CAAA,GAAA,mCAAQ,EAAE;QACzB,cAAc,aACV,gBAAgB,MAAM,CAAC,cACvB,gBAAgB,MAAM,CAAC;QAC3B,mBAAmB,aAAa,QAAQ,CAAC,EAAE;IAC7C;IAEA,IAAI,oBAAoB;QACtB,SAAS;YACP,IAAI,CAAC,aAAa,UAAU,EAAE;gBAC5B,MAAM,SAAS,CAAC,KAAK,GAAG;gBACxB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,GAAG;YAC/C;QACF;QACA,qBAAqB;QACrB,qBAAqB;QACrB,iCAAiC;QACjC,GAAG,UAAU;IACf;IAEA,+FAA+F;IAC/F,OAAO;QACL,GAAG,YAAY;2BACf;IACF;AACF","sources":["packages/react-aria/src/tree/useTreeItem.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaButtonProps} from '../button/useButton';\nimport {\n AriaGridListItemOptions,\n GridListItemAria,\n useGridListItem\n} from '../gridlist/useGridListItem';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\nimport intlMessages from '../../intl/tree/*.json';\nimport {TreeState} from 'react-stately/useTreeState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaTreeItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {\n /**\n * An object representing the treegrid item. Contains all the relevant information that makes up\n * the treegrid row.\n */\n node: Node<unknown>;\n}\n\nexport interface TreeItemAria extends GridListItemAria {\n /** Props for the tree grid row element. */\n rowProps: DOMAttributes;\n /** Props for the tree grid cell element within the tree grid list row. */\n gridCellProps: DOMAttributes;\n /** Props for the tree grid row description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the tree grid row expand button. */\n expandButtonProps: AriaButtonProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a tree grid list.\n *\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useTreeState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useTreeItem<T>(\n props: AriaTreeItemOptions,\n state: TreeState<T>,\n ref: RefObject<FocusableElement | null>\n): TreeItemAria {\n let {node} = props;\n let gridListAria = useGridListItem(props, state, ref);\n let isExpanded = gridListAria.rowProps['aria-expanded'] === true;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tree');\n let labelProps = useLabels({\n 'aria-label': isExpanded\n ? stringFormatter.format('collapse')\n : stringFormatter.format('expand'),\n 'aria-labelledby': gridListAria.rowProps.id\n });\n\n let expandButtonProps = {\n onPress: () => {\n if (!gridListAria.isDisabled) {\n state.toggleKey(node.key);\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(node.key);\n }\n },\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n 'data-react-aria-prevent-focus': true,\n ...labelProps\n };\n\n // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?\n return {\n ...gridListAria,\n expandButtonProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeItem.cjs.map"}
|