react-aria 3.49.0 → 3.50.0

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 (244) hide show
  1. package/dist/private/autocomplete/useAutocomplete.cjs +16 -7
  2. package/dist/private/autocomplete/useAutocomplete.cjs.map +1 -1
  3. package/dist/private/autocomplete/useAutocomplete.js +16 -7
  4. package/dist/private/autocomplete/useAutocomplete.js.map +1 -1
  5. package/dist/private/autocomplete/useAutocomplete.mjs +16 -7
  6. package/dist/private/autocomplete/useAutocomplete.mjs.map +1 -1
  7. package/dist/private/breadcrumbs/useBreadcrumbs.cjs.map +1 -1
  8. package/dist/private/breadcrumbs/useBreadcrumbs.js.map +1 -1
  9. package/dist/private/breadcrumbs/useBreadcrumbs.mjs.map +1 -1
  10. package/dist/private/calendar/useCalendarBase.cjs.map +1 -1
  11. package/dist/private/calendar/useCalendarBase.js.map +1 -1
  12. package/dist/private/calendar/useCalendarBase.mjs.map +1 -1
  13. package/dist/private/calendar/useCalendarCell.cjs.map +1 -1
  14. package/dist/private/calendar/useCalendarCell.js.map +1 -1
  15. package/dist/private/calendar/useCalendarCell.mjs.map +1 -1
  16. package/dist/private/calendar/useCalendarYearPicker.cjs +4 -4
  17. package/dist/private/calendar/useCalendarYearPicker.cjs.map +1 -1
  18. package/dist/private/calendar/useCalendarYearPicker.js +4 -4
  19. package/dist/private/calendar/useCalendarYearPicker.js.map +1 -1
  20. package/dist/private/calendar/useCalendarYearPicker.mjs +4 -4
  21. package/dist/private/calendar/useCalendarYearPicker.mjs.map +1 -1
  22. package/dist/private/calendar/utils.cjs.map +1 -1
  23. package/dist/private/calendar/utils.js.map +1 -1
  24. package/dist/private/calendar/utils.mjs.map +1 -1
  25. package/dist/private/color/useColorArea.cjs.map +1 -1
  26. package/dist/private/color/useColorArea.js.map +1 -1
  27. package/dist/private/color/useColorArea.mjs.map +1 -1
  28. package/dist/private/color/useColorSwatch.cjs.map +1 -1
  29. package/dist/private/color/useColorSwatch.js.map +1 -1
  30. package/dist/private/color/useColorSwatch.mjs.map +1 -1
  31. package/dist/private/combobox/useComboBox.cjs +2 -0
  32. package/dist/private/combobox/useComboBox.cjs.map +1 -1
  33. package/dist/private/combobox/useComboBox.js +2 -0
  34. package/dist/private/combobox/useComboBox.js.map +1 -1
  35. package/dist/private/combobox/useComboBox.mjs +2 -0
  36. package/dist/private/combobox/useComboBox.mjs.map +1 -1
  37. package/dist/private/datepicker/useDateField.cjs.map +1 -1
  38. package/dist/private/datepicker/useDateField.js.map +1 -1
  39. package/dist/private/datepicker/useDateField.mjs.map +1 -1
  40. package/dist/private/datepicker/useDatePicker.cjs.map +1 -1
  41. package/dist/private/datepicker/useDatePicker.js.map +1 -1
  42. package/dist/private/datepicker/useDatePicker.mjs.map +1 -1
  43. package/dist/private/datepicker/useDateRangePicker.cjs.map +1 -1
  44. package/dist/private/datepicker/useDateRangePicker.js.map +1 -1
  45. package/dist/private/datepicker/useDateRangePicker.mjs.map +1 -1
  46. package/dist/private/datepicker/useDisplayNames.cjs +1 -2
  47. package/dist/private/datepicker/useDisplayNames.cjs.map +1 -1
  48. package/dist/private/datepicker/useDisplayNames.js +1 -2
  49. package/dist/private/datepicker/useDisplayNames.js.map +1 -1
  50. package/dist/private/datepicker/useDisplayNames.mjs +1 -2
  51. package/dist/private/datepicker/useDisplayNames.mjs.map +1 -1
  52. package/dist/private/dnd/DragManager.cjs +4 -1
  53. package/dist/private/dnd/DragManager.cjs.map +1 -1
  54. package/dist/private/dnd/DragManager.js +4 -1
  55. package/dist/private/dnd/DragManager.js.map +1 -1
  56. package/dist/private/dnd/DragManager.mjs +4 -1
  57. package/dist/private/dnd/DragManager.mjs.map +1 -1
  58. package/dist/private/dnd/useDrag.cjs.map +1 -1
  59. package/dist/private/dnd/useDrag.js.map +1 -1
  60. package/dist/private/dnd/useDrag.mjs.map +1 -1
  61. package/dist/private/dnd/useDraggableItem.cjs.map +1 -1
  62. package/dist/private/dnd/useDraggableItem.js.map +1 -1
  63. package/dist/private/dnd/useDraggableItem.mjs.map +1 -1
  64. package/dist/private/dnd/useDropIndicator.cjs.map +1 -1
  65. package/dist/private/dnd/useDropIndicator.js.map +1 -1
  66. package/dist/private/dnd/useDropIndicator.mjs.map +1 -1
  67. package/dist/private/dnd/useVirtualDrop.cjs.map +1 -1
  68. package/dist/private/dnd/useVirtualDrop.js.map +1 -1
  69. package/dist/private/dnd/useVirtualDrop.mjs.map +1 -1
  70. package/dist/private/dnd/utils.cjs +13 -3
  71. package/dist/private/dnd/utils.cjs.map +1 -1
  72. package/dist/private/dnd/utils.js +13 -3
  73. package/dist/private/dnd/utils.js.map +1 -1
  74. package/dist/private/dnd/utils.mjs +13 -3
  75. package/dist/private/dnd/utils.mjs.map +1 -1
  76. package/dist/private/form/useFormValidation.cjs +1 -1
  77. package/dist/private/form/useFormValidation.cjs.map +1 -1
  78. package/dist/private/form/useFormValidation.js +1 -1
  79. package/dist/private/form/useFormValidation.js.map +1 -1
  80. package/dist/private/form/useFormValidation.mjs +1 -1
  81. package/dist/private/form/useFormValidation.mjs.map +1 -1
  82. package/dist/private/grid/useGridSelectionAnnouncement.cjs.map +1 -1
  83. package/dist/private/grid/useGridSelectionAnnouncement.js.map +1 -1
  84. package/dist/private/grid/useGridSelectionAnnouncement.mjs.map +1 -1
  85. package/dist/private/grid/useGridSelectionCheckbox.cjs.map +1 -1
  86. package/dist/private/grid/useGridSelectionCheckbox.js.map +1 -1
  87. package/dist/private/grid/useGridSelectionCheckbox.mjs.map +1 -1
  88. package/dist/private/grid/useHighlightSelectionDescription.cjs.map +1 -1
  89. package/dist/private/grid/useHighlightSelectionDescription.js.map +1 -1
  90. package/dist/private/grid/useHighlightSelectionDescription.mjs.map +1 -1
  91. package/dist/private/gridlist/useGridList.cjs +2 -1
  92. package/dist/private/gridlist/useGridList.cjs.map +1 -1
  93. package/dist/private/gridlist/useGridList.js +2 -1
  94. package/dist/private/gridlist/useGridList.js.map +1 -1
  95. package/dist/private/gridlist/useGridList.mjs +2 -1
  96. package/dist/private/gridlist/useGridList.mjs.map +1 -1
  97. package/dist/private/gridlist/useGridListItem.cjs +62 -21
  98. package/dist/private/gridlist/useGridListItem.cjs.map +1 -1
  99. package/dist/private/gridlist/useGridListItem.js +63 -22
  100. package/dist/private/gridlist/useGridListItem.js.map +1 -1
  101. package/dist/private/gridlist/useGridListItem.mjs +62 -21
  102. package/dist/private/gridlist/useGridListItem.mjs.map +1 -1
  103. package/dist/private/interactions/createEventHandler.cjs +3 -0
  104. package/dist/private/interactions/createEventHandler.cjs.map +1 -1
  105. package/dist/private/interactions/createEventHandler.js +3 -0
  106. package/dist/private/interactions/createEventHandler.js.map +1 -1
  107. package/dist/private/interactions/createEventHandler.mjs +3 -0
  108. package/dist/private/interactions/createEventHandler.mjs.map +1 -1
  109. package/dist/private/interactions/useFocusVisible.cjs +16 -5
  110. package/dist/private/interactions/useFocusVisible.cjs.map +1 -1
  111. package/dist/private/interactions/useFocusVisible.js +16 -5
  112. package/dist/private/interactions/useFocusVisible.js.map +1 -1
  113. package/dist/private/interactions/useFocusVisible.mjs +16 -5
  114. package/dist/private/interactions/useFocusVisible.mjs.map +1 -1
  115. package/dist/private/menu/useMenu.cjs.map +1 -1
  116. package/dist/private/menu/useMenu.js.map +1 -1
  117. package/dist/private/menu/useMenu.mjs.map +1 -1
  118. package/dist/private/menu/useMenuItem.cjs +1 -1
  119. package/dist/private/menu/useMenuItem.cjs.map +1 -1
  120. package/dist/private/menu/useMenuItem.js +1 -1
  121. package/dist/private/menu/useMenuItem.js.map +1 -1
  122. package/dist/private/menu/useMenuItem.mjs +1 -1
  123. package/dist/private/menu/useMenuItem.mjs.map +1 -1
  124. package/dist/private/menu/useMenuTrigger.cjs.map +1 -1
  125. package/dist/private/menu/useMenuTrigger.js.map +1 -1
  126. package/dist/private/menu/useMenuTrigger.mjs.map +1 -1
  127. package/dist/private/menu/utils.cjs.map +1 -1
  128. package/dist/private/menu/utils.js.map +1 -1
  129. package/dist/private/menu/utils.mjs.map +1 -1
  130. package/dist/private/numberfield/useNumberField.cjs.map +1 -1
  131. package/dist/private/numberfield/useNumberField.js.map +1 -1
  132. package/dist/private/numberfield/useNumberField.mjs.map +1 -1
  133. package/dist/private/overlays/DismissButton.cjs.map +1 -1
  134. package/dist/private/overlays/DismissButton.js.map +1 -1
  135. package/dist/private/overlays/DismissButton.mjs.map +1 -1
  136. package/dist/private/overlays/calculatePosition.cjs +7 -7
  137. package/dist/private/overlays/calculatePosition.cjs.map +1 -1
  138. package/dist/private/overlays/calculatePosition.js +7 -7
  139. package/dist/private/overlays/calculatePosition.js.map +1 -1
  140. package/dist/private/overlays/calculatePosition.mjs +7 -7
  141. package/dist/private/overlays/calculatePosition.mjs.map +1 -1
  142. package/dist/private/overlays/useOverlayPosition.cjs +3 -2
  143. package/dist/private/overlays/useOverlayPosition.cjs.map +1 -1
  144. package/dist/private/overlays/useOverlayPosition.js +3 -2
  145. package/dist/private/overlays/useOverlayPosition.js.map +1 -1
  146. package/dist/private/overlays/useOverlayPosition.mjs +3 -2
  147. package/dist/private/overlays/useOverlayPosition.mjs.map +1 -1
  148. package/dist/private/searchfield/useSearchField.cjs.map +1 -1
  149. package/dist/private/searchfield/useSearchField.js.map +1 -1
  150. package/dist/private/searchfield/useSearchField.mjs.map +1 -1
  151. package/dist/private/select/useSelect.cjs +1 -2
  152. package/dist/private/select/useSelect.cjs.map +1 -1
  153. package/dist/private/select/useSelect.js +1 -2
  154. package/dist/private/select/useSelect.js.map +1 -1
  155. package/dist/private/select/useSelect.mjs +1 -2
  156. package/dist/private/select/useSelect.mjs.map +1 -1
  157. package/dist/private/selection/ListKeyboardDelegate.cjs +31 -3
  158. package/dist/private/selection/ListKeyboardDelegate.cjs.map +1 -1
  159. package/dist/private/selection/ListKeyboardDelegate.js +31 -3
  160. package/dist/private/selection/ListKeyboardDelegate.js.map +1 -1
  161. package/dist/private/selection/ListKeyboardDelegate.mjs +31 -3
  162. package/dist/private/selection/ListKeyboardDelegate.mjs.map +1 -1
  163. package/dist/private/selection/useSelectableCollection.cjs +20 -14
  164. package/dist/private/selection/useSelectableCollection.cjs.map +1 -1
  165. package/dist/private/selection/useSelectableCollection.js +26 -19
  166. package/dist/private/selection/useSelectableCollection.js.map +1 -1
  167. package/dist/private/selection/useSelectableCollection.mjs +20 -14
  168. package/dist/private/selection/useSelectableCollection.mjs.map +1 -1
  169. package/dist/private/selection/useTypeSelect.cjs +50 -18
  170. package/dist/private/selection/useTypeSelect.cjs.map +1 -1
  171. package/dist/private/selection/useTypeSelect.js +51 -19
  172. package/dist/private/selection/useTypeSelect.js.map +1 -1
  173. package/dist/private/selection/useTypeSelect.mjs +51 -19
  174. package/dist/private/selection/useTypeSelect.mjs.map +1 -1
  175. package/dist/private/spinbutton/useSpinButton.cjs.map +1 -1
  176. package/dist/private/spinbutton/useSpinButton.js.map +1 -1
  177. package/dist/private/spinbutton/useSpinButton.mjs.map +1 -1
  178. package/dist/private/steplist/useStepList.cjs.map +1 -1
  179. package/dist/private/steplist/useStepList.js.map +1 -1
  180. package/dist/private/steplist/useStepList.mjs.map +1 -1
  181. package/dist/private/table/useTable.cjs.map +1 -1
  182. package/dist/private/table/useTable.js.map +1 -1
  183. package/dist/private/table/useTable.mjs.map +1 -1
  184. package/dist/private/table/useTableColumnHeader.cjs.map +1 -1
  185. package/dist/private/table/useTableColumnHeader.js.map +1 -1
  186. package/dist/private/table/useTableColumnHeader.mjs.map +1 -1
  187. package/dist/private/table/useTableColumnResize.cjs.map +1 -1
  188. package/dist/private/table/useTableColumnResize.js.map +1 -1
  189. package/dist/private/table/useTableColumnResize.mjs.map +1 -1
  190. package/dist/private/table/useTableRow.cjs.map +1 -1
  191. package/dist/private/table/useTableRow.js.map +1 -1
  192. package/dist/private/table/useTableRow.mjs.map +1 -1
  193. package/dist/private/table/useTableSelectionCheckbox.cjs.map +1 -1
  194. package/dist/private/table/useTableSelectionCheckbox.js.map +1 -1
  195. package/dist/private/table/useTableSelectionCheckbox.mjs.map +1 -1
  196. package/dist/private/tabs/TabsKeyboardDelegate.cjs +2 -2
  197. package/dist/private/tabs/TabsKeyboardDelegate.cjs.map +1 -1
  198. package/dist/private/tabs/TabsKeyboardDelegate.js +2 -2
  199. package/dist/private/tabs/TabsKeyboardDelegate.js.map +1 -1
  200. package/dist/private/tabs/TabsKeyboardDelegate.mjs +2 -2
  201. package/dist/private/tabs/TabsKeyboardDelegate.mjs.map +1 -1
  202. package/dist/private/tag/useTag.cjs.map +1 -1
  203. package/dist/private/tag/useTag.js.map +1 -1
  204. package/dist/private/tag/useTag.mjs.map +1 -1
  205. package/dist/private/toast/useToast.cjs.map +1 -1
  206. package/dist/private/toast/useToast.js.map +1 -1
  207. package/dist/private/toast/useToast.mjs.map +1 -1
  208. package/dist/private/toast/useToastRegion.cjs.map +1 -1
  209. package/dist/private/toast/useToastRegion.js.map +1 -1
  210. package/dist/private/toast/useToastRegion.mjs.map +1 -1
  211. package/dist/private/toolbar/useToolbar.cjs +0 -1
  212. package/dist/private/toolbar/useToolbar.cjs.map +1 -1
  213. package/dist/private/toolbar/useToolbar.js +0 -1
  214. package/dist/private/toolbar/useToolbar.js.map +1 -1
  215. package/dist/private/toolbar/useToolbar.mjs +0 -1
  216. package/dist/private/toolbar/useToolbar.mjs.map +1 -1
  217. package/dist/private/tree/useTree.cjs.map +1 -1
  218. package/dist/private/tree/useTree.js.map +1 -1
  219. package/dist/private/tree/useTree.mjs.map +1 -1
  220. package/dist/private/tree/useTreeItem.cjs.map +1 -1
  221. package/dist/private/tree/useTreeItem.js.map +1 -1
  222. package/dist/private/tree/useTreeItem.mjs.map +1 -1
  223. package/dist/private/utils/isElementVisible.cjs +1 -1
  224. package/dist/private/utils/isElementVisible.cjs.map +1 -1
  225. package/dist/private/utils/isElementVisible.js +1 -1
  226. package/dist/private/utils/isElementVisible.js.map +1 -1
  227. package/dist/private/utils/isElementVisible.mjs +1 -1
  228. package/dist/private/utils/isElementVisible.mjs.map +1 -1
  229. package/dist/private/utils/isFocusable.cjs +3 -1
  230. package/dist/private/utils/isFocusable.cjs.map +1 -1
  231. package/dist/private/utils/isFocusable.js +3 -1
  232. package/dist/private/utils/isFocusable.js.map +1 -1
  233. package/dist/private/utils/isFocusable.mjs +3 -1
  234. package/dist/private/utils/isFocusable.mjs.map +1 -1
  235. package/dist/types/src/dnd/utils.d.ts +2 -2
  236. package/dist/types/src/gridlist/useGridList.d.ts +7 -0
  237. package/dist/types/src/menu/useMenu.d.ts +1 -1
  238. package/dist/types/src/menu/utils.d.ts +1 -1
  239. package/dist/types/src/overlays/calculatePosition.d.ts +1 -0
  240. package/dist/types/src/overlays/useOverlayPosition.d.ts +8 -0
  241. package/dist/types/src/selection/ListKeyboardDelegate.d.ts +1 -0
  242. package/dist/types/src/selection/useSelectableCollection.d.ts +7 -0
  243. package/dist/types/src/tree/useTree.d.ts +1 -1
  244. package/package.json +4 -4
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAmEM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,4CAAiB;IAEjE,IAAI,aAAC,SAAS,UAAE,MAAM,EAAC,GAAG,CAAA,GAAA,mCAAQ;IAElC,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,qBAAO,EAAoB;IACjE,IAAI,aAAa,CAAA,GAAA,wBAAU,EACzB,CAAC,WAA+C,SAAS;QACvD,IAAI,SAAS,OAAO,EAClB,CAAA,GAAA,+CAAoB,EAAE,SAAS,OAAO;IAE1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AC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,CAAC,gBAAgB,iBAAiB,MAAM,YAAY;YAC1E;;;;MAIA,GACA,eACE,YAAY,CAAC,gBAAgB,iBAAiB,OAAO,0BACjD,YACA;sBACN;QACF;QACA,aAAa;YACX,GAAG,oBAAoB;YACvB,GAAG,mBAAmB;YACtB,GAAG,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,iBAAiB,MAAM,YAAY;YACzD;;;;MAIA,GACA,eACE,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC5E;QACF;IACF;AACF","sources":["packages/react-aria/src/color/useColorArea.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 {AriaLabelingProps, DOMAttributes, DOMProps, RefObject} from '@react-types/shared';\nimport {ColorAreaProps, ColorAreaState} from 'react-stately/useColorAreaState';\nimport {ColorChannel} from 'react-stately/Color';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport intlMessages from '../../intl/color/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {mergeProps} from '../utils/mergeProps';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\n// @ts-ignore\nimport {useFocus} from '../interactions/useFocus';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMove} from '../interactions/useMove';\nimport {useVisuallyHidden} from '../visually-hidden/VisuallyHidden';\n\nexport interface AriaColorAreaProps extends ColorAreaProps, DOMProps, AriaLabelingProps {\n /**\n * The name of the x channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n xName?: string;\n /**\n * The name of the y channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n yName?: string;\n /**\n * The `<form>` element to associate the ColorArea with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes;\n /** Props for the thumb element. */\n thumbProps: DOMAttributes;\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>;\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>;\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component. Color area\n * allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional\n * gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback(\n (inputRef: RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n },\n [inputXRef]\n );\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number; y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl'\n ? state.incrementX(state.xChannelPageStep)\n : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl'\n ? state.decrementX(state.xChannelPageStep)\n : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue =\n shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue =\n shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += ((direction === 'rtl' ? -1 : 1) * deltaX) / width;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin: boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (\n colorArea: Element,\n id: number | null | undefined,\n clientX: number,\n clientY: number\n ) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (\n x >= 0 &&\n x <= 1 &&\n y >= 0 &&\n y <= 1 &&\n !state.isDragging &&\n currentPointer.current === undefined\n ) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(\n e.currentTarget,\n e.changedTouches[0].identifier,\n e.changedTouches[0].clientX,\n e.changedTouches[0].clientY\n );\n }\n })\n },\n movePropsContainer\n );\n\n let thumbInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onThumbDown(e.pointerId);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n },\n focusWithinProps,\n keyboardProps,\n movePropsThumb\n );\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback(\n (channel: ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput\n ? stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n })\n : [\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),\n value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(zChannel, locale),\n value: value.formatChannelValue(zChannel, locale)\n })\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n },\n [\n locale,\n value,\n stringFormatter,\n valueChangedViaInputChangeEvent,\n valueChangedViaKeyboard,\n xChannel,\n yChannel,\n zChannel\n ]\n );\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n let {colorAreaStyleProps, thumbStyleProps} = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard\n ? undefined\n : 'true',\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAkEM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,4CAAiB;IAEjE,IAAI,aAAC,SAAS,UAAE,MAAM,EAAC,GAAG,CAAA,GAAA,mCAAQ;IAElC,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,qBAAO,EA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B,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,CAAC,gBAAgB,iBAAiB,MAAM,YAAY;YAC1E;;;;MAIA,GACA,eACE,YAAY,CAAC,gBAAgB,iBAAiB,OAAO,0BACjD,YACA;sBACN;QACF;QACA,aAAa;YACX,GAAG,oBAAoB;YACvB,GAAG,mBAAmB;YACtB,GAAG,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,iBAAiB,MAAM,YAAY;YACzD;;;;MAIA,GACA,eACE,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC5E;QACF;IACF;AACF","sources":["packages/react-aria/src/color/useColorArea.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 {AriaLabelingProps, DOMAttributes, DOMProps, RefObject} from '@react-types/shared';\nimport {ColorAreaProps, ColorAreaState} from 'react-stately/useColorAreaState';\nimport {ColorChannel} from 'react-stately/Color';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport intlMessages from '../../intl/color/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {mergeProps} from '../utils/mergeProps';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus} from '../interactions/useFocus';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMove} from '../interactions/useMove';\nimport {useVisuallyHidden} from '../visually-hidden/VisuallyHidden';\n\nexport interface AriaColorAreaProps extends ColorAreaProps, DOMProps, AriaLabelingProps {\n /**\n * The name of the x channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n xName?: string;\n /**\n * The name of the y channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n yName?: string;\n /**\n * The `<form>` element to associate the ColorArea with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes;\n /** Props for the thumb element. */\n thumbProps: DOMAttributes;\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>;\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>;\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component. Color area\n * allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional\n * gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback(\n (inputRef: RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n },\n [inputXRef]\n );\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number; y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl'\n ? state.incrementX(state.xChannelPageStep)\n : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl'\n ? state.decrementX(state.xChannelPageStep)\n : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue =\n shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue =\n shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += ((direction === 'rtl' ? -1 : 1) * deltaX) / width;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin: boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (\n colorArea: Element,\n id: number | null | undefined,\n clientX: number,\n clientY: number\n ) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (\n x >= 0 &&\n x <= 1 &&\n y >= 0 &&\n y <= 1 &&\n !state.isDragging &&\n currentPointer.current === undefined\n ) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(\n e.currentTarget,\n e.changedTouches[0].identifier,\n e.changedTouches[0].clientX,\n e.changedTouches[0].clientY\n );\n }\n })\n },\n movePropsContainer\n );\n\n let thumbInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onThumbDown(e.pointerId);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n },\n focusWithinProps,\n keyboardProps,\n movePropsThumb\n );\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback(\n (channel: ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput\n ? stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n })\n : [\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),\n value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(zChannel, locale),\n value: value.formatChannelValue(zChannel, locale)\n })\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n },\n [\n locale,\n value,\n stringFormatter,\n valueChangedViaInputChangeEvent,\n valueChangedViaKeyboard,\n xChannel,\n yChannel,\n zChannel\n ]\n );\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n let {colorAreaStyleProps, thumbStyleProps} = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard\n ? undefined\n : 'true',\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAmEM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,yCA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;YACtB,MAAM;QACR;QACA,YAAY;YACV,GAAG,iBAAiB;YACpB,GAAG,eAAe;YAClB,MAAM;QACR;QACA,aAAa;YACX,GAAG,oBAAoB;YACvB,GAAG,mBAAmB;YACtB,GAAG,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,CAAC,gBAAgB,iBAAiB,MAAM,YAAY;YAC1E;;;;MAIA,GACA,eACE,YAAY,CAAC,gBAAgB,iBAAiB,OAAO,0BACjD,YACA;sBACN;QACF;QACA,aAAa;YACX,GAAG,oBAAoB;YACvB,GAAG,mBAAmB;YACtB,GAAG,gBAAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,iBAAiB,MAAM,YAAY;YACzD;;;;MAIA,GACA,eACE,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC5E;QACF;IACF;AACF","sources":["packages/react-aria/src/color/useColorArea.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 {AriaLabelingProps, DOMAttributes, DOMProps, RefObject} from '@react-types/shared';\nimport {ColorAreaProps, ColorAreaState} from 'react-stately/useColorAreaState';\nimport {ColorChannel} from 'react-stately/Color';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport intlMessages from '../../intl/color/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {mergeProps} from '../utils/mergeProps';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\n// @ts-ignore\nimport {useFocus} from '../interactions/useFocus';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMove} from '../interactions/useMove';\nimport {useVisuallyHidden} from '../visually-hidden/VisuallyHidden';\n\nexport interface AriaColorAreaProps extends ColorAreaProps, DOMProps, AriaLabelingProps {\n /**\n * The name of the x channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n xName?: string;\n /**\n * The name of the y channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n yName?: string;\n /**\n * The `<form>` element to associate the ColorArea with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes;\n /** Props for the thumb element. */\n thumbProps: DOMAttributes;\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>;\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>;\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component. Color area\n * allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional\n * gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback(\n (inputRef: RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n },\n [inputXRef]\n );\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number; y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl'\n ? state.incrementX(state.xChannelPageStep)\n : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl'\n ? state.decrementX(state.xChannelPageStep)\n : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue =\n shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue =\n shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += ((direction === 'rtl' ? -1 : 1) * deltaX) / width;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin: boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (\n colorArea: Element,\n id: number | null | undefined,\n clientX: number,\n clientY: number\n ) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (\n x >= 0 &&\n x <= 1 &&\n y >= 0 &&\n y <= 1 &&\n !state.isDragging &&\n currentPointer.current === undefined\n ) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(\n e.currentTarget,\n e.changedTouches[0].identifier,\n e.changedTouches[0].clientX,\n e.changedTouches[0].clientY\n );\n }\n })\n },\n movePropsContainer\n );\n\n let thumbInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onThumbDown(e.pointerId);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n },\n focusWithinProps,\n keyboardProps,\n movePropsThumb\n );\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback(\n (channel: ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput\n ? stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n })\n : [\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),\n value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(zChannel, locale),\n value: value.formatChannelValue(zChannel, locale)\n })\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n },\n [\n locale,\n value,\n stringFormatter,\n valueChangedViaInputChangeEvent,\n valueChangedViaKeyboard,\n xChannel,\n yChannel,\n zChannel\n ]\n );\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n let {colorAreaStyleProps, thumbStyleProps} = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard\n ? undefined\n : 'true',\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAkE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C,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,iBAAiB,MAAM,YAAY;YACzD;;;;MAIA,GACA,eACE,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC5E;QACF;IACF;AACF","sources":["packages/react-aria/src/color/useColorArea.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 {AriaLabelingProps, DOMAttributes, DOMProps, RefObject} from '@react-types/shared';\nimport {ColorAreaProps, ColorAreaState} from 'react-stately/useColorAreaState';\nimport {ColorChannel} from 'react-stately/Color';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport intlMessages from '../../intl/color/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {mergeProps} from '../utils/mergeProps';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus} from '../interactions/useFocus';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMove} from '../interactions/useMove';\nimport {useVisuallyHidden} from '../visually-hidden/VisuallyHidden';\n\nexport interface AriaColorAreaProps extends ColorAreaProps, DOMProps, AriaLabelingProps {\n /**\n * The name of the x channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n xName?: string;\n /**\n * The name of the y channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n yName?: string;\n /**\n * The `<form>` element to associate the ColorArea with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes;\n /** Props for the thumb element. */\n thumbProps: DOMAttributes;\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>;\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>;\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component. Color area\n * allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional\n * gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback(\n (inputRef: RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n },\n [inputXRef]\n );\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number; y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl'\n ? state.incrementX(state.xChannelPageStep)\n : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl'\n ? state.decrementX(state.xChannelPageStep)\n : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue =\n shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue =\n shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += ((direction === 'rtl' ? -1 : 1) * deltaX) / width;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin: boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (\n colorArea: Element,\n id: number | null | undefined,\n clientX: number,\n clientY: number\n ) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (\n x >= 0 &&\n x <= 1 &&\n y >= 0 &&\n y <= 1 &&\n !state.isDragging &&\n currentPointer.current === undefined\n ) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(\n e.currentTarget,\n e.changedTouches[0].identifier,\n e.changedTouches[0].clientX,\n e.changedTouches[0].clientY\n );\n }\n })\n },\n movePropsContainer\n );\n\n let thumbInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onThumbDown(e.pointerId);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n },\n focusWithinProps,\n keyboardProps,\n movePropsThumb\n );\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback(\n (channel: ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput\n ? stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n })\n : [\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),\n value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(zChannel, locale),\n value: value.formatChannelValue(zChannel, locale)\n })\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n },\n [\n locale,\n value,\n stringFormatter,\n valueChangedViaInputChangeEvent,\n valueChangedViaKeyboard,\n xChannel,\n yChannel,\n zChannel\n ]\n );\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n let {colorAreaStyleProps, thumbStyleProps} = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard\n ? undefined\n : 'true',\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAmEM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,yCAAiB;IAEjE,IAAI,aAAC,SAAS,UAAE,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAQ;IAElC,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,eAAO,EAAoB;IACjE,IAAI,aAAa,CAAA,GAAA,kBAAU,EACzB,CAAC,WAA+C,SAAS;QACvD,IAAI,SAAS,OAAO,EAClB,CAAA,GAAA,yCAAoB,EAAE,SAAS,OAAO;IAE1C,GACA;QAAC;KAAU;IAGb,CAAA,GAAA,yCAAW,EAAE,WAAW,MAAM,YAAY,EAAE,MAAM,QAAQ;IAE1D,IAAI,CAAC,yBAAyB,2BAA2B,GAAG,CAAA,GAAA,eAAO,EAAE;IACrE,IAAI,CAAC,iCAAiC,mCAAmC,GAAG,CAAA,GAAA,eAAO,EAAE;IACrF,IAAI,YAAC,QAAQ,YAAE,QAAQ,YAAE,QAAQ,EAAC,GAAG,MAAM,QAAQ;IACnD,IAAI,eAAe,MAAM,YAAY;IACrC,IAAI,eAAe,MAAM,YAAY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;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,iBAAiB,MAAM,YAAY;YACzD;;;;MAIA,GACA,eACE,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC5E;QACF;IACF;AACF","sources":["packages/react-aria/src/color/useColorArea.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 {AriaLabelingProps, DOMAttributes, DOMProps, RefObject} from '@react-types/shared';\nimport {ColorAreaProps, ColorAreaState} from 'react-stately/useColorAreaState';\nimport {ColorChannel} from 'react-stately/Color';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport intlMessages from '../../intl/color/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {mergeProps} from '../utils/mergeProps';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\n// @ts-ignore\nimport {useFocus} from '../interactions/useFocus';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMove} from '../interactions/useMove';\nimport {useVisuallyHidden} from '../visually-hidden/VisuallyHidden';\n\nexport interface AriaColorAreaProps extends ColorAreaProps, DOMProps, AriaLabelingProps {\n /**\n * The name of the x channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n xName?: string;\n /**\n * The name of the y channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n yName?: string;\n /**\n * The `<form>` element to associate the ColorArea with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes;\n /** Props for the thumb element. */\n thumbProps: DOMAttributes;\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>;\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>;\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component. Color area\n * allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional\n * gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback(\n (inputRef: RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n },\n [inputXRef]\n );\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number; y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl'\n ? state.incrementX(state.xChannelPageStep)\n : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl'\n ? state.decrementX(state.xChannelPageStep)\n : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue =\n shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue =\n shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += ((direction === 'rtl' ? -1 : 1) * deltaX) / width;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin: boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (\n colorArea: Element,\n id: number | null | undefined,\n clientX: number,\n clientY: number\n ) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (\n x >= 0 &&\n x <= 1 &&\n y >= 0 &&\n y <= 1 &&\n !state.isDragging &&\n currentPointer.current === undefined\n ) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(\n e.currentTarget,\n e.changedTouches[0].identifier,\n e.changedTouches[0].clientX,\n e.changedTouches[0].clientY\n );\n }\n })\n },\n movePropsContainer\n );\n\n let thumbInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onThumbDown(e.pointerId);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n },\n focusWithinProps,\n keyboardProps,\n movePropsThumb\n );\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback(\n (channel: ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput\n ? stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n })\n : [\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),\n value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(zChannel, locale),\n value: value.formatChannelValue(zChannel, locale)\n })\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n },\n [\n locale,\n value,\n stringFormatter,\n valueChangedViaInputChangeEvent,\n valueChangedViaKeyboard,\n xChannel,\n yChannel,\n zChannel\n ]\n );\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n let {colorAreaStyleProps, thumbStyleProps} = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard\n ? undefined\n : 'true',\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAkEM,SAAS,0CAAa,KAA2B,EAAE,KAAqB;IAC7E,IAAI,cACF,UAAU,aACV,SAAS,aACT,SAAS,gBACT,YAAY,EACZ,cAAc,SAAS,SACvB,KAAK,SACL,KAAK,QACL,IAAI,EACL,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,yCAAiB;IAEjE,IAAI,aAAC,SAAS,UAAE,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAQ;IAElC,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,eAAO,EAAoB;IACjE,IAAI,aAAa,CAAA,GAAA,kBAAU,EACzB,CAAC,WAA+C,SAAS;QACvD,IAAI,SAAS,OAAO,EAClB,CAAA,GAAA,yCAAoB,EAAE,SAAS,OAAO;IAE1C,GACA;QAAC;KAAU;IAGb,CAAA,GAAA,yCAAW,EAAE,WAAW,MAAM,YAAY,EAAE,MAAM,QAAQ;IAE1D,IAAI,CAAC,yBAAyB,2BAA2B,GAAG,CAAA,GAAA,eAAO,EAAE;IACrE,IAAI,CAAC,iCAAiC,mCAAmC,GAAG,CAAA,GAAA,eAAO,EAAE;IACrF,IAA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AAgB;YACnB,MAAM;YACN,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,KAAK,MAAM,KAAK,CAAC,eAAe,CAAC,UAAU,QAAQ;YACnD,MAAM;YACN,wBAAwB;YACxB,kBAAkB,2BAA2B;YAC7C,oBAAoB;YACpB,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;YACrC,UAAU;YACV,OAAO,MAAM,KAAK,CAAC,eAAe,CAAC;YACnC,MAAM;kBACN;YACA,UAAU,YAAY,iBAAiB,MAAM,YAAY;YACzD;;;;MAIA,GACA,eACE,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC5E;QACF;IACF;AACF","sources":["packages/react-aria/src/color/useColorArea.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 {AriaLabelingProps, DOMAttributes, DOMProps, RefObject} from '@react-types/shared';\nimport {ColorAreaProps, ColorAreaState} from 'react-stately/useColorAreaState';\nimport {ColorChannel} from 'react-stately/Color';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport intlMessages from '../../intl/color/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {mergeProps} from '../utils/mergeProps';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus} from '../interactions/useFocus';\nimport {useFocusWithin} from '../interactions/useFocusWithin';\nimport {useFormReset} from '../utils/useFormReset';\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useKeyboard} from '../interactions/useKeyboard';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMove} from '../interactions/useMove';\nimport {useVisuallyHidden} from '../visually-hidden/VisuallyHidden';\n\nexport interface AriaColorAreaProps extends ColorAreaProps, DOMProps, AriaLabelingProps {\n /**\n * The name of the x channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n xName?: string;\n /**\n * The name of the y channel input element, used when submitting an HTML form. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).\n */\n yName?: string;\n /**\n * The `<form>` element to associate the ColorArea with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface ColorAreaAria {\n /** Props for the color area container element. */\n colorAreaProps: DOMAttributes;\n /** Props for the thumb element. */\n thumbProps: DOMAttributes;\n /** Props for the visually hidden horizontal range input element. */\n xInputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the visually hidden vertical range input element. */\n yInputProps: InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport interface AriaColorAreaOptions extends AriaColorAreaProps {\n /** A ref to the input that represents the x axis of the color area. */\n inputXRef: RefObject<HTMLInputElement | null>;\n /** A ref to the input that represents the y axis of the color area. */\n inputYRef: RefObject<HTMLInputElement | null>;\n /** A ref to the color area containing element. */\n containerRef: RefObject<Element | null>;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color area component. Color area\n * allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional\n * gradient background.\n */\nexport function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {\n let {\n isDisabled,\n inputXRef,\n inputYRef,\n containerRef,\n 'aria-label': ariaLabel,\n xName,\n yName,\n form\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {direction, locale} = useLocale();\n\n let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);\n let focusInput = useCallback(\n (inputRef: RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n },\n [inputXRef]\n );\n\n useFormReset(inputXRef, state.defaultValue, state.setValue);\n\n let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);\n let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);\n let {xChannel, yChannel, zChannel} = state.channels;\n let xChannelStep = state.xChannelStep;\n let yChannelStep = state.yChannelStep;\n\n let currentPosition = useRef<{x: number; y: number} | null>(null);\n\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n // these are the cases that useMove doesn't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us\n e.preventDefault();\n // remember to set this and unset it so that onChangeEnd is fired\n state.setDragging(true);\n setValueChangedViaKeyboard(true);\n let dir;\n switch (e.key) {\n case 'PageUp':\n state.incrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'PageDown':\n state.decrementY(state.yChannelPageStep);\n dir = 'y';\n break;\n case 'Home':\n direction === 'rtl'\n ? state.incrementX(state.xChannelPageStep)\n : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl'\n ? state.decrementX(state.xChannelPageStep)\n : state.incrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n }\n state.setDragging(false);\n if (dir) {\n let input = dir === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n setFocusedInput(dir);\n }\n }\n });\n\n let moveHandler = {\n onMoveStart() {\n currentPosition.current = null;\n state.setDragging(true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n let {\n incrementX,\n decrementX,\n incrementY,\n decrementY,\n xChannelPageStep,\n xChannelStep,\n yChannelPageStep,\n yChannelStep,\n getThumbPosition,\n setColorFromPoint\n } = state;\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPosition();\n }\n let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};\n let valueChanged = deltaX !== 0 || deltaY !== 0;\n if (pointerType === 'keyboard') {\n let deltaXValue =\n shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue =\n shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;\n if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {\n incrementX(deltaXValue);\n } else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {\n decrementX(deltaXValue);\n } else if (deltaY > 0) {\n decrementY(deltaYValue);\n } else if (deltaY < 0) {\n incrementY(deltaYValue);\n }\n setValueChangedViaKeyboard(valueChanged);\n // set the focused input based on which axis has the greater delta\n focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';\n setFocusedInput(focusedInput);\n } else {\n currentPosition.current.x += ((direction === 'rtl' ? -1 : 1) * deltaX) / width;\n currentPosition.current.y += deltaY / height;\n setColorFromPoint(currentPosition.current.x, currentPosition.current.y);\n }\n },\n onMoveEnd() {\n isOnColorArea.current = false;\n state.setDragging(false);\n let input = focusedInput === 'x' ? inputXRef : inputYRef;\n focusInput(input);\n }\n };\n let {moveProps: movePropsThumb} = useMove(moveHandler);\n\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: (focusWithin: boolean) => {\n if (!focusWithin) {\n setValueChangedViaKeyboard(false);\n setValueChangedViaInputChangeEvent(false);\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let isOnColorArea = useRef<boolean>(false);\n let {moveProps: movePropsContainer} = useMove({\n onMoveStart() {\n if (isOnColorArea.current) {\n moveHandler.onMoveStart();\n }\n },\n onMove(e) {\n if (isOnColorArea.current) {\n moveHandler.onMove(e);\n }\n },\n onMoveEnd() {\n if (isOnColorArea.current) {\n moveHandler.onMoveEnd();\n }\n }\n });\n\n let onThumbDown = (id: number | null | undefined) => {\n if (!state.isDragging) {\n currentPointer.current = id;\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(true);\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onThumbUp, false);\n addGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onThumbUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n setValueChangedViaKeyboard(false);\n focusInput();\n state.setDragging(false);\n currentPointer.current = undefined;\n isOnColorArea.current = false;\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onThumbUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onThumbUp, false);\n removeGlobalListener(window, 'touchend', onThumbUp, false);\n }\n }\n };\n\n let onColorAreaDown = (\n colorArea: Element,\n id: number | null | undefined,\n clientX: number,\n clientY: number\n ) => {\n let rect = colorArea.getBoundingClientRect();\n let {width, height} = rect;\n let x = (clientX - rect.x) / width;\n let y = (clientY - rect.y) / height;\n if (direction === 'rtl') {\n x = 1 - x;\n }\n if (\n x >= 0 &&\n x <= 1 &&\n y >= 0 &&\n y <= 1 &&\n !state.isDragging &&\n currentPointer.current === undefined\n ) {\n isOnColorArea.current = true;\n setValueChangedViaKeyboard(false);\n currentPointer.current = id;\n state.setColorFromPoint(x, y);\n\n focusInput();\n state.setDragging(true);\n\n if (typeof PointerEvent !== 'undefined') {\n addGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n addGlobalListener(window, 'mouseup', onColorAreaUp, false);\n addGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let onColorAreaUp = e => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (isOnColorArea.current && id === currentPointer.current) {\n isOnColorArea.current = false;\n setValueChangedViaKeyboard(false);\n currentPointer.current = undefined;\n state.setDragging(false);\n focusInput();\n\n if (typeof PointerEvent !== 'undefined') {\n removeGlobalListener(window, 'pointerup', onColorAreaUp, false);\n } else {\n removeGlobalListener(window, 'mouseup', onColorAreaUp, false);\n removeGlobalListener(window, 'touchend', onColorAreaUp, false);\n }\n }\n };\n\n let colorAreaInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onColorAreaDown(\n e.currentTarget,\n e.changedTouches[0].identifier,\n e.changedTouches[0].clientX,\n e.changedTouches[0].clientY\n );\n }\n })\n },\n movePropsContainer\n );\n\n let thumbInteractions = isDisabled\n ? {}\n : mergeProps(\n {\n ...(typeof PointerEvent !== 'undefined'\n ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (\n e.pointerType === 'mouse' &&\n (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)\n ) {\n return;\n }\n onThumbDown(e.pointerId);\n }\n }\n : {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onThumbDown(undefined);\n },\n onTouchStart: (e: React.TouchEvent) => {\n onThumbDown(e.changedTouches[0].identifier);\n }\n })\n },\n focusWithinProps,\n keyboardProps,\n movePropsThumb\n );\n\n let {focusProps: xInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('x');\n }\n });\n\n let {focusProps: yInputFocusProps} = useFocus({\n onFocus: () => {\n setFocusedInput('y');\n }\n });\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const {target} = e;\n setValueChangedViaInputChangeEvent(true);\n if (target === inputXRef.current) {\n state.setXValue(parseFloat(target.value));\n } else if (target === inputYRef.current) {\n state.setYValue(parseFloat(target.value));\n }\n };\n\n let isMobile = isIOS() || isAndroid();\n\n let value = state.getDisplayColor();\n const getAriaValueTextForChannel = useCallback(\n (channel: ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput\n ? stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n })\n : [\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel, locale),\n value: value.formatChannelValue(channel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),\n value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)\n }),\n stringFormatter.format('colorNameAndValue', {\n name: value.getChannelName(zChannel, locale),\n value: value.formatChannelValue(zChannel, locale)\n })\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n },\n [\n locale,\n value,\n stringFormatter,\n valueChangedViaInputChangeEvent,\n valueChangedViaKeyboard,\n xChannel,\n yChannel,\n zChannel\n ]\n );\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel\n ? stringFormatter.format('colorInputLabel', {\n label: ariaLabel,\n channelLabel: colorPickerLabel\n })\n : colorPickerLabel\n });\n\n let colorAreaLabellingProps = useLabels(\n {\n ...props,\n 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined\n },\n isMobile ? colorPickerLabel : undefined\n );\n\n let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');\n\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }\n });\n\n let {colorAreaStyleProps, thumbStyleProps} = useColorAreaGradient({\n direction,\n state,\n xChannel,\n yChannel,\n zChannel\n });\n\n return {\n colorAreaProps: {\n ...colorAreaLabellingProps,\n ...colorAreaInteractions,\n ...colorAreaStyleProps,\n role: 'group'\n },\n thumbProps: {\n ...thumbInteractions,\n ...thumbStyleProps,\n role: 'presentation'\n },\n xInputProps: {\n ...xInputLabellingProps,\n ...visuallyHiddenProps,\n ...xInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(xChannel).minValue,\n max: state.value.getChannelRange(xChannel).maxValue,\n step: xChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(xChannel),\n 'aria-orientation': 'horizontal',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(xChannel),\n name: xName,\n form,\n tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused control when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard\n ? undefined\n : 'true',\n onChange\n },\n yInputProps: {\n ...yInputLabellingProps,\n ...visuallyHiddenProps,\n ...yInputFocusProps,\n type: 'range',\n min: state.value.getChannelRange(yChannel).minValue,\n max: state.value.getChannelRange(yChannel).maxValue,\n step: yChannelStep,\n 'aria-roledescription': ariaRoleDescription,\n 'aria-valuetext': getAriaValueTextForChannel(yChannel),\n 'aria-orientation': 'vertical',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details'],\n disabled: isDisabled,\n value: state.value.getChannelValue(yChannel),\n name: yName,\n form,\n tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,\n /*\n So that only a single \"2d slider\" control shows up when listing form elements for screen readers,\n add aria-hidden=\"true\" to the unfocused input when the value has not changed via the keyboard,\n but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.\n */\n 'aria-hidden':\n isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAoCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAChB,IAAO,OAAO,iBAAiB,WAAW,CAAA,GAAA,mCAAS,EAAE,gBAAgB,cACrE;QAAC;KAAa;IAEhB,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,mCAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,wCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,+BAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YACE,MAAM,eAAe,CAAC,aAAa,IAC/B,gBAAgB,MAAM,CAAC,iBACvB,MAAM,YAAY,CAAC;IAG3B,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/react-aria/src/color/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from 'react-stately/Color';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {HTMLAttributes, useMemo} from 'react';\nimport intlMessages from '../../intl/color/*.json';\nimport {parseColor} from 'react-stately/Color';\n// @ts-ignore\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color;\n /**\n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string;\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>;\n /** The parsed color value of the swatch. */\n color: Color;\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(\n () => (typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue),\n [nonNullValue]\n );\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName =\n color.getChannelValue('alpha') === 0\n ? stringFormatter.format('transparent')\n : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAChB,IAAO,OAAO,iBAAiB,WAAW,CAAA,GAAA,mCAAS,EAAE,gBAAgB,cACrE;QAAC;KAAa;IAEhB,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,mCAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,wCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,+BAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YACE,MAAM,eAAe,CAAC,aAAa,IAC/B,gBAAgB,MAAM,CAAC,iBACvB,MAAM,YAAY,CAAC;IAG3B,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/react-aria/src/color/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from 'react-stately/Color';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {HTMLAttributes, useMemo} from 'react';\nimport intlMessages from '../../intl/color/*.json';\nimport {parseColor} from 'react-stately/Color';\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color;\n /**\n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string;\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>;\n /** The parsed color value of the swatch. */\n color: Color;\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(\n () => (typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue),\n [nonNullValue]\n );\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName =\n color.getChannelValue('alpha') === 0\n ? stringFormatter.format('transparent')\n : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAoCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,cAAM,EAChB,IAAO,OAAO,iBAAiB,WAAW,CAAA,GAAA,iBAAS,EAAE,gBAAgB,cACrE;QAAC;KAAa;IAEhB,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YACE,MAAM,eAAe,CAAC,aAAa,IAC/B,gBAAgB,MAAM,CAAC,iBACvB,MAAM,YAAY,CAAC;IAG3B,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/react-aria/src/color/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from 'react-stately/Color';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {HTMLAttributes, useMemo} from 'react';\nimport intlMessages from '../../intl/color/*.json';\nimport {parseColor} from 'react-stately/Color';\n// @ts-ignore\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color;\n /**\n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string;\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>;\n /** The parsed color value of the swatch. */\n color: Color;\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(\n () => (typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue),\n [nonNullValue]\n );\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName =\n color.getChannelValue('alpha') === 0\n ? stringFormatter.format('transparent')\n : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,cAAM,EAChB,IAAO,OAAO,iBAAiB,WAAW,CAAA,GAAA,iBAAS,EAAE,gBAAgB,cACrE;QAAC;KAAa;IAEhB,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YACE,MAAM,eAAe,CAAC,aAAa,IAC/B,gBAAgB,MAAM,CAAC,iBACvB,MAAM,YAAY,CAAC;IAG3B,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/react-aria/src/color/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from 'react-stately/Color';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {HTMLAttributes, useMemo} from 'react';\nimport intlMessages from '../../intl/color/*.json';\nimport {parseColor} from 'react-stately/Color';\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color;\n /**\n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string;\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>;\n /** The parsed color value of the swatch. */\n color: Color;\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(\n () => (typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue),\n [nonNullValue]\n );\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName =\n color.getChannelValue('alpha') === 0\n ? stringFormatter.format('transparent')\n : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAoCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,cAAM,EAChB,IAAO,OAAO,iBAAiB,WAAW,CAAA,GAAA,iBAAS,EAAE,gBAAgB,cACrE;QAAC;KAAa;IAEhB,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YACE,MAAM,eAAe,CAAC,aAAa,IAC/B,gBAAgB,MAAM,CAAC,iBACvB,MAAM,YAAY,CAAC;IAG3B,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/react-aria/src/color/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from 'react-stately/Color';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {HTMLAttributes, useMemo} from 'react';\nimport intlMessages from '../../intl/color/*.json';\nimport {parseColor} from 'react-stately/Color';\n// @ts-ignore\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color;\n /**\n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string;\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>;\n /** The parsed color value of the swatch. */\n color: Color;\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(\n () => (typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue),\n [nonNullValue]\n );\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName =\n color.getChannelValue('alpha') === 0\n ? stringFormatter.format('transparent')\n : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmCM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,OAAO,KAAK,aAAE,SAAS,EAAC,GAAG;IAChC,IAAI,eAAe,SAAS;IAC5B,IAAI,QAAQ,CAAA,GAAA,cAAM,EAChB,IAAO,OAAO,iBAAiB,WAAW,CAAA,GAAA,iBAAS,EAAE,gBAAgB,cACrE;QAAC;KAAa;IAEhB,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IAEvB,IAAI,CAAC,WACH,YACE,MAAM,eAAe,CAAC,aAAa,IAC/B,gBAAgB,MAAM,CAAC,iBACvB,MAAM,YAAY,CAAC;IAG3B,OAAO;QACL,kBAAkB;YAChB,GAAG,QAAQ;YACX,MAAM;YACN,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;gBAAC;gBAAW,KAAK,CAAC,aAAa,IAAI;aAAG,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YAC1E,mBAAmB,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,CAAC,EAAE,KAAK,CAAC,kBAAkB,EAAE,GAAG;gBACpF;YACA,OAAO;gBACL,iBAAiB,MAAM,QAAQ,CAAC;gBAChC,aAAa;gBACb,mBAAmB;YACrB;QACF;QACA,OAAO,SAAS;IAClB;AACF","sources":["packages/react-aria/src/color/useColorSwatch.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps, DOMProps} from '@react-types/shared';\nimport {Color} from 'react-stately/Color';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {HTMLAttributes, useMemo} from 'react';\nimport intlMessages from '../../intl/color/*.json';\nimport {parseColor} from 'react-stately/Color';\nimport {useId} from '../utils/useId';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaColorSwatchProps extends AriaLabelingProps, DOMProps {\n /** The color value to display in the swatch. */\n color?: string | Color;\n /**\n * A localized accessible name for the color.\n * By default, a description is generated from the color value,\n * but this can be overridden if you have a more specific color\n * name (e.g. Pantone colors).\n */\n colorName?: string;\n}\n\nexport interface ColorSwatchAria {\n /** Props for the color swatch element. */\n colorSwatchProps: HTMLAttributes<HTMLElement>;\n /** The parsed color value of the swatch. */\n color: Color;\n}\n\n/**\n * Provides the accessibility implementation for a color swatch component.\n * A color swatch displays a preview of a selected color.\n */\nexport function useColorSwatch(props: AriaColorSwatchProps): ColorSwatchAria {\n let {color: value, colorName} = props;\n let nonNullValue = value || '#fff0';\n let color = useMemo(\n () => (typeof nonNullValue === 'string' ? parseColor(nonNullValue) : nonNullValue),\n [nonNullValue]\n );\n let {locale} = useLocale();\n let DOMProps = filterDOMProps(props, {labelable: true});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');\n let id = useId(props.id);\n\n if (!colorName) {\n colorName =\n color.getChannelValue('alpha') === 0\n ? stringFormatter.format('transparent')\n : color.getColorName(locale);\n }\n\n return {\n colorSwatchProps: {\n ...DOMProps,\n role: 'img',\n 'aria-roledescription': stringFormatter.format('colorSwatch'),\n 'aria-label': [colorName, props['aria-label'] || ''].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby'] ? `${id} ${props['aria-labelledby']}` : undefined,\n id,\n style: {\n backgroundColor: color.toString('css'),\n // @ts-ignore\n forcedColorAdjust: 'none'\n }\n },\n color: color || null\n };\n}\n"],"names":[],"version":3,"file":"useColorSwatch.mjs.map"}
@@ -134,6 +134,7 @@ function $9f4ec1506bb7618d$export$8c18d1b4f7232bbf(props, state) {
134
134
  }
135
135
  }
136
136
  if (e.key === 'Enter' || state.isOpen) state.commit();
137
+ if (e.key === 'Tab') e.continuePropagation();
137
138
  break;
138
139
  case 'Escape':
139
140
  if (!state.selectionManager.isEmpty || state.inputValue === '' || props.allowsCustomValue) e.continuePropagation();
@@ -335,6 +336,7 @@ function $9f4ec1506bb7618d$export$8c18d1b4f7232bbf(props, state) {
335
336
  spellCheck: 'false'
336
337
  }),
337
338
  listBoxProps: (0, $89b39774f3b79dbb$exports.mergeProps)(menuProps, listBoxProps, {
339
+ onAction: undefined,
338
340
  autoFocus: state.focusStrategy || true,
339
341
  shouldUseVirtualFocus: true,
340
342
  shouldSelectOnPressUp: true,