@opengovsg/oui 0.0.12 → 0.0.14
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/cjs/badge/badge.cjs +4 -4
- package/dist/cjs/badge/use-badge.cjs +6 -6
- package/dist/cjs/banner/banner.cjs +4 -4
- package/dist/cjs/button/button.cjs +3 -3
- package/dist/cjs/calendar/calendar-bottom-content.cjs +2 -2
- package/dist/cjs/calendar/calendar-header.cjs +2 -2
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +2 -2
- package/dist/cjs/calendar/calendar.cjs +4 -4
- package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
- package/dist/cjs/calendar/utils.cjs +3 -3
- package/dist/cjs/checkbox/checkbox-group-style-context.cjs +16 -0
- package/dist/cjs/checkbox/checkbox.cjs +94 -0
- package/dist/cjs/checkbox/index.cjs +12 -0
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
- package/dist/cjs/combo-box/combo-box.cjs +3 -3
- package/dist/cjs/date-field/date-field.cjs +3 -3
- package/dist/cjs/date-picker/date-picker.cjs +6 -5
- package/dist/cjs/date-range-picker/date-range-picker.cjs +5 -5
- package/dist/cjs/govt-banner/govt-banner.cjs +27 -62
- package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
- package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
- package/dist/cjs/index.cjs +52 -35
- package/dist/cjs/input/input.cjs +2 -2
- package/dist/cjs/menu/menu.cjs +6 -6
- package/dist/cjs/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.cjs +45 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.cjs +21 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.cjs +72 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.cjs +60 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.cjs +210 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.cjs +100 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.cjs +152 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.cjs +676 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.cjs +160 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs +9 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs +9 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs +16 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs +9 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.cjs +11 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.cjs +10 -0
- package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.cjs +12 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/Icon.cjs +4 -4
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +3 -3
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.cjs +22 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.cjs +23 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.cjs +19 -0
- package/dist/cjs/pagination/hooks/use-pagination.cjs +117 -0
- package/dist/cjs/pagination/index.cjs +17 -0
- package/dist/cjs/pagination/pagination-cursor.cjs +18 -0
- package/dist/cjs/pagination/pagination-item.cjs +18 -0
- package/dist/cjs/pagination/pagination.cjs +263 -0
- package/dist/cjs/pagination/use-pagination-item.cjs +87 -0
- package/dist/cjs/pagination/use-pagination.cjs +251 -0
- package/dist/cjs/range-calendar/range-calendar.cjs +7 -7
- package/dist/cjs/ripple/use-ripple.cjs +4 -4
- package/dist/cjs/select/select.cjs +3 -3
- package/dist/cjs/spinner/use-spinner.cjs +3 -3
- package/dist/cjs/system/react-utils/context.cjs +3 -3
- package/dist/cjs/system/react-utils/dom-props.cjs +186 -0
- package/dist/cjs/system/react-utils/filter-dom-props.cjs +46 -0
- package/dist/cjs/system/react-utils/index.cjs +2 -0
- package/dist/cjs/system/react-utils/refs.cjs +3 -3
- package/dist/cjs/system/utils.cjs +3 -3
- package/dist/cjs/tabs/tabs.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
- package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
- package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
- package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
- package/dist/cjs/tag-field/tag-field.cjs +2 -2
- package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
- package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
- package/dist/cjs/text-area/text-area.cjs +2 -2
- package/dist/cjs/toggle/toggle.cjs +3 -3
- package/dist/esm/banner/banner.js +1 -1
- package/dist/esm/checkbox/checkbox-group-style-context.js +13 -0
- package/dist/esm/checkbox/checkbox.js +91 -0
- package/dist/esm/checkbox/index.js +3 -0
- package/dist/esm/date-picker/date-picker.js +4 -3
- package/dist/esm/date-range-picker/date-range-picker.js +2 -2
- package/dist/esm/govt-banner/govt-banner.js +25 -60
- package/dist/esm/index.js +19 -12
- package/dist/esm/node_modules/.pnpm/@react-aria_focus@3.20.5_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/focus/dist/useFocusRing.js +43 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/context.js +19 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/textSelection.js +69 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocus.js +58 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusVisible.js +205 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useFocusWithin.js +98 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/useHover.js +150 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/usePress.js +674 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_interactions@3.25.3_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@react-aria/interactions/dist/utils.js +155 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +7 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js +7 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js +14 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js +7 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.js +9 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.js +8 -0
- package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.js +10 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/chevrons-right.js +17 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/ellipsis.js +18 -0
- package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/minus.js +14 -0
- package/dist/esm/pagination/hooks/use-pagination.js +114 -0
- package/dist/esm/pagination/index.js +6 -0
- package/dist/esm/pagination/pagination-cursor.js +16 -0
- package/dist/esm/pagination/pagination-item.js +16 -0
- package/dist/esm/pagination/pagination.js +261 -0
- package/dist/esm/pagination/use-pagination-item.js +85 -0
- package/dist/esm/pagination/use-pagination.js +248 -0
- package/dist/esm/range-calendar/range-calendar.js +1 -1
- package/dist/esm/select/select.js +1 -1
- package/dist/esm/system/react-utils/dom-props.js +183 -0
- package/dist/esm/system/react-utils/filter-dom-props.js +44 -0
- package/dist/esm/system/react-utils/index.js +1 -0
- package/dist/types/badge/badge.d.ts +3 -1
- package/dist/types/badge/badge.d.ts.map +1 -1
- package/dist/types/badge/use-badge.d.ts +7 -48
- package/dist/types/badge/use-badge.d.ts.map +1 -1
- package/dist/types/checkbox/checkbox-group-style-context.d.ts +6 -0
- package/dist/types/checkbox/checkbox-group-style-context.d.ts.map +1 -0
- package/dist/types/checkbox/checkbox.d.ts +19 -0
- package/dist/types/checkbox/checkbox.d.ts.map +1 -0
- package/dist/types/checkbox/index.d.ts +3 -0
- package/dist/types/checkbox/index.d.ts.map +1 -0
- package/dist/types/govt-banner/govt-banner.d.ts.map +1 -1
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pagination/hooks/use-pagination.d.ts +51 -0
- package/dist/types/pagination/hooks/use-pagination.d.ts.map +1 -0
- package/dist/types/pagination/index.d.ts +7 -0
- package/dist/types/pagination/index.d.ts.map +1 -0
- package/dist/types/pagination/pagination-cursor.d.ts +9 -0
- package/dist/types/pagination/pagination-cursor.d.ts.map +1 -0
- package/dist/types/pagination/pagination-item.d.ts +5 -0
- package/dist/types/pagination/pagination-item.d.ts.map +1 -0
- package/dist/types/pagination/pagination.d.ts +5 -0
- package/dist/types/pagination/pagination.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination-item.d.ts +51 -0
- package/dist/types/pagination/use-pagination-item.d.ts.map +1 -0
- package/dist/types/pagination/use-pagination.d.ts +353 -0
- package/dist/types/pagination/use-pagination.d.ts.map +1 -0
- package/dist/types/spinner/use-spinner.d.ts +8 -8
- package/dist/types/system/react-utils/context.d.ts.map +1 -1
- package/dist/types/system/react-utils/dom-props.d.ts +3 -0
- package/dist/types/system/react-utils/dom-props.d.ts.map +1 -0
- package/dist/types/system/react-utils/filter-dom-props.d.ts +39 -0
- package/dist/types/system/react-utils/filter-dom-props.d.ts.map +1 -0
- package/dist/types/system/react-utils/index.d.ts +1 -0
- package/dist/types/system/react-utils/index.d.ts.map +1 -1
- package/package.json +8 -6
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ignoreFocusEvent as $8a9cb279dc87e130$export$fda7da73ab5d4c48 } from './utils.js';
|
|
2
|
+
import { getOwnerWindow, getOwnerDocument, isVirtualClick, isMac } from '@react-aria/utils';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
16
|
+
// Original licensing for the following can be found in the
|
|
17
|
+
// NOTICE file in the root directory of this source tree.
|
|
18
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
let $507fabe10e71c6fb$var$currentModality = null;
|
|
24
|
+
let $507fabe10e71c6fb$var$changeHandlers = new Set();
|
|
25
|
+
let $507fabe10e71c6fb$export$d90243b58daecda7 = new Map(); // We use a map here to support setting event listeners across multiple document objects.
|
|
26
|
+
let $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
27
|
+
let $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
28
|
+
// Only Tab or Esc keys will make focus visible on text input elements
|
|
29
|
+
const $507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS = {
|
|
30
|
+
Tab: true,
|
|
31
|
+
Escape: true
|
|
32
|
+
};
|
|
33
|
+
function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
34
|
+
for (let handler of $507fabe10e71c6fb$var$changeHandlers)handler(modality, e);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
38
|
+
*/ function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
39
|
+
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
40
|
+
return !(e.metaKey || !(isMac)() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
|
|
41
|
+
}
|
|
42
|
+
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
43
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
44
|
+
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
45
|
+
$507fabe10e71c6fb$var$currentModality = 'keyboard';
|
|
46
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
50
|
+
$507fabe10e71c6fb$var$currentModality = 'pointer';
|
|
51
|
+
if (e.type === 'mousedown' || e.type === 'pointerdown') {
|
|
52
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
53
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
57
|
+
if ((isVirtualClick)(e)) {
|
|
58
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
59
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
63
|
+
// Firefox fires two extra focus events when the user first clicks into an iframe:
|
|
64
|
+
// first on the window, then on the document. We ignore these events so they don't
|
|
65
|
+
// cause keyboard focus rings to appear.
|
|
66
|
+
if (e.target === window || e.target === document || ($8a9cb279dc87e130$export$fda7da73ab5d4c48) || !e.isTrusted) return;
|
|
67
|
+
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
68
|
+
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
69
|
+
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
70
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
71
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
|
|
72
|
+
}
|
|
73
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
74
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
75
|
+
}
|
|
76
|
+
function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
77
|
+
if ($8a9cb279dc87e130$export$fda7da73ab5d4c48) return;
|
|
78
|
+
// When the window is blurred, reset state. This is necessary when tabbing out of the window,
|
|
79
|
+
// for example, since a subsequent focus event won't be fired.
|
|
80
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
81
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
85
|
+
*/ function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
|
|
86
|
+
if (typeof window === 'undefined' || typeof document === 'undefined' || $507fabe10e71c6fb$export$d90243b58daecda7.get((getOwnerWindow)(element))) return;
|
|
87
|
+
const windowObject = (getOwnerWindow)(element);
|
|
88
|
+
const documentObject = (getOwnerDocument)(element);
|
|
89
|
+
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
90
|
+
// However, we need to detect other cases when a focus event occurs without
|
|
91
|
+
// a preceding user event (e.g. screen reader focus). Overriding the focus
|
|
92
|
+
// method on HTMLElement.prototype is a bit hacky, but works.
|
|
93
|
+
let focus = windowObject.HTMLElement.prototype.focus;
|
|
94
|
+
windowObject.HTMLElement.prototype.focus = function() {
|
|
95
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
96
|
+
focus.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
documentObject.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
99
|
+
documentObject.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
100
|
+
documentObject.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
101
|
+
// Register focus events on the window so they are sure to happen
|
|
102
|
+
// before React's event listeners (registered on the document).
|
|
103
|
+
windowObject.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
104
|
+
windowObject.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
105
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
106
|
+
documentObject.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
107
|
+
documentObject.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
108
|
+
documentObject.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
109
|
+
} else if (process.env.NODE_ENV === 'test') {
|
|
110
|
+
documentObject.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
111
|
+
documentObject.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
112
|
+
documentObject.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
113
|
+
}
|
|
114
|
+
// Add unmount handler
|
|
115
|
+
windowObject.addEventListener('beforeunload', ()=>{
|
|
116
|
+
$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
|
|
117
|
+
}, {
|
|
118
|
+
once: true
|
|
119
|
+
});
|
|
120
|
+
$507fabe10e71c6fb$export$d90243b58daecda7.set(windowObject, {
|
|
121
|
+
focus: focus
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener)=>{
|
|
125
|
+
const windowObject = (getOwnerWindow)(element);
|
|
126
|
+
const documentObject = (getOwnerDocument)(element);
|
|
127
|
+
if (loadListener) documentObject.removeEventListener('DOMContentLoaded', loadListener);
|
|
128
|
+
if (!$507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject)) return;
|
|
129
|
+
windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus;
|
|
130
|
+
documentObject.removeEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
131
|
+
documentObject.removeEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
132
|
+
documentObject.removeEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
133
|
+
windowObject.removeEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
134
|
+
windowObject.removeEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
135
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
136
|
+
documentObject.removeEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
137
|
+
documentObject.removeEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
138
|
+
documentObject.removeEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
139
|
+
} else if (process.env.NODE_ENV === 'test') {
|
|
140
|
+
documentObject.removeEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
141
|
+
documentObject.removeEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
142
|
+
documentObject.removeEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
143
|
+
}
|
|
144
|
+
$507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject);
|
|
145
|
+
};
|
|
146
|
+
function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
|
|
147
|
+
const documentObject = (getOwnerDocument)(element);
|
|
148
|
+
let loadListener;
|
|
149
|
+
if (documentObject.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
|
150
|
+
else {
|
|
151
|
+
loadListener = ()=>{
|
|
152
|
+
$507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
|
|
153
|
+
};
|
|
154
|
+
documentObject.addEventListener('DOMContentLoaded', loadListener);
|
|
155
|
+
}
|
|
156
|
+
return ()=>$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
|
|
157
|
+
}
|
|
158
|
+
// Server-side rendering does not have the document object defined
|
|
159
|
+
// eslint-disable-next-line no-restricted-globals
|
|
160
|
+
if (typeof document !== 'undefined') $507fabe10e71c6fb$export$2f1888112f558a7d();
|
|
161
|
+
function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
|
|
162
|
+
return $507fabe10e71c6fb$var$currentModality !== 'pointer';
|
|
163
|
+
}
|
|
164
|
+
const $507fabe10e71c6fb$var$nonTextInputTypes = new Set([
|
|
165
|
+
'checkbox',
|
|
166
|
+
'radio',
|
|
167
|
+
'range',
|
|
168
|
+
'color',
|
|
169
|
+
'file',
|
|
170
|
+
'image',
|
|
171
|
+
'button',
|
|
172
|
+
'submit',
|
|
173
|
+
'reset'
|
|
174
|
+
]);
|
|
175
|
+
/**
|
|
176
|
+
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
177
|
+
* focus visible style can be properly set.
|
|
178
|
+
*/ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
179
|
+
let document1 = (getOwnerDocument)(e === null || e === void 0 ? void 0 : e.target);
|
|
180
|
+
const IHTMLInputElement = typeof window !== 'undefined' ? (getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLInputElement : HTMLInputElement;
|
|
181
|
+
const IHTMLTextAreaElement = typeof window !== 'undefined' ? (getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLTextAreaElement : HTMLTextAreaElement;
|
|
182
|
+
const IHTMLElement = typeof window !== 'undefined' ? (getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLElement : HTMLElement;
|
|
183
|
+
const IKeyboardEvent = typeof window !== 'undefined' ? (getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).KeyboardEvent : KeyboardEvent;
|
|
184
|
+
// For keyboard events that occur on a non-input element that will move focus into input element (aka ArrowLeft going from Datepicker button to the main input group)
|
|
185
|
+
// we need to rely on the user passing isTextInput into here. This way we can skip toggling focus visiblity for said input element
|
|
186
|
+
isTextInput = isTextInput || document1.activeElement instanceof IHTMLInputElement && !$507fabe10e71c6fb$var$nonTextInputTypes.has(document1.activeElement.type) || document1.activeElement instanceof IHTMLTextAreaElement || document1.activeElement instanceof IHTMLElement && document1.activeElement.isContentEditable;
|
|
187
|
+
return !(isTextInput && modality === 'keyboard' && e instanceof IKeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
188
|
+
}
|
|
189
|
+
function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
190
|
+
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
191
|
+
(useEffect)(()=>{
|
|
192
|
+
let handler = (modality, e)=>{
|
|
193
|
+
// We want to early return for any keyboard events that occur inside text inputs EXCEPT for Tab and Escape
|
|
194
|
+
if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(!!(opts === null || opts === void 0 ? void 0 : opts.isTextInput), modality, e)) return;
|
|
195
|
+
fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
196
|
+
};
|
|
197
|
+
$507fabe10e71c6fb$var$changeHandlers.add(handler);
|
|
198
|
+
return ()=>{
|
|
199
|
+
$507fabe10e71c6fb$var$changeHandlers.delete(handler);
|
|
200
|
+
};
|
|
201
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
202
|
+
}, deps);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export { $507fabe10e71c6fb$export$2f1888112f558a7d as addWindowFocusTracking, $507fabe10e71c6fb$export$d90243b58daecda7 as hasSetupGlobalListeners, $507fabe10e71c6fb$export$b9b3dfddab17db27 as isFocusVisible, $507fabe10e71c6fb$export$ec71b4b83ac08ec3 as useFocusVisibleListener };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useSyntheticBlurEvent as $8a9cb279dc87e130$export$715c682d09d639cc, setEventTarget as $8a9cb279dc87e130$export$c2b7abe5d61ec696, createSyntheticEvent as $8a9cb279dc87e130$export$525bc4921d56d4a } from './utils.js';
|
|
2
|
+
import { useRef, useCallback } from 'react';
|
|
3
|
+
import { useGlobalListeners, getOwnerDocument, getActiveElement, getEventTarget, nodeContains } from '@react-aria/utils';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
16
|
+
// Original licensing for the following can be found in the
|
|
17
|
+
// NOTICE file in the root directory of this source tree.
|
|
18
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
23
|
+
let { isDisabled: isDisabled, onBlurWithin: onBlurWithin, onFocusWithin: onFocusWithin, onFocusWithinChange: onFocusWithinChange } = props;
|
|
24
|
+
let state = (useRef)({
|
|
25
|
+
isFocusWithin: false
|
|
26
|
+
});
|
|
27
|
+
let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (useGlobalListeners)();
|
|
28
|
+
let onBlur = (useCallback)((e)=>{
|
|
29
|
+
// Ignore events bubbling through portals.
|
|
30
|
+
if (!e.currentTarget.contains(e.target)) return;
|
|
31
|
+
// We don't want to trigger onBlurWithin and then immediately onFocusWithin again
|
|
32
|
+
// when moving focus inside the element. Only trigger if the currentTarget doesn't
|
|
33
|
+
// include the relatedTarget (where focus is moving).
|
|
34
|
+
if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
|
|
35
|
+
state.current.isFocusWithin = false;
|
|
36
|
+
removeAllGlobalListeners();
|
|
37
|
+
if (onBlurWithin) onBlurWithin(e);
|
|
38
|
+
if (onFocusWithinChange) onFocusWithinChange(false);
|
|
39
|
+
}
|
|
40
|
+
}, [
|
|
41
|
+
onBlurWithin,
|
|
42
|
+
onFocusWithinChange,
|
|
43
|
+
state,
|
|
44
|
+
removeAllGlobalListeners
|
|
45
|
+
]);
|
|
46
|
+
let onSyntheticFocus = ($8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
47
|
+
let onFocus = (useCallback)((e)=>{
|
|
48
|
+
// Ignore events bubbling through portals.
|
|
49
|
+
if (!e.currentTarget.contains(e.target)) return;
|
|
50
|
+
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
51
|
+
// focus handler already moved focus somewhere else.
|
|
52
|
+
const ownerDocument = (getOwnerDocument)(e.target);
|
|
53
|
+
const activeElement = (getActiveElement)(ownerDocument);
|
|
54
|
+
if (!state.current.isFocusWithin && activeElement === (getEventTarget)(e.nativeEvent)) {
|
|
55
|
+
if (onFocusWithin) onFocusWithin(e);
|
|
56
|
+
if (onFocusWithinChange) onFocusWithinChange(true);
|
|
57
|
+
state.current.isFocusWithin = true;
|
|
58
|
+
onSyntheticFocus(e);
|
|
59
|
+
// Browsers don't fire blur events when elements are removed from the DOM.
|
|
60
|
+
// However, if a focus event occurs outside the element we're tracking, we
|
|
61
|
+
// can manually fire onBlur.
|
|
62
|
+
let currentTarget = e.currentTarget;
|
|
63
|
+
addGlobalListener(ownerDocument, 'focus', (e)=>{
|
|
64
|
+
if (state.current.isFocusWithin && !(nodeContains)(currentTarget, e.target)) {
|
|
65
|
+
let nativeEvent = new ownerDocument.defaultView.FocusEvent('blur', {
|
|
66
|
+
relatedTarget: e.target
|
|
67
|
+
});
|
|
68
|
+
($8a9cb279dc87e130$export$c2b7abe5d61ec696)(nativeEvent, currentTarget);
|
|
69
|
+
let event = ($8a9cb279dc87e130$export$525bc4921d56d4a)(nativeEvent);
|
|
70
|
+
onBlur(event);
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
capture: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}, [
|
|
77
|
+
onFocusWithin,
|
|
78
|
+
onFocusWithinChange,
|
|
79
|
+
onSyntheticFocus,
|
|
80
|
+
addGlobalListener,
|
|
81
|
+
onBlur
|
|
82
|
+
]);
|
|
83
|
+
if (isDisabled) return {
|
|
84
|
+
focusWithinProps: {
|
|
85
|
+
// These cannot be null, that would conflict in mergeProps
|
|
86
|
+
onFocus: undefined,
|
|
87
|
+
onBlur: undefined
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
focusWithinProps: {
|
|
92
|
+
onFocus: onFocus,
|
|
93
|
+
onBlur: onBlur
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { $9ab94262bd0047c7$export$420e68273165f4ec as useFocusWithin };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { useGlobalListeners, getOwnerDocument, nodeContains } from '@react-aria/utils';
|
|
2
|
+
import { useState, useRef, useEffect, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
15
|
+
// Original licensing for the following can be found in the
|
|
16
|
+
// NOTICE file in the root directory of this source tree.
|
|
17
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
|
|
21
|
+
// We want to ignore these emulated events so they do not trigger hover behavior.
|
|
22
|
+
// See https://bugs.webkit.org/show_bug.cgi?id=214609.
|
|
23
|
+
let $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
|
|
24
|
+
let $6179b936705e76d3$var$hoverCount = 0;
|
|
25
|
+
function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
26
|
+
$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true;
|
|
27
|
+
// Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter
|
|
28
|
+
// with pointerType="mouse" immediately after onPointerUp and before onFocus. On other
|
|
29
|
+
// devices that don't have this quirk, we don't want to ignore a mouse hover sometime in
|
|
30
|
+
// the distant future because a user previously touched the element.
|
|
31
|
+
setTimeout(()=>{
|
|
32
|
+
$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
|
|
33
|
+
}, 50);
|
|
34
|
+
}
|
|
35
|
+
function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
|
|
36
|
+
if (e.pointerType === 'touch') $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
37
|
+
}
|
|
38
|
+
function $6179b936705e76d3$var$setupGlobalTouchEvents() {
|
|
39
|
+
if (typeof document === 'undefined') return;
|
|
40
|
+
if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
41
|
+
else if (process.env.NODE_ENV === 'test') document.addEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
42
|
+
$6179b936705e76d3$var$hoverCount++;
|
|
43
|
+
return ()=>{
|
|
44
|
+
$6179b936705e76d3$var$hoverCount--;
|
|
45
|
+
if ($6179b936705e76d3$var$hoverCount > 0) return;
|
|
46
|
+
if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
47
|
+
else if (process.env.NODE_ENV === 'test') document.removeEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
51
|
+
let { onHoverStart: onHoverStart, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, isDisabled: isDisabled } = props;
|
|
52
|
+
let [isHovered, setHovered] = (useState)(false);
|
|
53
|
+
let state = (useRef)({
|
|
54
|
+
isHovered: false,
|
|
55
|
+
ignoreEmulatedMouseEvents: false,
|
|
56
|
+
pointerType: '',
|
|
57
|
+
target: null
|
|
58
|
+
}).current;
|
|
59
|
+
(useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
60
|
+
let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (useGlobalListeners)();
|
|
61
|
+
let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = (useMemo)(()=>{
|
|
62
|
+
let triggerHoverStart = (event, pointerType)=>{
|
|
63
|
+
state.pointerType = pointerType;
|
|
64
|
+
if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
65
|
+
state.isHovered = true;
|
|
66
|
+
let target = event.currentTarget;
|
|
67
|
+
state.target = target;
|
|
68
|
+
// When an element that is hovered over is removed, no pointerleave event is fired by the browser,
|
|
69
|
+
// even though the originally hovered target may have shrunk in size so it is no longer hovered.
|
|
70
|
+
// However, a pointerover event will be fired on the new target the mouse is over.
|
|
71
|
+
// In Chrome this happens immediately. In Safari and Firefox, it happens upon moving the mouse one pixel.
|
|
72
|
+
addGlobalListener((getOwnerDocument)(event.target), 'pointerover', (e)=>{
|
|
73
|
+
if (state.isHovered && state.target && !(nodeContains)(state.target, e.target)) triggerHoverEnd(e, e.pointerType);
|
|
74
|
+
}, {
|
|
75
|
+
capture: true
|
|
76
|
+
});
|
|
77
|
+
if (onHoverStart) onHoverStart({
|
|
78
|
+
type: 'hoverstart',
|
|
79
|
+
target: target,
|
|
80
|
+
pointerType: pointerType
|
|
81
|
+
});
|
|
82
|
+
if (onHoverChange) onHoverChange(true);
|
|
83
|
+
setHovered(true);
|
|
84
|
+
};
|
|
85
|
+
let triggerHoverEnd = (event, pointerType)=>{
|
|
86
|
+
let target = state.target;
|
|
87
|
+
state.pointerType = '';
|
|
88
|
+
state.target = null;
|
|
89
|
+
if (pointerType === 'touch' || !state.isHovered || !target) return;
|
|
90
|
+
state.isHovered = false;
|
|
91
|
+
removeAllGlobalListeners();
|
|
92
|
+
if (onHoverEnd) onHoverEnd({
|
|
93
|
+
type: 'hoverend',
|
|
94
|
+
target: target,
|
|
95
|
+
pointerType: pointerType
|
|
96
|
+
});
|
|
97
|
+
if (onHoverChange) onHoverChange(false);
|
|
98
|
+
setHovered(false);
|
|
99
|
+
};
|
|
100
|
+
let hoverProps = {};
|
|
101
|
+
if (typeof PointerEvent !== 'undefined') {
|
|
102
|
+
hoverProps.onPointerEnter = (e)=>{
|
|
103
|
+
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
|
|
104
|
+
triggerHoverStart(e, e.pointerType);
|
|
105
|
+
};
|
|
106
|
+
hoverProps.onPointerLeave = (e)=>{
|
|
107
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
|
|
108
|
+
};
|
|
109
|
+
} else if (process.env.NODE_ENV === 'test') {
|
|
110
|
+
hoverProps.onTouchStart = ()=>{
|
|
111
|
+
state.ignoreEmulatedMouseEvents = true;
|
|
112
|
+
};
|
|
113
|
+
hoverProps.onMouseEnter = (e)=>{
|
|
114
|
+
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
|
|
115
|
+
state.ignoreEmulatedMouseEvents = false;
|
|
116
|
+
};
|
|
117
|
+
hoverProps.onMouseLeave = (e)=>{
|
|
118
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
hoverProps: hoverProps,
|
|
123
|
+
triggerHoverEnd: triggerHoverEnd
|
|
124
|
+
};
|
|
125
|
+
}, [
|
|
126
|
+
onHoverStart,
|
|
127
|
+
onHoverChange,
|
|
128
|
+
onHoverEnd,
|
|
129
|
+
isDisabled,
|
|
130
|
+
state,
|
|
131
|
+
addGlobalListener,
|
|
132
|
+
removeAllGlobalListeners
|
|
133
|
+
]);
|
|
134
|
+
(useEffect)(()=>{
|
|
135
|
+
// Call the triggerHoverEnd as soon as isDisabled changes to true
|
|
136
|
+
// Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
|
|
137
|
+
if (isDisabled) triggerHoverEnd({
|
|
138
|
+
currentTarget: state.target
|
|
139
|
+
}, state.pointerType);
|
|
140
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
+
}, [
|
|
142
|
+
isDisabled
|
|
143
|
+
]);
|
|
144
|
+
return {
|
|
145
|
+
hoverProps: hoverProps,
|
|
146
|
+
isHovered: isHovered
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { $6179b936705e76d3$export$ae780daf29e6d456 as useHover };
|