@react-aria/interactions 3.21.2 → 3.21.3
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/PressResponder.mjs +1 -1
- package/dist/Pressable.mjs +1 -1
- package/dist/context.main.js +1 -1
- package/dist/context.mjs +2 -2
- package/dist/context.module.js +1 -1
- package/dist/createEventHandler.main.js +1 -1
- package/dist/createEventHandler.mjs +2 -2
- package/dist/createEventHandler.module.js +1 -1
- package/dist/textSelection.main.js +14 -14
- package/dist/textSelection.mjs +15 -15
- package/dist/textSelection.module.js +14 -14
- package/dist/useFocus.mjs +1 -1
- package/dist/useFocusVisible.main.js +54 -54
- package/dist/useFocusVisible.mjs +55 -55
- package/dist/useFocusVisible.module.js +54 -54
- package/dist/useFocusWithin.mjs +1 -1
- package/dist/useHover.main.js +16 -16
- package/dist/useHover.mjs +17 -17
- package/dist/useHover.module.js +16 -16
- package/dist/useInteractOutside.main.js +14 -14
- package/dist/useInteractOutside.mjs +15 -15
- package/dist/useInteractOutside.module.js +14 -14
- package/dist/useKeyboard.mjs +1 -1
- package/dist/useLongPress.main.js +10 -10
- package/dist/useLongPress.mjs +11 -11
- package/dist/useLongPress.module.js +10 -10
- package/dist/useMove.main.js +36 -36
- package/dist/useMove.mjs +37 -37
- package/dist/useMove.module.js +36 -36
- package/dist/usePress.main.js +44 -44
- package/dist/usePress.mjs +45 -45
- package/dist/usePress.module.js +44 -44
- package/dist/useScrollWheel.main.js +1 -1
- package/dist/useScrollWheel.mjs +2 -2
- package/dist/useScrollWheel.module.js +1 -1
- package/dist/utils.main.js +5 -5
- package/dist/utils.mjs +6 -6
- package/dist/utils.module.js +5 -5
- package/package.json +5 -5
package/dist/useMove.mjs
CHANGED
|
@@ -28,7 +28,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
28
28
|
if (!state.current.didMove) {
|
|
29
29
|
state.current.didMove = true;
|
|
30
30
|
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
31
|
-
type:
|
|
31
|
+
type: 'movestart',
|
|
32
32
|
pointerType: pointerType,
|
|
33
33
|
shiftKey: originalEvent.shiftKey,
|
|
34
34
|
metaKey: originalEvent.metaKey,
|
|
@@ -37,7 +37,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
onMove === null || onMove === void 0 ? void 0 : onMove({
|
|
40
|
-
type:
|
|
40
|
+
type: 'move',
|
|
41
41
|
pointerType: pointerType,
|
|
42
42
|
deltaX: deltaX,
|
|
43
43
|
deltaY: deltaY,
|
|
@@ -50,7 +50,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
50
50
|
let end = (0, $5GN7j$useEffectEvent)((originalEvent, pointerType)=>{
|
|
51
51
|
(0, $14c0b72509d70225$export$b0d6fa1ab32e3295)();
|
|
52
52
|
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
53
|
-
type:
|
|
53
|
+
type: 'moveend',
|
|
54
54
|
pointerType: pointerType,
|
|
55
55
|
shiftKey: originalEvent.shiftKey,
|
|
56
56
|
metaKey: originalEvent.metaKey,
|
|
@@ -64,12 +64,12 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
64
64
|
(0, $14c0b72509d70225$export$16a4697467175487)();
|
|
65
65
|
state.current.didMove = false;
|
|
66
66
|
};
|
|
67
|
-
if (typeof PointerEvent ===
|
|
67
|
+
if (typeof PointerEvent === 'undefined') {
|
|
68
68
|
let onMouseMove = (e)=>{
|
|
69
69
|
if (e.button === 0) {
|
|
70
70
|
var _state_current_lastPosition, _state_current_lastPosition1;
|
|
71
71
|
var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
|
72
|
-
move(e,
|
|
72
|
+
move(e, 'mouse', e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
|
73
73
|
state.current.lastPosition = {
|
|
74
74
|
pageX: e.pageX,
|
|
75
75
|
pageY: e.pageY
|
|
@@ -78,9 +78,9 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
78
78
|
};
|
|
79
79
|
let onMouseUp = (e)=>{
|
|
80
80
|
if (e.button === 0) {
|
|
81
|
-
end(e,
|
|
82
|
-
removeGlobalListener(window,
|
|
83
|
-
removeGlobalListener(window,
|
|
81
|
+
end(e, 'mouse');
|
|
82
|
+
removeGlobalListener(window, 'mousemove', onMouseMove, false);
|
|
83
|
+
removeGlobalListener(window, 'mouseup', onMouseUp, false);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
moveProps.onMouseDown = (e)=>{
|
|
@@ -92,8 +92,8 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
92
92
|
pageX: e.pageX,
|
|
93
93
|
pageY: e.pageY
|
|
94
94
|
};
|
|
95
|
-
addGlobalListener(window,
|
|
96
|
-
addGlobalListener(window,
|
|
95
|
+
addGlobalListener(window, 'mousemove', onMouseMove, false);
|
|
96
|
+
addGlobalListener(window, 'mouseup', onMouseUp, false);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
let onTouchMove = (e)=>{
|
|
@@ -104,7 +104,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
104
104
|
var _state_current_lastPosition, _state_current_lastPosition1;
|
|
105
105
|
let { pageX: pageX, pageY: pageY } = e.changedTouches[touch];
|
|
106
106
|
var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
|
107
|
-
move(e,
|
|
107
|
+
move(e, 'touch', pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
|
108
108
|
state.current.lastPosition = {
|
|
109
109
|
pageX: pageX,
|
|
110
110
|
pageY: pageY
|
|
@@ -116,11 +116,11 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
116
116
|
...e.changedTouches
|
|
117
117
|
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
118
118
|
if (touch >= 0) {
|
|
119
|
-
end(e,
|
|
119
|
+
end(e, 'touch');
|
|
120
120
|
state.current.id = null;
|
|
121
|
-
removeGlobalListener(window,
|
|
122
|
-
removeGlobalListener(window,
|
|
123
|
-
removeGlobalListener(window,
|
|
121
|
+
removeGlobalListener(window, 'touchmove', onTouchMove);
|
|
122
|
+
removeGlobalListener(window, 'touchend', onTouchEnd);
|
|
123
|
+
removeGlobalListener(window, 'touchcancel', onTouchEnd);
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
moveProps.onTouchStart = (e)=>{
|
|
@@ -134,15 +134,15 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
134
134
|
pageY: pageY
|
|
135
135
|
};
|
|
136
136
|
state.current.id = identifier;
|
|
137
|
-
addGlobalListener(window,
|
|
138
|
-
addGlobalListener(window,
|
|
139
|
-
addGlobalListener(window,
|
|
137
|
+
addGlobalListener(window, 'touchmove', onTouchMove, false);
|
|
138
|
+
addGlobalListener(window, 'touchend', onTouchEnd, false);
|
|
139
|
+
addGlobalListener(window, 'touchcancel', onTouchEnd, false);
|
|
140
140
|
};
|
|
141
141
|
} else {
|
|
142
142
|
let onPointerMove = (e)=>{
|
|
143
143
|
if (e.pointerId === state.current.id) {
|
|
144
144
|
var _state_current_lastPosition, _state_current_lastPosition1;
|
|
145
|
-
let pointerType = e.pointerType ||
|
|
145
|
+
let pointerType = e.pointerType || 'mouse';
|
|
146
146
|
var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
|
147
147
|
// Problems with PointerEvent#movementX/movementY:
|
|
148
148
|
// 1. it is always 0 on macOS Safari.
|
|
@@ -156,12 +156,12 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
156
156
|
};
|
|
157
157
|
let onPointerUp = (e)=>{
|
|
158
158
|
if (e.pointerId === state.current.id) {
|
|
159
|
-
let pointerType = e.pointerType ||
|
|
159
|
+
let pointerType = e.pointerType || 'mouse';
|
|
160
160
|
end(e, pointerType);
|
|
161
161
|
state.current.id = null;
|
|
162
|
-
removeGlobalListener(window,
|
|
163
|
-
removeGlobalListener(window,
|
|
164
|
-
removeGlobalListener(window,
|
|
162
|
+
removeGlobalListener(window, 'pointermove', onPointerMove, false);
|
|
163
|
+
removeGlobalListener(window, 'pointerup', onPointerUp, false);
|
|
164
|
+
removeGlobalListener(window, 'pointercancel', onPointerUp, false);
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
167
|
moveProps.onPointerDown = (e)=>{
|
|
@@ -174,39 +174,39 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
174
174
|
pageY: e.pageY
|
|
175
175
|
};
|
|
176
176
|
state.current.id = e.pointerId;
|
|
177
|
-
addGlobalListener(window,
|
|
178
|
-
addGlobalListener(window,
|
|
179
|
-
addGlobalListener(window,
|
|
177
|
+
addGlobalListener(window, 'pointermove', onPointerMove, false);
|
|
178
|
+
addGlobalListener(window, 'pointerup', onPointerUp, false);
|
|
179
|
+
addGlobalListener(window, 'pointercancel', onPointerUp, false);
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
|
184
184
|
start();
|
|
185
|
-
move(e,
|
|
186
|
-
end(e,
|
|
185
|
+
move(e, 'keyboard', deltaX, deltaY);
|
|
186
|
+
end(e, 'keyboard');
|
|
187
187
|
};
|
|
188
188
|
moveProps.onKeyDown = (e)=>{
|
|
189
189
|
switch(e.key){
|
|
190
|
-
case
|
|
191
|
-
case
|
|
190
|
+
case 'Left':
|
|
191
|
+
case 'ArrowLeft':
|
|
192
192
|
e.preventDefault();
|
|
193
193
|
e.stopPropagation();
|
|
194
194
|
triggerKeyboardMove(e, -1, 0);
|
|
195
195
|
break;
|
|
196
|
-
case
|
|
197
|
-
case
|
|
196
|
+
case 'Right':
|
|
197
|
+
case 'ArrowRight':
|
|
198
198
|
e.preventDefault();
|
|
199
199
|
e.stopPropagation();
|
|
200
200
|
triggerKeyboardMove(e, 1, 0);
|
|
201
201
|
break;
|
|
202
|
-
case
|
|
203
|
-
case
|
|
202
|
+
case 'Up':
|
|
203
|
+
case 'ArrowUp':
|
|
204
204
|
e.preventDefault();
|
|
205
205
|
e.stopPropagation();
|
|
206
206
|
triggerKeyboardMove(e, 0, -1);
|
|
207
207
|
break;
|
|
208
|
-
case
|
|
209
|
-
case
|
|
208
|
+
case 'Down':
|
|
209
|
+
case 'ArrowDown':
|
|
210
210
|
e.preventDefault();
|
|
211
211
|
e.stopPropagation();
|
|
212
212
|
triggerKeyboardMove(e, 0, 1);
|
|
@@ -228,4 +228,4 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
228
228
|
|
|
229
229
|
|
|
230
230
|
export {$e8a7022cf87cba2a$export$36da96379f79f245 as useMove};
|
|
231
|
-
//# sourceMappingURL=useMove.
|
|
231
|
+
//# sourceMappingURL=useMove.module.js.map
|
package/dist/useMove.module.js
CHANGED
|
@@ -28,7 +28,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
28
28
|
if (!state.current.didMove) {
|
|
29
29
|
state.current.didMove = true;
|
|
30
30
|
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
31
|
-
type:
|
|
31
|
+
type: 'movestart',
|
|
32
32
|
pointerType: pointerType,
|
|
33
33
|
shiftKey: originalEvent.shiftKey,
|
|
34
34
|
metaKey: originalEvent.metaKey,
|
|
@@ -37,7 +37,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
onMove === null || onMove === void 0 ? void 0 : onMove({
|
|
40
|
-
type:
|
|
40
|
+
type: 'move',
|
|
41
41
|
pointerType: pointerType,
|
|
42
42
|
deltaX: deltaX,
|
|
43
43
|
deltaY: deltaY,
|
|
@@ -50,7 +50,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
50
50
|
let end = (0, $5GN7j$useEffectEvent)((originalEvent, pointerType)=>{
|
|
51
51
|
(0, $14c0b72509d70225$export$b0d6fa1ab32e3295)();
|
|
52
52
|
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
53
|
-
type:
|
|
53
|
+
type: 'moveend',
|
|
54
54
|
pointerType: pointerType,
|
|
55
55
|
shiftKey: originalEvent.shiftKey,
|
|
56
56
|
metaKey: originalEvent.metaKey,
|
|
@@ -64,12 +64,12 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
64
64
|
(0, $14c0b72509d70225$export$16a4697467175487)();
|
|
65
65
|
state.current.didMove = false;
|
|
66
66
|
};
|
|
67
|
-
if (typeof PointerEvent ===
|
|
67
|
+
if (typeof PointerEvent === 'undefined') {
|
|
68
68
|
let onMouseMove = (e)=>{
|
|
69
69
|
if (e.button === 0) {
|
|
70
70
|
var _state_current_lastPosition, _state_current_lastPosition1;
|
|
71
71
|
var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
|
72
|
-
move(e,
|
|
72
|
+
move(e, 'mouse', e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
|
73
73
|
state.current.lastPosition = {
|
|
74
74
|
pageX: e.pageX,
|
|
75
75
|
pageY: e.pageY
|
|
@@ -78,9 +78,9 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
78
78
|
};
|
|
79
79
|
let onMouseUp = (e)=>{
|
|
80
80
|
if (e.button === 0) {
|
|
81
|
-
end(e,
|
|
82
|
-
removeGlobalListener(window,
|
|
83
|
-
removeGlobalListener(window,
|
|
81
|
+
end(e, 'mouse');
|
|
82
|
+
removeGlobalListener(window, 'mousemove', onMouseMove, false);
|
|
83
|
+
removeGlobalListener(window, 'mouseup', onMouseUp, false);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
moveProps.onMouseDown = (e)=>{
|
|
@@ -92,8 +92,8 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
92
92
|
pageX: e.pageX,
|
|
93
93
|
pageY: e.pageY
|
|
94
94
|
};
|
|
95
|
-
addGlobalListener(window,
|
|
96
|
-
addGlobalListener(window,
|
|
95
|
+
addGlobalListener(window, 'mousemove', onMouseMove, false);
|
|
96
|
+
addGlobalListener(window, 'mouseup', onMouseUp, false);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
let onTouchMove = (e)=>{
|
|
@@ -104,7 +104,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
104
104
|
var _state_current_lastPosition, _state_current_lastPosition1;
|
|
105
105
|
let { pageX: pageX, pageY: pageY } = e.changedTouches[touch];
|
|
106
106
|
var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
|
107
|
-
move(e,
|
|
107
|
+
move(e, 'touch', pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
|
108
108
|
state.current.lastPosition = {
|
|
109
109
|
pageX: pageX,
|
|
110
110
|
pageY: pageY
|
|
@@ -116,11 +116,11 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
116
116
|
...e.changedTouches
|
|
117
117
|
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
118
118
|
if (touch >= 0) {
|
|
119
|
-
end(e,
|
|
119
|
+
end(e, 'touch');
|
|
120
120
|
state.current.id = null;
|
|
121
|
-
removeGlobalListener(window,
|
|
122
|
-
removeGlobalListener(window,
|
|
123
|
-
removeGlobalListener(window,
|
|
121
|
+
removeGlobalListener(window, 'touchmove', onTouchMove);
|
|
122
|
+
removeGlobalListener(window, 'touchend', onTouchEnd);
|
|
123
|
+
removeGlobalListener(window, 'touchcancel', onTouchEnd);
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
moveProps.onTouchStart = (e)=>{
|
|
@@ -134,15 +134,15 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
134
134
|
pageY: pageY
|
|
135
135
|
};
|
|
136
136
|
state.current.id = identifier;
|
|
137
|
-
addGlobalListener(window,
|
|
138
|
-
addGlobalListener(window,
|
|
139
|
-
addGlobalListener(window,
|
|
137
|
+
addGlobalListener(window, 'touchmove', onTouchMove, false);
|
|
138
|
+
addGlobalListener(window, 'touchend', onTouchEnd, false);
|
|
139
|
+
addGlobalListener(window, 'touchcancel', onTouchEnd, false);
|
|
140
140
|
};
|
|
141
141
|
} else {
|
|
142
142
|
let onPointerMove = (e)=>{
|
|
143
143
|
if (e.pointerId === state.current.id) {
|
|
144
144
|
var _state_current_lastPosition, _state_current_lastPosition1;
|
|
145
|
-
let pointerType = e.pointerType ||
|
|
145
|
+
let pointerType = e.pointerType || 'mouse';
|
|
146
146
|
var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
|
147
147
|
// Problems with PointerEvent#movementX/movementY:
|
|
148
148
|
// 1. it is always 0 on macOS Safari.
|
|
@@ -156,12 +156,12 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
156
156
|
};
|
|
157
157
|
let onPointerUp = (e)=>{
|
|
158
158
|
if (e.pointerId === state.current.id) {
|
|
159
|
-
let pointerType = e.pointerType ||
|
|
159
|
+
let pointerType = e.pointerType || 'mouse';
|
|
160
160
|
end(e, pointerType);
|
|
161
161
|
state.current.id = null;
|
|
162
|
-
removeGlobalListener(window,
|
|
163
|
-
removeGlobalListener(window,
|
|
164
|
-
removeGlobalListener(window,
|
|
162
|
+
removeGlobalListener(window, 'pointermove', onPointerMove, false);
|
|
163
|
+
removeGlobalListener(window, 'pointerup', onPointerUp, false);
|
|
164
|
+
removeGlobalListener(window, 'pointercancel', onPointerUp, false);
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
167
|
moveProps.onPointerDown = (e)=>{
|
|
@@ -174,39 +174,39 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
174
174
|
pageY: e.pageY
|
|
175
175
|
};
|
|
176
176
|
state.current.id = e.pointerId;
|
|
177
|
-
addGlobalListener(window,
|
|
178
|
-
addGlobalListener(window,
|
|
179
|
-
addGlobalListener(window,
|
|
177
|
+
addGlobalListener(window, 'pointermove', onPointerMove, false);
|
|
178
|
+
addGlobalListener(window, 'pointerup', onPointerUp, false);
|
|
179
|
+
addGlobalListener(window, 'pointercancel', onPointerUp, false);
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
|
184
184
|
start();
|
|
185
|
-
move(e,
|
|
186
|
-
end(e,
|
|
185
|
+
move(e, 'keyboard', deltaX, deltaY);
|
|
186
|
+
end(e, 'keyboard');
|
|
187
187
|
};
|
|
188
188
|
moveProps.onKeyDown = (e)=>{
|
|
189
189
|
switch(e.key){
|
|
190
|
-
case
|
|
191
|
-
case
|
|
190
|
+
case 'Left':
|
|
191
|
+
case 'ArrowLeft':
|
|
192
192
|
e.preventDefault();
|
|
193
193
|
e.stopPropagation();
|
|
194
194
|
triggerKeyboardMove(e, -1, 0);
|
|
195
195
|
break;
|
|
196
|
-
case
|
|
197
|
-
case
|
|
196
|
+
case 'Right':
|
|
197
|
+
case 'ArrowRight':
|
|
198
198
|
e.preventDefault();
|
|
199
199
|
e.stopPropagation();
|
|
200
200
|
triggerKeyboardMove(e, 1, 0);
|
|
201
201
|
break;
|
|
202
|
-
case
|
|
203
|
-
case
|
|
202
|
+
case 'Up':
|
|
203
|
+
case 'ArrowUp':
|
|
204
204
|
e.preventDefault();
|
|
205
205
|
e.stopPropagation();
|
|
206
206
|
triggerKeyboardMove(e, 0, -1);
|
|
207
207
|
break;
|
|
208
|
-
case
|
|
209
|
-
case
|
|
208
|
+
case 'Down':
|
|
209
|
+
case 'ArrowDown':
|
|
210
210
|
e.preventDefault();
|
|
211
211
|
e.stopPropagation();
|
|
212
212
|
triggerKeyboardMove(e, 0, 1);
|
package/dist/usePress.main.js
CHANGED
|
@@ -67,7 +67,7 @@ class $0294ea432cd92340$var$PressEvent {
|
|
|
67
67
|
this.altKey = originalEvent.altKey;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
const $0294ea432cd92340$var$LINK_CLICKED = Symbol(
|
|
70
|
+
const $0294ea432cd92340$var$LINK_CLICKED = Symbol('linkClicked');
|
|
71
71
|
function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
72
72
|
let { onPress: onPress, onPressChange: onPressChange, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, isDisabled: isDisabled, isPressed: isPressedProp, preventFocusOnPress: preventFocusOnPress, shouldCancelOnPointerExit: shouldCancelOnPointerExit, allowTextSelectionOnPress: allowTextSelectionOnPress, // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
73
73
|
ref: _, ...domProps } = $0294ea432cd92340$var$usePressResponderContext(props);
|
|
@@ -90,7 +90,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
90
90
|
let shouldStopPropagation = true;
|
|
91
91
|
state.isTriggeringEvent = true;
|
|
92
92
|
if (onPressStart) {
|
|
93
|
-
let event = new $0294ea432cd92340$var$PressEvent(
|
|
93
|
+
let event = new $0294ea432cd92340$var$PressEvent('pressstart', pointerType, originalEvent);
|
|
94
94
|
onPressStart(event);
|
|
95
95
|
shouldStopPropagation = event.shouldStopPropagation;
|
|
96
96
|
}
|
|
@@ -108,14 +108,14 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
108
108
|
state.isTriggeringEvent = true;
|
|
109
109
|
let shouldStopPropagation = true;
|
|
110
110
|
if (onPressEnd) {
|
|
111
|
-
let event = new $0294ea432cd92340$var$PressEvent(
|
|
111
|
+
let event = new $0294ea432cd92340$var$PressEvent('pressend', pointerType, originalEvent);
|
|
112
112
|
onPressEnd(event);
|
|
113
113
|
shouldStopPropagation = event.shouldStopPropagation;
|
|
114
114
|
}
|
|
115
115
|
if (onPressChange) onPressChange(false);
|
|
116
116
|
setPressed(false);
|
|
117
117
|
if (onPress && wasPressed && !isDisabled) {
|
|
118
|
-
let event = new $0294ea432cd92340$var$PressEvent(
|
|
118
|
+
let event = new $0294ea432cd92340$var$PressEvent('press', pointerType, originalEvent);
|
|
119
119
|
onPress(event);
|
|
120
120
|
shouldStopPropagation && (shouldStopPropagation = event.shouldStopPropagation);
|
|
121
121
|
}
|
|
@@ -127,7 +127,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
127
127
|
if (isDisabled) return false;
|
|
128
128
|
if (onPressUp) {
|
|
129
129
|
state.isTriggeringEvent = true;
|
|
130
|
-
let event = new $0294ea432cd92340$var$PressEvent(
|
|
130
|
+
let event = new $0294ea432cd92340$var$PressEvent('pressup', pointerType, originalEvent);
|
|
131
131
|
onPressUp(event);
|
|
132
132
|
state.isTriggeringEvent = false;
|
|
133
133
|
return event.shouldStopPropagation;
|
|
@@ -163,15 +163,15 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
163
163
|
if (!state.isPressed && !e.repeat) {
|
|
164
164
|
state.target = e.currentTarget;
|
|
165
165
|
state.isPressed = true;
|
|
166
|
-
shouldStopPropagation = triggerPressStart(e,
|
|
166
|
+
shouldStopPropagation = triggerPressStart(e, 'keyboard');
|
|
167
167
|
// Focus may move before the key up event, so register the event on the document
|
|
168
168
|
// instead of the same element where the key down event occurred. Make it capturing so that it will trigger
|
|
169
169
|
// before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.
|
|
170
170
|
let originalTarget = e.currentTarget;
|
|
171
171
|
let pressUp = (e)=>{
|
|
172
|
-
if ($0294ea432cd92340$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && originalTarget.contains(e.target) && state.target) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e),
|
|
172
|
+
if ($0294ea432cd92340$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && originalTarget.contains(e.target) && state.target) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard');
|
|
173
173
|
};
|
|
174
|
-
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget),
|
|
174
|
+
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'keyup', (0, $bBqCQ$reactariautils.chain)(pressUp, onKeyUp), true);
|
|
175
175
|
}
|
|
176
176
|
if (shouldStopPropagation) e.stopPropagation();
|
|
177
177
|
// Keep track of the keydown events that occur while the Meta (e.g. Command) key is held.
|
|
@@ -182,7 +182,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
182
182
|
// https://bugs.webkit.org/show_bug.cgi?id=55291
|
|
183
183
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1299553
|
|
184
184
|
if (e.metaKey && (0, $bBqCQ$reactariautils.isMac)()) (_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.set(e.key, e.nativeEvent);
|
|
185
|
-
} else if (e.key ===
|
|
185
|
+
} else if (e.key === 'Meta') state.metaKeyEvents = new Map();
|
|
186
186
|
},
|
|
187
187
|
onClick (e) {
|
|
188
188
|
if (e && !e.currentTarget.contains(e.target)) return;
|
|
@@ -191,12 +191,12 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
191
191
|
if (isDisabled) e.preventDefault();
|
|
192
192
|
// If triggered from a screen reader or by using element.click(),
|
|
193
193
|
// trigger as if it were a keyboard click.
|
|
194
|
-
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType ===
|
|
194
|
+
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === 'virtual' || (0, $bBqCQ$reactariautils.isVirtualClick)(e.nativeEvent))) {
|
|
195
195
|
// Ensure the element receives focus (VoiceOver on iOS does not do this)
|
|
196
196
|
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
197
|
-
let stopPressStart = triggerPressStart(e,
|
|
198
|
-
let stopPressUp = triggerPressUp(e,
|
|
199
|
-
let stopPressEnd = triggerPressEnd(e,
|
|
197
|
+
let stopPressStart = triggerPressStart(e, 'virtual');
|
|
198
|
+
let stopPressUp = triggerPressUp(e, 'virtual');
|
|
199
|
+
let stopPressEnd = triggerPressEnd(e, 'virtual');
|
|
200
200
|
shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
|
|
201
201
|
}
|
|
202
202
|
state.ignoreEmulatedMouseEvents = false;
|
|
@@ -211,12 +211,12 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
211
211
|
var _state_metaKeyEvents1;
|
|
212
212
|
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
|
213
213
|
let target = e.target;
|
|
214
|
-
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e),
|
|
214
|
+
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard', state.target.contains(target));
|
|
215
215
|
removeAllGlobalListeners();
|
|
216
216
|
// If a link was triggered with a key other than Enter, open the URL ourselves.
|
|
217
217
|
// This means the link has a role override, and the default browser behavior
|
|
218
218
|
// only applies when using the Enter key.
|
|
219
|
-
if (e.key !==
|
|
219
|
+
if (e.key !== 'Enter' && $0294ea432cd92340$var$isHTMLAnchorLink(state.target) && state.target.contains(target) && !e[$0294ea432cd92340$var$LINK_CLICKED]) {
|
|
220
220
|
// Store a hidden property on the event so we only trigger link click once,
|
|
221
221
|
// even if there are multiple usePress instances attached to the element.
|
|
222
222
|
e[$0294ea432cd92340$var$LINK_CLICKED] = true;
|
|
@@ -224,17 +224,17 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
224
224
|
}
|
|
225
225
|
state.isPressed = false;
|
|
226
226
|
(_state_metaKeyEvents1 = state.metaKeyEvents) === null || _state_metaKeyEvents1 === void 0 ? void 0 : _state_metaKeyEvents1.delete(e.key);
|
|
227
|
-
} else if (e.key ===
|
|
227
|
+
} else if (e.key === 'Meta' && ((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.size)) {
|
|
228
228
|
var _state_target;
|
|
229
229
|
// If we recorded keydown events that occurred while the Meta key was pressed,
|
|
230
230
|
// and those haven't received keyup events already, fire keyup events ourselves.
|
|
231
231
|
// See comment above for more info about the macOS bug causing this.
|
|
232
232
|
let events = state.metaKeyEvents;
|
|
233
233
|
state.metaKeyEvents = undefined;
|
|
234
|
-
for (let event of events.values())(_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.dispatchEvent(new KeyboardEvent(
|
|
234
|
+
for (let event of events.values())(_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.dispatchEvent(new KeyboardEvent('keyup', event));
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
|
-
if (typeof PointerEvent !==
|
|
237
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
238
238
|
pressProps.onPointerDown = (e)=>{
|
|
239
239
|
// Only handle left clicks, and ignore events that bubbled through portals.
|
|
240
240
|
if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
|
|
@@ -243,7 +243,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
243
243
|
// https://bugs.webkit.org/show_bug.cgi?id=222627
|
|
244
244
|
// https://bugs.webkit.org/show_bug.cgi?id=223202
|
|
245
245
|
if ((0, $bBqCQ$reactariautils.isVirtualPointerEvent)(e.nativeEvent)) {
|
|
246
|
-
state.pointerType =
|
|
246
|
+
state.pointerType = 'virtual';
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
@@ -259,9 +259,9 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
259
259
|
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
260
260
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.disableTextSelection)(state.target);
|
|
261
261
|
shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
262
|
-
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget),
|
|
263
|
-
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget),
|
|
264
|
-
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget),
|
|
262
|
+
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'pointermove', onPointerMove, false);
|
|
263
|
+
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'pointerup', onPointerUp, false);
|
|
264
|
+
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'pointercancel', onPointerCancel, false);
|
|
265
265
|
}
|
|
266
266
|
if (shouldStopPropagation) e.stopPropagation();
|
|
267
267
|
};
|
|
@@ -277,7 +277,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
277
277
|
};
|
|
278
278
|
pressProps.onPointerUp = (e)=>{
|
|
279
279
|
// iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.
|
|
280
|
-
if (!e.currentTarget.contains(e.target) || state.pointerType ===
|
|
280
|
+
if (!e.currentTarget.contains(e.target) || state.pointerType === 'virtual') return;
|
|
281
281
|
// Only handle left clicks
|
|
282
282
|
// Safari on iOS sometimes fires pointerup events, even
|
|
283
283
|
// when the touch isn't over the target, so double check.
|
|
@@ -333,11 +333,11 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
333
333
|
state.isPressed = true;
|
|
334
334
|
state.isOverTarget = true;
|
|
335
335
|
state.target = e.currentTarget;
|
|
336
|
-
state.pointerType = (0, $bBqCQ$reactariautils.isVirtualClick)(e.nativeEvent) ?
|
|
336
|
+
state.pointerType = (0, $bBqCQ$reactariautils.isVirtualClick)(e.nativeEvent) ? 'virtual' : 'mouse';
|
|
337
337
|
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
338
338
|
let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
339
339
|
if (shouldStopPropagation) e.stopPropagation();
|
|
340
|
-
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget),
|
|
340
|
+
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'mouseup', onMouseUp, false);
|
|
341
341
|
};
|
|
342
342
|
pressProps.onMouseEnter = (e)=>{
|
|
343
343
|
if (!e.currentTarget.contains(e.target)) return;
|
|
@@ -360,7 +360,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
360
360
|
};
|
|
361
361
|
pressProps.onMouseUp = (e)=>{
|
|
362
362
|
if (!e.currentTarget.contains(e.target)) return;
|
|
363
|
-
if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType ||
|
|
363
|
+
if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType || 'mouse');
|
|
364
364
|
};
|
|
365
365
|
let onMouseUp = (e)=>{
|
|
366
366
|
// Only handle left clicks
|
|
@@ -384,14 +384,14 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
384
384
|
state.isOverTarget = true;
|
|
385
385
|
state.isPressed = true;
|
|
386
386
|
state.target = e.currentTarget;
|
|
387
|
-
state.pointerType =
|
|
387
|
+
state.pointerType = 'touch';
|
|
388
388
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent default
|
|
389
389
|
// on the emulated mouse event and handle focusing the pressable element ourselves.
|
|
390
390
|
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
391
391
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.disableTextSelection)(state.target);
|
|
392
392
|
let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
393
393
|
if (shouldStopPropagation) e.stopPropagation();
|
|
394
|
-
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerWindow)(e.currentTarget),
|
|
394
|
+
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerWindow)(e.currentTarget), 'scroll', onScroll, true);
|
|
395
395
|
};
|
|
396
396
|
pressProps.onTouchMove = (e)=>{
|
|
397
397
|
if (!e.currentTarget.contains(e.target)) return;
|
|
@@ -482,16 +482,16 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
function $0294ea432cd92340$var$isHTMLAnchorLink(target) {
|
|
485
|
-
return target.tagName ===
|
|
485
|
+
return target.tagName === 'A' && target.hasAttribute('href');
|
|
486
486
|
}
|
|
487
487
|
function $0294ea432cd92340$var$isValidKeyboardEvent(event, currentTarget) {
|
|
488
488
|
const { key: key, code: code } = event;
|
|
489
489
|
const element = currentTarget;
|
|
490
|
-
const role = element.getAttribute(
|
|
490
|
+
const role = element.getAttribute('role');
|
|
491
491
|
// Accessibility for keyboards. Space and Enter only.
|
|
492
492
|
// "Spacebar" is for IE 11
|
|
493
|
-
return (key ===
|
|
494
|
-
!((role ===
|
|
493
|
+
return (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') && !(element instanceof (0, $bBqCQ$reactariautils.getOwnerWindow)(element).HTMLInputElement && !$0294ea432cd92340$var$isValidInputKey(element, key) || element instanceof (0, $bBqCQ$reactariautils.getOwnerWindow)(element).HTMLTextAreaElement || element.isContentEditable) && // Links should only trigger with Enter key
|
|
494
|
+
!((role === 'link' || !role && $0294ea432cd92340$var$isHTMLAnchorLink(element)) && key !== 'Enter');
|
|
495
495
|
}
|
|
496
496
|
function $0294ea432cd92340$var$getTouchFromEvent(event) {
|
|
497
497
|
const { targetTouches: targetTouches } = event;
|
|
@@ -543,28 +543,28 @@ function $0294ea432cd92340$var$isOverTarget(point, target) {
|
|
|
543
543
|
}
|
|
544
544
|
function $0294ea432cd92340$var$shouldPreventDefault(target) {
|
|
545
545
|
// We cannot prevent default if the target is a draggable element.
|
|
546
|
-
return !(target instanceof HTMLElement) || !target.hasAttribute(
|
|
546
|
+
return !(target instanceof HTMLElement) || !target.hasAttribute('draggable');
|
|
547
547
|
}
|
|
548
548
|
function $0294ea432cd92340$var$shouldPreventDefaultKeyboard(target, key) {
|
|
549
549
|
if (target instanceof HTMLInputElement) return !$0294ea432cd92340$var$isValidInputKey(target, key);
|
|
550
|
-
if (target instanceof HTMLButtonElement) return target.type !==
|
|
550
|
+
if (target instanceof HTMLButtonElement) return target.type !== 'submit' && target.type !== 'reset';
|
|
551
551
|
if ($0294ea432cd92340$var$isHTMLAnchorLink(target)) return false;
|
|
552
552
|
return true;
|
|
553
553
|
}
|
|
554
554
|
const $0294ea432cd92340$var$nonTextInputTypes = new Set([
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
555
|
+
'checkbox',
|
|
556
|
+
'radio',
|
|
557
|
+
'range',
|
|
558
|
+
'color',
|
|
559
|
+
'file',
|
|
560
|
+
'image',
|
|
561
|
+
'button',
|
|
562
|
+
'submit',
|
|
563
|
+
'reset'
|
|
564
564
|
]);
|
|
565
565
|
function $0294ea432cd92340$var$isValidInputKey(target, key) {
|
|
566
566
|
// Only space should toggle checkboxes and radios, not enter.
|
|
567
|
-
return target.type ===
|
|
567
|
+
return target.type === 'checkbox' || target.type === 'radio' ? key === ' ' : $0294ea432cd92340$var$nonTextInputTypes.has(target.type);
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
|