react-aria 3.51.0 → 3.52.1

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 (142) hide show
  1. package/dist/exports/index.cjs +1 -0
  2. package/dist/exports/index.cjs.map +1 -1
  3. package/dist/exports/index.js +2 -2
  4. package/dist/exports/index.js.map +1 -1
  5. package/dist/exports/index.mjs +2 -2
  6. package/dist/exports/index.mjs.map +1 -1
  7. package/dist/exports/private/utils/domHelpers.cjs +1 -0
  8. package/dist/exports/private/utils/domHelpers.cjs.map +1 -1
  9. package/dist/exports/private/utils/domHelpers.js +2 -2
  10. package/dist/exports/private/utils/domHelpers.js.map +1 -1
  11. package/dist/exports/private/utils/domHelpers.mjs +2 -2
  12. package/dist/exports/private/utils/domHelpers.mjs.map +1 -1
  13. package/dist/exports/useFocusVisible.cjs +1 -0
  14. package/dist/exports/useFocusVisible.cjs.map +1 -1
  15. package/dist/exports/useFocusVisible.js +2 -2
  16. package/dist/exports/useFocusVisible.js.map +1 -1
  17. package/dist/exports/useFocusVisible.mjs +2 -2
  18. package/dist/exports/useFocusVisible.mjs.map +1 -1
  19. package/dist/private/actiongroup/useActionGroup.cjs +3 -1
  20. package/dist/private/actiongroup/useActionGroup.cjs.map +1 -1
  21. package/dist/private/actiongroup/useActionGroup.js +3 -1
  22. package/dist/private/actiongroup/useActionGroup.js.map +1 -1
  23. package/dist/private/actiongroup/useActionGroup.mjs +3 -1
  24. package/dist/private/actiongroup/useActionGroup.mjs.map +1 -1
  25. package/dist/private/calendar/useRangeCalendar.cjs +1 -1
  26. package/dist/private/calendar/useRangeCalendar.cjs.map +1 -1
  27. package/dist/private/calendar/useRangeCalendar.js +2 -2
  28. package/dist/private/calendar/useRangeCalendar.js.map +1 -1
  29. package/dist/private/calendar/useRangeCalendar.mjs +2 -2
  30. package/dist/private/calendar/useRangeCalendar.mjs.map +1 -1
  31. package/dist/private/color/useColorField.cjs +26 -4
  32. package/dist/private/color/useColorField.cjs.map +1 -1
  33. package/dist/private/color/useColorField.js +26 -4
  34. package/dist/private/color/useColorField.js.map +1 -1
  35. package/dist/private/color/useColorField.mjs +26 -4
  36. package/dist/private/color/useColorField.mjs.map +1 -1
  37. package/dist/private/combobox/useComboBox.cjs +1 -1
  38. package/dist/private/combobox/useComboBox.cjs.map +1 -1
  39. package/dist/private/combobox/useComboBox.js +1 -1
  40. package/dist/private/combobox/useComboBox.js.map +1 -1
  41. package/dist/private/combobox/useComboBox.mjs +1 -1
  42. package/dist/private/combobox/useComboBox.mjs.map +1 -1
  43. package/dist/private/focus/FocusScope.cjs +7 -2
  44. package/dist/private/focus/FocusScope.cjs.map +1 -1
  45. package/dist/private/focus/FocusScope.js +7 -2
  46. package/dist/private/focus/FocusScope.js.map +1 -1
  47. package/dist/private/focus/FocusScope.mjs +7 -2
  48. package/dist/private/focus/FocusScope.mjs.map +1 -1
  49. package/dist/private/interactions/useFocusVisible.cjs +15 -3
  50. package/dist/private/interactions/useFocusVisible.cjs.map +1 -1
  51. package/dist/private/interactions/useFocusVisible.js +15 -3
  52. package/dist/private/interactions/useFocusVisible.js.map +1 -1
  53. package/dist/private/interactions/useFocusVisible.mjs +15 -3
  54. package/dist/private/interactions/useFocusVisible.mjs.map +1 -1
  55. package/dist/private/interactions/utils.cjs +23 -13
  56. package/dist/private/interactions/utils.cjs.map +1 -1
  57. package/dist/private/interactions/utils.js +25 -15
  58. package/dist/private/interactions/utils.js.map +1 -1
  59. package/dist/private/interactions/utils.mjs +25 -15
  60. package/dist/private/interactions/utils.mjs.map +1 -1
  61. package/dist/private/overlays/calculatePosition.cjs +3 -2
  62. package/dist/private/overlays/calculatePosition.cjs.map +1 -1
  63. package/dist/private/overlays/calculatePosition.js +5 -2
  64. package/dist/private/overlays/calculatePosition.js.map +1 -1
  65. package/dist/private/overlays/calculatePosition.mjs +3 -2
  66. package/dist/private/overlays/calculatePosition.mjs.map +1 -1
  67. package/dist/private/overlays/useOverlayPosition.cjs +5 -0
  68. package/dist/private/overlays/useOverlayPosition.cjs.map +1 -1
  69. package/dist/private/overlays/useOverlayPosition.js +6 -1
  70. package/dist/private/overlays/useOverlayPosition.js.map +1 -1
  71. package/dist/private/overlays/useOverlayPosition.mjs +6 -1
  72. package/dist/private/overlays/useOverlayPosition.mjs.map +1 -1
  73. package/dist/private/overlays/usePreventScroll.cjs +27 -35
  74. package/dist/private/overlays/usePreventScroll.cjs.map +1 -1
  75. package/dist/private/overlays/usePreventScroll.js +27 -35
  76. package/dist/private/overlays/usePreventScroll.js.map +1 -1
  77. package/dist/private/overlays/usePreventScroll.mjs +27 -35
  78. package/dist/private/overlays/usePreventScroll.mjs.map +1 -1
  79. package/dist/private/selection/useSelectableCollection.cjs +1 -0
  80. package/dist/private/selection/useSelectableCollection.cjs.map +1 -1
  81. package/dist/private/selection/useSelectableCollection.js +1 -0
  82. package/dist/private/selection/useSelectableCollection.js.map +1 -1
  83. package/dist/private/selection/useSelectableCollection.mjs +1 -0
  84. package/dist/private/selection/useSelectableCollection.mjs.map +1 -1
  85. package/dist/private/tabs/TabsKeyboardDelegate.cjs +3 -1
  86. package/dist/private/tabs/TabsKeyboardDelegate.cjs.map +1 -1
  87. package/dist/private/tabs/TabsKeyboardDelegate.js +3 -1
  88. package/dist/private/tabs/TabsKeyboardDelegate.js.map +1 -1
  89. package/dist/private/tabs/TabsKeyboardDelegate.mjs +3 -1
  90. package/dist/private/tabs/TabsKeyboardDelegate.mjs.map +1 -1
  91. package/dist/private/tokenfield/useToken.cjs +19 -4
  92. package/dist/private/tokenfield/useToken.cjs.map +1 -1
  93. package/dist/private/tokenfield/useToken.js +20 -4
  94. package/dist/private/tokenfield/useToken.js.map +1 -1
  95. package/dist/private/tokenfield/useToken.mjs +19 -4
  96. package/dist/private/tokenfield/useToken.mjs.map +1 -1
  97. package/dist/private/tokenfield/useTokenField.cjs +172 -43
  98. package/dist/private/tokenfield/useTokenField.cjs.map +1 -1
  99. package/dist/private/tokenfield/useTokenField.js +175 -45
  100. package/dist/private/tokenfield/useTokenField.js.map +1 -1
  101. package/dist/private/tokenfield/useTokenField.mjs +173 -44
  102. package/dist/private/tokenfield/useTokenField.mjs.map +1 -1
  103. package/dist/private/utils/domHelpers.cjs +21 -0
  104. package/dist/private/utils/domHelpers.cjs.map +1 -1
  105. package/dist/private/utils/domHelpers.js +20 -1
  106. package/dist/private/utils/domHelpers.js.map +1 -1
  107. package/dist/private/utils/domHelpers.mjs +20 -1
  108. package/dist/private/utils/domHelpers.mjs.map +1 -1
  109. package/dist/private/utils/getMetaValue.cjs +36 -0
  110. package/dist/private/utils/getMetaValue.cjs.map +1 -0
  111. package/dist/private/utils/getMetaValue.js +31 -0
  112. package/dist/private/utils/getMetaValue.js.map +1 -0
  113. package/dist/private/utils/getMetaValue.mjs +31 -0
  114. package/dist/private/utils/getMetaValue.mjs.map +1 -0
  115. package/dist/private/utils/getNonce.cjs +6 -10
  116. package/dist/private/utils/getNonce.cjs.map +1 -1
  117. package/dist/private/utils/getNonce.js +7 -11
  118. package/dist/private/utils/getNonce.js.map +1 -1
  119. package/dist/private/utils/getNonce.mjs +7 -11
  120. package/dist/private/utils/getNonce.mjs.map +1 -1
  121. package/dist/private/utils/scrollIntoView.cjs +6 -2
  122. package/dist/private/utils/scrollIntoView.cjs.map +1 -1
  123. package/dist/private/utils/scrollIntoView.js +6 -3
  124. package/dist/private/utils/scrollIntoView.js.map +1 -1
  125. package/dist/private/utils/scrollIntoView.mjs +6 -3
  126. package/dist/private/utils/scrollIntoView.mjs.map +1 -1
  127. package/dist/private/utils/useEvent.cjs +7 -9
  128. package/dist/private/utils/useEvent.cjs.map +1 -1
  129. package/dist/private/utils/useEvent.js +7 -9
  130. package/dist/private/utils/useEvent.js.map +1 -1
  131. package/dist/private/utils/useEvent.mjs +7 -9
  132. package/dist/private/utils/useEvent.mjs.map +1 -1
  133. package/dist/types/exports/index.d.ts +2 -2
  134. package/dist/types/exports/private/utils/domHelpers.d.ts +1 -1
  135. package/dist/types/exports/useFocusVisible.d.ts +2 -1
  136. package/dist/types/src/tokenfield/useTokenField.d.ts +3 -2
  137. package/dist/types/src/utils/domHelpers.d.ts +6 -2
  138. package/dist/types/src/utils/getMetaValue.d.ts +7 -0
  139. package/dist/types/src/utils/scrollIntoView.d.ts +1 -0
  140. package/dist/types/src/utils/useEvent.d.ts +2 -2
  141. package/dist/types/src/virtualizer/Virtualizer.d.ts +3 -3
  142. package/package.json +6 -5
@@ -3,8 +3,10 @@ import {useFocusWithin as $2c9edc598a03d523$export$420e68273165f4ec} from "../in
3
3
  import {useFormattedTextField as $62888b2ec35be488$export$4f384c9210e583c3} from "../textfield/useFormattedTextField.mjs";
4
4
  import {useFormReset as $3274bf1495747a7b$export$5add1d006293d136} from "../utils/useFormReset.mjs";
5
5
  import {useId as $390e54f620492c70$export$f680877a34711e37} from "../utils/useId.mjs";
6
+ import {useKeyboard as $8296dad1a4c5e0dc$export$8f71654801c2f7cd} from "../interactions/useKeyboard.mjs";
6
7
  import {useScrollWheel as $14554ba6a2007b17$export$2123ff2b87c81ca} from "../interactions/useScrollWheel.mjs";
7
8
  import {useSpinButton as $757ec6630f26125c$export$e908e06f4b8e3402} from "../spinbutton/useSpinButton.mjs";
9
+ import {flushSync as $bVRGN$flushSync} from "react-dom";
8
10
  import {useState as $bVRGN$useState, useCallback as $bVRGN$useCallback} from "react";
9
11
  import {privateValidationStateProp as $bVRGN$privateValidationStateProp} from "react-stately/private/form/useFormValidationState";
10
12
 
@@ -27,9 +29,11 @@ import {privateValidationStateProp as $bVRGN$privateValidationStateProp} from "r
27
29
 
28
30
 
29
31
 
32
+
33
+
30
34
  function $3945427e9f7dd37b$export$77e32ca575a28fdf(props, state, ref) {
31
- let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = 'aria' } = props;
32
- let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
35
+ let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = 'aria', onKeyDown: onKeyDown, onKeyUp: onKeyUp } = props;
36
+ let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit, commitValidation: commitValidation } = state;
33
37
  let inputId = (0, $390e54f620492c70$export$f680877a34711e37)();
34
38
  let { spinButtonProps: spinButtonProps } = (0, $757ec6630f26125c$export$e908e06f4b8e3402)({
35
39
  isDisabled: isDisabled,
@@ -63,6 +67,22 @@ function $3945427e9f7dd37b$export$77e32ca575a28fdf(props, state, ref) {
63
67
  onScroll: onWheel,
64
68
  isDisabled: scrollingDisabled
65
69
  }, ref);
70
+ let { keyboardProps: keyboardProps } = (0, $8296dad1a4c5e0dc$export$8f71654801c2f7cd)({
71
+ isDisabled: isDisabled || isReadOnly,
72
+ shortcuts: {
73
+ Enter: ()=>{
74
+ (0, $bVRGN$flushSync)(()=>{
75
+ commit();
76
+ });
77
+ commitValidation();
78
+ return {
79
+ shouldPreventDefault: false
80
+ };
81
+ }
82
+ },
83
+ onKeyDown: onKeyDown,
84
+ onKeyUp: onKeyUp
85
+ });
66
86
  let onChange = (value)=>{
67
87
  if (state.validate(value)) state.setInputValue(value);
68
88
  };
@@ -77,10 +97,12 @@ function $3945427e9f7dd37b$export$77e32ca575a28fdf(props, state, ref) {
77
97
  [(0, $bVRGN$privateValidationStateProp)]: state,
78
98
  type: 'text',
79
99
  autoComplete: 'off',
80
- onChange: onChange
100
+ onChange: onChange,
101
+ onKeyDown: undefined,
102
+ onKeyUp: undefined
81
103
  }, state, ref);
82
104
  (0, $3274bf1495747a7b$export$5add1d006293d136)(ref, state.defaultColorValue, state.setColorValue);
83
- inputProps = (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(inputProps, spinButtonProps, focusWithinProps, {
105
+ inputProps = (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(keyboardProps, inputProps, spinButtonProps, focusWithinProps, {
84
106
  role: 'textbox',
85
107
  'aria-valuemax': null,
86
108
  'aria-valuemin': null,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAyDM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAuC;IAEvC,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,mBAAE,eAAe,sBAAE,qBAAqB,QAAO,GAAG;IAEzF,IAAI,cAAC,UAAU,cAAE,UAAU,aAAE,SAAS,aAAE,SAAS,kBAAE,cAAc,kBAAE,cAAc,UAAE,MAAM,EAAC,GACxF;IAEF,IAAI,UAAU,CAAA,GAAA,yCAAI;IAClB,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,yCAAY,EAAE;oBACpC;oBACA;oBACA;QACA,UAAU;QACV,UAAU;QACV,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,kBAAkB;QAClB,OAAO,aAAa,WAAW,QAAQ,KAAK;QAC5C,WAAW,aAAa,WAAW,QAAQ,CAAC,SAAS;IACvD;IAEA,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,yCAAa,EAAE;oBAAC;QAAY,qBAAqB;IAAc;IAExF,IAAI,UAAU,CAAA,GAAA,kBAAU,EACtB,CAAA;QACE,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,KAAK,KAAK,GAAG,CAAC,EAAE,MAAM,GACzC;QAEF,IAAI,EAAE,MAAM,GAAG,GACb;aACK,IAAI,EAAE,MAAM,GAAG,GACpB;IAEJ,GACA;QAAC;QAAW;KAAU;IAExB,mEAAmE;IACnE,IAAI,oBAAoB,mBAAmB,cAAc,cAAc,CAAC;IACxE,CAAA,GAAA,wCAAa,EAAE;QAAC,UAAU;QAAS,YAAY;IAAiB,GAAG;IAEnE,IAAI,WAAW,CAAA;QACb,IAAI,MAAM,QAAQ,CAAC,QACjB,MAAM,aAAa,CAAC;IAExB;IAEA,IAAI,cAAC,UAAU,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,yCAAoB,EACpD;QACE,GAAG,KAAK;QACR,IAAI;QACJ,OAAO;QACP,iFAAiF;QACjF,oCAAoC;QACpC,cAAc;QACd,UAAU;QACV,CAAC,CAAA,GAAA,iCAAyB,EAAE,EAAE;QAC9B,MAAM;QACN,cAAc;kBACd;IACF,GACA,OACA;IAGF,CAAA,GAAA,yCAAW,EAAE,KAAK,MAAM,iBAAiB,EAAE,MAAM,aAAa;IAE9D,aAAa,CAAA,GAAA,yCAAS,EAAE,YAAY,iBAAiB,kBAAkB;QACrE,MAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/color/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AriaLabelingProps,\n AriaValidationProps,\n DOMAttributes,\n FocusableDOMProps,\n TextInputDOMProps,\n ValidationResult\n} from '@react-types/shared';\nimport {ColorFieldProps, ColorFieldState} from 'react-stately/useColorFieldState';\nimport {InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useState} from 'react';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormattedTextField} from '../textfield/useFormattedTextField';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useScrollWheel} from '../interactions/useScrollWheel';\nimport {useSpinButton} from '../spinbutton/useSpinButton';\n\nexport interface AriaColorFieldProps\n extends\n ColorFieldProps,\n AriaLabelingProps,\n FocusableDOMProps,\n Omit<\n TextInputDOMProps,\n | 'minLength'\n | 'maxLength'\n | 'pattern'\n | 'type'\n | 'inputMode'\n | 'autoComplete'\n | 'autoCorrect'\n | 'spellCheck'\n >,\n AriaValidationProps {\n /** Enables or disables changing the value with scroll. */\n isWheelDisabled?: boolean;\n}\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement | null>\n): ColorFieldAria {\n let {isDisabled, isReadOnly, isRequired, isWheelDisabled, validationBehavior = 'aria'} = props;\n\n let {colorValue, inputValue, increment, decrement, incrementToMax, decrementToMin, commit} =\n state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton({\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xffffff,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n });\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback(\n e => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n },\n [decrement, increment]\n );\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField(\n {\n ...props,\n id: inputId,\n value: inputValue,\n // Intentionally invalid value that will be ignored by onChange during form reset\n // This is handled separately below.\n defaultValue: '!',\n validate: undefined,\n [privateValidationStateProp]: state,\n type: 'text',\n autoComplete: 'off',\n onChange\n },\n state,\n ref\n );\n\n useFormReset(ref, state.defaultColorValue, state.setColorValue);\n\n inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n onBlur: commit\n });\n\n if (validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n return {\n inputProps,\n ...otherProps\n };\n}\n"],"names":[],"version":3,"file":"useColorField.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AA2DM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAuC;IAEvC,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,sBACf,qBAAqB,mBACrB,SAAS,WACT,OAAO,EACR,GAAG;IAEJ,IAAI,cACF,UAAU,cACV,UAAU,aACV,SAAS,aACT,SAAS,kBACT,cAAc,kBACd,cAAc,UACd,MAAM,oBACN,gBAAgB,EACjB,GAA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F,oCAAoC;QACpC,cAAc;QACd,UAAU;QACV,CAAC,CAAA,GAAA,iCAAyB,EAAE,EAAE;QAC9B,MAAM;QACN,cAAc;kBACd;QACA,WAAW;QACX,SAAS;IACX,GACA,OACA;IAGF,CAAA,GAAA,yCAAW,EAAE,KAAK,MAAM,iBAAiB,EAAE,MAAM,aAAa;IAE9D,aAAa,CAAA,GAAA,yCAAS,EAAE,eAAe,YAAY,iBAAiB,kBAAkB;QACpF,MAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/color/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n AriaLabelingProps,\n AriaValidationProps,\n DOMAttributes,\n FocusableDOMProps,\n TextInputDOMProps,\n ValidationResult\n} from '@react-types/shared';\nimport {ColorFieldProps, ColorFieldState} from 'react-stately/useColorFieldState';\nimport {flushSync} from 'react-dom';\nimport {InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useState} from 'react';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormattedTextField} from '../textfield/useFormattedTextField';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useScrollWheel} from '../interactions/useScrollWheel';\nimport {useSpinButton} from '../spinbutton/useSpinButton';\n\nexport interface AriaColorFieldProps\n extends\n ColorFieldProps,\n AriaLabelingProps,\n FocusableDOMProps,\n Omit<\n TextInputDOMProps,\n | 'minLength'\n | 'maxLength'\n | 'pattern'\n | 'type'\n | 'inputMode'\n | 'autoComplete'\n | 'autoCorrect'\n | 'spellCheck'\n >,\n AriaValidationProps {\n /** Enables or disables changing the value with scroll. */\n isWheelDisabled?: boolean;\n}\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement | null>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria',\n onKeyDown,\n onKeyUp\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit,\n commitValidation\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton({\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xffffff,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n });\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback(\n e => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n },\n [decrement, increment]\n );\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let {keyboardProps} = useKeyboard({\n isDisabled: isDisabled || isReadOnly,\n shortcuts: {\n Enter: () => {\n flushSync(() => {\n commit();\n });\n commitValidation();\n return {shouldPreventDefault: false};\n }\n },\n onKeyDown,\n onKeyUp\n });\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField(\n {\n ...props,\n id: inputId,\n value: inputValue,\n // Intentionally invalid value that will be ignored by onChange during form reset\n // This is handled separately below.\n defaultValue: '!',\n validate: undefined,\n [privateValidationStateProp]: state,\n type: 'text',\n autoComplete: 'off',\n onChange,\n onKeyDown: undefined,\n onKeyUp: undefined\n },\n state,\n ref\n );\n\n useFormReset(ref, state.defaultColorValue, state.setColorValue);\n\n inputProps = mergeProps(keyboardProps, inputProps, spinButtonProps, focusWithinProps, {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n onBlur: commit\n });\n\n if (validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n return {\n inputProps,\n ...otherProps\n };\n}\n"],"names":[],"version":3,"file":"useColorField.mjs.map"}
@@ -208,7 +208,7 @@ function $9f4ec1506bb7618d$export$8c18d1b4f7232bbf(props, state) {
208
208
  allowRepeats: true
209
209
  });
210
210
  let onBlur = (e)=>{
211
- let blurFromButton = buttonRef?.current && buttonRef.current === e.relatedTarget;
211
+ let blurFromButton = (0, $da02ee888921bc9e$exports.nodeContains)(buttonRef.current, e.relatedTarget);
212
212
  let blurIntoPopover = (0, $da02ee888921bc9e$exports.nodeContains)(popoverRef.current, e.relatedTarget);
213
213
  // Ignore blur if focused moved to the button(if exists) or into the popover.
214
214
  if (blurFromButton || blurIntoPopover) return;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHM,SAAS,0CACd,KAAgC,EAChC,KAA0B;IAE1B,IAAI,aACF,SAAS,cACT,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,kBAChB,cAAc,mBACd,8BAA8B;IAC9B,eAAe,cACf,UAAU,cACV,UAAU,EACX,GAAG;IACJ,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAC1B,YAAY,aAAa;IAEzB,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,wCAAa,EAC/C;QACE,MAAM;QACN,YAAY,cAAc;IAC5B,GACA,OACA;IAGF,gEAAgE;IAChE,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC,OAAO;QAAC,IAAI,UAAU,EAAE;IAAA;IAErC,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,gBAAC,YAAY,EAAC,GAAG,MAAM,gBAAgB;IAC3C,IAAI,WAAW,CAAA,GAAA,oBAAM,EACnB,IACE,oBACA,IAAI,CAAA,GAAA,8CAAmB,EAAE;wBACvB;0BACA;YACA,KAAK;4BACL;QACF,IACF;QAAC;QAAkB;QAAgB;QAAY;QAAc;KAAW;IAG1E,qFAAqF;IACrF,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,iDAAsB,EAAE;QAC9C,kBAAkB,MAAM,gBAAgB;QACxC,kBAAkB;QAClB,mBAAmB;QACnB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vC,qFAAqF;IACrF,IAAI,SAAS,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;QACvD,UAAU;QACV,YAAY;IACd;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,SAAS,cAAc,CAAC,KACrC,gDAAgD;QAChD,UAAU;IAEd,GAAG;QAAC;QAAI;QAAQ;KAAS;IAEzB,OAAO,SAAS,KAAK;AACvB","sources":["packages/react-aria/src/combobox/useComboBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {ariaHideOutside} from '../overlays/ariaHideOutside';\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n RefObject,\n RouterOptions,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {ComboBoxProps, ComboBoxState, SelectionMode} from 'react-stately/useComboBoxState';\nimport {dispatchVirtualFocus} from '../focus/virtualFocus';\nimport {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getChildNodes} from 'react-stately/private/collections/getChildNodes';\nimport {getItemCount} from 'react-stately/private/collections/getItemCount';\nimport {getItemId, listData} from '../listbox/utils';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/combobox/*.json';\nimport {isAppleDevice} from '../utils/platform';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEvent} from '../utils/useEvent';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useRouter} from '../utils/openLink';\nimport {useSelectableCollection} from '../selection/useSelectableCollection';\nimport {useTextField} from '../textfield/useTextField';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = 'single'>\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaComboBoxProps<T, M>,\n 'children'\n> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: RefObject<Element | null>;\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: RefObject<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function useComboBox<T, M extends SelectionMode = 'single'>(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n let {\n buttonRef,\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n layoutDelegate,\n // completionMode = 'suggest',\n shouldFocusWrap,\n isReadOnly,\n isDisabled\n } = props;\n let backupBtnRef = useRef(null);\n buttonRef = buttonRef ?? backupBtnRef;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/combobox');\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n type: 'listbox',\n isDisabled: isDisabled || isReadOnly\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {id: menuProps.id});\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let {collection} = state;\n let {disabledKeys} = state.selectionManager;\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate({\n collection,\n disabledKeys,\n ref: listBoxRef,\n layoutDelegate\n }),\n [keyboardDelegate, layoutDelegate, collection, disabledKeys, listBoxRef]\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n let {collectionProps} = useSelectableCollection({\n selectionManager: state.selectionManager,\n keyboardDelegate: delegate,\n disallowTypeAhead: true,\n disallowEmptySelection: true,\n shouldFocusWrap,\n ref: inputRef,\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n isVirtualized: true\n });\n\n let router = useRouter();\n\n // for textfield specific operations\n let {keyboardProps} = useKeyboard({\n shortcuts: {\n Enter: e => {\n // Prevent default form submission if menu is open since we may be selecting a option\n let shouldPreventDefault = state.isOpen;\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n let item = listBoxRef.current.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItem.props.href,\n collectionItem.props.routerOptions as RouterOptions\n );\n }\n state.close();\n return {shouldPreventDefault};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault};\n }\n }\n state.commit();\n return {shouldPreventDefault};\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n state.close();\n return {shouldPreventDefault: false};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n }\n }\n if (state.isOpen) {\n state.commit();\n }\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) {\n shouldContinuePropagation = true;\n }\n state.revert();\n return {shouldContinuePropagation};\n }\n }\n });\n\n let {keyboardProps: repeatKeyboardProps} = useKeyboard({\n shortcuts: {\n ArrowDown: () => {\n state.open('first', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowUp: () => {\n state.open('last', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n }\n },\n allowRepeats: true\n });\n\n let onBlur = (e: FocusEvent<HTMLInputElement>) => {\n let blurFromButton = buttonRef?.current && buttonRef.current === e.relatedTarget;\n let blurIntoPopover = nodeContains(popoverRef.current, e.relatedTarget);\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n let onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n let valueId = useValueId([\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode\n ]);\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(\n {\n ...props,\n // In multi-select mode, only set required if the selection is empty.\n isRequired:\n props.selectionMode === 'multiple'\n ? props.isRequired && state.selectionManager.isEmpty\n : props.isRequired,\n onChange: state.setInputValue,\n onKeyDown: !isReadOnly\n ? // oxlint-disable-next-line react/react-compiler\n chain(\n state.isOpen && collectionProps.onKeyDown,\n keyboardProps.onKeyDown,\n repeatKeyboardProps.onKeyDown,\n props.onKeyDown\n )\n : props.onKeyDown,\n onBlur,\n value: state.inputValue,\n defaultValue: state.defaultInputValue,\n onFocus,\n autoComplete: 'off',\n validate: undefined,\n [privateValidationStateProp]: state,\n 'aria-describedby':\n [valueId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n },\n inputRef\n );\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n // Press handlers for the ComboBox button\n let onPress = (e: PressEvent) => {\n if (e.pointerType === 'touch') {\n // Focus the input field in case it isn't focused yet\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n }\n };\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType !== 'touch') {\n inputRef.current?.focus();\n state.toggle(\n e.pointerType === 'keyboard' || e.pointerType === 'virtual' ? 'first' : null,\n 'manual'\n );\n }\n };\n\n let triggerLabelProps = useLabels({\n id: menuTriggerProps.id,\n 'aria-label': stringFormatter.format('buttonLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n let listBoxProps = useLabels({\n id: menuProps.id,\n 'aria-label': stringFormatter.format('listboxLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = useRef(0);\n let onTouchEnd = (e: TouchEvent) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime.current < 500) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n let rect = (getEventTarget(e) as Element).getBoundingClientRect();\n let touch = e.changedTouches[0];\n\n let centerX = Math.ceil(rect.left + 0.5 * rect.width);\n let centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n\n lastEventTime.current = e.timeStamp;\n }\n };\n\n // VoiceOver has issues with announcing aria-activedescendant properly on change\n // (especially on iOS). We use a live region announcer to announce focus changes\n // manually. In addition, section titles are announced when navigating into a new section.\n let focusedItem =\n state.selectionManager.focusedKey != null && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined;\n let sectionKey = focusedItem?.parentKey ?? null;\n let itemKey = state.selectionManager.focusedKey ?? null;\n let lastSection = useRef(sectionKey);\n let lastItem = useRef(itemKey);\n useEffect(() => {\n if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {\n let isSelected = state.selectionManager.isSelected(itemKey);\n let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;\n let sectionTitle =\n section?.['aria-label'] ||\n (typeof section?.rendered === 'string' ? section.rendered : '') ||\n '';\n\n let announcement = stringFormatter.format('focusAnnouncement', {\n isGroupChange: (section && sectionKey !== lastSection.current) ?? false,\n groupTitle: sectionTitle,\n groupCount: section ? [...getChildNodes(section, state.collection)].length : 0,\n optionText: focusedItem['aria-label'] || focusedItem.textValue || '',\n isSelected\n });\n\n announce(announcement);\n }\n\n lastSection.current = sectionKey;\n lastItem.current = itemKey;\n });\n\n // Announce the number of available suggestions when it changes\n let optionCount = getItemCount(state.collection);\n let lastSize = useRef(optionCount);\n let lastOpen = useRef(state.isOpen);\n useEffect(() => {\n // Only announce the number of options available when the menu opens if there is no\n // focused item, otherwise screen readers will typically read e.g. \"1 of 6\".\n // The exception is VoiceOver since this isn't included in the message above.\n let didOpenWithoutFocusedItem =\n state.isOpen !== lastOpen.current &&\n (state.selectionManager.focusedKey == null || isAppleDevice());\n\n if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {\n let announcement = stringFormatter.format('countAnnouncement', {optionCount});\n announce(announcement);\n }\n\n lastSize.current = optionCount;\n lastOpen.current = state.isOpen;\n });\n\n // Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.\n // TODO: do we need to do this for multi-select?\n let lastSelectedKey = useRef(state.selectedKey);\n useEffect(() => {\n if (\n isAppleDevice() &&\n state.isFocused &&\n state.selectedItem &&\n state.selectedKey !== lastSelectedKey.current\n ) {\n let optionText = state.selectedItem['aria-label'] || state.selectedItem.textValue || '';\n let announcement = stringFormatter.format('selectedAnnouncement', {optionText});\n announce(announcement);\n }\n\n lastSelectedKey.current = state.selectedKey;\n });\n\n useEffect(() => {\n if (state.isOpen) {\n return ariaHideOutside(\n [inputRef.current, popoverRef.current].filter(element => element != null)\n );\n }\n }, [state.isOpen, inputRef, popoverRef]);\n\n useUpdateEffect(() => {\n // Re-show focus ring when there is no virtually focused item.\n if (\n !focusedItem &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) === inputRef.current\n ) {\n dispatchVirtualFocus(inputRef.current, null);\n }\n }, [focusedItem]);\n\n useEvent(\n listBoxRef,\n 'react-aria-item-action',\n state.isOpen\n ? () => {\n state.close();\n }\n : undefined\n );\n\n return {\n labelProps: {\n ...labelProps,\n // Focus the input in case the label is not a native <label> element.\n onClick:\n ('htmlFor' in labelProps && labelProps.htmlFor) || props.isDisabled\n ? undefined\n : () => {\n inputRef.current?.focus();\n setInteractionModality('keyboard');\n }\n },\n buttonProps: {\n ...menuTriggerProps,\n ...triggerLabelProps,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n onPress,\n onPressStart,\n isDisabled: isDisabled || isReadOnly\n },\n // oxlint-disable-next-line react/react-compiler\n inputProps: mergeProps(inputProps, {\n role: 'combobox',\n 'aria-expanded': menuTriggerProps['aria-expanded'],\n 'aria-controls': state.isOpen ? menuProps.id : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': focusedItem ? getItemId(state, focusedItem.key) : undefined,\n onTouchEnd,\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n }),\n listBoxProps: mergeProps(menuProps, listBoxProps, {\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldUseVirtualFocus: true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n linkBehavior: 'selection' as const,\n ['UNSTABLE_itemBehavior']: 'action'\n }),\n valueProps: {\n id: valueId\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\n// This is a modified version of useSlotId that uses useEffect instead of useLayoutEffect.\n// Triggering re-renders from useLayoutEffect breaks useComboBoxState's useEffect logic in React 18.\n// These re-renders preempt async state updates in the useEffect, which ends up running multiple times\n// prior to the state being updated. This results in onSelectionChange being called multiple times.\n// TODO: refactor useComboBoxState to avoid this.\nfunction useValueId(depArray: ReadonlyArray<any> = []): string | undefined {\n let id = useId();\n let [exists, setExists] = useState(true);\n let [lastDeps, setLastDeps] = useState(depArray);\n\n // If the deps changed, set exists to true so we can test whether the element exists.\n if (lastDeps.some((v, i) => !Object.is(v, depArray[i]))) {\n setExists(true);\n setLastDeps(depArray);\n }\n\n useEffect(() => {\n if (exists && !document.getElementById(id)) {\n // oxlint-disable-next-line react/react-compiler\n setExists(false);\n }\n }, [id, exists, lastDeps]);\n\n return exists ? id : undefined;\n}\n"],"names":[],"version":3,"file":"useComboBox.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHM,SAAS,0CACd,KAAgC,EAChC,KAA0B;IAE1B,IAAI,aACF,SAAS,cACT,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,kBAChB,cAAc,mBACd,8BAA8B;IAC9B,eAAe,cACf,UAAU,cACV,UAAU,EACX,GAAG;IACJ,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAC1B,YAAY,aAAa;IAEzB,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,wCAAa,EAC/C;QACE,MAAM;QACN,YAAY,cAAc;IAC5B,GACA,OACA;IAGF,gEAAgE;IAChE,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC,OAAO;QAAC,IAAI,UAAU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U;YACV,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,uBAAuB;YACvB,oBAAoB;YACpB,cAAc;YACd,CAAC,wBAAwB,EAAE;QAC7B;QACA,YAAY;YACV,IAAI;QACN;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF;AAEA,0FAA0F;AAC1F,oGAAoG;AACpG,sGAAsG;AACtG,mGAAmG;AACnG,iDAAiD;AACjD,SAAS,iCAAW,WAA+B,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,+BAAI;IACb,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,qBAAO,EAAE;IACnC,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEvC,qFAAqF;IACrF,IAAI,SAAS,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;QACvD,UAAU;QACV,YAAY;IACd;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,SAAS,cAAc,CAAC,KACrC,gDAAgD;QAChD,UAAU;IAEd,GAAG;QAAC;QAAI;QAAQ;KAAS;IAEzB,OAAO,SAAS,KAAK;AACvB","sources":["packages/react-aria/src/combobox/useComboBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {ariaHideOutside} from '../overlays/ariaHideOutside';\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n RefObject,\n RouterOptions,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {ComboBoxProps, ComboBoxState, SelectionMode} from 'react-stately/useComboBoxState';\nimport {dispatchVirtualFocus} from '../focus/virtualFocus';\nimport {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getChildNodes} from 'react-stately/private/collections/getChildNodes';\nimport {getItemCount} from 'react-stately/private/collections/getItemCount';\nimport {getItemId, listData} from '../listbox/utils';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/combobox/*.json';\nimport {isAppleDevice} from '../utils/platform';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEvent} from '../utils/useEvent';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useRouter} from '../utils/openLink';\nimport {useSelectableCollection} from '../selection/useSelectableCollection';\nimport {useTextField} from '../textfield/useTextField';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = 'single'>\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaComboBoxProps<T, M>,\n 'children'\n> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: RefObject<Element | null>;\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: RefObject<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function useComboBox<T, M extends SelectionMode = 'single'>(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n let {\n buttonRef,\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n layoutDelegate,\n // completionMode = 'suggest',\n shouldFocusWrap,\n isReadOnly,\n isDisabled\n } = props;\n let backupBtnRef = useRef(null);\n buttonRef = buttonRef ?? backupBtnRef;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/combobox');\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n type: 'listbox',\n isDisabled: isDisabled || isReadOnly\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {id: menuProps.id});\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let {collection} = state;\n let {disabledKeys} = state.selectionManager;\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate({\n collection,\n disabledKeys,\n ref: listBoxRef,\n layoutDelegate\n }),\n [keyboardDelegate, layoutDelegate, collection, disabledKeys, listBoxRef]\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n let {collectionProps} = useSelectableCollection({\n selectionManager: state.selectionManager,\n keyboardDelegate: delegate,\n disallowTypeAhead: true,\n disallowEmptySelection: true,\n shouldFocusWrap,\n ref: inputRef,\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n isVirtualized: true\n });\n\n let router = useRouter();\n\n // for textfield specific operations\n let {keyboardProps} = useKeyboard({\n shortcuts: {\n Enter: e => {\n // Prevent default form submission if menu is open since we may be selecting a option\n let shouldPreventDefault = state.isOpen;\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n let item = listBoxRef.current.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItem.props.href,\n collectionItem.props.routerOptions as RouterOptions\n );\n }\n state.close();\n return {shouldPreventDefault};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault};\n }\n }\n state.commit();\n return {shouldPreventDefault};\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n state.close();\n return {shouldPreventDefault: false};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n }\n }\n if (state.isOpen) {\n state.commit();\n }\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) {\n shouldContinuePropagation = true;\n }\n state.revert();\n return {shouldContinuePropagation};\n }\n }\n });\n\n let {keyboardProps: repeatKeyboardProps} = useKeyboard({\n shortcuts: {\n ArrowDown: () => {\n state.open('first', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowUp: () => {\n state.open('last', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n }\n },\n allowRepeats: true\n });\n\n let onBlur = (e: FocusEvent<HTMLInputElement>) => {\n let blurFromButton = nodeContains(buttonRef.current, e.relatedTarget as Element);\n let blurIntoPopover = nodeContains(popoverRef.current, e.relatedTarget);\n\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n let onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n let valueId = useValueId([\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode\n ]);\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(\n {\n ...props,\n // In multi-select mode, only set required if the selection is empty.\n isRequired:\n props.selectionMode === 'multiple'\n ? props.isRequired && state.selectionManager.isEmpty\n : props.isRequired,\n onChange: state.setInputValue,\n onKeyDown: !isReadOnly\n ? // oxlint-disable-next-line react/react-compiler\n chain(\n state.isOpen && collectionProps.onKeyDown,\n keyboardProps.onKeyDown,\n repeatKeyboardProps.onKeyDown,\n props.onKeyDown\n )\n : props.onKeyDown,\n onBlur,\n value: state.inputValue,\n defaultValue: state.defaultInputValue,\n onFocus,\n autoComplete: 'off',\n validate: undefined,\n [privateValidationStateProp]: state,\n 'aria-describedby':\n [valueId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n },\n inputRef\n );\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n // Press handlers for the ComboBox button\n let onPress = (e: PressEvent) => {\n if (e.pointerType === 'touch') {\n // Focus the input field in case it isn't focused yet\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n }\n };\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType !== 'touch') {\n inputRef.current?.focus();\n state.toggle(\n e.pointerType === 'keyboard' || e.pointerType === 'virtual' ? 'first' : null,\n 'manual'\n );\n }\n };\n\n let triggerLabelProps = useLabels({\n id: menuTriggerProps.id,\n 'aria-label': stringFormatter.format('buttonLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n let listBoxProps = useLabels({\n id: menuProps.id,\n 'aria-label': stringFormatter.format('listboxLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = useRef(0);\n let onTouchEnd = (e: TouchEvent) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime.current < 500) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n let rect = (getEventTarget(e) as Element).getBoundingClientRect();\n let touch = e.changedTouches[0];\n\n let centerX = Math.ceil(rect.left + 0.5 * rect.width);\n let centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n\n lastEventTime.current = e.timeStamp;\n }\n };\n\n // VoiceOver has issues with announcing aria-activedescendant properly on change\n // (especially on iOS). We use a live region announcer to announce focus changes\n // manually. In addition, section titles are announced when navigating into a new section.\n let focusedItem =\n state.selectionManager.focusedKey != null && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined;\n let sectionKey = focusedItem?.parentKey ?? null;\n let itemKey = state.selectionManager.focusedKey ?? null;\n let lastSection = useRef(sectionKey);\n let lastItem = useRef(itemKey);\n useEffect(() => {\n if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {\n let isSelected = state.selectionManager.isSelected(itemKey);\n let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;\n let sectionTitle =\n section?.['aria-label'] ||\n (typeof section?.rendered === 'string' ? section.rendered : '') ||\n '';\n\n let announcement = stringFormatter.format('focusAnnouncement', {\n isGroupChange: (section && sectionKey !== lastSection.current) ?? false,\n groupTitle: sectionTitle,\n groupCount: section ? [...getChildNodes(section, state.collection)].length : 0,\n optionText: focusedItem['aria-label'] || focusedItem.textValue || '',\n isSelected\n });\n\n announce(announcement);\n }\n\n lastSection.current = sectionKey;\n lastItem.current = itemKey;\n });\n\n // Announce the number of available suggestions when it changes\n let optionCount = getItemCount(state.collection);\n let lastSize = useRef(optionCount);\n let lastOpen = useRef(state.isOpen);\n useEffect(() => {\n // Only announce the number of options available when the menu opens if there is no\n // focused item, otherwise screen readers will typically read e.g. \"1 of 6\".\n // The exception is VoiceOver since this isn't included in the message above.\n let didOpenWithoutFocusedItem =\n state.isOpen !== lastOpen.current &&\n (state.selectionManager.focusedKey == null || isAppleDevice());\n\n if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {\n let announcement = stringFormatter.format('countAnnouncement', {optionCount});\n announce(announcement);\n }\n\n lastSize.current = optionCount;\n lastOpen.current = state.isOpen;\n });\n\n // Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.\n // TODO: do we need to do this for multi-select?\n let lastSelectedKey = useRef(state.selectedKey);\n useEffect(() => {\n if (\n isAppleDevice() &&\n state.isFocused &&\n state.selectedItem &&\n state.selectedKey !== lastSelectedKey.current\n ) {\n let optionText = state.selectedItem['aria-label'] || state.selectedItem.textValue || '';\n let announcement = stringFormatter.format('selectedAnnouncement', {optionText});\n announce(announcement);\n }\n\n lastSelectedKey.current = state.selectedKey;\n });\n\n useEffect(() => {\n if (state.isOpen) {\n return ariaHideOutside(\n [inputRef.current, popoverRef.current].filter(element => element != null)\n );\n }\n }, [state.isOpen, inputRef, popoverRef]);\n\n useUpdateEffect(() => {\n // Re-show focus ring when there is no virtually focused item.\n if (\n !focusedItem &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) === inputRef.current\n ) {\n dispatchVirtualFocus(inputRef.current, null);\n }\n }, [focusedItem]);\n\n useEvent(\n listBoxRef,\n 'react-aria-item-action',\n state.isOpen\n ? () => {\n state.close();\n }\n : undefined\n );\n\n return {\n labelProps: {\n ...labelProps,\n // Focus the input in case the label is not a native <label> element.\n onClick:\n ('htmlFor' in labelProps && labelProps.htmlFor) || props.isDisabled\n ? undefined\n : () => {\n inputRef.current?.focus();\n setInteractionModality('keyboard');\n }\n },\n buttonProps: {\n ...menuTriggerProps,\n ...triggerLabelProps,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n onPress,\n onPressStart,\n isDisabled: isDisabled || isReadOnly\n },\n // oxlint-disable-next-line react/react-compiler\n inputProps: mergeProps(inputProps, {\n role: 'combobox',\n 'aria-expanded': menuTriggerProps['aria-expanded'],\n 'aria-controls': state.isOpen ? menuProps.id : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': focusedItem ? getItemId(state, focusedItem.key) : undefined,\n onTouchEnd,\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n }),\n listBoxProps: mergeProps(menuProps, listBoxProps, {\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldUseVirtualFocus: true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n linkBehavior: 'selection' as const,\n ['UNSTABLE_itemBehavior']: 'action'\n }),\n valueProps: {\n id: valueId\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\n// This is a modified version of useSlotId that uses useEffect instead of useLayoutEffect.\n// Triggering re-renders from useLayoutEffect breaks useComboBoxState's useEffect logic in React 18.\n// These re-renders preempt async state updates in the useEffect, which ends up running multiple times\n// prior to the state being updated. This results in onSelectionChange being called multiple times.\n// TODO: refactor useComboBoxState to avoid this.\nfunction useValueId(depArray: ReadonlyArray<any> = []): string | undefined {\n let id = useId();\n let [exists, setExists] = useState(true);\n let [lastDeps, setLastDeps] = useState(depArray);\n\n // If the deps changed, set exists to true so we can test whether the element exists.\n if (lastDeps.some((v, i) => !Object.is(v, depArray[i]))) {\n setExists(true);\n setLastDeps(depArray);\n }\n\n useEffect(() => {\n if (exists && !document.getElementById(id)) {\n // oxlint-disable-next-line react/react-compiler\n setExists(false);\n }\n }, [id, exists, lastDeps]);\n\n return exists ? id : undefined;\n}\n"],"names":[],"version":3,"file":"useComboBox.cjs.map"}
@@ -202,7 +202,7 @@ function $61b9b89d5634b83f$export$8c18d1b4f7232bbf(props, state) {
202
202
  allowRepeats: true
203
203
  });
204
204
  let onBlur = (e)=>{
205
- let blurFromButton = (buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) && buttonRef.current === e.relatedTarget;
205
+ let blurFromButton = (0, $d8ac7ed472840322$export$4282f70798064fe0)(buttonRef.current, e.relatedTarget);
206
206
  let blurIntoPopover = (0, $d8ac7ed472840322$export$4282f70798064fe0)(popoverRef.current, e.relatedTarget);
207
207
  // Ignore blur if focused moved to the button(if exists) or into the popover.
208
208
  if (blurFromButton || blurIntoPopover) return;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHM,SAAS,0CACd,KAAgC,EAChC,KAA0B;IAE1B,IAAI,aACF,SAAS,cACT,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,kBAChB,cAAc,mBACd,8BAA8B;IAC9B,eAAe,cACf,UAAU,cACV,UAAU,EACX,GAAG;IACJ,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,YAAY,sBAAA,uBAAA,YAAa;IAEzB,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAa,EAC/C;QACE,MAAM;QACN,YAAY,cAAc;IAC5B,GACA,OACA;IAGF,gEAAgE;IAChE,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;QAAC,IAAI,UAAU,EAAE;IAAA;IAErC,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,gBAAC,YAAY,EAAC,GAAG,MAAM,gBAAgB;IAC3C,IAAI,WAAW,CAAA,GAAA,cAAM,EACnB,IACE,oBACA,IAAI,CAAA,GAAA,yCAAmB,EAAE;wBACvB;0BACA;YACA,KAAK;4BACL;QACF,IACF;QAAC;QAAkB;QAAgB;QAAY;QAAc;KAAW;IAG1E,qFAAqF;IACrF,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,G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;YACb,gEAAgE;YAChE,YAAY;QACd;QACA,cAAc,CAAA,GAAA,yCAAS,EAAE,WAAW,cAAc;YAChD,UAAU;YACV,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,uBAAuB;YACvB,oBAAoB;YACpB,cAAc;YACd,CAAC,wBAAwB,EAAE;QAC7B;QACA,YAAY;YACV,IAAI;QACN;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF;AAEA,0FAA0F;AAC1F,oGAAoG;AACpG,sGAAsG;AACtG,mGAAmG;AACnG,iDAAiD;AACjD,SAAS,iCAAW,WAA+B,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,yCAAI;IACb,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAE;IACnC,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,qFAAqF;IACrF,IAAI,SAAS,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;QACvD,UAAU;QACV,YAAY;IACd;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,SAAS,cAAc,CAAC,KACrC,gDAAgD;QAChD,UAAU;IAEd,GAAG;QAAC;QAAI;QAAQ;KAAS;IAEzB,OAAO,SAAS,KAAK;AACvB","sources":["packages/react-aria/src/combobox/useComboBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {ariaHideOutside} from '../overlays/ariaHideOutside';\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n RefObject,\n RouterOptions,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {ComboBoxProps, ComboBoxState, SelectionMode} from 'react-stately/useComboBoxState';\nimport {dispatchVirtualFocus} from '../focus/virtualFocus';\nimport {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getChildNodes} from 'react-stately/private/collections/getChildNodes';\nimport {getItemCount} from 'react-stately/private/collections/getItemCount';\nimport {getItemId, listData} from '../listbox/utils';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/combobox/*.json';\nimport {isAppleDevice} from '../utils/platform';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEvent} from '../utils/useEvent';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useRouter} from '../utils/openLink';\nimport {useSelectableCollection} from '../selection/useSelectableCollection';\nimport {useTextField} from '../textfield/useTextField';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = 'single'>\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaComboBoxProps<T, M>,\n 'children'\n> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: RefObject<Element | null>;\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: RefObject<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function useComboBox<T, M extends SelectionMode = 'single'>(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n let {\n buttonRef,\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n layoutDelegate,\n // completionMode = 'suggest',\n shouldFocusWrap,\n isReadOnly,\n isDisabled\n } = props;\n let backupBtnRef = useRef(null);\n buttonRef = buttonRef ?? backupBtnRef;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/combobox');\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n type: 'listbox',\n isDisabled: isDisabled || isReadOnly\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {id: menuProps.id});\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let {collection} = state;\n let {disabledKeys} = state.selectionManager;\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate({\n collection,\n disabledKeys,\n ref: listBoxRef,\n layoutDelegate\n }),\n [keyboardDelegate, layoutDelegate, collection, disabledKeys, listBoxRef]\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n let {collectionProps} = useSelectableCollection({\n selectionManager: state.selectionManager,\n keyboardDelegate: delegate,\n disallowTypeAhead: true,\n disallowEmptySelection: true,\n shouldFocusWrap,\n ref: inputRef,\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n isVirtualized: true\n });\n\n let router = useRouter();\n\n // for textfield specific operations\n let {keyboardProps} = useKeyboard({\n shortcuts: {\n Enter: e => {\n // Prevent default form submission if menu is open since we may be selecting a option\n let shouldPreventDefault = state.isOpen;\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n let item = listBoxRef.current.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItem.props.href,\n collectionItem.props.routerOptions as RouterOptions\n );\n }\n state.close();\n return {shouldPreventDefault};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault};\n }\n }\n state.commit();\n return {shouldPreventDefault};\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n state.close();\n return {shouldPreventDefault: false};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n }\n }\n if (state.isOpen) {\n state.commit();\n }\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) {\n shouldContinuePropagation = true;\n }\n state.revert();\n return {shouldContinuePropagation};\n }\n }\n });\n\n let {keyboardProps: repeatKeyboardProps} = useKeyboard({\n shortcuts: {\n ArrowDown: () => {\n state.open('first', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowUp: () => {\n state.open('last', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n }\n },\n allowRepeats: true\n });\n\n let onBlur = (e: FocusEvent<HTMLInputElement>) => {\n let blurFromButton = buttonRef?.current && buttonRef.current === e.relatedTarget;\n let blurIntoPopover = nodeContains(popoverRef.current, e.relatedTarget);\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n let onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n let valueId = useValueId([\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode\n ]);\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(\n {\n ...props,\n // In multi-select mode, only set required if the selection is empty.\n isRequired:\n props.selectionMode === 'multiple'\n ? props.isRequired && state.selectionManager.isEmpty\n : props.isRequired,\n onChange: state.setInputValue,\n onKeyDown: !isReadOnly\n ? // oxlint-disable-next-line react/react-compiler\n chain(\n state.isOpen && collectionProps.onKeyDown,\n keyboardProps.onKeyDown,\n repeatKeyboardProps.onKeyDown,\n props.onKeyDown\n )\n : props.onKeyDown,\n onBlur,\n value: state.inputValue,\n defaultValue: state.defaultInputValue,\n onFocus,\n autoComplete: 'off',\n validate: undefined,\n [privateValidationStateProp]: state,\n 'aria-describedby':\n [valueId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n },\n inputRef\n );\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n // Press handlers for the ComboBox button\n let onPress = (e: PressEvent) => {\n if (e.pointerType === 'touch') {\n // Focus the input field in case it isn't focused yet\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n }\n };\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType !== 'touch') {\n inputRef.current?.focus();\n state.toggle(\n e.pointerType === 'keyboard' || e.pointerType === 'virtual' ? 'first' : null,\n 'manual'\n );\n }\n };\n\n let triggerLabelProps = useLabels({\n id: menuTriggerProps.id,\n 'aria-label': stringFormatter.format('buttonLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n let listBoxProps = useLabels({\n id: menuProps.id,\n 'aria-label': stringFormatter.format('listboxLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = useRef(0);\n let onTouchEnd = (e: TouchEvent) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime.current < 500) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n let rect = (getEventTarget(e) as Element).getBoundingClientRect();\n let touch = e.changedTouches[0];\n\n let centerX = Math.ceil(rect.left + 0.5 * rect.width);\n let centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n\n lastEventTime.current = e.timeStamp;\n }\n };\n\n // VoiceOver has issues with announcing aria-activedescendant properly on change\n // (especially on iOS). We use a live region announcer to announce focus changes\n // manually. In addition, section titles are announced when navigating into a new section.\n let focusedItem =\n state.selectionManager.focusedKey != null && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined;\n let sectionKey = focusedItem?.parentKey ?? null;\n let itemKey = state.selectionManager.focusedKey ?? null;\n let lastSection = useRef(sectionKey);\n let lastItem = useRef(itemKey);\n useEffect(() => {\n if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {\n let isSelected = state.selectionManager.isSelected(itemKey);\n let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;\n let sectionTitle =\n section?.['aria-label'] ||\n (typeof section?.rendered === 'string' ? section.rendered : '') ||\n '';\n\n let announcement = stringFormatter.format('focusAnnouncement', {\n isGroupChange: (section && sectionKey !== lastSection.current) ?? false,\n groupTitle: sectionTitle,\n groupCount: section ? [...getChildNodes(section, state.collection)].length : 0,\n optionText: focusedItem['aria-label'] || focusedItem.textValue || '',\n isSelected\n });\n\n announce(announcement);\n }\n\n lastSection.current = sectionKey;\n lastItem.current = itemKey;\n });\n\n // Announce the number of available suggestions when it changes\n let optionCount = getItemCount(state.collection);\n let lastSize = useRef(optionCount);\n let lastOpen = useRef(state.isOpen);\n useEffect(() => {\n // Only announce the number of options available when the menu opens if there is no\n // focused item, otherwise screen readers will typically read e.g. \"1 of 6\".\n // The exception is VoiceOver since this isn't included in the message above.\n let didOpenWithoutFocusedItem =\n state.isOpen !== lastOpen.current &&\n (state.selectionManager.focusedKey == null || isAppleDevice());\n\n if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {\n let announcement = stringFormatter.format('countAnnouncement', {optionCount});\n announce(announcement);\n }\n\n lastSize.current = optionCount;\n lastOpen.current = state.isOpen;\n });\n\n // Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.\n // TODO: do we need to do this for multi-select?\n let lastSelectedKey = useRef(state.selectedKey);\n useEffect(() => {\n if (\n isAppleDevice() &&\n state.isFocused &&\n state.selectedItem &&\n state.selectedKey !== lastSelectedKey.current\n ) {\n let optionText = state.selectedItem['aria-label'] || state.selectedItem.textValue || '';\n let announcement = stringFormatter.format('selectedAnnouncement', {optionText});\n announce(announcement);\n }\n\n lastSelectedKey.current = state.selectedKey;\n });\n\n useEffect(() => {\n if (state.isOpen) {\n return ariaHideOutside(\n [inputRef.current, popoverRef.current].filter(element => element != null)\n );\n }\n }, [state.isOpen, inputRef, popoverRef]);\n\n useUpdateEffect(() => {\n // Re-show focus ring when there is no virtually focused item.\n if (\n !focusedItem &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) === inputRef.current\n ) {\n dispatchVirtualFocus(inputRef.current, null);\n }\n }, [focusedItem]);\n\n useEvent(\n listBoxRef,\n 'react-aria-item-action',\n state.isOpen\n ? () => {\n state.close();\n }\n : undefined\n );\n\n return {\n labelProps: {\n ...labelProps,\n // Focus the input in case the label is not a native <label> element.\n onClick:\n ('htmlFor' in labelProps && labelProps.htmlFor) || props.isDisabled\n ? undefined\n : () => {\n inputRef.current?.focus();\n setInteractionModality('keyboard');\n }\n },\n buttonProps: {\n ...menuTriggerProps,\n ...triggerLabelProps,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n onPress,\n onPressStart,\n isDisabled: isDisabled || isReadOnly\n },\n // oxlint-disable-next-line react/react-compiler\n inputProps: mergeProps(inputProps, {\n role: 'combobox',\n 'aria-expanded': menuTriggerProps['aria-expanded'],\n 'aria-controls': state.isOpen ? menuProps.id : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': focusedItem ? getItemId(state, focusedItem.key) : undefined,\n onTouchEnd,\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n }),\n listBoxProps: mergeProps(menuProps, listBoxProps, {\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldUseVirtualFocus: true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n linkBehavior: 'selection' as const,\n ['UNSTABLE_itemBehavior']: 'action'\n }),\n valueProps: {\n id: valueId\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\n// This is a modified version of useSlotId that uses useEffect instead of useLayoutEffect.\n// Triggering re-renders from useLayoutEffect breaks useComboBoxState's useEffect logic in React 18.\n// These re-renders preempt async state updates in the useEffect, which ends up running multiple times\n// prior to the state being updated. This results in onSelectionChange being called multiple times.\n// TODO: refactor useComboBoxState to avoid this.\nfunction useValueId(depArray: ReadonlyArray<any> = []): string | undefined {\n let id = useId();\n let [exists, setExists] = useState(true);\n let [lastDeps, setLastDeps] = useState(depArray);\n\n // If the deps changed, set exists to true so we can test whether the element exists.\n if (lastDeps.some((v, i) => !Object.is(v, depArray[i]))) {\n setExists(true);\n setLastDeps(depArray);\n }\n\n useEffect(() => {\n if (exists && !document.getElementById(id)) {\n // oxlint-disable-next-line react/react-compiler\n setExists(false);\n }\n }, [id, exists, lastDeps]);\n\n return exists ? id : undefined;\n}\n"],"names":[],"version":3,"file":"useComboBox.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;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AiD;AACjD,SAAS,iCAAW,WAA+B,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,yCAAI;IACb,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAE;IACnC,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,qFAAqF;IACrF,IAAI,SAAS,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;QACvD,UAAU;QACV,YAAY;IACd;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,SAAS,cAAc,CAAC,KACrC,gDAAgD;QAChD,UAAU;IAEd,GAAG;QAAC;QAAI;QAAQ;KAAS;IAEzB,OAAO,SAAS,KAAK;AACvB","sources":["packages/react-aria/src/combobox/useComboBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {ariaHideOutside} from '../overlays/ariaHideOutside';\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n RefObject,\n RouterOptions,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {ComboBoxProps, ComboBoxState, SelectionMode} from 'react-stately/useComboBoxState';\nimport {dispatchVirtualFocus} from '../focus/virtualFocus';\nimport {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getChildNodes} from 'react-stately/private/collections/getChildNodes';\nimport {getItemCount} from 'react-stately/private/collections/getItemCount';\nimport {getItemId, listData} from '../listbox/utils';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/combobox/*.json';\nimport {isAppleDevice} from '../utils/platform';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEvent} from '../utils/useEvent';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useRouter} from '../utils/openLink';\nimport {useSelectableCollection} from '../selection/useSelectableCollection';\nimport {useTextField} from '../textfield/useTextField';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = 'single'>\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaComboBoxProps<T, M>,\n 'children'\n> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: RefObject<Element | null>;\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: RefObject<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function useComboBox<T, M extends SelectionMode = 'single'>(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n let {\n buttonRef,\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n layoutDelegate,\n // completionMode = 'suggest',\n shouldFocusWrap,\n isReadOnly,\n isDisabled\n } = props;\n let backupBtnRef = useRef(null);\n buttonRef = buttonRef ?? backupBtnRef;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/combobox');\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n type: 'listbox',\n isDisabled: isDisabled || isReadOnly\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {id: menuProps.id});\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let {collection} = state;\n let {disabledKeys} = state.selectionManager;\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate({\n collection,\n disabledKeys,\n ref: listBoxRef,\n layoutDelegate\n }),\n [keyboardDelegate, layoutDelegate, collection, disabledKeys, listBoxRef]\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n let {collectionProps} = useSelectableCollection({\n selectionManager: state.selectionManager,\n keyboardDelegate: delegate,\n disallowTypeAhead: true,\n disallowEmptySelection: true,\n shouldFocusWrap,\n ref: inputRef,\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n isVirtualized: true\n });\n\n let router = useRouter();\n\n // for textfield specific operations\n let {keyboardProps} = useKeyboard({\n shortcuts: {\n Enter: e => {\n // Prevent default form submission if menu is open since we may be selecting a option\n let shouldPreventDefault = state.isOpen;\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n let item = listBoxRef.current.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItem.props.href,\n collectionItem.props.routerOptions as RouterOptions\n );\n }\n state.close();\n return {shouldPreventDefault};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault};\n }\n }\n state.commit();\n return {shouldPreventDefault};\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n state.close();\n return {shouldPreventDefault: false};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n }\n }\n if (state.isOpen) {\n state.commit();\n }\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) {\n shouldContinuePropagation = true;\n }\n state.revert();\n return {shouldContinuePropagation};\n }\n }\n });\n\n let {keyboardProps: repeatKeyboardProps} = useKeyboard({\n shortcuts: {\n ArrowDown: () => {\n state.open('first', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowUp: () => {\n state.open('last', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n }\n },\n allowRepeats: true\n });\n\n let onBlur = (e: FocusEvent<HTMLInputElement>) => {\n let blurFromButton = nodeContains(buttonRef.current, e.relatedTarget as Element);\n let blurIntoPopover = nodeContains(popoverRef.current, e.relatedTarget);\n\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n let onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n let valueId = useValueId([\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode\n ]);\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(\n {\n ...props,\n // In multi-select mode, only set required if the selection is empty.\n isRequired:\n props.selectionMode === 'multiple'\n ? props.isRequired && state.selectionManager.isEmpty\n : props.isRequired,\n onChange: state.setInputValue,\n onKeyDown: !isReadOnly\n ? // oxlint-disable-next-line react/react-compiler\n chain(\n state.isOpen && collectionProps.onKeyDown,\n keyboardProps.onKeyDown,\n repeatKeyboardProps.onKeyDown,\n props.onKeyDown\n )\n : props.onKeyDown,\n onBlur,\n value: state.inputValue,\n defaultValue: state.defaultInputValue,\n onFocus,\n autoComplete: 'off',\n validate: undefined,\n [privateValidationStateProp]: state,\n 'aria-describedby':\n [valueId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n },\n inputRef\n );\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n // Press handlers for the ComboBox button\n let onPress = (e: PressEvent) => {\n if (e.pointerType === 'touch') {\n // Focus the input field in case it isn't focused yet\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n }\n };\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType !== 'touch') {\n inputRef.current?.focus();\n state.toggle(\n e.pointerType === 'keyboard' || e.pointerType === 'virtual' ? 'first' : null,\n 'manual'\n );\n }\n };\n\n let triggerLabelProps = useLabels({\n id: menuTriggerProps.id,\n 'aria-label': stringFormatter.format('buttonLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n let listBoxProps = useLabels({\n id: menuProps.id,\n 'aria-label': stringFormatter.format('listboxLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = useRef(0);\n let onTouchEnd = (e: TouchEvent) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime.current < 500) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n let rect = (getEventTarget(e) as Element).getBoundingClientRect();\n let touch = e.changedTouches[0];\n\n let centerX = Math.ceil(rect.left + 0.5 * rect.width);\n let centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n\n lastEventTime.current = e.timeStamp;\n }\n };\n\n // VoiceOver has issues with announcing aria-activedescendant properly on change\n // (especially on iOS). We use a live region announcer to announce focus changes\n // manually. In addition, section titles are announced when navigating into a new section.\n let focusedItem =\n state.selectionManager.focusedKey != null && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined;\n let sectionKey = focusedItem?.parentKey ?? null;\n let itemKey = state.selectionManager.focusedKey ?? null;\n let lastSection = useRef(sectionKey);\n let lastItem = useRef(itemKey);\n useEffect(() => {\n if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {\n let isSelected = state.selectionManager.isSelected(itemKey);\n let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;\n let sectionTitle =\n section?.['aria-label'] ||\n (typeof section?.rendered === 'string' ? section.rendered : '') ||\n '';\n\n let announcement = stringFormatter.format('focusAnnouncement', {\n isGroupChange: (section && sectionKey !== lastSection.current) ?? false,\n groupTitle: sectionTitle,\n groupCount: section ? [...getChildNodes(section, state.collection)].length : 0,\n optionText: focusedItem['aria-label'] || focusedItem.textValue || '',\n isSelected\n });\n\n announce(announcement);\n }\n\n lastSection.current = sectionKey;\n lastItem.current = itemKey;\n });\n\n // Announce the number of available suggestions when it changes\n let optionCount = getItemCount(state.collection);\n let lastSize = useRef(optionCount);\n let lastOpen = useRef(state.isOpen);\n useEffect(() => {\n // Only announce the number of options available when the menu opens if there is no\n // focused item, otherwise screen readers will typically read e.g. \"1 of 6\".\n // The exception is VoiceOver since this isn't included in the message above.\n let didOpenWithoutFocusedItem =\n state.isOpen !== lastOpen.current &&\n (state.selectionManager.focusedKey == null || isAppleDevice());\n\n if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {\n let announcement = stringFormatter.format('countAnnouncement', {optionCount});\n announce(announcement);\n }\n\n lastSize.current = optionCount;\n lastOpen.current = state.isOpen;\n });\n\n // Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.\n // TODO: do we need to do this for multi-select?\n let lastSelectedKey = useRef(state.selectedKey);\n useEffect(() => {\n if (\n isAppleDevice() &&\n state.isFocused &&\n state.selectedItem &&\n state.selectedKey !== lastSelectedKey.current\n ) {\n let optionText = state.selectedItem['aria-label'] || state.selectedItem.textValue || '';\n let announcement = stringFormatter.format('selectedAnnouncement', {optionText});\n announce(announcement);\n }\n\n lastSelectedKey.current = state.selectedKey;\n });\n\n useEffect(() => {\n if (state.isOpen) {\n return ariaHideOutside(\n [inputRef.current, popoverRef.current].filter(element => element != null)\n );\n }\n }, [state.isOpen, inputRef, popoverRef]);\n\n useUpdateEffect(() => {\n // Re-show focus ring when there is no virtually focused item.\n if (\n !focusedItem &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) === inputRef.current\n ) {\n dispatchVirtualFocus(inputRef.current, null);\n }\n }, [focusedItem]);\n\n useEvent(\n listBoxRef,\n 'react-aria-item-action',\n state.isOpen\n ? () => {\n state.close();\n }\n : undefined\n );\n\n return {\n labelProps: {\n ...labelProps,\n // Focus the input in case the label is not a native <label> element.\n onClick:\n ('htmlFor' in labelProps && labelProps.htmlFor) || props.isDisabled\n ? undefined\n : () => {\n inputRef.current?.focus();\n setInteractionModality('keyboard');\n }\n },\n buttonProps: {\n ...menuTriggerProps,\n ...triggerLabelProps,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n onPress,\n onPressStart,\n isDisabled: isDisabled || isReadOnly\n },\n // oxlint-disable-next-line react/react-compiler\n inputProps: mergeProps(inputProps, {\n role: 'combobox',\n 'aria-expanded': menuTriggerProps['aria-expanded'],\n 'aria-controls': state.isOpen ? menuProps.id : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': focusedItem ? getItemId(state, focusedItem.key) : undefined,\n onTouchEnd,\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n }),\n listBoxProps: mergeProps(menuProps, listBoxProps, {\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldUseVirtualFocus: true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n linkBehavior: 'selection' as const,\n ['UNSTABLE_itemBehavior']: 'action'\n }),\n valueProps: {\n id: valueId\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\n// This is a modified version of useSlotId that uses useEffect instead of useLayoutEffect.\n// Triggering re-renders from useLayoutEffect breaks useComboBoxState's useEffect logic in React 18.\n// These re-renders preempt async state updates in the useEffect, which ends up running multiple times\n// prior to the state being updated. This results in onSelectionChange being called multiple times.\n// TODO: refactor useComboBoxState to avoid this.\nfunction useValueId(depArray: ReadonlyArray<any> = []): string | undefined {\n let id = useId();\n let [exists, setExists] = useState(true);\n let [lastDeps, setLastDeps] = useState(depArray);\n\n // If the deps changed, set exists to true so we can test whether the element exists.\n if (lastDeps.some((v, i) => !Object.is(v, depArray[i]))) {\n setExists(true);\n setLastDeps(depArray);\n }\n\n useEffect(() => {\n if (exists && !document.getElementById(id)) {\n // oxlint-disable-next-line react/react-compiler\n setExists(false);\n }\n }, [id, exists, lastDeps]);\n\n return exists ? id : undefined;\n}\n"],"names":[],"version":3,"file":"useComboBox.js.map"}
@@ -202,7 +202,7 @@ function $bf505c7417d9b616$export$8c18d1b4f7232bbf(props, state) {
202
202
  allowRepeats: true
203
203
  });
204
204
  let onBlur = (e)=>{
205
- let blurFromButton = buttonRef?.current && buttonRef.current === e.relatedTarget;
205
+ let blurFromButton = (0, $23f2114a1b82827e$export$4282f70798064fe0)(buttonRef.current, e.relatedTarget);
206
206
  let blurIntoPopover = (0, $23f2114a1b82827e$export$4282f70798064fe0)(popoverRef.current, e.relatedTarget);
207
207
  // Ignore blur if focused moved to the button(if exists) or into the popover.
208
208
  if (blurFromButton || blurIntoPopover) return;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;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AChD,UAAU;IAEd,GAAG;QAAC;QAAI;QAAQ;KAAS;IAEzB,OAAO,SAAS,KAAK;AACvB","sources":["packages/react-aria/src/combobox/useComboBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {ariaHideOutside} from '../overlays/ariaHideOutside';\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n RefObject,\n RouterOptions,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {ComboBoxProps, ComboBoxState, SelectionMode} from 'react-stately/useComboBoxState';\nimport {dispatchVirtualFocus} from '../focus/virtualFocus';\nimport {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getChildNodes} from 'react-stately/private/collections/getChildNodes';\nimport {getItemCount} from 'react-stately/private/collections/getItemCount';\nimport {getItemId, listData} from '../listbox/utils';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/combobox/*.json';\nimport {isAppleDevice} from '../utils/platform';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEvent} from '../utils/useEvent';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useRouter} from '../utils/openLink';\nimport {useSelectableCollection} from '../selection/useSelectableCollection';\nimport {useTextField} from '../textfield/useTextField';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = 'single'>\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaComboBoxProps<T, M>,\n 'children'\n> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: RefObject<Element | null>;\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: RefObject<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function useComboBox<T, M extends SelectionMode = 'single'>(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n let {\n buttonRef,\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n layoutDelegate,\n // completionMode = 'suggest',\n shouldFocusWrap,\n isReadOnly,\n isDisabled\n } = props;\n let backupBtnRef = useRef(null);\n buttonRef = buttonRef ?? backupBtnRef;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/combobox');\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n type: 'listbox',\n isDisabled: isDisabled || isReadOnly\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {id: menuProps.id});\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let {collection} = state;\n let {disabledKeys} = state.selectionManager;\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate({\n collection,\n disabledKeys,\n ref: listBoxRef,\n layoutDelegate\n }),\n [keyboardDelegate, layoutDelegate, collection, disabledKeys, listBoxRef]\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n let {collectionProps} = useSelectableCollection({\n selectionManager: state.selectionManager,\n keyboardDelegate: delegate,\n disallowTypeAhead: true,\n disallowEmptySelection: true,\n shouldFocusWrap,\n ref: inputRef,\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n isVirtualized: true\n });\n\n let router = useRouter();\n\n // for textfield specific operations\n let {keyboardProps} = useKeyboard({\n shortcuts: {\n Enter: e => {\n // Prevent default form submission if menu is open since we may be selecting a option\n let shouldPreventDefault = state.isOpen;\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n let item = listBoxRef.current.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItem.props.href,\n collectionItem.props.routerOptions as RouterOptions\n );\n }\n state.close();\n return {shouldPreventDefault};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault};\n }\n }\n state.commit();\n return {shouldPreventDefault};\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n state.close();\n return {shouldPreventDefault: false};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n }\n }\n if (state.isOpen) {\n state.commit();\n }\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) {\n shouldContinuePropagation = true;\n }\n state.revert();\n return {shouldContinuePropagation};\n }\n }\n });\n\n let {keyboardProps: repeatKeyboardProps} = useKeyboard({\n shortcuts: {\n ArrowDown: () => {\n state.open('first', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowUp: () => {\n state.open('last', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n }\n },\n allowRepeats: true\n });\n\n let onBlur = (e: FocusEvent<HTMLInputElement>) => {\n let blurFromButton = buttonRef?.current && buttonRef.current === e.relatedTarget;\n let blurIntoPopover = nodeContains(popoverRef.current, e.relatedTarget);\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n let onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n let valueId = useValueId([\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode\n ]);\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(\n {\n ...props,\n // In multi-select mode, only set required if the selection is empty.\n isRequired:\n props.selectionMode === 'multiple'\n ? props.isRequired && state.selectionManager.isEmpty\n : props.isRequired,\n onChange: state.setInputValue,\n onKeyDown: !isReadOnly\n ? // oxlint-disable-next-line react/react-compiler\n chain(\n state.isOpen && collectionProps.onKeyDown,\n keyboardProps.onKeyDown,\n repeatKeyboardProps.onKeyDown,\n props.onKeyDown\n )\n : props.onKeyDown,\n onBlur,\n value: state.inputValue,\n defaultValue: state.defaultInputValue,\n onFocus,\n autoComplete: 'off',\n validate: undefined,\n [privateValidationStateProp]: state,\n 'aria-describedby':\n [valueId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n },\n inputRef\n );\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n // Press handlers for the ComboBox button\n let onPress = (e: PressEvent) => {\n if (e.pointerType === 'touch') {\n // Focus the input field in case it isn't focused yet\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n }\n };\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType !== 'touch') {\n inputRef.current?.focus();\n state.toggle(\n e.pointerType === 'keyboard' || e.pointerType === 'virtual' ? 'first' : null,\n 'manual'\n );\n }\n };\n\n let triggerLabelProps = useLabels({\n id: menuTriggerProps.id,\n 'aria-label': stringFormatter.format('buttonLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n let listBoxProps = useLabels({\n id: menuProps.id,\n 'aria-label': stringFormatter.format('listboxLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = useRef(0);\n let onTouchEnd = (e: TouchEvent) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime.current < 500) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n let rect = (getEventTarget(e) as Element).getBoundingClientRect();\n let touch = e.changedTouches[0];\n\n let centerX = Math.ceil(rect.left + 0.5 * rect.width);\n let centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n\n lastEventTime.current = e.timeStamp;\n }\n };\n\n // VoiceOver has issues with announcing aria-activedescendant properly on change\n // (especially on iOS). We use a live region announcer to announce focus changes\n // manually. In addition, section titles are announced when navigating into a new section.\n let focusedItem =\n state.selectionManager.focusedKey != null && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined;\n let sectionKey = focusedItem?.parentKey ?? null;\n let itemKey = state.selectionManager.focusedKey ?? null;\n let lastSection = useRef(sectionKey);\n let lastItem = useRef(itemKey);\n useEffect(() => {\n if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {\n let isSelected = state.selectionManager.isSelected(itemKey);\n let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;\n let sectionTitle =\n section?.['aria-label'] ||\n (typeof section?.rendered === 'string' ? section.rendered : '') ||\n '';\n\n let announcement = stringFormatter.format('focusAnnouncement', {\n isGroupChange: (section && sectionKey !== lastSection.current) ?? false,\n groupTitle: sectionTitle,\n groupCount: section ? [...getChildNodes(section, state.collection)].length : 0,\n optionText: focusedItem['aria-label'] || focusedItem.textValue || '',\n isSelected\n });\n\n announce(announcement);\n }\n\n lastSection.current = sectionKey;\n lastItem.current = itemKey;\n });\n\n // Announce the number of available suggestions when it changes\n let optionCount = getItemCount(state.collection);\n let lastSize = useRef(optionCount);\n let lastOpen = useRef(state.isOpen);\n useEffect(() => {\n // Only announce the number of options available when the menu opens if there is no\n // focused item, otherwise screen readers will typically read e.g. \"1 of 6\".\n // The exception is VoiceOver since this isn't included in the message above.\n let didOpenWithoutFocusedItem =\n state.isOpen !== lastOpen.current &&\n (state.selectionManager.focusedKey == null || isAppleDevice());\n\n if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {\n let announcement = stringFormatter.format('countAnnouncement', {optionCount});\n announce(announcement);\n }\n\n lastSize.current = optionCount;\n lastOpen.current = state.isOpen;\n });\n\n // Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.\n // TODO: do we need to do this for multi-select?\n let lastSelectedKey = useRef(state.selectedKey);\n useEffect(() => {\n if (\n isAppleDevice() &&\n state.isFocused &&\n state.selectedItem &&\n state.selectedKey !== lastSelectedKey.current\n ) {\n let optionText = state.selectedItem['aria-label'] || state.selectedItem.textValue || '';\n let announcement = stringFormatter.format('selectedAnnouncement', {optionText});\n announce(announcement);\n }\n\n lastSelectedKey.current = state.selectedKey;\n });\n\n useEffect(() => {\n if (state.isOpen) {\n return ariaHideOutside(\n [inputRef.current, popoverRef.current].filter(element => element != null)\n );\n }\n }, [state.isOpen, inputRef, popoverRef]);\n\n useUpdateEffect(() => {\n // Re-show focus ring when there is no virtually focused item.\n if (\n !focusedItem &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) === inputRef.current\n ) {\n dispatchVirtualFocus(inputRef.current, null);\n }\n }, [focusedItem]);\n\n useEvent(\n listBoxRef,\n 'react-aria-item-action',\n state.isOpen\n ? () => {\n state.close();\n }\n : undefined\n );\n\n return {\n labelProps: {\n ...labelProps,\n // Focus the input in case the label is not a native <label> element.\n onClick:\n ('htmlFor' in labelProps && labelProps.htmlFor) || props.isDisabled\n ? undefined\n : () => {\n inputRef.current?.focus();\n setInteractionModality('keyboard');\n }\n },\n buttonProps: {\n ...menuTriggerProps,\n ...triggerLabelProps,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n onPress,\n onPressStart,\n isDisabled: isDisabled || isReadOnly\n },\n // oxlint-disable-next-line react/react-compiler\n inputProps: mergeProps(inputProps, {\n role: 'combobox',\n 'aria-expanded': menuTriggerProps['aria-expanded'],\n 'aria-controls': state.isOpen ? menuProps.id : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': focusedItem ? getItemId(state, focusedItem.key) : undefined,\n onTouchEnd,\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n }),\n listBoxProps: mergeProps(menuProps, listBoxProps, {\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldUseVirtualFocus: true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n linkBehavior: 'selection' as const,\n ['UNSTABLE_itemBehavior']: 'action'\n }),\n valueProps: {\n id: valueId\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\n// This is a modified version of useSlotId that uses useEffect instead of useLayoutEffect.\n// Triggering re-renders from useLayoutEffect breaks useComboBoxState's useEffect logic in React 18.\n// These re-renders preempt async state updates in the useEffect, which ends up running multiple times\n// prior to the state being updated. This results in onSelectionChange being called multiple times.\n// TODO: refactor useComboBoxState to avoid this.\nfunction useValueId(depArray: ReadonlyArray<any> = []): string | undefined {\n let id = useId();\n let [exists, setExists] = useState(true);\n let [lastDeps, setLastDeps] = useState(depArray);\n\n // If the deps changed, set exists to true so we can test whether the element exists.\n if (lastDeps.some((v, i) => !Object.is(v, depArray[i]))) {\n setExists(true);\n setLastDeps(depArray);\n }\n\n useEffect(() => {\n if (exists && !document.getElementById(id)) {\n // oxlint-disable-next-line react/react-compiler\n setExists(false);\n }\n }, [id, exists, lastDeps]);\n\n return exists ? id : undefined;\n}\n"],"names":[],"version":3,"file":"useComboBox.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHM,SAAS,0CACd,KAAgC,EAChC,KAA0B;IAE1B,IAAI,aACF,SAAS,cACT,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,kBAChB,cAAc,mBACd,8BAA8B;IAC9B,eAAe,cACf,UAAU,cACV,UAAU,EACX,GAAG;IACJ,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,YAAY,aAAa;IAEzB,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAa,EAC/C;QACE,MAAM;QACN,YAAY,cAAc;IAC5B,GACA,OACA;IAGF,gEAAgE;IAChE,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;QAAC,IAAI,UAAU,EAAE;IAAA;IAErC,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,cAAC,UAAU,EAAC,GAAG;IACnB,IAAI,gBAAC,YAAY,EAAC,GAAG,MAAM,gBAAgB;IAC3C,IAAI,WAAW,CAAA,GAAA,cAAM,EACnB,IACE,oBACA,IAAI,CAAA,GAAA,yCAAmB,EAAE;wBACvB;0BACA;YACA,KAAK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,iDAAiD;AACjD,SAAS,iCAAW,WAA+B,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,yCAAI;IACb,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAE;IACnC,IAAI,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,qFAAqF;IACrF,IAAI,SAAS,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI;QACvD,UAAU;QACV,YAAY;IACd;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,CAAC,SAAS,cAAc,CAAC,KACrC,gDAAgD;QAChD,UAAU;IAEd,GAAG;QAAC;QAAI;QAAQ;KAAS;IAEzB,OAAO,SAAS,KAAK;AACvB","sources":["packages/react-aria/src/combobox/useComboBox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {ariaHideOutside} from '../overlays/ariaHideOutside';\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n RefObject,\n RouterOptions,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {ComboBoxProps, ComboBoxState, SelectionMode} from 'react-stately/useComboBoxState';\nimport {dispatchVirtualFocus} from '../focus/virtualFocus';\nimport {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {getActiveElement, getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getChildNodes} from 'react-stately/private/collections/getChildNodes';\nimport {getItemCount} from 'react-stately/private/collections/getItemCount';\nimport {getItemId, listData} from '../listbox/utils';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/combobox/*.json';\nimport {isAppleDevice} from '../utils/platform';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {privateValidationStateProp} from 'react-stately/private/form/useFormValidationState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEvent} from '../utils/useEvent';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useId} from '../utils/useId';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useRouter} from '../utils/openLink';\nimport {useSelectableCollection} from '../selection/useSelectableCollection';\nimport {useTextField} from '../textfield/useTextField';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = 'single'>\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaComboBoxProps<T, M>,\n 'children'\n> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: RefObject<Element | null>;\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: RefObject<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function useComboBox<T, M extends SelectionMode = 'single'>(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n let {\n buttonRef,\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n layoutDelegate,\n // completionMode = 'suggest',\n shouldFocusWrap,\n isReadOnly,\n isDisabled\n } = props;\n let backupBtnRef = useRef(null);\n buttonRef = buttonRef ?? backupBtnRef;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/combobox');\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n type: 'listbox',\n isDisabled: isDisabled || isReadOnly\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {id: menuProps.id});\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let {collection} = state;\n let {disabledKeys} = state.selectionManager;\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate({\n collection,\n disabledKeys,\n ref: listBoxRef,\n layoutDelegate\n }),\n [keyboardDelegate, layoutDelegate, collection, disabledKeys, listBoxRef]\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n let {collectionProps} = useSelectableCollection({\n selectionManager: state.selectionManager,\n keyboardDelegate: delegate,\n disallowTypeAhead: true,\n disallowEmptySelection: true,\n shouldFocusWrap,\n ref: inputRef,\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n isVirtualized: true\n });\n\n let router = useRouter();\n\n // for textfield specific operations\n let {keyboardProps} = useKeyboard({\n shortcuts: {\n Enter: e => {\n // Prevent default form submission if menu is open since we may be selecting a option\n let shouldPreventDefault = state.isOpen;\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n let item = listBoxRef.current.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItem.props.href,\n collectionItem.props.routerOptions as RouterOptions\n );\n }\n state.close();\n return {shouldPreventDefault};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault};\n }\n }\n state.commit();\n return {shouldPreventDefault};\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (state.isOpen && listBoxRef.current && state.selectionManager.focusedKey != null) {\n let collectionItem = state.collection.getItem(state.selectionManager.focusedKey);\n if (collectionItem?.props.href) {\n state.close();\n return {shouldPreventDefault: false};\n } else if (collectionItem?.props.onAction) {\n collectionItem.props.onAction();\n state.close();\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n }\n }\n if (state.isOpen) {\n state.commit();\n }\n return {shouldPreventDefault: false, shouldContinuePropagation: true};\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) {\n shouldContinuePropagation = true;\n }\n state.revert();\n return {shouldContinuePropagation};\n }\n }\n });\n\n let {keyboardProps: repeatKeyboardProps} = useKeyboard({\n shortcuts: {\n ArrowDown: () => {\n state.open('first', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowUp: () => {\n state.open('last', 'manual');\n return {shouldPreventDefault: false};\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n return {shouldPreventDefault: false};\n }\n },\n allowRepeats: true\n });\n\n let onBlur = (e: FocusEvent<HTMLInputElement>) => {\n let blurFromButton = nodeContains(buttonRef.current, e.relatedTarget as Element);\n let blurIntoPopover = nodeContains(popoverRef.current, e.relatedTarget);\n\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n let onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n let valueId = useValueId([\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode\n ]);\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField(\n {\n ...props,\n // In multi-select mode, only set required if the selection is empty.\n isRequired:\n props.selectionMode === 'multiple'\n ? props.isRequired && state.selectionManager.isEmpty\n : props.isRequired,\n onChange: state.setInputValue,\n onKeyDown: !isReadOnly\n ? // oxlint-disable-next-line react/react-compiler\n chain(\n state.isOpen && collectionProps.onKeyDown,\n keyboardProps.onKeyDown,\n repeatKeyboardProps.onKeyDown,\n props.onKeyDown\n )\n : props.onKeyDown,\n onBlur,\n value: state.inputValue,\n defaultValue: state.defaultInputValue,\n onFocus,\n autoComplete: 'off',\n validate: undefined,\n [privateValidationStateProp]: state,\n 'aria-describedby':\n [valueId, props['aria-describedby']].filter(Boolean).join(' ') || undefined\n },\n inputRef\n );\n\n useFormReset(inputRef, state.defaultValue, state.setValue);\n\n // Press handlers for the ComboBox button\n let onPress = (e: PressEvent) => {\n if (e.pointerType === 'touch') {\n // Focus the input field in case it isn't focused yet\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n }\n };\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType !== 'touch') {\n inputRef.current?.focus();\n state.toggle(\n e.pointerType === 'keyboard' || e.pointerType === 'virtual' ? 'first' : null,\n 'manual'\n );\n }\n };\n\n let triggerLabelProps = useLabels({\n id: menuTriggerProps.id,\n 'aria-label': stringFormatter.format('buttonLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n let listBoxProps = useLabels({\n id: menuProps.id,\n 'aria-label': stringFormatter.format('listboxLabel'),\n 'aria-labelledby': props['aria-labelledby'] || labelProps.id\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = useRef(0);\n let onTouchEnd = (e: TouchEvent) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime.current < 500) {\n e.preventDefault();\n inputRef.current?.focus();\n return;\n }\n\n let rect = (getEventTarget(e) as Element).getBoundingClientRect();\n let touch = e.changedTouches[0];\n\n let centerX = Math.ceil(rect.left + 0.5 * rect.width);\n let centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n inputRef.current?.focus();\n state.toggle(null, 'manual');\n\n lastEventTime.current = e.timeStamp;\n }\n };\n\n // VoiceOver has issues with announcing aria-activedescendant properly on change\n // (especially on iOS). We use a live region announcer to announce focus changes\n // manually. In addition, section titles are announced when navigating into a new section.\n let focusedItem =\n state.selectionManager.focusedKey != null && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined;\n let sectionKey = focusedItem?.parentKey ?? null;\n let itemKey = state.selectionManager.focusedKey ?? null;\n let lastSection = useRef(sectionKey);\n let lastItem = useRef(itemKey);\n useEffect(() => {\n if (isAppleDevice() && focusedItem != null && itemKey != null && itemKey !== lastItem.current) {\n let isSelected = state.selectionManager.isSelected(itemKey);\n let section = sectionKey != null ? state.collection.getItem(sectionKey) : null;\n let sectionTitle =\n section?.['aria-label'] ||\n (typeof section?.rendered === 'string' ? section.rendered : '') ||\n '';\n\n let announcement = stringFormatter.format('focusAnnouncement', {\n isGroupChange: (section && sectionKey !== lastSection.current) ?? false,\n groupTitle: sectionTitle,\n groupCount: section ? [...getChildNodes(section, state.collection)].length : 0,\n optionText: focusedItem['aria-label'] || focusedItem.textValue || '',\n isSelected\n });\n\n announce(announcement);\n }\n\n lastSection.current = sectionKey;\n lastItem.current = itemKey;\n });\n\n // Announce the number of available suggestions when it changes\n let optionCount = getItemCount(state.collection);\n let lastSize = useRef(optionCount);\n let lastOpen = useRef(state.isOpen);\n useEffect(() => {\n // Only announce the number of options available when the menu opens if there is no\n // focused item, otherwise screen readers will typically read e.g. \"1 of 6\".\n // The exception is VoiceOver since this isn't included in the message above.\n let didOpenWithoutFocusedItem =\n state.isOpen !== lastOpen.current &&\n (state.selectionManager.focusedKey == null || isAppleDevice());\n\n if (state.isOpen && (didOpenWithoutFocusedItem || optionCount !== lastSize.current)) {\n let announcement = stringFormatter.format('countAnnouncement', {optionCount});\n announce(announcement);\n }\n\n lastSize.current = optionCount;\n lastOpen.current = state.isOpen;\n });\n\n // Announce when a selection occurs for VoiceOver. Other screen readers typically do this automatically.\n // TODO: do we need to do this for multi-select?\n let lastSelectedKey = useRef(state.selectedKey);\n useEffect(() => {\n if (\n isAppleDevice() &&\n state.isFocused &&\n state.selectedItem &&\n state.selectedKey !== lastSelectedKey.current\n ) {\n let optionText = state.selectedItem['aria-label'] || state.selectedItem.textValue || '';\n let announcement = stringFormatter.format('selectedAnnouncement', {optionText});\n announce(announcement);\n }\n\n lastSelectedKey.current = state.selectedKey;\n });\n\n useEffect(() => {\n if (state.isOpen) {\n return ariaHideOutside(\n [inputRef.current, popoverRef.current].filter(element => element != null)\n );\n }\n }, [state.isOpen, inputRef, popoverRef]);\n\n useUpdateEffect(() => {\n // Re-show focus ring when there is no virtually focused item.\n if (\n !focusedItem &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) === inputRef.current\n ) {\n dispatchVirtualFocus(inputRef.current, null);\n }\n }, [focusedItem]);\n\n useEvent(\n listBoxRef,\n 'react-aria-item-action',\n state.isOpen\n ? () => {\n state.close();\n }\n : undefined\n );\n\n return {\n labelProps: {\n ...labelProps,\n // Focus the input in case the label is not a native <label> element.\n onClick:\n ('htmlFor' in labelProps && labelProps.htmlFor) || props.isDisabled\n ? undefined\n : () => {\n inputRef.current?.focus();\n setInteractionModality('keyboard');\n }\n },\n buttonProps: {\n ...menuTriggerProps,\n ...triggerLabelProps,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n onPress,\n onPressStart,\n isDisabled: isDisabled || isReadOnly\n },\n // oxlint-disable-next-line react/react-compiler\n inputProps: mergeProps(inputProps, {\n role: 'combobox',\n 'aria-expanded': menuTriggerProps['aria-expanded'],\n 'aria-controls': state.isOpen ? menuProps.id : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': focusedItem ? getItemId(state, focusedItem.key) : undefined,\n onTouchEnd,\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false'\n }),\n listBoxProps: mergeProps(menuProps, listBoxProps, {\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldUseVirtualFocus: true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n linkBehavior: 'selection' as const,\n ['UNSTABLE_itemBehavior']: 'action'\n }),\n valueProps: {\n id: valueId\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\n// This is a modified version of useSlotId that uses useEffect instead of useLayoutEffect.\n// Triggering re-renders from useLayoutEffect breaks useComboBoxState's useEffect logic in React 18.\n// These re-renders preempt async state updates in the useEffect, which ends up running multiple times\n// prior to the state being updated. This results in onSelectionChange being called multiple times.\n// TODO: refactor useComboBoxState to avoid this.\nfunction useValueId(depArray: ReadonlyArray<any> = []): string | undefined {\n let id = useId();\n let [exists, setExists] = useState(true);\n let [lastDeps, setLastDeps] = useState(depArray);\n\n // If the deps changed, set exists to true so we can test whether the element exists.\n if (lastDeps.some((v, i) => !Object.is(v, depArray[i]))) {\n setExists(true);\n setLastDeps(depArray);\n }\n\n useEffect(() => {\n if (exists && !document.getElementById(id)) {\n // oxlint-disable-next-line react/react-compiler\n setExists(false);\n }\n }, [id, exists, lastDeps]);\n\n return exists ? id : undefined;\n}\n"],"names":[],"version":3,"file":"useComboBox.mjs.map"}