@react-aria/interactions 3.0.0-nightly.1729 → 3.0.0-nightly.1734
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/main.js +22 -6
- package/dist/main.js.map +1 -1
- package/dist/module.js +22 -6
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/src/usePress.ts +34 -8
package/dist/main.js
CHANGED
|
@@ -293,7 +293,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
293
293
|
let pressProps = {
|
|
294
294
|
onKeyDown (e) {
|
|
295
295
|
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) {
|
|
296
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
|
|
296
|
+
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
|
297
297
|
e.stopPropagation();
|
|
298
298
|
// If the event is repeating, it may have started on a different element
|
|
299
299
|
// after which focus moved to the current element. Ignore these events and
|
|
@@ -335,7 +335,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
335
335
|
};
|
|
336
336
|
let onKeyUp = (e)=>{
|
|
337
337
|
if (state.isPressed && $0294ea432cd92340$var$isValidKeyboardEvent(e, state.target)) {
|
|
338
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
|
|
338
|
+
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
|
339
339
|
e.stopPropagation();
|
|
340
340
|
state.isPressed = false;
|
|
341
341
|
let target = e.target;
|
|
@@ -578,11 +578,10 @@ function $0294ea432cd92340$var$isHTMLAnchorLink(target) {
|
|
|
578
578
|
function $0294ea432cd92340$var$isValidKeyboardEvent(event, currentTarget) {
|
|
579
579
|
const { key: key , code: code } = event;
|
|
580
580
|
const element = currentTarget;
|
|
581
|
-
const { tagName: tagName , isContentEditable: isContentEditable } = element;
|
|
582
581
|
const role = element.getAttribute('role');
|
|
583
582
|
// Accessibility for keyboards. Space and Enter only.
|
|
584
583
|
// "Spacebar" is for IE 11
|
|
585
|
-
return (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') &&
|
|
584
|
+
return (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') && !(element instanceof HTMLInputElement && !$0294ea432cd92340$var$isValidInputKey(element, key) || element instanceof HTMLTextAreaElement || element.isContentEditable) && (!$0294ea432cd92340$var$isHTMLAnchorLink(element) || role === 'button' && key !== 'Enter') && // An element with role='link' should only trigger with Enter key
|
|
586
585
|
!(role === 'link' && key !== 'Enter');
|
|
587
586
|
}
|
|
588
587
|
function $0294ea432cd92340$var$getTouchFromEvent(event) {
|
|
@@ -633,8 +632,25 @@ function $0294ea432cd92340$var$shouldPreventDefault(target) {
|
|
|
633
632
|
// We cannot prevent default if the target is a draggable element.
|
|
634
633
|
return !(target instanceof HTMLElement) || !target.draggable;
|
|
635
634
|
}
|
|
636
|
-
function $0294ea432cd92340$var$shouldPreventDefaultKeyboard(target) {
|
|
637
|
-
|
|
635
|
+
function $0294ea432cd92340$var$shouldPreventDefaultKeyboard(target, key) {
|
|
636
|
+
if (target instanceof HTMLInputElement) return !$0294ea432cd92340$var$isValidInputKey(target, key);
|
|
637
|
+
if (target instanceof HTMLButtonElement) return target.type !== 'submit';
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
const $0294ea432cd92340$var$nonTextInputTypes = new Set([
|
|
641
|
+
'checkbox',
|
|
642
|
+
'radio',
|
|
643
|
+
'range',
|
|
644
|
+
'color',
|
|
645
|
+
'file',
|
|
646
|
+
'image',
|
|
647
|
+
'button',
|
|
648
|
+
'submit',
|
|
649
|
+
'reset'
|
|
650
|
+
]);
|
|
651
|
+
function $0294ea432cd92340$var$isValidInputKey(target, key) {
|
|
652
|
+
// Only space should toggle checkboxes and radios, not enter.
|
|
653
|
+
return target.type === 'checkbox' || target.type === 'radio' ? key === ' ' : $0294ea432cd92340$var$nonTextInputTypes.has(target.type);
|
|
638
654
|
}
|
|
639
655
|
function $0294ea432cd92340$var$isVirtualPointerEvent(event) {
|
|
640
656
|
// If the pointer size is zero, then we assume it's from a screen reader.
|