@react-aria/interactions 3.15.1 → 3.17.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/import.mjs +216 -173
- package/dist/main.js +215 -172
- package/dist/main.js.map +1 -1
- package/dist/module.js +216 -173
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/PressResponder.tsx +1 -0
- package/src/useHover.ts +1 -2
- package/src/useInteractOutside.ts +25 -22
- package/src/useLongPress.ts +1 -0
- package/src/useMove.ts +43 -41
- package/src/usePress.ts +188 -129
- package/src/utils.ts +10 -7
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AEuBA,2BAA4B,SAAQ,WAAW;IAC7C,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,yEAAyE;IACzE,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC;AAED,+BAAgC,SAAQ,UAAU;IAChD,mCAAmC;IACnC,GAAG,CAAC,EAAE,UAAU,OAAO,CAAC,CAAA;CACzB;AAsBD;IACE,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,UAAU,EAAE,aAAa,CAAA;CAC1B;
|
|
1
|
+
{"mappings":";;AEuBA,2BAA4B,SAAQ,WAAW;IAC7C,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;I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,CAAA;CACrB;AAED;;;GAGG;AACH,mCAAmC,KAAK,EAAE,oBAAoB,QA4E7D;AE7FD,8BAA+B,SAAQ,cAAc;IACnD,sDAAsD;IACtD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;IACE,+CAA+C;IAC/C,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED;;GAEG;AACH,4BAA4B,KAAK,EAAE,aAAa,GAAG,cAAc,CAOhE;AClBD;IACE,6CAA6C;IAC7C,SAAS,EAAE,aAAa,CAAA;CACzB;AASD;;;;GAIG;AACH,wBAAwB,KAAK,EAAE,UAAU,GAAG,UAAU,CAoMrD;ACtND,iCAAkC,SAAQ,YAAY;IACpD,sDAAsD;IACtD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAGD,+BAA+B,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,IAAI,CAkBzF;ACvBD;IACE,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/C;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED;IACE,6CAA6C;IAC7C,cAAc,EAAE,aAAa,CAAA;CAC9B;AAID;;;GAGG;AACH,6BAA6B,KAAK,EAAE,cAAc,GAAG,eAAe,CAyEnE;ACzFD,YAAY,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/textSelection.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/context.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/usePress.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/Pressable.tsx","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/PressResponder.tsx","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/utils.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocus.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocusVisible.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocusWithin.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useHover.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useInteractOutside.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/createEventHandler.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useKeyboard.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useMove.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useScrollWheel.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useLongPress.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/index.ts","packages/@react-aria/interactions/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\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\nexport {Pressable} from './Pressable';\nexport {PressResponder} from './PressResponder';\nexport {useFocus} from './useFocus';\nexport {\n isFocusVisible,\n getInteractionModality,\n setInteractionModality,\n useInteractionModality,\n useFocusVisible,\n useFocusVisibleListener\n} from './useFocusVisible';\nexport {useFocusWithin} from './useFocusWithin';\nexport {useHover} from './useHover';\nexport {useInteractOutside} from './useInteractOutside';\nexport {useKeyboard} from './useKeyboard';\nexport {useMove} from './useMove';\nexport {usePress} from './usePress';\nexport {useScrollWheel} from './useScrollWheel';\nexport {useLongPress} from './useLongPress';\n\nexport type {FocusProps, FocusResult} from './useFocus';\nexport type {FocusVisibleHandler, FocusVisibleProps, FocusVisibleResult, Modality} from './useFocusVisible';\nexport type {FocusWithinProps, FocusWithinResult} from './useFocusWithin';\nexport type {HoverProps, HoverResult} from './useHover';\nexport type {InteractOutsideProps} from './useInteractOutside';\nexport type {KeyboardProps, KeyboardResult} from './useKeyboard';\nexport type {PressProps, PressHookProps, PressResult} from './usePress';\nexport type {MoveEvents} from '@react-types/shared';\nexport type {MoveResult} from './useMove';\nexport type {LongPressProps, LongPressResult} from './useLongPress';\nexport type {ScrollWheelProps} from './useScrollWheel';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/interactions",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/ssr": "^3.
|
|
26
|
-
"@react-aria/utils": "^3.
|
|
27
|
-
"@react-types/shared": "^3.
|
|
28
|
-
"@swc/helpers": "^0.
|
|
25
|
+
"@react-aria/ssr": "^3.7.1",
|
|
26
|
+
"@react-aria/utils": "^3.19.0",
|
|
27
|
+
"@react-types/shared": "^3.19.0",
|
|
28
|
+
"@swc/helpers": "^0.5.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "d4dfe4bb842a914f10045ee63fc6b92f034c5b30"
|
|
37
37
|
}
|
package/src/PressResponder.tsx
CHANGED
|
@@ -42,6 +42,7 @@ export const PressResponder = React.forwardRef(({children, ...props}: PressRespo
|
|
|
42
42
|
'A PressResponder was rendered without a pressable child. ' +
|
|
43
43
|
'Either call the usePress hook, or wrap your DOM node with <Pressable> component.'
|
|
44
44
|
);
|
|
45
|
+
isRegistered.current = true; // only warn once in strict mode.
|
|
45
46
|
}
|
|
46
47
|
}, []);
|
|
47
48
|
|
package/src/useHover.ts
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
// NOTICE file in the root directory of this source tree.
|
|
16
16
|
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
17
17
|
|
|
18
|
-
import {DOMAttributes} from '@react-types/shared';
|
|
19
|
-
import {HoverEvents} from '@react-types/shared';
|
|
18
|
+
import {DOMAttributes, HoverEvents} from '@react-types/shared';
|
|
20
19
|
import {useEffect, useMemo, useRef, useState} from 'react';
|
|
21
20
|
|
|
22
21
|
export interface HoverProps extends HoverEvents {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
17
17
|
|
|
18
18
|
import {RefObject, SyntheticEvent, useEffect, useRef} from 'react';
|
|
19
|
+
import {useEffectEvent} from '@react-aria/utils';
|
|
19
20
|
|
|
20
21
|
export interface InteractOutsideProps {
|
|
21
22
|
ref: RefObject<Element>,
|
|
@@ -33,33 +34,35 @@ export function useInteractOutside(props: InteractOutsideProps) {
|
|
|
33
34
|
let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;
|
|
34
35
|
let stateRef = useRef({
|
|
35
36
|
isPointerDown: false,
|
|
36
|
-
ignoreEmulatedMouseEvents: false
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
ignoreEmulatedMouseEvents: false
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
let onPointerDown = useEffectEvent((e: SyntheticEvent) => {
|
|
41
|
+
if (onInteractOutside && isValidEvent(e, ref)) {
|
|
42
|
+
if (onInteractOutsideStart) {
|
|
43
|
+
onInteractOutsideStart(e);
|
|
44
|
+
}
|
|
45
|
+
stateRef.current.isPointerDown = true;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let triggerInteractOutside = useEffectEvent((e: SyntheticEvent) => {
|
|
50
|
+
if (onInteractOutside) {
|
|
51
|
+
onInteractOutside(e);
|
|
52
|
+
}
|
|
39
53
|
});
|
|
40
|
-
let state = stateRef.current;
|
|
41
|
-
state.onInteractOutside = onInteractOutside;
|
|
42
|
-
state.onInteractOutsideStart = onInteractOutsideStart;
|
|
43
54
|
|
|
44
55
|
useEffect(() => {
|
|
56
|
+
let state = stateRef.current;
|
|
45
57
|
if (isDisabled) {
|
|
46
58
|
return;
|
|
47
59
|
}
|
|
48
60
|
|
|
49
|
-
let onPointerDown = (e) => {
|
|
50
|
-
if (isValidEvent(e, ref) && state.onInteractOutside) {
|
|
51
|
-
if (state.onInteractOutsideStart) {
|
|
52
|
-
state.onInteractOutsideStart(e);
|
|
53
|
-
}
|
|
54
|
-
state.isPointerDown = true;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
61
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
59
62
|
if (typeof PointerEvent !== 'undefined') {
|
|
60
63
|
let onPointerUp = (e) => {
|
|
61
|
-
if (state.isPointerDown &&
|
|
62
|
-
|
|
64
|
+
if (state.isPointerDown && isValidEvent(e, ref)) {
|
|
65
|
+
triggerInteractOutside(e);
|
|
63
66
|
}
|
|
64
67
|
state.isPointerDown = false;
|
|
65
68
|
};
|
|
@@ -76,16 +79,16 @@ export function useInteractOutside(props: InteractOutsideProps) {
|
|
|
76
79
|
let onMouseUp = (e) => {
|
|
77
80
|
if (state.ignoreEmulatedMouseEvents) {
|
|
78
81
|
state.ignoreEmulatedMouseEvents = false;
|
|
79
|
-
} else if (state.isPointerDown &&
|
|
80
|
-
|
|
82
|
+
} else if (state.isPointerDown && isValidEvent(e, ref)) {
|
|
83
|
+
triggerInteractOutside(e);
|
|
81
84
|
}
|
|
82
85
|
state.isPointerDown = false;
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
let onTouchEnd = (e) => {
|
|
86
89
|
state.ignoreEmulatedMouseEvents = true;
|
|
87
|
-
if (state.
|
|
88
|
-
|
|
90
|
+
if (state.isPointerDown && isValidEvent(e, ref)) {
|
|
91
|
+
triggerInteractOutside(e);
|
|
89
92
|
}
|
|
90
93
|
state.isPointerDown = false;
|
|
91
94
|
};
|
|
@@ -102,7 +105,7 @@ export function useInteractOutside(props: InteractOutsideProps) {
|
|
|
102
105
|
document.removeEventListener('touchend', onTouchEnd, true);
|
|
103
106
|
};
|
|
104
107
|
}
|
|
105
|
-
}, [ref,
|
|
108
|
+
}, [ref, isDisabled, onPointerDown, triggerInteractOutside]);
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
function isValidEvent(event, ref) {
|
package/src/useLongPress.ts
CHANGED
|
@@ -69,6 +69,7 @@ export function useLongPress(props: LongPressProps): LongPressResult {
|
|
|
69
69
|
let {pressProps} = usePress({
|
|
70
70
|
isDisabled,
|
|
71
71
|
onPressStart(e) {
|
|
72
|
+
e.continuePropagation();
|
|
72
73
|
if (e.pointerType === 'mouse' || e.pointerType === 'touch') {
|
|
73
74
|
if (onLongPressStart) {
|
|
74
75
|
onLongPressStart({
|
package/src/useMove.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import {disableTextSelection, restoreTextSelection} from './textSelection';
|
|
14
14
|
import {DOMAttributes, MoveEvents, PointerType} from '@react-types/shared';
|
|
15
15
|
import React, {useMemo, useRef} from 'react';
|
|
16
|
-
import {useGlobalListeners} from '@react-aria/utils';
|
|
16
|
+
import {useEffectEvent, useGlobalListeners} from '@react-aria/utils';
|
|
17
17
|
|
|
18
18
|
export interface MoveResult {
|
|
19
19
|
/** Props to spread on the target element. */
|
|
@@ -43,52 +43,54 @@ export function useMove(props: MoveEvents): MoveResult {
|
|
|
43
43
|
|
|
44
44
|
let {addGlobalListener, removeGlobalListener} = useGlobalListeners();
|
|
45
45
|
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
disableTextSelection();
|
|
51
|
-
state.current.didMove = false;
|
|
52
|
-
};
|
|
53
|
-
let move = (originalEvent: EventBase, pointerType: PointerType, deltaX: number, deltaY: number) => {
|
|
54
|
-
if (deltaX === 0 && deltaY === 0) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
46
|
+
let move = useEffectEvent((originalEvent: EventBase, pointerType: PointerType, deltaX: number, deltaY: number) => {
|
|
47
|
+
if (deltaX === 0 && deltaY === 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
pointerType,
|
|
63
|
-
shiftKey: originalEvent.shiftKey,
|
|
64
|
-
metaKey: originalEvent.metaKey,
|
|
65
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
66
|
-
altKey: originalEvent.altKey
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
onMove({
|
|
70
|
-
type: 'move',
|
|
51
|
+
if (!state.current.didMove) {
|
|
52
|
+
state.current.didMove = true;
|
|
53
|
+
onMoveStart?.({
|
|
54
|
+
type: 'movestart',
|
|
71
55
|
pointerType,
|
|
72
|
-
deltaX: deltaX,
|
|
73
|
-
deltaY: deltaY,
|
|
74
56
|
shiftKey: originalEvent.shiftKey,
|
|
75
57
|
metaKey: originalEvent.metaKey,
|
|
76
58
|
ctrlKey: originalEvent.ctrlKey,
|
|
77
59
|
altKey: originalEvent.altKey
|
|
78
60
|
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
61
|
+
}
|
|
62
|
+
onMove({
|
|
63
|
+
type: 'move',
|
|
64
|
+
pointerType,
|
|
65
|
+
deltaX: deltaX,
|
|
66
|
+
deltaY: deltaY,
|
|
67
|
+
shiftKey: originalEvent.shiftKey,
|
|
68
|
+
metaKey: originalEvent.metaKey,
|
|
69
|
+
ctrlKey: originalEvent.ctrlKey,
|
|
70
|
+
altKey: originalEvent.altKey
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
let end = useEffectEvent((originalEvent: EventBase, pointerType: PointerType) => {
|
|
75
|
+
restoreTextSelection();
|
|
76
|
+
if (state.current.didMove) {
|
|
77
|
+
onMoveEnd?.({
|
|
78
|
+
type: 'moveend',
|
|
79
|
+
pointerType,
|
|
80
|
+
shiftKey: originalEvent.shiftKey,
|
|
81
|
+
metaKey: originalEvent.metaKey,
|
|
82
|
+
ctrlKey: originalEvent.ctrlKey,
|
|
83
|
+
altKey: originalEvent.altKey
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
let moveProps = useMemo(() => {
|
|
89
|
+
let moveProps: DOMAttributes = {};
|
|
90
|
+
|
|
91
|
+
let start = () => {
|
|
92
|
+
disableTextSelection();
|
|
93
|
+
state.current.didMove = false;
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
if (typeof PointerEvent === 'undefined') {
|
|
@@ -223,7 +225,7 @@ export function useMove(props: MoveEvents): MoveResult {
|
|
|
223
225
|
};
|
|
224
226
|
|
|
225
227
|
return moveProps;
|
|
226
|
-
}, [state,
|
|
228
|
+
}, [state, addGlobalListener, removeGlobalListener, move, end]);
|
|
227
229
|
|
|
228
230
|
return {moveProps};
|
|
229
231
|
}
|