@opengovsg/oui 0.0.22 → 0.0.24

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 (115) 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 +3 -3
  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.cjs +1 -1
  12. package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
  13. package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
  14. package/dist/cjs/combo-box/combo-box.cjs +5 -5
  15. package/dist/cjs/date-field/date-field.cjs +4 -4
  16. package/dist/cjs/date-picker/date-picker.cjs +4 -4
  17. package/dist/cjs/date-range-picker/date-range-picker.cjs +6 -6
  18. package/dist/cjs/field/field.cjs +2 -2
  19. package/dist/cjs/file-dropzone/file-dropzone.cjs +12 -12
  20. package/dist/cjs/file-dropzone/file-info.cjs +3 -3
  21. package/dist/cjs/govt-banner/govt-banner.cjs +3 -3
  22. package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
  23. package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
  24. package/dist/cjs/index.cjs +49 -47
  25. package/dist/cjs/input/input.cjs +2 -2
  26. package/dist/cjs/menu/menu.cjs +7 -7
  27. 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
  28. 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
  29. package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/plus.cjs +22 -0
  30. package/dist/cjs/number-field/index.cjs +8 -0
  31. package/dist/cjs/number-field/number-field.cjs +136 -0
  32. package/dist/cjs/pagination/hooks/use-pagination.cjs +7 -7
  33. package/dist/cjs/pagination/pagination.cjs +6 -6
  34. package/dist/cjs/pagination/use-pagination-item.cjs +7 -8
  35. package/dist/cjs/pagination/use-pagination.cjs +8 -8
  36. package/dist/cjs/range-calendar/range-calendar.cjs +6 -6
  37. package/dist/cjs/ripple/use-ripple.cjs +4 -4
  38. package/dist/cjs/select/select.cjs +4 -4
  39. package/dist/cjs/spinner/use-spinner.cjs +3 -3
  40. package/dist/cjs/system/react-utils/context.cjs +3 -3
  41. package/dist/cjs/system/react-utils/refs.cjs +3 -3
  42. package/dist/cjs/system/utils.cjs +3 -3
  43. package/dist/cjs/tabs/tabs.cjs +2 -2
  44. package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
  45. package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
  46. package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
  47. package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
  48. package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
  49. package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
  50. package/dist/cjs/tag-field/tag-field.cjs +5 -5
  51. package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
  52. package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
  53. package/dist/cjs/text-area/text-area.cjs +2 -2
  54. package/dist/cjs/text-area-field/text-area-field.cjs +1 -1
  55. package/dist/cjs/text-field/text-field.cjs +1 -1
  56. package/dist/cjs/toggle/toggle.cjs +3 -3
  57. package/dist/esm/button/button.js +1 -1
  58. package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
  59. package/dist/esm/checkbox/checkbox.js +1 -1
  60. package/dist/esm/combo-box/combo-box.js +2 -2
  61. package/dist/esm/date-field/date-field.js +1 -1
  62. package/dist/esm/date-picker/date-picker.js +2 -2
  63. package/dist/esm/date-range-picker/date-range-picker.js +3 -3
  64. package/dist/esm/file-dropzone/file-dropzone.js +2 -2
  65. package/dist/esm/index.js +18 -17
  66. package/dist/esm/menu/menu.js +1 -1
  67. package/dist/esm/node_modules/.pnpm/lucide-react@0.475.0_react@19.0.0/node_modules/lucide-react/dist/esm/icons/plus.js +17 -0
  68. package/dist/esm/number-field/index.js +2 -0
  69. package/dist/esm/number-field/number-field.js +134 -0
  70. package/dist/esm/pagination/use-pagination-item.js +5 -6
  71. package/dist/esm/select/select.js +2 -2
  72. package/dist/esm/tag-field/tag-field.js +3 -3
  73. package/dist/esm/text-area-field/text-area-field.js +1 -1
  74. package/dist/esm/text-field/text-field.js +1 -1
  75. package/dist/types/index.d.mts +1 -0
  76. package/dist/types/index.d.ts +1 -0
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/menu/menu.d.ts.map +1 -1
  79. package/dist/types/number-field/index.d.ts +3 -0
  80. package/dist/types/number-field/index.d.ts.map +1 -0
  81. package/dist/types/number-field/number-field.d.ts +24 -0
  82. package/dist/types/number-field/number-field.d.ts.map +1 -0
  83. package/package.json +11 -8
  84. 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 +0 -45
  85. 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 +0 -21
  86. 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 +0 -72
  87. 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 +0 -60
  88. 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 +0 -210
  89. 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 +0 -100
  90. 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 +0 -152
  91. 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 +0 -676
  92. 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 +0 -160
  93. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs +0 -9
  94. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs +0 -9
  95. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs +0 -16
  96. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs +0 -9
  97. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.cjs +0 -11
  98. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.cjs +0 -10
  99. package/dist/cjs/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.cjs +0 -12
  100. 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 +0 -43
  101. 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 +0 -19
  102. 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 +0 -69
  103. 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 +0 -58
  104. 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 +0 -205
  105. 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 +0 -98
  106. 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 +0 -150
  107. 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 +0 -674
  108. 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 +0 -155
  109. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_check_private_redeclaration.js +0 -7
  110. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js +0 -7
  111. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js +0 -14
  112. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js +0 -7
  113. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_get.js +0 -9
  114. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_init.js +0 -8
  115. package/dist/esm/node_modules/.pnpm/@swc_helpers@0.5.17/node_modules/@swc/helpers/esm/_class_private_field_set.js +0 -10
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('@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
- */
16
- // Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
17
- // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
18
- let $14c0b72509d70225$var$state = 'default';
19
- let $14c0b72509d70225$var$savedUserSelect = '';
20
- let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
21
- function $14c0b72509d70225$export$16a4697467175487(target) {
22
- if ((utils.isIOS)()) {
23
- if ($14c0b72509d70225$var$state === 'default') {
24
- const documentObject = (utils.getOwnerDocument)(target);
25
- $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
26
- documentObject.documentElement.style.webkitUserSelect = 'none';
27
- }
28
- $14c0b72509d70225$var$state = 'disabled';
29
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
30
- // If not iOS, store the target's original user-select and change to user-select: none
31
- // Ignore state since it doesn't apply for non iOS
32
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
33
- $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]);
34
- target.style[property] = 'none';
35
- }
36
- }
37
- function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
38
- if ((utils.isIOS)()) {
39
- // If the state is already default, there's nothing to do.
40
- // If it is restoring, then there's no need to queue a second restore.
41
- if ($14c0b72509d70225$var$state !== 'disabled') return;
42
- $14c0b72509d70225$var$state = 'restoring';
43
- // There appears to be a delay on iOS where selection still might occur
44
- // after pointer up, so wait a bit before removing user-select.
45
- setTimeout(()=>{
46
- // Wait for any CSS transitions to complete so we don't recompute style
47
- // for the whole page in the middle of the animation and cause jank.
48
- (utils.runAfterTransition)(()=>{
49
- // Avoid race conditions
50
- if ($14c0b72509d70225$var$state === 'restoring') {
51
- const documentObject = (utils.getOwnerDocument)(target);
52
- if (documentObject.documentElement.style.webkitUserSelect === 'none') documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || '';
53
- $14c0b72509d70225$var$savedUserSelect = '';
54
- $14c0b72509d70225$var$state = 'default';
55
- }
56
- });
57
- }, 300);
58
- } else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
59
- // Ignore state since it doesn't apply for non iOS
60
- {
61
- if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
62
- let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
63
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
64
- if (target.style[property] === 'none') target.style[property] = targetOldUserSelect;
65
- if (target.getAttribute('style') === '') target.removeAttribute('style');
66
- $14c0b72509d70225$var$modifiedElementMap.delete(target);
67
- }
68
- }
69
- }
70
-
71
- exports.disableTextSelection = $14c0b72509d70225$export$16a4697467175487;
72
- exports.restoreTextSelection = $14c0b72509d70225$export$b0d6fa1ab32e3295;
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('./utils.cjs');
4
- var $670gB$react = require('react');
5
- var utils$1 = 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 $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
25
- let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
26
- const onBlur = ($670gB$react.useCallback)((e)=>{
27
- if (e.target === e.currentTarget) {
28
- if (onBlurProp) onBlurProp(e);
29
- if (onFocusChange) onFocusChange(false);
30
- return true;
31
- }
32
- }, [
33
- onBlurProp,
34
- onFocusChange
35
- ]);
36
- const onSyntheticFocus = (utils.useSyntheticBlurEvent)(onBlur);
37
- const onFocus = ($670gB$react.useCallback)((e)=>{
38
- // Double check that document.activeElement actually matches e.target in case a previously chained
39
- // focus handler already moved focus somewhere else.
40
- const ownerDocument = (utils$1.getOwnerDocument)(e.target);
41
- const activeElement = ownerDocument ? (utils$1.getActiveElement)(ownerDocument) : (utils$1.getActiveElement)();
42
- if (e.target === e.currentTarget && activeElement === (utils$1.getEventTarget)(e.nativeEvent)) {
43
- if (onFocusProp) onFocusProp(e);
44
- if (onFocusChange) onFocusChange(true);
45
- onSyntheticFocus(e);
46
- }
47
- }, [
48
- onFocusChange,
49
- onFocusProp,
50
- onSyntheticFocus
51
- ]);
52
- return {
53
- focusProps: {
54
- onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
55
- onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
56
- }
57
- };
58
- }
59
-
60
- exports.useFocus = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6;
@@ -1,210 +0,0 @@
1
- 'use strict';
2
-
3
- var utils$1 = require('./utils.cjs');
4
- var utils = require('@react-aria/utils');
5
- var $670gB$react = require('react');
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
-
25
- let $507fabe10e71c6fb$var$currentModality = null;
26
- let $507fabe10e71c6fb$var$changeHandlers = new Set();
27
- let $507fabe10e71c6fb$export$d90243b58daecda7 = new Map(); // We use a map here to support setting event listeners across multiple document objects.
28
- let $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
29
- let $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
30
- // Only Tab or Esc keys will make focus visible on text input elements
31
- const $507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS = {
32
- Tab: true,
33
- Escape: true
34
- };
35
- function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
36
- for (let handler of $507fabe10e71c6fb$var$changeHandlers)handler(modality, e);
37
- }
38
- /**
39
- * Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
40
- */ function $507fabe10e71c6fb$var$isValidKey(e) {
41
- // Control and Shift keys trigger when navigating back to the tab with keyboard.
42
- return !(e.metaKey || !(utils.isMac)() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
43
- }
44
- function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
45
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
46
- if ($507fabe10e71c6fb$var$isValidKey(e)) {
47
- $507fabe10e71c6fb$var$currentModality = 'keyboard';
48
- $507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
49
- }
50
- }
51
- function $507fabe10e71c6fb$var$handlePointerEvent(e) {
52
- $507fabe10e71c6fb$var$currentModality = 'pointer';
53
- if (e.type === 'mousedown' || e.type === 'pointerdown') {
54
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
55
- $507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
56
- }
57
- }
58
- function $507fabe10e71c6fb$var$handleClickEvent(e) {
59
- if ((utils.isVirtualClick)(e)) {
60
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
61
- $507fabe10e71c6fb$var$currentModality = 'virtual';
62
- }
63
- }
64
- function $507fabe10e71c6fb$var$handleFocusEvent(e) {
65
- // Firefox fires two extra focus events when the user first clicks into an iframe:
66
- // first on the window, then on the document. We ignore these events so they don't
67
- // cause keyboard focus rings to appear.
68
- if (e.target === window || e.target === document || (utils$1.ignoreFocusEvent) || !e.isTrusted) return;
69
- // If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
70
- // This occurs, for example, when navigating a form with the next/previous buttons on iOS.
71
- if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
72
- $507fabe10e71c6fb$var$currentModality = 'virtual';
73
- $507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
74
- }
75
- $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
76
- $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
77
- }
78
- function $507fabe10e71c6fb$var$handleWindowBlur() {
79
- if (utils$1.ignoreFocusEvent) return;
80
- // When the window is blurred, reset state. This is necessary when tabbing out of the window,
81
- // for example, since a subsequent focus event won't be fired.
82
- $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
83
- $507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
84
- }
85
- /**
86
- * Setup global event listeners to control when keyboard focus style should be visible.
87
- */ function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
88
- if (typeof window === 'undefined' || typeof document === 'undefined' || $507fabe10e71c6fb$export$d90243b58daecda7.get((utils.getOwnerWindow)(element))) return;
89
- const windowObject = (utils.getOwnerWindow)(element);
90
- const documentObject = (utils.getOwnerDocument)(element);
91
- // Programmatic focus() calls shouldn't affect the current input modality.
92
- // However, we need to detect other cases when a focus event occurs without
93
- // a preceding user event (e.g. screen reader focus). Overriding the focus
94
- // method on HTMLElement.prototype is a bit hacky, but works.
95
- let focus = windowObject.HTMLElement.prototype.focus;
96
- windowObject.HTMLElement.prototype.focus = function() {
97
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
98
- focus.apply(this, arguments);
99
- };
100
- documentObject.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
101
- documentObject.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
102
- documentObject.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
103
- // Register focus events on the window so they are sure to happen
104
- // before React's event listeners (registered on the document).
105
- windowObject.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
106
- windowObject.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
107
- if (typeof PointerEvent !== 'undefined') {
108
- documentObject.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
109
- documentObject.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
110
- documentObject.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
111
- } else if (process.env.NODE_ENV === 'test') {
112
- documentObject.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
113
- documentObject.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
114
- documentObject.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
115
- }
116
- // Add unmount handler
117
- windowObject.addEventListener('beforeunload', ()=>{
118
- $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
119
- }, {
120
- once: true
121
- });
122
- $507fabe10e71c6fb$export$d90243b58daecda7.set(windowObject, {
123
- focus: focus
124
- });
125
- }
126
- const $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener)=>{
127
- const windowObject = (utils.getOwnerWindow)(element);
128
- const documentObject = (utils.getOwnerDocument)(element);
129
- if (loadListener) documentObject.removeEventListener('DOMContentLoaded', loadListener);
130
- if (!$507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject)) return;
131
- windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus;
132
- documentObject.removeEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
133
- documentObject.removeEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
134
- documentObject.removeEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
135
- windowObject.removeEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
136
- windowObject.removeEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
137
- if (typeof PointerEvent !== 'undefined') {
138
- documentObject.removeEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
139
- documentObject.removeEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
140
- documentObject.removeEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
141
- } else if (process.env.NODE_ENV === 'test') {
142
- documentObject.removeEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
143
- documentObject.removeEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
144
- documentObject.removeEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
145
- }
146
- $507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject);
147
- };
148
- function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
149
- const documentObject = (utils.getOwnerDocument)(element);
150
- let loadListener;
151
- if (documentObject.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
152
- else {
153
- loadListener = ()=>{
154
- $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
155
- };
156
- documentObject.addEventListener('DOMContentLoaded', loadListener);
157
- }
158
- return ()=>$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
159
- }
160
- // Server-side rendering does not have the document object defined
161
- // eslint-disable-next-line no-restricted-globals
162
- if (typeof document !== 'undefined') $507fabe10e71c6fb$export$2f1888112f558a7d();
163
- function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
164
- return $507fabe10e71c6fb$var$currentModality !== 'pointer';
165
- }
166
- const $507fabe10e71c6fb$var$nonTextInputTypes = new Set([
167
- 'checkbox',
168
- 'radio',
169
- 'range',
170
- 'color',
171
- 'file',
172
- 'image',
173
- 'button',
174
- 'submit',
175
- 'reset'
176
- ]);
177
- /**
178
- * If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
179
- * focus visible style can be properly set.
180
- */ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
181
- let document1 = (utils.getOwnerDocument)(e === null || e === void 0 ? void 0 : e.target);
182
- const IHTMLInputElement = typeof window !== 'undefined' ? (utils.getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLInputElement : HTMLInputElement;
183
- const IHTMLTextAreaElement = typeof window !== 'undefined' ? (utils.getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLTextAreaElement : HTMLTextAreaElement;
184
- const IHTMLElement = typeof window !== 'undefined' ? (utils.getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLElement : HTMLElement;
185
- const IKeyboardEvent = typeof window !== 'undefined' ? (utils.getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).KeyboardEvent : KeyboardEvent;
186
- // 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)
187
- // we need to rely on the user passing isTextInput into here. This way we can skip toggling focus visiblity for said input element
188
- isTextInput = isTextInput || document1.activeElement instanceof IHTMLInputElement && !$507fabe10e71c6fb$var$nonTextInputTypes.has(document1.activeElement.type) || document1.activeElement instanceof IHTMLTextAreaElement || document1.activeElement instanceof IHTMLElement && document1.activeElement.isContentEditable;
189
- return !(isTextInput && modality === 'keyboard' && e instanceof IKeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
190
- }
191
- function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
192
- $507fabe10e71c6fb$var$setupGlobalFocusEvents();
193
- ($670gB$react.useEffect)(()=>{
194
- let handler = (modality, e)=>{
195
- // We want to early return for any keyboard events that occur inside text inputs EXCEPT for Tab and Escape
196
- if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(!!(opts === null || opts === void 0 ? void 0 : opts.isTextInput), modality, e)) return;
197
- fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
198
- };
199
- $507fabe10e71c6fb$var$changeHandlers.add(handler);
200
- return ()=>{
201
- $507fabe10e71c6fb$var$changeHandlers.delete(handler);
202
- };
203
- // eslint-disable-next-line react-hooks/exhaustive-deps
204
- }, deps);
205
- }
206
-
207
- exports.addWindowFocusTracking = $507fabe10e71c6fb$export$2f1888112f558a7d;
208
- exports.hasSetupGlobalListeners = $507fabe10e71c6fb$export$d90243b58daecda7;
209
- exports.isFocusVisible = $507fabe10e71c6fb$export$b9b3dfddab17db27;
210
- exports.useFocusVisibleListener = $507fabe10e71c6fb$export$ec71b4b83ac08ec3;
@@ -1,100 +0,0 @@
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;
@@ -1,152 +0,0 @@
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;