@opengovsg/oui 0.0.0-snapshot-20250812083020 → 0.0.0-snapshot-20250813172831

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.
Files changed (147) hide show
  1. package/dist/cjs/badge/badge.cjs +4 -4
  2. package/dist/cjs/badge/use-badge.cjs +6 -6
  3. package/dist/cjs/banner/banner.cjs +3 -3
  4. package/dist/cjs/button/button.cjs +4 -4
  5. package/dist/cjs/calendar/calendar-bottom-content.cjs +2 -2
  6. package/dist/cjs/calendar/calendar-header.cjs +2 -2
  7. package/dist/cjs/calendar/calendar-month-day-selector.cjs +4 -4
  8. package/dist/cjs/calendar/calendar.cjs +4 -4
  9. package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
  10. package/dist/cjs/calendar/utils.cjs +3 -3
  11. package/dist/cjs/checkbox/checkbox-group-style-context.cjs +16 -0
  12. package/dist/cjs/checkbox/checkbox.cjs +94 -0
  13. package/dist/cjs/checkbox/index.cjs +12 -0
  14. package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
  15. package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
  16. package/dist/cjs/combo-box/combo-box.cjs +4 -4
  17. package/dist/cjs/date-field/date-field.cjs +3 -3
  18. package/dist/cjs/date-picker/date-picker.cjs +3 -3
  19. package/dist/cjs/date-range-picker/date-range-picker.cjs +5 -5
  20. package/dist/cjs/govt-banner/govt-banner.cjs +3 -3
  21. package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
  22. package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
  23. package/dist/cjs/index.cjs +56 -39
  24. package/dist/cjs/input/input.cjs +2 -2
  25. package/dist/cjs/menu/menu.cjs +7 -7
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs +9 -0
  36. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs +9 -0
  37. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs +16 -0
  38. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs +9 -0
  39. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.cjs +11 -0
  40. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.cjs +10 -0
  41. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.cjs +12 -0
  42. 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
  43. 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
  44. 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
  45. 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
  46. 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
  47. package/dist/cjs/pagination/hooks/use-pagination.cjs +117 -0
  48. package/dist/cjs/pagination/index.cjs +17 -0
  49. package/dist/cjs/pagination/pagination-cursor.cjs +18 -0
  50. package/dist/cjs/pagination/pagination-item.cjs +18 -0
  51. package/dist/cjs/pagination/pagination.cjs +263 -0
  52. package/dist/cjs/pagination/use-pagination-item.cjs +87 -0
  53. package/dist/cjs/pagination/use-pagination.cjs +251 -0
  54. package/dist/cjs/range-calendar/range-calendar.cjs +6 -6
  55. package/dist/cjs/ripple/use-ripple.cjs +4 -4
  56. package/dist/cjs/select/select.cjs +3 -3
  57. package/dist/cjs/spinner/use-spinner.cjs +3 -3
  58. package/dist/cjs/system/react-utils/context.cjs +3 -3
  59. package/dist/cjs/system/react-utils/dom-props.cjs +186 -0
  60. package/dist/cjs/system/react-utils/filter-dom-props.cjs +46 -0
  61. package/dist/cjs/system/react-utils/index.cjs +2 -0
  62. package/dist/cjs/system/react-utils/refs.cjs +3 -3
  63. package/dist/cjs/system/utils.cjs +3 -3
  64. package/dist/cjs/tabs/tabs.cjs +2 -2
  65. package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
  66. package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
  67. package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
  68. package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
  69. package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
  70. package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
  71. package/dist/cjs/tag-field/tag-field.cjs +4 -4
  72. package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
  73. package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
  74. package/dist/cjs/text-area/text-area.cjs +2 -2
  75. package/dist/cjs/toggle/toggle.cjs +3 -3
  76. package/dist/esm/button/button.js +1 -1
  77. package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
  78. package/dist/esm/checkbox/checkbox-group-style-context.js +13 -0
  79. package/dist/esm/checkbox/checkbox.js +91 -0
  80. package/dist/esm/checkbox/index.js +3 -0
  81. package/dist/esm/combo-box/combo-box.js +1 -1
  82. package/dist/esm/date-picker/date-picker.js +1 -1
  83. package/dist/esm/date-range-picker/date-range-picker.js +2 -2
  84. package/dist/esm/index.js +19 -12
  85. package/dist/esm/menu/menu.js +1 -1
  86. 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
  87. 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
  88. 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
  89. 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
  90. 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
  91. 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
  92. 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
  93. 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
  94. 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
  95. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +7 -0
  96. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js +7 -0
  97. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js +14 -0
  98. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js +7 -0
  99. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.js +9 -0
  100. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.js +8 -0
  101. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.js +10 -0
  102. 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
  103. 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
  104. 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
  105. package/dist/esm/pagination/hooks/use-pagination.js +114 -0
  106. package/dist/esm/pagination/index.js +6 -0
  107. package/dist/esm/pagination/pagination-cursor.js +16 -0
  108. package/dist/esm/pagination/pagination-item.js +16 -0
  109. package/dist/esm/pagination/pagination.js +261 -0
  110. package/dist/esm/pagination/use-pagination-item.js +85 -0
  111. package/dist/esm/pagination/use-pagination.js +248 -0
  112. package/dist/esm/select/select.js +1 -1
  113. package/dist/esm/system/react-utils/dom-props.js +183 -0
  114. package/dist/esm/system/react-utils/filter-dom-props.js +44 -0
  115. package/dist/esm/system/react-utils/index.js +1 -0
  116. package/dist/esm/tag-field/tag-field.js +2 -2
  117. package/dist/types/checkbox/checkbox-group-style-context.d.ts +6 -0
  118. package/dist/types/checkbox/checkbox-group-style-context.d.ts.map +1 -0
  119. package/dist/types/checkbox/checkbox.d.ts +19 -0
  120. package/dist/types/checkbox/checkbox.d.ts.map +1 -0
  121. package/dist/types/checkbox/index.d.ts +3 -0
  122. package/dist/types/checkbox/index.d.ts.map +1 -0
  123. package/dist/types/index.d.mts +2 -0
  124. package/dist/types/index.d.ts +2 -0
  125. package/dist/types/index.d.ts.map +1 -1
  126. package/dist/types/pagination/hooks/use-pagination.d.ts +51 -0
  127. package/dist/types/pagination/hooks/use-pagination.d.ts.map +1 -0
  128. package/dist/types/pagination/index.d.ts +7 -0
  129. package/dist/types/pagination/index.d.ts.map +1 -0
  130. package/dist/types/pagination/pagination-cursor.d.ts +9 -0
  131. package/dist/types/pagination/pagination-cursor.d.ts.map +1 -0
  132. package/dist/types/pagination/pagination-item.d.ts +5 -0
  133. package/dist/types/pagination/pagination-item.d.ts.map +1 -0
  134. package/dist/types/pagination/pagination.d.ts +5 -0
  135. package/dist/types/pagination/pagination.d.ts.map +1 -0
  136. package/dist/types/pagination/use-pagination-item.d.ts +51 -0
  137. package/dist/types/pagination/use-pagination-item.d.ts.map +1 -0
  138. package/dist/types/pagination/use-pagination.d.ts +353 -0
  139. package/dist/types/pagination/use-pagination.d.ts.map +1 -0
  140. package/dist/types/system/react-utils/context.d.ts.map +1 -1
  141. package/dist/types/system/react-utils/dom-props.d.ts +3 -0
  142. package/dist/types/system/react-utils/dom-props.d.ts.map +1 -0
  143. package/dist/types/system/react-utils/filter-dom-props.d.ts +39 -0
  144. package/dist/types/system/react-utils/filter-dom-props.d.ts.map +1 -0
  145. package/dist/types/system/react-utils/index.d.ts +1 -0
  146. package/dist/types/system/react-utils/index.d.ts.map +1 -1
  147. package/package.json +8 -6
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+
3
+ var utils$1 = require('./utils.cjs');
4
+ var $670gB$react = require('react');
5
+ var utils = require('@react-aria/utils');
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ // Portions of the code in this file are based on code from react.
18
+ // Original licensing for the following can be found in the
19
+ // NOTICE file in the root directory of this source tree.
20
+ // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
21
+
22
+
23
+
24
+ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
25
+ let { isDisabled: isDisabled, onBlurWithin: onBlurWithin, onFocusWithin: onFocusWithin, onFocusWithinChange: onFocusWithinChange } = props;
26
+ let state = ($670gB$react.useRef)({
27
+ isFocusWithin: false
28
+ });
29
+ let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (utils.useGlobalListeners)();
30
+ let onBlur = ($670gB$react.useCallback)((e)=>{
31
+ // Ignore events bubbling through portals.
32
+ if (!e.currentTarget.contains(e.target)) return;
33
+ // We don't want to trigger onBlurWithin and then immediately onFocusWithin again
34
+ // when moving focus inside the element. Only trigger if the currentTarget doesn't
35
+ // include the relatedTarget (where focus is moving).
36
+ if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
37
+ state.current.isFocusWithin = false;
38
+ removeAllGlobalListeners();
39
+ if (onBlurWithin) onBlurWithin(e);
40
+ if (onFocusWithinChange) onFocusWithinChange(false);
41
+ }
42
+ }, [
43
+ onBlurWithin,
44
+ onFocusWithinChange,
45
+ state,
46
+ removeAllGlobalListeners
47
+ ]);
48
+ let onSyntheticFocus = (utils$1.useSyntheticBlurEvent)(onBlur);
49
+ let onFocus = ($670gB$react.useCallback)((e)=>{
50
+ // Ignore events bubbling through portals.
51
+ if (!e.currentTarget.contains(e.target)) return;
52
+ // Double check that document.activeElement actually matches e.target in case a previously chained
53
+ // focus handler already moved focus somewhere else.
54
+ const ownerDocument = (utils.getOwnerDocument)(e.target);
55
+ const activeElement = (utils.getActiveElement)(ownerDocument);
56
+ if (!state.current.isFocusWithin && activeElement === (utils.getEventTarget)(e.nativeEvent)) {
57
+ if (onFocusWithin) onFocusWithin(e);
58
+ if (onFocusWithinChange) onFocusWithinChange(true);
59
+ state.current.isFocusWithin = true;
60
+ onSyntheticFocus(e);
61
+ // Browsers don't fire blur events when elements are removed from the DOM.
62
+ // However, if a focus event occurs outside the element we're tracking, we
63
+ // can manually fire onBlur.
64
+ let currentTarget = e.currentTarget;
65
+ addGlobalListener(ownerDocument, 'focus', (e)=>{
66
+ if (state.current.isFocusWithin && !(utils.nodeContains)(currentTarget, e.target)) {
67
+ let nativeEvent = new ownerDocument.defaultView.FocusEvent('blur', {
68
+ relatedTarget: e.target
69
+ });
70
+ (utils$1.setEventTarget)(nativeEvent, currentTarget);
71
+ let event = (utils$1.createSyntheticEvent)(nativeEvent);
72
+ onBlur(event);
73
+ }
74
+ }, {
75
+ capture: true
76
+ });
77
+ }
78
+ }, [
79
+ onFocusWithin,
80
+ onFocusWithinChange,
81
+ onSyntheticFocus,
82
+ addGlobalListener,
83
+ onBlur
84
+ ]);
85
+ if (isDisabled) return {
86
+ focusWithinProps: {
87
+ // These cannot be null, that would conflict in mergeProps
88
+ onFocus: undefined,
89
+ onBlur: undefined
90
+ }
91
+ };
92
+ return {
93
+ focusWithinProps: {
94
+ onFocus: onFocus,
95
+ onBlur: onBlur
96
+ }
97
+ };
98
+ }
99
+
100
+ exports.useFocusWithin = $9ab94262bd0047c7$export$420e68273165f4ec;
@@ -0,0 +1,152 @@
1
+ 'use strict';
2
+
3
+ var utils = require('@react-aria/utils');
4
+ var $670gB$react = require('react');
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */ // Portions of the code in this file are based on code from react.
17
+ // Original licensing for the following can be found in the
18
+ // NOTICE file in the root directory of this source tree.
19
+ // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
20
+
21
+
22
+ // iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
23
+ // We want to ignore these emulated events so they do not trigger hover behavior.
24
+ // See https://bugs.webkit.org/show_bug.cgi?id=214609.
25
+ let $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
26
+ let $6179b936705e76d3$var$hoverCount = 0;
27
+ function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
28
+ $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true;
29
+ // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter
30
+ // with pointerType="mouse" immediately after onPointerUp and before onFocus. On other
31
+ // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in
32
+ // the distant future because a user previously touched the element.
33
+ setTimeout(()=>{
34
+ $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
35
+ }, 50);
36
+ }
37
+ function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
38
+ if (e.pointerType === 'touch') $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
39
+ }
40
+ function $6179b936705e76d3$var$setupGlobalTouchEvents() {
41
+ if (typeof document === 'undefined') return;
42
+ if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
43
+ else if (process.env.NODE_ENV === 'test') document.addEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
44
+ $6179b936705e76d3$var$hoverCount++;
45
+ return ()=>{
46
+ $6179b936705e76d3$var$hoverCount--;
47
+ if ($6179b936705e76d3$var$hoverCount > 0) return;
48
+ if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
49
+ else if (process.env.NODE_ENV === 'test') document.removeEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
50
+ };
51
+ }
52
+ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
53
+ let { onHoverStart: onHoverStart, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, isDisabled: isDisabled } = props;
54
+ let [isHovered, setHovered] = ($670gB$react.useState)(false);
55
+ let state = ($670gB$react.useRef)({
56
+ isHovered: false,
57
+ ignoreEmulatedMouseEvents: false,
58
+ pointerType: '',
59
+ target: null
60
+ }).current;
61
+ ($670gB$react.useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
62
+ let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (utils.useGlobalListeners)();
63
+ let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = ($670gB$react.useMemo)(()=>{
64
+ let triggerHoverStart = (event, pointerType)=>{
65
+ state.pointerType = pointerType;
66
+ if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
67
+ state.isHovered = true;
68
+ let target = event.currentTarget;
69
+ state.target = target;
70
+ // When an element that is hovered over is removed, no pointerleave event is fired by the browser,
71
+ // even though the originally hovered target may have shrunk in size so it is no longer hovered.
72
+ // However, a pointerover event will be fired on the new target the mouse is over.
73
+ // In Chrome this happens immediately. In Safari and Firefox, it happens upon moving the mouse one pixel.
74
+ addGlobalListener((utils.getOwnerDocument)(event.target), 'pointerover', (e)=>{
75
+ if (state.isHovered && state.target && !(utils.nodeContains)(state.target, e.target)) triggerHoverEnd(e, e.pointerType);
76
+ }, {
77
+ capture: true
78
+ });
79
+ if (onHoverStart) onHoverStart({
80
+ type: 'hoverstart',
81
+ target: target,
82
+ pointerType: pointerType
83
+ });
84
+ if (onHoverChange) onHoverChange(true);
85
+ setHovered(true);
86
+ };
87
+ let triggerHoverEnd = (event, pointerType)=>{
88
+ let target = state.target;
89
+ state.pointerType = '';
90
+ state.target = null;
91
+ if (pointerType === 'touch' || !state.isHovered || !target) return;
92
+ state.isHovered = false;
93
+ removeAllGlobalListeners();
94
+ if (onHoverEnd) onHoverEnd({
95
+ type: 'hoverend',
96
+ target: target,
97
+ pointerType: pointerType
98
+ });
99
+ if (onHoverChange) onHoverChange(false);
100
+ setHovered(false);
101
+ };
102
+ let hoverProps = {};
103
+ if (typeof PointerEvent !== 'undefined') {
104
+ hoverProps.onPointerEnter = (e)=>{
105
+ if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
106
+ triggerHoverStart(e, e.pointerType);
107
+ };
108
+ hoverProps.onPointerLeave = (e)=>{
109
+ if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
110
+ };
111
+ } else if (process.env.NODE_ENV === 'test') {
112
+ hoverProps.onTouchStart = ()=>{
113
+ state.ignoreEmulatedMouseEvents = true;
114
+ };
115
+ hoverProps.onMouseEnter = (e)=>{
116
+ if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
117
+ state.ignoreEmulatedMouseEvents = false;
118
+ };
119
+ hoverProps.onMouseLeave = (e)=>{
120
+ if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
121
+ };
122
+ }
123
+ return {
124
+ hoverProps: hoverProps,
125
+ triggerHoverEnd: triggerHoverEnd
126
+ };
127
+ }, [
128
+ onHoverStart,
129
+ onHoverChange,
130
+ onHoverEnd,
131
+ isDisabled,
132
+ state,
133
+ addGlobalListener,
134
+ removeAllGlobalListeners
135
+ ]);
136
+ ($670gB$react.useEffect)(()=>{
137
+ // Call the triggerHoverEnd as soon as isDisabled changes to true
138
+ // Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
139
+ if (isDisabled) triggerHoverEnd({
140
+ currentTarget: state.target
141
+ }, state.pointerType);
142
+ // eslint-disable-next-line react-hooks/exhaustive-deps
143
+ }, [
144
+ isDisabled
145
+ ]);
146
+ return {
147
+ hoverProps: hoverProps,
148
+ isHovered: isHovered
149
+ };
150
+ }
151
+
152
+ exports.useHover = $6179b936705e76d3$export$ae780daf29e6d456;