@react-aria/selection
Advanced tools
Comparing version 3.0.0-nightly-ab9fd5c68-241126 to 3.0.0-nightly-adae13c78-241218
@@ -1,2 +0,2 @@ | ||
import { DOMAttributes, Key, KeyboardDelegate, FocusStrategy, RefObject, FocusableElement, LayoutDelegate, Rect, Size, Collection, Direction, DisabledBehavior, Node, Orientation } from "@react-types/shared"; | ||
import { DOMAttributes, Key, KeyboardDelegate, FocusStrategy, RefObject, DOMProps, FocusableElement, LayoutDelegate, Rect, Size, Collection, Direction, DisabledBehavior, Node, Orientation } from "@react-types/shared"; | ||
import { MultipleSelectionManager } from "@react-stately/selection"; | ||
@@ -104,3 +104,3 @@ export interface AriaTypeSelectOptions { | ||
export function useSelectableCollection(options: AriaSelectableCollectionOptions): SelectableCollectionAria; | ||
export interface SelectableItemOptions { | ||
export interface SelectableItemOptions extends DOMProps { | ||
/** | ||
@@ -107,0 +107,0 @@ * An interface for reading and updating multiple selection state. |
var $ee0bdf4faa47f2a8$exports = require("./utils.main.js"); | ||
var $a1189052f36475e8$exports = require("./useTypeSelect.main.js"); | ||
var $bT8Bh$reactariautils = require("@react-aria/utils"); | ||
var $bT8Bh$reactdom = require("react-dom"); | ||
var $bT8Bh$react = require("react"); | ||
var $bT8Bh$reactariafocus = require("@react-aria/focus"); | ||
var $bT8Bh$reactariautils = require("@react-aria/utils"); | ||
var $bT8Bh$reactariainteractions = require("@react-aria/interactions"); | ||
@@ -112,2 +112,3 @@ var $bT8Bh$reactariai18n = require("@react-aria/i18n"); | ||
if (delegate.getFirstKey) { | ||
if (manager.focusedKey === null && e.shiftKey) return; | ||
e.preventDefault(); | ||
@@ -124,2 +125,3 @@ let firstKey = delegate.getFirstKey(manager.focusedKey, (0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e)); | ||
if (delegate.getLastKey) { | ||
if (manager.focusedKey === null && e.shiftKey) return; | ||
e.preventDefault(); | ||
@@ -250,2 +252,27 @@ let lastKey = delegate.getLastKey(manager.focusedKey, (0, $ee0bdf4faa47f2a8$exports.isCtrlKeyPressed)(e)); | ||
}; | ||
// Add event listeners for custom virtual events. These handle updating the focused key in response to various keyboard events | ||
// at the autocomplete level | ||
// TODO: fix type later | ||
(0, $bT8Bh$reactariautils.useEvent)(ref, (0, $bT8Bh$reactariautils.FOCUS_EVENT), !shouldUseVirtualFocus ? undefined : (e)=>{ | ||
let { detail: detail } = e; | ||
e.stopPropagation(); | ||
manager.setFocused(true); | ||
// If the user is typing forwards, autofocus the first option in the list. | ||
if ((detail === null || detail === void 0 ? void 0 : detail.focusStrategy) === 'first') { | ||
var _delegate_getFirstKey, _ref_current; | ||
var _delegate_getFirstKey1; | ||
let keyToFocus = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null; | ||
// If no focusable items exist in the list, make sure to clear any activedescendant that may still exist | ||
if (keyToFocus == null) (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(new CustomEvent((0, $bT8Bh$reactariautils.UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
})); | ||
manager.setFocusedKey(keyToFocus); | ||
} | ||
}); | ||
(0, $bT8Bh$reactariautils.useEvent)(ref, (0, $bT8Bh$reactariautils.CLEAR_FOCUS_EVENT), !shouldUseVirtualFocus ? undefined : (e)=>{ | ||
e.stopPropagation(); | ||
manager.setFocused(false); | ||
manager.setFocusedKey(null); | ||
}); | ||
const autoFocusRef = (0, $bT8Bh$react.useRef)(autoFocus); | ||
@@ -320,6 +347,5 @@ (0, $bT8Bh$react.useEffect)(()=>{ | ||
// This will be marshalled to either the first or last item depending on where focus came from. | ||
// If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try | ||
// to move real DOM focus to the element anyway. | ||
let tabIndex = undefined; | ||
if (!shouldUseVirtualFocus) tabIndex = manager.focusedKey == null ? 0 : -1; | ||
else tabIndex = -1; | ||
return { | ||
@@ -326,0 +352,0 @@ collectionProps: { |
import {isCtrlKeyPressed as $feb5ffebff200149$export$16792effe837dba3, isNonContiguousSelectionModifier as $feb5ffebff200149$export$d3e3bd3e26688c04} from "./utils.module.js"; | ||
import {useTypeSelect as $fb3050f43d946246$export$e32c88dfddc6e1d8} from "./useTypeSelect.module.js"; | ||
import {useRouter as $3H3GQ$useRouter, focusWithoutScrolling as $3H3GQ$focusWithoutScrolling, useEvent as $3H3GQ$useEvent, scrollIntoViewport as $3H3GQ$scrollIntoViewport, FOCUS_EVENT as $3H3GQ$FOCUS_EVENT, UPDATE_ACTIVEDESCENDANT as $3H3GQ$UPDATE_ACTIVEDESCENDANT, CLEAR_FOCUS_EVENT as $3H3GQ$CLEAR_FOCUS_EVENT, scrollIntoView as $3H3GQ$scrollIntoView, mergeProps as $3H3GQ$mergeProps} from "@react-aria/utils"; | ||
import {flushSync as $3H3GQ$flushSync} from "react-dom"; | ||
import {useRef as $3H3GQ$useRef, useEffect as $3H3GQ$useEffect} from "react"; | ||
import {getFocusableTreeWalker as $3H3GQ$getFocusableTreeWalker, focusSafely as $3H3GQ$focusSafely} from "@react-aria/focus"; | ||
import {useRouter as $3H3GQ$useRouter, focusWithoutScrolling as $3H3GQ$focusWithoutScrolling, useEvent as $3H3GQ$useEvent, scrollIntoViewport as $3H3GQ$scrollIntoViewport, scrollIntoView as $3H3GQ$scrollIntoView, mergeProps as $3H3GQ$mergeProps} from "@react-aria/utils"; | ||
import {getInteractionModality as $3H3GQ$getInteractionModality} from "@react-aria/interactions"; | ||
@@ -106,2 +106,3 @@ import {useLocale as $3H3GQ$useLocale} from "@react-aria/i18n"; | ||
if (delegate.getFirstKey) { | ||
if (manager.focusedKey === null && e.shiftKey) return; | ||
e.preventDefault(); | ||
@@ -118,2 +119,3 @@ let firstKey = delegate.getFirstKey(manager.focusedKey, (0, $feb5ffebff200149$export$16792effe837dba3)(e)); | ||
if (delegate.getLastKey) { | ||
if (manager.focusedKey === null && e.shiftKey) return; | ||
e.preventDefault(); | ||
@@ -244,2 +246,27 @@ let lastKey = delegate.getLastKey(manager.focusedKey, (0, $feb5ffebff200149$export$16792effe837dba3)(e)); | ||
}; | ||
// Add event listeners for custom virtual events. These handle updating the focused key in response to various keyboard events | ||
// at the autocomplete level | ||
// TODO: fix type later | ||
(0, $3H3GQ$useEvent)(ref, (0, $3H3GQ$FOCUS_EVENT), !shouldUseVirtualFocus ? undefined : (e)=>{ | ||
let { detail: detail } = e; | ||
e.stopPropagation(); | ||
manager.setFocused(true); | ||
// If the user is typing forwards, autofocus the first option in the list. | ||
if ((detail === null || detail === void 0 ? void 0 : detail.focusStrategy) === 'first') { | ||
var _delegate_getFirstKey, _ref_current; | ||
var _delegate_getFirstKey1; | ||
let keyToFocus = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null; | ||
// If no focusable items exist in the list, make sure to clear any activedescendant that may still exist | ||
if (keyToFocus == null) (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(new CustomEvent((0, $3H3GQ$UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
})); | ||
manager.setFocusedKey(keyToFocus); | ||
} | ||
}); | ||
(0, $3H3GQ$useEvent)(ref, (0, $3H3GQ$CLEAR_FOCUS_EVENT), !shouldUseVirtualFocus ? undefined : (e)=>{ | ||
e.stopPropagation(); | ||
manager.setFocused(false); | ||
manager.setFocusedKey(null); | ||
}); | ||
const autoFocusRef = (0, $3H3GQ$useRef)(autoFocus); | ||
@@ -314,6 +341,5 @@ (0, $3H3GQ$useEffect)(()=>{ | ||
// This will be marshalled to either the first or last item depending on where focus came from. | ||
// If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try | ||
// to move real DOM focus to the element anyway. | ||
let tabIndex = undefined; | ||
if (!shouldUseVirtualFocus) tabIndex = manager.focusedKey == null ? 0 : -1; | ||
else tabIndex = -1; | ||
return { | ||
@@ -320,0 +346,0 @@ collectionProps: { |
@@ -29,4 +29,5 @@ var $ee0bdf4faa47f2a8$exports = require("./utils.main.js"); | ||
function $433b1145b0781e10$export$ecf600387e221c37(options) { | ||
let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options; | ||
let { id: id, selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options; | ||
let router = (0, $i4XHw$reactariautils.useRouter)(); | ||
id = (0, $i4XHw$reactariautils.useId)(id); | ||
let onSelect = (e)=>{ | ||
@@ -57,5 +58,14 @@ if (e.pointerType === 'keyboard' && (0, $ee0bdf4faa47f2a8$exports.isNonContiguousSelectionModifier)(e)) manager.toggleSelection(key); | ||
let isFocused = key === manager.focusedKey; | ||
if (isFocused && manager.isFocused && !shouldUseVirtualFocus) { | ||
if (focus) focus(); | ||
else if (document.activeElement !== ref.current && ref.current) (0, $i4XHw$reactariafocus.focusSafely)(ref.current); | ||
if (isFocused && manager.isFocused) { | ||
if (!shouldUseVirtualFocus) { | ||
if (focus) focus(); | ||
else if (document.activeElement !== ref.current && ref.current) (0, $i4XHw$reactariafocus.focusSafely)(ref.current); | ||
} else { | ||
var _ref_current; | ||
let updateActiveDescendant = new CustomEvent((0, $i4XHw$reactariautils.UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
}); | ||
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(updateActiveDescendant); | ||
} | ||
} | ||
@@ -122,3 +132,3 @@ // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.) | ||
// If allowsDifferentPressOrigin and interacting with mouse, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.) | ||
// Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row) | ||
@@ -133,5 +143,7 @@ if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{ | ||
itemPressProps.onPressUp = hasPrimaryAction ? undefined : (e)=>{ | ||
if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e); | ||
if (e.pointerType === 'mouse' && allowsSelection) onSelect(e); | ||
}; | ||
itemPressProps.onPress = hasPrimaryAction ? performAction : undefined; | ||
itemPressProps.onPress = hasPrimaryAction ? performAction : (e)=>{ | ||
if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse' && allowsSelection) onSelect(e); | ||
}; | ||
} | ||
@@ -197,3 +209,4 @@ } else { | ||
onDragStartCapture: onDragStartCapture, | ||
onClick: onClick | ||
onClick: onClick, | ||
id: id | ||
}), | ||
@@ -200,0 +213,0 @@ isPressed: isPressed, |
import {isCtrlKeyPressed as $feb5ffebff200149$export$16792effe837dba3, isNonContiguousSelectionModifier as $feb5ffebff200149$export$d3e3bd3e26688c04} from "./utils.module.js"; | ||
import {focusSafely as $581M0$focusSafely} from "@react-aria/focus"; | ||
import {useRouter as $581M0$useRouter, openLink as $581M0$openLink, mergeProps as $581M0$mergeProps} from "@react-aria/utils"; | ||
import {useRouter as $581M0$useRouter, useId as $581M0$useId, UPDATE_ACTIVEDESCENDANT as $581M0$UPDATE_ACTIVEDESCENDANT, openLink as $581M0$openLink, mergeProps as $581M0$mergeProps} from "@react-aria/utils"; | ||
import {usePress as $581M0$usePress, useLongPress as $581M0$useLongPress} from "@react-aria/interactions"; | ||
@@ -23,4 +23,5 @@ import {useEffect as $581M0$useEffect, useRef as $581M0$useRef} from "react"; | ||
function $880e95eb8b93ba9a$export$ecf600387e221c37(options) { | ||
let { selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options; | ||
let { id: id, selectionManager: manager, key: key, ref: ref, shouldSelectOnPressUp: shouldSelectOnPressUp, shouldUseVirtualFocus: shouldUseVirtualFocus, focus: focus, isDisabled: isDisabled, onAction: onAction, allowsDifferentPressOrigin: allowsDifferentPressOrigin, linkBehavior: linkBehavior = 'action' } = options; | ||
let router = (0, $581M0$useRouter)(); | ||
id = (0, $581M0$useId)(id); | ||
let onSelect = (e)=>{ | ||
@@ -51,5 +52,14 @@ if (e.pointerType === 'keyboard' && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key); | ||
let isFocused = key === manager.focusedKey; | ||
if (isFocused && manager.isFocused && !shouldUseVirtualFocus) { | ||
if (focus) focus(); | ||
else if (document.activeElement !== ref.current && ref.current) (0, $581M0$focusSafely)(ref.current); | ||
if (isFocused && manager.isFocused) { | ||
if (!shouldUseVirtualFocus) { | ||
if (focus) focus(); | ||
else if (document.activeElement !== ref.current && ref.current) (0, $581M0$focusSafely)(ref.current); | ||
} else { | ||
var _ref_current; | ||
let updateActiveDescendant = new CustomEvent((0, $581M0$UPDATE_ACTIVEDESCENDANT), { | ||
cancelable: true, | ||
bubbles: true | ||
}); | ||
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.dispatchEvent(updateActiveDescendant); | ||
} | ||
} | ||
@@ -116,3 +126,3 @@ // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.) | ||
// If allowsDifferentPressOrigin and interacting with mouse, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.) | ||
// Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row) | ||
@@ -127,5 +137,7 @@ if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{ | ||
itemPressProps.onPressUp = hasPrimaryAction ? undefined : (e)=>{ | ||
if (e.pointerType !== 'keyboard' && allowsSelection) onSelect(e); | ||
if (e.pointerType === 'mouse' && allowsSelection) onSelect(e); | ||
}; | ||
itemPressProps.onPress = hasPrimaryAction ? performAction : undefined; | ||
itemPressProps.onPress = hasPrimaryAction ? performAction : (e)=>{ | ||
if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse' && allowsSelection) onSelect(e); | ||
}; | ||
} | ||
@@ -191,3 +203,4 @@ } else { | ||
onDragStartCapture: onDragStartCapture, | ||
onClick: onClick | ||
onClick: onClick, | ||
id: id | ||
}), | ||
@@ -194,0 +207,0 @@ isPressed: isPressed, |
{ | ||
"name": "@react-aria/selection", | ||
"version": "3.0.0-nightly-ab9fd5c68-241126", | ||
"version": "3.0.0-nightly-adae13c78-241218", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,8 +25,8 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/focus": "^3.0.0-nightly-ab9fd5c68-241126", | ||
"@react-aria/i18n": "^3.0.0-nightly-ab9fd5c68-241126", | ||
"@react-aria/interactions": "^3.0.0-nightly-ab9fd5c68-241126", | ||
"@react-aria/utils": "^3.0.0-nightly-ab9fd5c68-241126", | ||
"@react-stately/selection": "^3.0.0-nightly-ab9fd5c68-241126", | ||
"@react-types/shared": "^3.0.0-nightly-ab9fd5c68-241126", | ||
"@react-aria/focus": "3.0.0-nightly-adae13c78-241218", | ||
"@react-aria/i18n": "3.0.0-nightly-adae13c78-241218", | ||
"@react-aria/interactions": "3.0.0-nightly-adae13c78-241218", | ||
"@react-aria/utils": "3.0.0-nightly-adae13c78-241218", | ||
"@react-stately/selection": "3.0.0-nightly-adae13c78-241218", | ||
"@react-types/shared": "3.0.0-nightly-adae13c78-241218", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -40,4 +40,3 @@ }, | ||
"access": "public" | ||
}, | ||
"stableVersion": "3.21.0" | ||
} | ||
} |
@@ -13,2 +13,3 @@ /* | ||
import {CLEAR_FOCUS_EVENT, FOCUS_EVENT, focusWithoutScrolling, mergeProps, scrollIntoView, scrollIntoViewport, UPDATE_ACTIVEDESCENDANT, useEvent, useRouter} from '@react-aria/utils'; | ||
import {DOMAttributes, FocusableElement, FocusStrategy, Key, KeyboardDelegate, RefObject} from '@react-types/shared'; | ||
@@ -18,3 +19,2 @@ import {flushSync} from 'react-dom'; | ||
import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus'; | ||
import {focusWithoutScrolling, mergeProps, scrollIntoView, scrollIntoViewport, useEvent, useRouter} from '@react-aria/utils'; | ||
import {getInteractionModality} from '@react-aria/interactions'; | ||
@@ -227,2 +227,5 @@ import {isCtrlKeyPressed, isNonContiguousSelectionModifier} from './utils'; | ||
if (delegate.getFirstKey) { | ||
if (manager.focusedKey === null && e.shiftKey) { | ||
return; | ||
} | ||
e.preventDefault(); | ||
@@ -242,2 +245,5 @@ let firstKey: Key | null = delegate.getFirstKey(manager.focusedKey, isCtrlKeyPressed(e)); | ||
if (delegate.getLastKey) { | ||
if (manager.focusedKey === null && e.shiftKey) { | ||
return; | ||
} | ||
e.preventDefault(); | ||
@@ -392,2 +398,33 @@ let lastKey = delegate.getLastKey(manager.focusedKey, isCtrlKeyPressed(e)); | ||
// Add event listeners for custom virtual events. These handle updating the focused key in response to various keyboard events | ||
// at the autocomplete level | ||
// TODO: fix type later | ||
useEvent(ref, FOCUS_EVENT, !shouldUseVirtualFocus ? undefined : (e: any) => { | ||
let {detail} = e; | ||
e.stopPropagation(); | ||
manager.setFocused(true); | ||
// If the user is typing forwards, autofocus the first option in the list. | ||
if (detail?.focusStrategy === 'first') { | ||
let keyToFocus = delegate.getFirstKey?.() ?? null; | ||
// If no focusable items exist in the list, make sure to clear any activedescendant that may still exist | ||
if (keyToFocus == null) { | ||
ref.current?.dispatchEvent( | ||
new CustomEvent(UPDATE_ACTIVEDESCENDANT, { | ||
cancelable: true, | ||
bubbles: true | ||
}) | ||
); | ||
} | ||
manager.setFocusedKey(keyToFocus); | ||
} | ||
}); | ||
useEvent(ref, CLEAR_FOCUS_EVENT, !shouldUseVirtualFocus ? undefined : (e) => { | ||
e.stopPropagation(); | ||
manager.setFocused(false); | ||
manager.setFocusedKey(null); | ||
}); | ||
const autoFocusRef = useRef(autoFocus); | ||
@@ -488,7 +525,7 @@ useEffect(() => { | ||
// This will be marshalled to either the first or last item depending on where focus came from. | ||
// If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try | ||
// to move real DOM focus to the element anyway. | ||
let tabIndex: number | undefined = undefined; | ||
if (!shouldUseVirtualFocus) { | ||
tabIndex = manager.focusedKey == null ? 0 : -1; | ||
} else { | ||
tabIndex = -1; | ||
} | ||
@@ -495,0 +532,0 @@ |
@@ -13,6 +13,6 @@ /* | ||
import {DOMAttributes, FocusableElement, Key, LongPressEvent, PointerType, PressEvent, RefObject} from '@react-types/shared'; | ||
import {DOMAttributes, DOMProps, FocusableElement, Key, LongPressEvent, PointerType, PressEvent, RefObject} from '@react-types/shared'; | ||
import {focusSafely} from '@react-aria/focus'; | ||
import {isCtrlKeyPressed, isNonContiguousSelectionModifier} from './utils'; | ||
import {mergeProps, openLink, useRouter} from '@react-aria/utils'; | ||
import {mergeProps, openLink, UPDATE_ACTIVEDESCENDANT, useId, useRouter} from '@react-aria/utils'; | ||
import {MultipleSelectionManager} from '@react-stately/selection'; | ||
@@ -22,3 +22,3 @@ import {PressProps, useLongPress, usePress} from '@react-aria/interactions'; | ||
export interface SelectableItemOptions { | ||
export interface SelectableItemOptions extends DOMProps { | ||
/** | ||
@@ -113,2 +113,3 @@ * An interface for reading and updating multiple selection state. | ||
let { | ||
id, | ||
selectionManager: manager, | ||
@@ -126,3 +127,3 @@ key, | ||
let router = useRouter(); | ||
id = useId(id); | ||
let onSelect = (e: PressEvent | LongPressEvent | PointerEvent) => { | ||
@@ -168,7 +169,16 @@ if (e.pointerType === 'keyboard' && isNonContiguousSelectionModifier(e)) { | ||
let isFocused = key === manager.focusedKey; | ||
if (isFocused && manager.isFocused && !shouldUseVirtualFocus) { | ||
if (focus) { | ||
focus(); | ||
} else if (document.activeElement !== ref.current && ref.current) { | ||
focusSafely(ref.current); | ||
if (isFocused && manager.isFocused) { | ||
if (!shouldUseVirtualFocus) { | ||
if (focus) { | ||
focus(); | ||
} else if (document.activeElement !== ref.current && ref.current) { | ||
focusSafely(ref.current); | ||
} | ||
} else { | ||
let updateActiveDescendant = new CustomEvent(UPDATE_ACTIVEDESCENDANT, { | ||
cancelable: true, | ||
bubbles: true | ||
}); | ||
ref.current?.dispatchEvent(updateActiveDescendant); | ||
} | ||
@@ -249,3 +259,3 @@ } | ||
// If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.) | ||
// If allowsDifferentPressOrigin and interacting with mouse, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.) | ||
// Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row) | ||
@@ -266,3 +276,3 @@ if (!allowsDifferentPressOrigin) { | ||
itemPressProps.onPressUp = hasPrimaryAction ? undefined : (e) => { | ||
if (e.pointerType !== 'keyboard' && allowsSelection) { | ||
if (e.pointerType === 'mouse' && allowsSelection) { | ||
onSelect(e); | ||
@@ -272,3 +282,7 @@ } | ||
itemPressProps.onPress = hasPrimaryAction ? performAction : undefined; | ||
itemPressProps.onPress = hasPrimaryAction ? performAction : (e) => { | ||
if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse' && allowsSelection) { | ||
onSelect(e); | ||
} | ||
}; | ||
} | ||
@@ -363,3 +377,3 @@ } else { | ||
longPressEnabled ? longPressProps : {}, | ||
{onDoubleClick, onDragStartCapture, onClick} | ||
{onDoubleClick, onDragStartCapture, onClick, id} | ||
), | ||
@@ -366,0 +380,0 @@ isPressed, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
406652
4553
+ Added@internationalized/date@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@internationalized/message@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@internationalized/number@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@internationalized/string@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-aria/focus@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-aria/i18n@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-aria/interactions@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-aria/ssr@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-aria/utils@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-stately/collections@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-stately/selection@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-stately/utils@3.0.0-nightly-adae13c78-241218(transitive)
+ Added@react-types/shared@3.0.0-nightly-adae13c78-241218(transitive)
- Removed@internationalized/date@3.6.0(transitive)
- Removed@internationalized/message@3.1.6(transitive)
- Removed@internationalized/number@3.6.0(transitive)
- Removed@internationalized/string@3.2.5(transitive)
- Removed@react-aria/focus@3.19.0(transitive)
- Removed@react-aria/i18n@3.12.4(transitive)
- Removed@react-aria/interactions@3.22.5(transitive)
- Removed@react-aria/ssr@3.9.7(transitive)
- Removed@react-aria/utils@3.26.0(transitive)
- Removed@react-stately/collections@3.12.0(transitive)
- Removed@react-stately/selection@3.18.0(transitive)
- Removed@react-stately/utils@3.10.5(transitive)
- Removed@react-types/shared@3.26.0(transitive)
Updated@react-aria/interactions@3.0.0-nightly-adae13c78-241218
Updated@react-stately/selection@3.0.0-nightly-adae13c78-241218