@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/useFocusVisible.mjs
CHANGED
|
@@ -36,26 +36,26 @@ function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
|
36
36
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
37
37
|
*/ function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
38
38
|
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
39
|
-
return !(e.metaKey || !(0, $28AnR$isMac)() && e.altKey || e.ctrlKey || e.key ===
|
|
39
|
+
return !(e.metaKey || !(0, $28AnR$isMac)() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
|
|
40
40
|
}
|
|
41
41
|
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
42
42
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
43
43
|
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
44
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
45
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
44
|
+
$507fabe10e71c6fb$var$currentModality = 'keyboard';
|
|
45
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
49
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
50
|
-
if (e.type ===
|
|
49
|
+
$507fabe10e71c6fb$var$currentModality = 'pointer';
|
|
50
|
+
if (e.type === 'mousedown' || e.type === 'pointerdown') {
|
|
51
51
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
52
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
52
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
56
56
|
if ((0, $28AnR$isVirtualClick)(e)) {
|
|
57
57
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
58
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
58
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
@@ -66,8 +66,8 @@ function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
|
66
66
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
67
67
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
68
68
|
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
69
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
70
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
69
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
70
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
|
|
71
71
|
}
|
|
72
72
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
73
73
|
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
@@ -81,7 +81,7 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
81
81
|
/**
|
|
82
82
|
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
83
83
|
*/ function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
|
|
84
|
-
if (typeof window ===
|
|
84
|
+
if (typeof window === 'undefined' || $507fabe10e71c6fb$export$d90243b58daecda7.get((0, $28AnR$getOwnerWindow)(element))) return;
|
|
85
85
|
const windowObject = (0, $28AnR$getOwnerWindow)(element);
|
|
86
86
|
const documentObject = (0, $28AnR$getOwnerDocument)(element);
|
|
87
87
|
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
@@ -93,24 +93,24 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
93
93
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
94
94
|
focus.apply(this, arguments);
|
|
95
95
|
};
|
|
96
|
-
documentObject.addEventListener(
|
|
97
|
-
documentObject.addEventListener(
|
|
98
|
-
documentObject.addEventListener(
|
|
96
|
+
documentObject.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
97
|
+
documentObject.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
98
|
+
documentObject.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
99
99
|
// Register focus events on the window so they are sure to happen
|
|
100
100
|
// before React's event listeners (registered on the document).
|
|
101
|
-
windowObject.addEventListener(
|
|
102
|
-
windowObject.addEventListener(
|
|
103
|
-
if (typeof PointerEvent !==
|
|
104
|
-
documentObject.addEventListener(
|
|
105
|
-
documentObject.addEventListener(
|
|
106
|
-
documentObject.addEventListener(
|
|
101
|
+
windowObject.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
102
|
+
windowObject.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
103
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
104
|
+
documentObject.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
105
|
+
documentObject.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
106
|
+
documentObject.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
107
107
|
} else {
|
|
108
|
-
documentObject.addEventListener(
|
|
109
|
-
documentObject.addEventListener(
|
|
110
|
-
documentObject.addEventListener(
|
|
108
|
+
documentObject.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
109
|
+
documentObject.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
110
|
+
documentObject.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
111
111
|
}
|
|
112
112
|
// Add unmount handler
|
|
113
|
-
windowObject.addEventListener(
|
|
113
|
+
windowObject.addEventListener('beforeunload', ()=>{
|
|
114
114
|
$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
|
|
115
115
|
}, {
|
|
116
116
|
once: true
|
|
@@ -122,42 +122,42 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
122
122
|
const $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener)=>{
|
|
123
123
|
const windowObject = (0, $28AnR$getOwnerWindow)(element);
|
|
124
124
|
const documentObject = (0, $28AnR$getOwnerDocument)(element);
|
|
125
|
-
if (loadListener) documentObject.removeEventListener(
|
|
125
|
+
if (loadListener) documentObject.removeEventListener('DOMContentLoaded', loadListener);
|
|
126
126
|
if (!$507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject)) return;
|
|
127
127
|
windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus;
|
|
128
|
-
documentObject.removeEventListener(
|
|
129
|
-
documentObject.removeEventListener(
|
|
130
|
-
documentObject.removeEventListener(
|
|
131
|
-
windowObject.removeEventListener(
|
|
132
|
-
windowObject.removeEventListener(
|
|
133
|
-
if (typeof PointerEvent !==
|
|
134
|
-
documentObject.removeEventListener(
|
|
135
|
-
documentObject.removeEventListener(
|
|
136
|
-
documentObject.removeEventListener(
|
|
128
|
+
documentObject.removeEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
129
|
+
documentObject.removeEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
130
|
+
documentObject.removeEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
131
|
+
windowObject.removeEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
132
|
+
windowObject.removeEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
133
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
134
|
+
documentObject.removeEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
135
|
+
documentObject.removeEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
136
|
+
documentObject.removeEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
137
137
|
} else {
|
|
138
|
-
documentObject.removeEventListener(
|
|
139
|
-
documentObject.removeEventListener(
|
|
140
|
-
documentObject.removeEventListener(
|
|
138
|
+
documentObject.removeEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
139
|
+
documentObject.removeEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
140
|
+
documentObject.removeEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
141
141
|
}
|
|
142
142
|
$507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject);
|
|
143
143
|
};
|
|
144
144
|
function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
|
|
145
145
|
const documentObject = (0, $28AnR$getOwnerDocument)(element);
|
|
146
146
|
let loadListener;
|
|
147
|
-
if (documentObject.readyState !==
|
|
147
|
+
if (documentObject.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
|
148
148
|
else {
|
|
149
149
|
loadListener = ()=>{
|
|
150
150
|
$507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
|
151
151
|
};
|
|
152
|
-
documentObject.addEventListener(
|
|
152
|
+
documentObject.addEventListener('DOMContentLoaded', loadListener);
|
|
153
153
|
}
|
|
154
154
|
return ()=>$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
|
|
155
155
|
}
|
|
156
156
|
// Server-side rendering does not have the document object defined
|
|
157
157
|
// eslint-disable-next-line no-restricted-globals
|
|
158
|
-
if (typeof document !==
|
|
158
|
+
if (typeof document !== 'undefined') $507fabe10e71c6fb$export$2f1888112f558a7d();
|
|
159
159
|
function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
|
|
160
|
-
return $507fabe10e71c6fb$var$currentModality !==
|
|
160
|
+
return $507fabe10e71c6fb$var$currentModality !== 'pointer';
|
|
161
161
|
}
|
|
162
162
|
function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
|
|
163
163
|
return $507fabe10e71c6fb$var$currentModality;
|
|
@@ -181,27 +181,27 @@ function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
|
181
181
|
return (0, $28AnR$useIsSSR)() ? null : modality;
|
|
182
182
|
}
|
|
183
183
|
const $507fabe10e71c6fb$var$nonTextInputTypes = new Set([
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
'checkbox',
|
|
185
|
+
'radio',
|
|
186
|
+
'range',
|
|
187
|
+
'color',
|
|
188
|
+
'file',
|
|
189
|
+
'image',
|
|
190
|
+
'button',
|
|
191
|
+
'submit',
|
|
192
|
+
'reset'
|
|
193
193
|
]);
|
|
194
194
|
/**
|
|
195
195
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
196
196
|
* focus visible style can be properly set.
|
|
197
197
|
*/ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
198
198
|
var _e_target;
|
|
199
|
-
const IHTMLInputElement = typeof window !==
|
|
200
|
-
const IHTMLTextAreaElement = typeof window !==
|
|
201
|
-
const IHTMLElement = typeof window !==
|
|
202
|
-
const IKeyboardEvent = typeof window !==
|
|
199
|
+
const IHTMLInputElement = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLInputElement : HTMLInputElement;
|
|
200
|
+
const IHTMLTextAreaElement = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLTextAreaElement : HTMLTextAreaElement;
|
|
201
|
+
const IHTMLElement = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLElement : HTMLElement;
|
|
202
|
+
const IKeyboardEvent = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).KeyboardEvent : KeyboardEvent;
|
|
203
203
|
isTextInput = isTextInput || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLInputElement && !$507fabe10e71c6fb$var$nonTextInputTypes.has(e === null || e === void 0 ? void 0 : (_e_target = e.target) === null || _e_target === void 0 ? void 0 : _e_target.type) || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLTextAreaElement || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLElement && (e === null || e === void 0 ? void 0 : e.target.isContentEditable);
|
|
204
|
-
return !(isTextInput && modality ===
|
|
204
|
+
return !(isTextInput && modality === 'keyboard' && e instanceof IKeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
205
205
|
}
|
|
206
206
|
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {}) {
|
|
207
207
|
let { isTextInput: isTextInput, autoFocus: autoFocus } = props;
|
|
@@ -234,4 +234,4 @@ function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
|
234
234
|
|
|
235
235
|
|
|
236
236
|
export {$507fabe10e71c6fb$export$d90243b58daecda7 as hasSetupGlobalListeners, $507fabe10e71c6fb$export$2f1888112f558a7d as addWindowFocusTracking, $507fabe10e71c6fb$export$b9b3dfddab17db27 as isFocusVisible, $507fabe10e71c6fb$export$630ff653c5ada6a9 as getInteractionModality, $507fabe10e71c6fb$export$8397ddfc504fdb9a as setInteractionModality, $507fabe10e71c6fb$export$98e20ec92f614cfe as useInteractionModality, $507fabe10e71c6fb$export$ffd9e5021c1fb2d6 as useFocusVisible, $507fabe10e71c6fb$export$ec71b4b83ac08ec3 as useFocusVisibleListener};
|
|
237
|
-
//# sourceMappingURL=useFocusVisible.
|
|
237
|
+
//# sourceMappingURL=useFocusVisible.module.js.map
|
|
@@ -36,26 +36,26 @@ function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
|
36
36
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
37
37
|
*/ function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
38
38
|
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
39
|
-
return !(e.metaKey || !(0, $28AnR$isMac)() && e.altKey || e.ctrlKey || e.key ===
|
|
39
|
+
return !(e.metaKey || !(0, $28AnR$isMac)() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
|
|
40
40
|
}
|
|
41
41
|
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
42
42
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
43
43
|
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
44
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
45
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
44
|
+
$507fabe10e71c6fb$var$currentModality = 'keyboard';
|
|
45
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
49
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
50
|
-
if (e.type ===
|
|
49
|
+
$507fabe10e71c6fb$var$currentModality = 'pointer';
|
|
50
|
+
if (e.type === 'mousedown' || e.type === 'pointerdown') {
|
|
51
51
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
52
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
52
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
56
56
|
if ((0, $28AnR$isVirtualClick)(e)) {
|
|
57
57
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
58
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
58
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
@@ -66,8 +66,8 @@ function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
|
66
66
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
67
67
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
68
68
|
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
69
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
70
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
69
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
70
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
|
|
71
71
|
}
|
|
72
72
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
73
73
|
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
@@ -81,7 +81,7 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
81
81
|
/**
|
|
82
82
|
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
83
83
|
*/ function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
|
|
84
|
-
if (typeof window ===
|
|
84
|
+
if (typeof window === 'undefined' || $507fabe10e71c6fb$export$d90243b58daecda7.get((0, $28AnR$getOwnerWindow)(element))) return;
|
|
85
85
|
const windowObject = (0, $28AnR$getOwnerWindow)(element);
|
|
86
86
|
const documentObject = (0, $28AnR$getOwnerDocument)(element);
|
|
87
87
|
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
@@ -93,24 +93,24 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
93
93
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
94
94
|
focus.apply(this, arguments);
|
|
95
95
|
};
|
|
96
|
-
documentObject.addEventListener(
|
|
97
|
-
documentObject.addEventListener(
|
|
98
|
-
documentObject.addEventListener(
|
|
96
|
+
documentObject.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
97
|
+
documentObject.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
98
|
+
documentObject.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
99
99
|
// Register focus events on the window so they are sure to happen
|
|
100
100
|
// before React's event listeners (registered on the document).
|
|
101
|
-
windowObject.addEventListener(
|
|
102
|
-
windowObject.addEventListener(
|
|
103
|
-
if (typeof PointerEvent !==
|
|
104
|
-
documentObject.addEventListener(
|
|
105
|
-
documentObject.addEventListener(
|
|
106
|
-
documentObject.addEventListener(
|
|
101
|
+
windowObject.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
102
|
+
windowObject.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
103
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
104
|
+
documentObject.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
105
|
+
documentObject.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
106
|
+
documentObject.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
107
107
|
} else {
|
|
108
|
-
documentObject.addEventListener(
|
|
109
|
-
documentObject.addEventListener(
|
|
110
|
-
documentObject.addEventListener(
|
|
108
|
+
documentObject.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
109
|
+
documentObject.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
110
|
+
documentObject.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
111
111
|
}
|
|
112
112
|
// Add unmount handler
|
|
113
|
-
windowObject.addEventListener(
|
|
113
|
+
windowObject.addEventListener('beforeunload', ()=>{
|
|
114
114
|
$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
|
|
115
115
|
}, {
|
|
116
116
|
once: true
|
|
@@ -122,42 +122,42 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
122
122
|
const $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener)=>{
|
|
123
123
|
const windowObject = (0, $28AnR$getOwnerWindow)(element);
|
|
124
124
|
const documentObject = (0, $28AnR$getOwnerDocument)(element);
|
|
125
|
-
if (loadListener) documentObject.removeEventListener(
|
|
125
|
+
if (loadListener) documentObject.removeEventListener('DOMContentLoaded', loadListener);
|
|
126
126
|
if (!$507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject)) return;
|
|
127
127
|
windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus;
|
|
128
|
-
documentObject.removeEventListener(
|
|
129
|
-
documentObject.removeEventListener(
|
|
130
|
-
documentObject.removeEventListener(
|
|
131
|
-
windowObject.removeEventListener(
|
|
132
|
-
windowObject.removeEventListener(
|
|
133
|
-
if (typeof PointerEvent !==
|
|
134
|
-
documentObject.removeEventListener(
|
|
135
|
-
documentObject.removeEventListener(
|
|
136
|
-
documentObject.removeEventListener(
|
|
128
|
+
documentObject.removeEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
129
|
+
documentObject.removeEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
130
|
+
documentObject.removeEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
131
|
+
windowObject.removeEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
132
|
+
windowObject.removeEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
133
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
134
|
+
documentObject.removeEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
135
|
+
documentObject.removeEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
136
|
+
documentObject.removeEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
137
137
|
} else {
|
|
138
|
-
documentObject.removeEventListener(
|
|
139
|
-
documentObject.removeEventListener(
|
|
140
|
-
documentObject.removeEventListener(
|
|
138
|
+
documentObject.removeEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
139
|
+
documentObject.removeEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
140
|
+
documentObject.removeEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
141
141
|
}
|
|
142
142
|
$507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject);
|
|
143
143
|
};
|
|
144
144
|
function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
|
|
145
145
|
const documentObject = (0, $28AnR$getOwnerDocument)(element);
|
|
146
146
|
let loadListener;
|
|
147
|
-
if (documentObject.readyState !==
|
|
147
|
+
if (documentObject.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
|
148
148
|
else {
|
|
149
149
|
loadListener = ()=>{
|
|
150
150
|
$507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
|
151
151
|
};
|
|
152
|
-
documentObject.addEventListener(
|
|
152
|
+
documentObject.addEventListener('DOMContentLoaded', loadListener);
|
|
153
153
|
}
|
|
154
154
|
return ()=>$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
|
|
155
155
|
}
|
|
156
156
|
// Server-side rendering does not have the document object defined
|
|
157
157
|
// eslint-disable-next-line no-restricted-globals
|
|
158
|
-
if (typeof document !==
|
|
158
|
+
if (typeof document !== 'undefined') $507fabe10e71c6fb$export$2f1888112f558a7d();
|
|
159
159
|
function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
|
|
160
|
-
return $507fabe10e71c6fb$var$currentModality !==
|
|
160
|
+
return $507fabe10e71c6fb$var$currentModality !== 'pointer';
|
|
161
161
|
}
|
|
162
162
|
function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
|
|
163
163
|
return $507fabe10e71c6fb$var$currentModality;
|
|
@@ -181,27 +181,27 @@ function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
|
181
181
|
return (0, $28AnR$useIsSSR)() ? null : modality;
|
|
182
182
|
}
|
|
183
183
|
const $507fabe10e71c6fb$var$nonTextInputTypes = new Set([
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
'checkbox',
|
|
185
|
+
'radio',
|
|
186
|
+
'range',
|
|
187
|
+
'color',
|
|
188
|
+
'file',
|
|
189
|
+
'image',
|
|
190
|
+
'button',
|
|
191
|
+
'submit',
|
|
192
|
+
'reset'
|
|
193
193
|
]);
|
|
194
194
|
/**
|
|
195
195
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
196
196
|
* focus visible style can be properly set.
|
|
197
197
|
*/ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
198
198
|
var _e_target;
|
|
199
|
-
const IHTMLInputElement = typeof window !==
|
|
200
|
-
const IHTMLTextAreaElement = typeof window !==
|
|
201
|
-
const IHTMLElement = typeof window !==
|
|
202
|
-
const IKeyboardEvent = typeof window !==
|
|
199
|
+
const IHTMLInputElement = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLInputElement : HTMLInputElement;
|
|
200
|
+
const IHTMLTextAreaElement = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLTextAreaElement : HTMLTextAreaElement;
|
|
201
|
+
const IHTMLElement = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLElement : HTMLElement;
|
|
202
|
+
const IKeyboardEvent = typeof window !== 'undefined' ? (0, $28AnR$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).KeyboardEvent : KeyboardEvent;
|
|
203
203
|
isTextInput = isTextInput || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLInputElement && !$507fabe10e71c6fb$var$nonTextInputTypes.has(e === null || e === void 0 ? void 0 : (_e_target = e.target) === null || _e_target === void 0 ? void 0 : _e_target.type) || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLTextAreaElement || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLElement && (e === null || e === void 0 ? void 0 : e.target.isContentEditable);
|
|
204
|
-
return !(isTextInput && modality ===
|
|
204
|
+
return !(isTextInput && modality === 'keyboard' && e instanceof IKeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
205
205
|
}
|
|
206
206
|
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {}) {
|
|
207
207
|
let { isTextInput: isTextInput, autoFocus: autoFocus } = props;
|
package/dist/useFocusWithin.mjs
CHANGED
package/dist/useHover.main.js
CHANGED
|
@@ -37,18 +37,18 @@ function $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
|
37
37
|
}, 50);
|
|
38
38
|
}
|
|
39
39
|
function $ffbc150311c75f01$var$handleGlobalPointerEvent(e) {
|
|
40
|
-
if (e.pointerType ===
|
|
40
|
+
if (e.pointerType === 'touch') $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
41
41
|
}
|
|
42
42
|
function $ffbc150311c75f01$var$setupGlobalTouchEvents() {
|
|
43
|
-
if (typeof document ===
|
|
44
|
-
if (typeof PointerEvent !==
|
|
45
|
-
else document.addEventListener(
|
|
43
|
+
if (typeof document === 'undefined') return;
|
|
44
|
+
if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $ffbc150311c75f01$var$handleGlobalPointerEvent);
|
|
45
|
+
else document.addEventListener('touchend', $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
46
46
|
$ffbc150311c75f01$var$hoverCount++;
|
|
47
47
|
return ()=>{
|
|
48
48
|
$ffbc150311c75f01$var$hoverCount--;
|
|
49
49
|
if ($ffbc150311c75f01$var$hoverCount > 0) return;
|
|
50
|
-
if (typeof PointerEvent !==
|
|
51
|
-
else document.removeEventListener(
|
|
50
|
+
if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $ffbc150311c75f01$var$handleGlobalPointerEvent);
|
|
51
|
+
else document.removeEventListener('touchend', $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
@@ -57,19 +57,19 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
57
57
|
let state = (0, $82z6W$react.useRef)({
|
|
58
58
|
isHovered: false,
|
|
59
59
|
ignoreEmulatedMouseEvents: false,
|
|
60
|
-
pointerType:
|
|
60
|
+
pointerType: '',
|
|
61
61
|
target: null
|
|
62
62
|
}).current;
|
|
63
63
|
(0, $82z6W$react.useEffect)($ffbc150311c75f01$var$setupGlobalTouchEvents, []);
|
|
64
64
|
let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = (0, $82z6W$react.useMemo)(()=>{
|
|
65
65
|
let triggerHoverStart = (event, pointerType)=>{
|
|
66
66
|
state.pointerType = pointerType;
|
|
67
|
-
if (isDisabled || pointerType ===
|
|
67
|
+
if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
68
68
|
state.isHovered = true;
|
|
69
69
|
let target = event.currentTarget;
|
|
70
70
|
state.target = target;
|
|
71
71
|
if (onHoverStart) onHoverStart({
|
|
72
|
-
type:
|
|
72
|
+
type: 'hoverstart',
|
|
73
73
|
target: target,
|
|
74
74
|
pointerType: pointerType
|
|
75
75
|
});
|
|
@@ -77,13 +77,13 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
77
77
|
setHovered(true);
|
|
78
78
|
};
|
|
79
79
|
let triggerHoverEnd = (event, pointerType)=>{
|
|
80
|
-
state.pointerType =
|
|
80
|
+
state.pointerType = '';
|
|
81
81
|
state.target = null;
|
|
82
|
-
if (pointerType ===
|
|
82
|
+
if (pointerType === 'touch' || !state.isHovered) return;
|
|
83
83
|
state.isHovered = false;
|
|
84
84
|
let target = event.currentTarget;
|
|
85
85
|
if (onHoverEnd) onHoverEnd({
|
|
86
|
-
type:
|
|
86
|
+
type: 'hoverend',
|
|
87
87
|
target: target,
|
|
88
88
|
pointerType: pointerType
|
|
89
89
|
});
|
|
@@ -91,9 +91,9 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
91
91
|
setHovered(false);
|
|
92
92
|
};
|
|
93
93
|
let hoverProps = {};
|
|
94
|
-
if (typeof PointerEvent !==
|
|
94
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
95
95
|
hoverProps.onPointerEnter = (e)=>{
|
|
96
|
-
if ($ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents && e.pointerType ===
|
|
96
|
+
if ($ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
|
|
97
97
|
triggerHoverStart(e, e.pointerType);
|
|
98
98
|
};
|
|
99
99
|
hoverProps.onPointerLeave = (e)=>{
|
|
@@ -104,11 +104,11 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
104
104
|
state.ignoreEmulatedMouseEvents = true;
|
|
105
105
|
};
|
|
106
106
|
hoverProps.onMouseEnter = (e)=>{
|
|
107
|
-
if (!state.ignoreEmulatedMouseEvents && !$ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e,
|
|
107
|
+
if (!state.ignoreEmulatedMouseEvents && !$ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
|
|
108
108
|
state.ignoreEmulatedMouseEvents = false;
|
|
109
109
|
};
|
|
110
110
|
hoverProps.onMouseLeave = (e)=>{
|
|
111
|
-
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e,
|
|
111
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
return {
|
package/dist/useHover.mjs
CHANGED
|
@@ -31,18 +31,18 @@ function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
|
31
31
|
}, 50);
|
|
32
32
|
}
|
|
33
33
|
function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
|
|
34
|
-
if (e.pointerType ===
|
|
34
|
+
if (e.pointerType === 'touch') $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
35
35
|
}
|
|
36
36
|
function $6179b936705e76d3$var$setupGlobalTouchEvents() {
|
|
37
|
-
if (typeof document ===
|
|
38
|
-
if (typeof PointerEvent !==
|
|
39
|
-
else document.addEventListener(
|
|
37
|
+
if (typeof document === 'undefined') return;
|
|
38
|
+
if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
39
|
+
else document.addEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
40
40
|
$6179b936705e76d3$var$hoverCount++;
|
|
41
41
|
return ()=>{
|
|
42
42
|
$6179b936705e76d3$var$hoverCount--;
|
|
43
43
|
if ($6179b936705e76d3$var$hoverCount > 0) return;
|
|
44
|
-
if (typeof PointerEvent !==
|
|
45
|
-
else document.removeEventListener(
|
|
44
|
+
if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
45
|
+
else document.removeEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
@@ -51,19 +51,19 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
51
51
|
let state = (0, $AWxnT$useRef)({
|
|
52
52
|
isHovered: false,
|
|
53
53
|
ignoreEmulatedMouseEvents: false,
|
|
54
|
-
pointerType:
|
|
54
|
+
pointerType: '',
|
|
55
55
|
target: null
|
|
56
56
|
}).current;
|
|
57
57
|
(0, $AWxnT$useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
58
58
|
let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = (0, $AWxnT$useMemo)(()=>{
|
|
59
59
|
let triggerHoverStart = (event, pointerType)=>{
|
|
60
60
|
state.pointerType = pointerType;
|
|
61
|
-
if (isDisabled || pointerType ===
|
|
61
|
+
if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
62
62
|
state.isHovered = true;
|
|
63
63
|
let target = event.currentTarget;
|
|
64
64
|
state.target = target;
|
|
65
65
|
if (onHoverStart) onHoverStart({
|
|
66
|
-
type:
|
|
66
|
+
type: 'hoverstart',
|
|
67
67
|
target: target,
|
|
68
68
|
pointerType: pointerType
|
|
69
69
|
});
|
|
@@ -71,13 +71,13 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
71
71
|
setHovered(true);
|
|
72
72
|
};
|
|
73
73
|
let triggerHoverEnd = (event, pointerType)=>{
|
|
74
|
-
state.pointerType =
|
|
74
|
+
state.pointerType = '';
|
|
75
75
|
state.target = null;
|
|
76
|
-
if (pointerType ===
|
|
76
|
+
if (pointerType === 'touch' || !state.isHovered) return;
|
|
77
77
|
state.isHovered = false;
|
|
78
78
|
let target = event.currentTarget;
|
|
79
79
|
if (onHoverEnd) onHoverEnd({
|
|
80
|
-
type:
|
|
80
|
+
type: 'hoverend',
|
|
81
81
|
target: target,
|
|
82
82
|
pointerType: pointerType
|
|
83
83
|
});
|
|
@@ -85,9 +85,9 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
85
85
|
setHovered(false);
|
|
86
86
|
};
|
|
87
87
|
let hoverProps = {};
|
|
88
|
-
if (typeof PointerEvent !==
|
|
88
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
89
89
|
hoverProps.onPointerEnter = (e)=>{
|
|
90
|
-
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType ===
|
|
90
|
+
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
|
|
91
91
|
triggerHoverStart(e, e.pointerType);
|
|
92
92
|
};
|
|
93
93
|
hoverProps.onPointerLeave = (e)=>{
|
|
@@ -98,11 +98,11 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
98
98
|
state.ignoreEmulatedMouseEvents = true;
|
|
99
99
|
};
|
|
100
100
|
hoverProps.onMouseEnter = (e)=>{
|
|
101
|
-
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e,
|
|
101
|
+
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
|
|
102
102
|
state.ignoreEmulatedMouseEvents = false;
|
|
103
103
|
};
|
|
104
104
|
hoverProps.onMouseLeave = (e)=>{
|
|
105
|
-
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e,
|
|
105
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
return {
|
|
@@ -134,4 +134,4 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
export {$6179b936705e76d3$export$ae780daf29e6d456 as useHover};
|
|
137
|
-
//# sourceMappingURL=useHover.
|
|
137
|
+
//# sourceMappingURL=useHover.module.js.map
|