@react-aria/color 3.1.4 → 3.2.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 (227) hide show
  1. package/dist/import.mjs +6 -8
  2. package/dist/main.js +11 -13
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -8
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +10 -0
  7. package/package.json +15 -23
  8. package/src/index.ts +11 -13
  9. package/dist/ar-AE.main.js +0 -11
  10. package/dist/ar-AE.main.js.map +0 -1
  11. package/dist/ar-AE.mjs +0 -13
  12. package/dist/ar-AE.module.js +0 -13
  13. package/dist/ar-AE.module.js.map +0 -1
  14. package/dist/bg-BG.main.js +0 -11
  15. package/dist/bg-BG.main.js.map +0 -1
  16. package/dist/bg-BG.mjs +0 -13
  17. package/dist/bg-BG.module.js +0 -13
  18. package/dist/bg-BG.module.js.map +0 -1
  19. package/dist/cs-CZ.main.js +0 -11
  20. package/dist/cs-CZ.main.js.map +0 -1
  21. package/dist/cs-CZ.mjs +0 -13
  22. package/dist/cs-CZ.module.js +0 -13
  23. package/dist/cs-CZ.module.js.map +0 -1
  24. package/dist/da-DK.main.js +0 -11
  25. package/dist/da-DK.main.js.map +0 -1
  26. package/dist/da-DK.mjs +0 -13
  27. package/dist/da-DK.module.js +0 -13
  28. package/dist/da-DK.module.js.map +0 -1
  29. package/dist/de-DE.main.js +0 -11
  30. package/dist/de-DE.main.js.map +0 -1
  31. package/dist/de-DE.mjs +0 -13
  32. package/dist/de-DE.module.js +0 -13
  33. package/dist/de-DE.module.js.map +0 -1
  34. package/dist/el-GR.main.js +0 -11
  35. package/dist/el-GR.main.js.map +0 -1
  36. package/dist/el-GR.mjs +0 -13
  37. package/dist/el-GR.module.js +0 -13
  38. package/dist/el-GR.module.js.map +0 -1
  39. package/dist/en-US.main.js +0 -11
  40. package/dist/en-US.main.js.map +0 -1
  41. package/dist/en-US.mjs +0 -13
  42. package/dist/en-US.module.js +0 -13
  43. package/dist/en-US.module.js.map +0 -1
  44. package/dist/es-ES.main.js +0 -11
  45. package/dist/es-ES.main.js.map +0 -1
  46. package/dist/es-ES.mjs +0 -13
  47. package/dist/es-ES.module.js +0 -13
  48. package/dist/es-ES.module.js.map +0 -1
  49. package/dist/et-EE.main.js +0 -11
  50. package/dist/et-EE.main.js.map +0 -1
  51. package/dist/et-EE.mjs +0 -13
  52. package/dist/et-EE.module.js +0 -13
  53. package/dist/et-EE.module.js.map +0 -1
  54. package/dist/fi-FI.main.js +0 -11
  55. package/dist/fi-FI.main.js.map +0 -1
  56. package/dist/fi-FI.mjs +0 -13
  57. package/dist/fi-FI.module.js +0 -13
  58. package/dist/fi-FI.module.js.map +0 -1
  59. package/dist/fr-FR.main.js +0 -11
  60. package/dist/fr-FR.main.js.map +0 -1
  61. package/dist/fr-FR.mjs +0 -13
  62. package/dist/fr-FR.module.js +0 -13
  63. package/dist/fr-FR.module.js.map +0 -1
  64. package/dist/he-IL.main.js +0 -11
  65. package/dist/he-IL.main.js.map +0 -1
  66. package/dist/he-IL.mjs +0 -13
  67. package/dist/he-IL.module.js +0 -13
  68. package/dist/he-IL.module.js.map +0 -1
  69. package/dist/hr-HR.main.js +0 -11
  70. package/dist/hr-HR.main.js.map +0 -1
  71. package/dist/hr-HR.mjs +0 -13
  72. package/dist/hr-HR.module.js +0 -13
  73. package/dist/hr-HR.module.js.map +0 -1
  74. package/dist/hu-HU.main.js +0 -11
  75. package/dist/hu-HU.main.js.map +0 -1
  76. package/dist/hu-HU.mjs +0 -13
  77. package/dist/hu-HU.module.js +0 -13
  78. package/dist/hu-HU.module.js.map +0 -1
  79. package/dist/intlStrings.main.js +0 -108
  80. package/dist/intlStrings.main.js.map +0 -1
  81. package/dist/intlStrings.mjs +0 -110
  82. package/dist/intlStrings.module.js +0 -110
  83. package/dist/intlStrings.module.js.map +0 -1
  84. package/dist/it-IT.main.js +0 -11
  85. package/dist/it-IT.main.js.map +0 -1
  86. package/dist/it-IT.mjs +0 -13
  87. package/dist/it-IT.module.js +0 -13
  88. package/dist/it-IT.module.js.map +0 -1
  89. package/dist/ja-JP.main.js +0 -11
  90. package/dist/ja-JP.main.js.map +0 -1
  91. package/dist/ja-JP.mjs +0 -13
  92. package/dist/ja-JP.module.js +0 -13
  93. package/dist/ja-JP.module.js.map +0 -1
  94. package/dist/ko-KR.main.js +0 -11
  95. package/dist/ko-KR.main.js.map +0 -1
  96. package/dist/ko-KR.mjs +0 -13
  97. package/dist/ko-KR.module.js +0 -13
  98. package/dist/ko-KR.module.js.map +0 -1
  99. package/dist/lt-LT.main.js +0 -11
  100. package/dist/lt-LT.main.js.map +0 -1
  101. package/dist/lt-LT.mjs +0 -13
  102. package/dist/lt-LT.module.js +0 -13
  103. package/dist/lt-LT.module.js.map +0 -1
  104. package/dist/lv-LV.main.js +0 -11
  105. package/dist/lv-LV.main.js.map +0 -1
  106. package/dist/lv-LV.mjs +0 -13
  107. package/dist/lv-LV.module.js +0 -13
  108. package/dist/lv-LV.module.js.map +0 -1
  109. package/dist/nb-NO.main.js +0 -11
  110. package/dist/nb-NO.main.js.map +0 -1
  111. package/dist/nb-NO.mjs +0 -13
  112. package/dist/nb-NO.module.js +0 -13
  113. package/dist/nb-NO.module.js.map +0 -1
  114. package/dist/nl-NL.main.js +0 -11
  115. package/dist/nl-NL.main.js.map +0 -1
  116. package/dist/nl-NL.mjs +0 -13
  117. package/dist/nl-NL.module.js +0 -13
  118. package/dist/nl-NL.module.js.map +0 -1
  119. package/dist/pl-PL.main.js +0 -11
  120. package/dist/pl-PL.main.js.map +0 -1
  121. package/dist/pl-PL.mjs +0 -13
  122. package/dist/pl-PL.module.js +0 -13
  123. package/dist/pl-PL.module.js.map +0 -1
  124. package/dist/pt-BR.main.js +0 -11
  125. package/dist/pt-BR.main.js.map +0 -1
  126. package/dist/pt-BR.mjs +0 -13
  127. package/dist/pt-BR.module.js +0 -13
  128. package/dist/pt-BR.module.js.map +0 -1
  129. package/dist/pt-PT.main.js +0 -11
  130. package/dist/pt-PT.main.js.map +0 -1
  131. package/dist/pt-PT.mjs +0 -13
  132. package/dist/pt-PT.module.js +0 -13
  133. package/dist/pt-PT.module.js.map +0 -1
  134. package/dist/ro-RO.main.js +0 -11
  135. package/dist/ro-RO.main.js.map +0 -1
  136. package/dist/ro-RO.mjs +0 -13
  137. package/dist/ro-RO.module.js +0 -13
  138. package/dist/ro-RO.module.js.map +0 -1
  139. package/dist/ru-RU.main.js +0 -11
  140. package/dist/ru-RU.main.js.map +0 -1
  141. package/dist/ru-RU.mjs +0 -13
  142. package/dist/ru-RU.module.js +0 -13
  143. package/dist/ru-RU.module.js.map +0 -1
  144. package/dist/sk-SK.main.js +0 -11
  145. package/dist/sk-SK.main.js.map +0 -1
  146. package/dist/sk-SK.mjs +0 -13
  147. package/dist/sk-SK.module.js +0 -13
  148. package/dist/sk-SK.module.js.map +0 -1
  149. package/dist/sl-SI.main.js +0 -11
  150. package/dist/sl-SI.main.js.map +0 -1
  151. package/dist/sl-SI.mjs +0 -13
  152. package/dist/sl-SI.module.js +0 -13
  153. package/dist/sl-SI.module.js.map +0 -1
  154. package/dist/sr-SP.main.js +0 -11
  155. package/dist/sr-SP.main.js.map +0 -1
  156. package/dist/sr-SP.mjs +0 -13
  157. package/dist/sr-SP.module.js +0 -13
  158. package/dist/sr-SP.module.js.map +0 -1
  159. package/dist/sv-SE.main.js +0 -11
  160. package/dist/sv-SE.main.js.map +0 -1
  161. package/dist/sv-SE.mjs +0 -13
  162. package/dist/sv-SE.module.js +0 -13
  163. package/dist/sv-SE.module.js.map +0 -1
  164. package/dist/tr-TR.main.js +0 -11
  165. package/dist/tr-TR.main.js.map +0 -1
  166. package/dist/tr-TR.mjs +0 -13
  167. package/dist/tr-TR.module.js +0 -13
  168. package/dist/tr-TR.module.js.map +0 -1
  169. package/dist/types.d.ts +0 -119
  170. package/dist/types.d.ts.map +0 -1
  171. package/dist/uk-UA.main.js +0 -11
  172. package/dist/uk-UA.main.js.map +0 -1
  173. package/dist/uk-UA.mjs +0 -13
  174. package/dist/uk-UA.module.js +0 -13
  175. package/dist/uk-UA.module.js.map +0 -1
  176. package/dist/useColorArea.main.js +0 -400
  177. package/dist/useColorArea.main.js.map +0 -1
  178. package/dist/useColorArea.mjs +0 -395
  179. package/dist/useColorArea.module.js +0 -395
  180. package/dist/useColorArea.module.js.map +0 -1
  181. package/dist/useColorAreaGradient.main.js +0 -123
  182. package/dist/useColorAreaGradient.main.js.map +0 -1
  183. package/dist/useColorAreaGradient.mjs +0 -118
  184. package/dist/useColorAreaGradient.module.js +0 -118
  185. package/dist/useColorAreaGradient.module.js.map +0 -1
  186. package/dist/useColorChannelField.main.js +0 -36
  187. package/dist/useColorChannelField.main.js.map +0 -1
  188. package/dist/useColorChannelField.mjs +0 -31
  189. package/dist/useColorChannelField.module.js +0 -31
  190. package/dist/useColorChannelField.module.js.map +0 -1
  191. package/dist/useColorField.main.js +0 -101
  192. package/dist/useColorField.main.js.map +0 -1
  193. package/dist/useColorField.mjs +0 -96
  194. package/dist/useColorField.module.js +0 -96
  195. package/dist/useColorField.module.js.map +0 -1
  196. package/dist/useColorSlider.main.js +0 -133
  197. package/dist/useColorSlider.main.js.map +0 -1
  198. package/dist/useColorSlider.mjs +0 -128
  199. package/dist/useColorSlider.module.js +0 -128
  200. package/dist/useColorSlider.module.js.map +0 -1
  201. package/dist/useColorSwatch.main.js +0 -67
  202. package/dist/useColorSwatch.main.js.map +0 -1
  203. package/dist/useColorSwatch.mjs +0 -62
  204. package/dist/useColorSwatch.module.js +0 -62
  205. package/dist/useColorSwatch.module.js.map +0 -1
  206. package/dist/useColorWheel.main.js +0 -275
  207. package/dist/useColorWheel.main.js.map +0 -1
  208. package/dist/useColorWheel.mjs +0 -270
  209. package/dist/useColorWheel.module.js +0 -270
  210. package/dist/useColorWheel.module.js.map +0 -1
  211. package/dist/zh-CN.main.js +0 -11
  212. package/dist/zh-CN.main.js.map +0 -1
  213. package/dist/zh-CN.mjs +0 -13
  214. package/dist/zh-CN.module.js +0 -13
  215. package/dist/zh-CN.module.js.map +0 -1
  216. package/dist/zh-TW.main.js +0 -11
  217. package/dist/zh-TW.main.js.map +0 -1
  218. package/dist/zh-TW.mjs +0 -13
  219. package/dist/zh-TW.module.js +0 -13
  220. package/dist/zh-TW.module.js.map +0 -1
  221. package/src/useColorArea.ts +0 -467
  222. package/src/useColorAreaGradient.ts +0 -139
  223. package/src/useColorChannelField.ts +0 -36
  224. package/src/useColorField.ts +0 -142
  225. package/src/useColorSlider.ts +0 -151
  226. package/src/useColorSwatch.ts +0 -74
  227. package/src/useColorWheel.ts +0 -345
@@ -1,400 +0,0 @@
1
- var $4a33e168940636d5$exports = require("./intlStrings.main.js");
2
- var $99936ad0bf67c8c4$exports = require("./useColorAreaGradient.main.js");
3
- var $fZxfU$reactariautils = require("@react-aria/utils");
4
- var $fZxfU$react = require("react");
5
- var $fZxfU$reactariainteractions = require("@react-aria/interactions");
6
- var $fZxfU$reactariai18n = require("@react-aria/i18n");
7
- var $fZxfU$reactariavisuallyhidden = require("@react-aria/visually-hidden");
8
-
9
-
10
- function $parcel$interopDefault(a) {
11
- return a && a.__esModule ? a.default : a;
12
- }
13
-
14
- function $parcel$export(e, n, v, s) {
15
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
- }
17
-
18
- $parcel$export(module.exports, "useColorArea", () => $47925bd68062ac17$export$2f92a7a615a014f6);
19
- /*
20
- * Copyright 2020 Adobe. All rights reserved.
21
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License. You may obtain a copy
23
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
- *
25
- * Unless required by applicable law or agreed to in writing, software distributed under
26
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
- * OF ANY KIND, either express or implied. See the License for the specific language
28
- * governing permissions and limitations under the License.
29
- */
30
-
31
-
32
-
33
-
34
-
35
-
36
- function $47925bd68062ac17$export$2f92a7a615a014f6(props, state) {
37
- let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName, form: form } = props;
38
- let stringFormatter = (0, $fZxfU$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4a33e168940636d5$exports))), '@react-aria/color');
39
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $fZxfU$reactariautils.useGlobalListeners)();
40
- let { direction: direction, locale: locale } = (0, $fZxfU$reactariai18n.useLocale)();
41
- let [focusedInput, setFocusedInput] = (0, $fZxfU$react.useState)(null);
42
- let focusInput = (0, $fZxfU$react.useCallback)((inputRef = inputXRef)=>{
43
- if (inputRef.current) (0, $fZxfU$reactariautils.focusWithoutScrolling)(inputRef.current);
44
- }, [
45
- inputXRef
46
- ]);
47
- (0, $fZxfU$reactariautils.useFormReset)(inputXRef, state.defaultValue, state.setValue);
48
- let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $fZxfU$react.useState)(false);
49
- let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $fZxfU$react.useState)(false);
50
- let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
51
- let xChannelStep = state.xChannelStep;
52
- let yChannelStep = state.yChannelStep;
53
- let currentPosition = (0, $fZxfU$react.useRef)(null);
54
- let { keyboardProps: keyboardProps } = (0, $fZxfU$reactariainteractions.useKeyboard)({
55
- onKeyDown (e) {
56
- // these are the cases that useMove doesn't handle
57
- if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
58
- e.continuePropagation();
59
- return;
60
- }
61
- // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
62
- e.preventDefault();
63
- // remember to set this and unset it so that onChangeEnd is fired
64
- state.setDragging(true);
65
- setValueChangedViaKeyboard(true);
66
- let dir;
67
- switch(e.key){
68
- case 'PageUp':
69
- state.incrementY(state.yChannelPageStep);
70
- dir = 'y';
71
- break;
72
- case 'PageDown':
73
- state.decrementY(state.yChannelPageStep);
74
- dir = 'y';
75
- break;
76
- case 'Home':
77
- direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
78
- dir = 'x';
79
- break;
80
- case 'End':
81
- direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
82
- dir = 'x';
83
- break;
84
- }
85
- state.setDragging(false);
86
- if (dir) {
87
- let input = dir === 'x' ? inputXRef : inputYRef;
88
- focusInput(input);
89
- setFocusedInput(dir);
90
- }
91
- }
92
- });
93
- let moveHandler = {
94
- onMoveStart () {
95
- currentPosition.current = null;
96
- state.setDragging(true);
97
- },
98
- onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
99
- var _containerRef_current;
100
- let { incrementX: incrementX, decrementX: decrementX, incrementY: incrementY, decrementY: decrementY, xChannelPageStep: xChannelPageStep, xChannelStep: xChannelStep, yChannelPageStep: yChannelPageStep, yChannelStep: yChannelStep, getThumbPosition: getThumbPosition, setColorFromPoint: setColorFromPoint } = state;
101
- if (currentPosition.current == null) currentPosition.current = getThumbPosition();
102
- let { width: width, height: height } = ((_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect()) || {
103
- width: 0,
104
- height: 0
105
- };
106
- let valueChanged = deltaX !== 0 || deltaY !== 0;
107
- if (pointerType === 'keyboard') {
108
- let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
109
- let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
110
- if (deltaX > 0 && direction === 'ltr' || deltaX < 0 && direction === 'rtl') incrementX(deltaXValue);
111
- else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
112
- else if (deltaY > 0) decrementY(deltaYValue);
113
- else if (deltaY < 0) incrementY(deltaYValue);
114
- setValueChangedViaKeyboard(valueChanged);
115
- // set the focused input based on which axis has the greater delta
116
- focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';
117
- setFocusedInput(focusedInput);
118
- } else {
119
- currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width;
120
- currentPosition.current.y += deltaY / height;
121
- setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
122
- }
123
- },
124
- onMoveEnd () {
125
- isOnColorArea.current = false;
126
- state.setDragging(false);
127
- let input = focusedInput === 'x' ? inputXRef : inputYRef;
128
- focusInput(input);
129
- }
130
- };
131
- let { moveProps: movePropsThumb } = (0, $fZxfU$reactariainteractions.useMove)(moveHandler);
132
- let { focusWithinProps: focusWithinProps } = (0, $fZxfU$reactariainteractions.useFocusWithin)({
133
- onFocusWithinChange: (focusWithin)=>{
134
- if (!focusWithin) {
135
- setValueChangedViaKeyboard(false);
136
- setValueChangedViaInputChangeEvent(false);
137
- }
138
- }
139
- });
140
- let currentPointer = (0, $fZxfU$react.useRef)(undefined);
141
- let isOnColorArea = (0, $fZxfU$react.useRef)(false);
142
- let { moveProps: movePropsContainer } = (0, $fZxfU$reactariainteractions.useMove)({
143
- onMoveStart () {
144
- if (isOnColorArea.current) moveHandler.onMoveStart();
145
- },
146
- onMove (e) {
147
- if (isOnColorArea.current) moveHandler.onMove(e);
148
- },
149
- onMoveEnd () {
150
- if (isOnColorArea.current) moveHandler.onMoveEnd();
151
- }
152
- });
153
- let onThumbDown = (id)=>{
154
- if (!state.isDragging) {
155
- currentPointer.current = id;
156
- setValueChangedViaKeyboard(false);
157
- focusInput();
158
- state.setDragging(true);
159
- if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
160
- else {
161
- addGlobalListener(window, 'mouseup', onThumbUp, false);
162
- addGlobalListener(window, 'touchend', onThumbUp, false);
163
- }
164
- }
165
- };
166
- let onThumbUp = (e)=>{
167
- var _e_changedTouches;
168
- var _e_pointerId;
169
- let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
170
- if (id === currentPointer.current) {
171
- setValueChangedViaKeyboard(false);
172
- focusInput();
173
- state.setDragging(false);
174
- currentPointer.current = undefined;
175
- isOnColorArea.current = false;
176
- if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
177
- else {
178
- removeGlobalListener(window, 'mouseup', onThumbUp, false);
179
- removeGlobalListener(window, 'touchend', onThumbUp, false);
180
- }
181
- }
182
- };
183
- let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
184
- let rect = colorArea.getBoundingClientRect();
185
- let { width: width, height: height } = rect;
186
- let x = (clientX - rect.x) / width;
187
- let y = (clientY - rect.y) / height;
188
- if (direction === 'rtl') x = 1 - x;
189
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
190
- isOnColorArea.current = true;
191
- setValueChangedViaKeyboard(false);
192
- currentPointer.current = id;
193
- state.setColorFromPoint(x, y);
194
- focusInput();
195
- state.setDragging(true);
196
- if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onColorAreaUp, false);
197
- else {
198
- addGlobalListener(window, 'mouseup', onColorAreaUp, false);
199
- addGlobalListener(window, 'touchend', onColorAreaUp, false);
200
- }
201
- }
202
- };
203
- let onColorAreaUp = (e)=>{
204
- var _e_changedTouches;
205
- var _e_pointerId;
206
- let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
207
- if (isOnColorArea.current && id === currentPointer.current) {
208
- isOnColorArea.current = false;
209
- setValueChangedViaKeyboard(false);
210
- currentPointer.current = undefined;
211
- state.setDragging(false);
212
- focusInput();
213
- if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
214
- else {
215
- removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
216
- removeGlobalListener(window, 'touchend', onColorAreaUp, false);
217
- }
218
- }
219
- };
220
- let colorAreaInteractions = isDisabled ? {} : (0, $fZxfU$reactariautils.mergeProps)({
221
- ...typeof PointerEvent !== 'undefined' ? {
222
- onPointerDown: (e)=>{
223
- if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
224
- onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
225
- }
226
- } : {
227
- onMouseDown: (e)=>{
228
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
229
- onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
230
- },
231
- onTouchStart: (e)=>{
232
- onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
233
- }
234
- }
235
- }, movePropsContainer);
236
- let thumbInteractions = isDisabled ? {} : (0, $fZxfU$reactariautils.mergeProps)({
237
- ...typeof PointerEvent !== 'undefined' ? {
238
- onPointerDown: (e)=>{
239
- if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
240
- onThumbDown(e.pointerId);
241
- }
242
- } : {
243
- onMouseDown: (e)=>{
244
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
245
- onThumbDown(undefined);
246
- },
247
- onTouchStart: (e)=>{
248
- onThumbDown(e.changedTouches[0].identifier);
249
- }
250
- }
251
- }, focusWithinProps, keyboardProps, movePropsThumb);
252
- let { focusProps: xInputFocusProps } = (0, $fZxfU$reactariainteractions.useFocus)({
253
- onFocus: ()=>{
254
- setFocusedInput('x');
255
- }
256
- });
257
- let { focusProps: yInputFocusProps } = (0, $fZxfU$reactariainteractions.useFocus)({
258
- onFocus: ()=>{
259
- setFocusedInput('y');
260
- }
261
- });
262
- const onChange = (e)=>{
263
- const { target: target } = e;
264
- setValueChangedViaInputChangeEvent(true);
265
- if (target === inputXRef.current) state.setXValue(parseFloat(target.value));
266
- else if (target === inputYRef.current) state.setYValue(parseFloat(target.value));
267
- };
268
- let isMobile = (0, $fZxfU$reactariautils.isIOS)() || (0, $fZxfU$reactariautils.isAndroid)();
269
- let value = state.getDisplayColor();
270
- const getAriaValueTextForChannel = (0, $fZxfU$react.useCallback)((channel)=>{
271
- const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
272
- return `${isAfterInput ? stringFormatter.format('colorNameAndValue', {
273
- name: value.getChannelName(channel, locale),
274
- value: value.formatChannelValue(channel, locale)
275
- }) : [
276
- stringFormatter.format('colorNameAndValue', {
277
- name: value.getChannelName(channel, locale),
278
- value: value.formatChannelValue(channel, locale)
279
- }),
280
- stringFormatter.format('colorNameAndValue', {
281
- name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
282
- value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
283
- }),
284
- stringFormatter.format('colorNameAndValue', {
285
- name: value.getChannelName(zChannel, locale),
286
- value: value.formatChannelValue(zChannel, locale)
287
- })
288
- ].join(', ')}, ${value.getColorName(locale)}`;
289
- }, [
290
- locale,
291
- value,
292
- stringFormatter,
293
- valueChangedViaInputChangeEvent,
294
- valueChangedViaKeyboard,
295
- xChannel,
296
- yChannel,
297
- zChannel
298
- ]);
299
- let colorPickerLabel = stringFormatter.format('colorPicker');
300
- let xInputLabellingProps = (0, $fZxfU$reactariautils.useLabels)({
301
- ...props,
302
- 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
303
- label: ariaLabel,
304
- channelLabel: colorPickerLabel
305
- }) : colorPickerLabel
306
- });
307
- let yInputLabellingProps = (0, $fZxfU$reactariautils.useLabels)({
308
- ...props,
309
- 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
310
- label: ariaLabel,
311
- channelLabel: colorPickerLabel
312
- }) : colorPickerLabel
313
- });
314
- let colorAreaLabellingProps = (0, $fZxfU$reactariautils.useLabels)({
315
- ...props,
316
- 'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
317
- }, isMobile ? colorPickerLabel : undefined);
318
- let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');
319
- let { visuallyHiddenProps: visuallyHiddenProps } = (0, $fZxfU$reactariavisuallyhidden.useVisuallyHidden)({
320
- style: {
321
- opacity: '0.0001',
322
- width: '100%',
323
- height: '100%',
324
- pointerEvents: 'none'
325
- }
326
- });
327
- let { colorAreaStyleProps: colorAreaStyleProps, thumbStyleProps: thumbStyleProps } = (0, $99936ad0bf67c8c4$exports.useColorAreaGradient)({
328
- direction: direction,
329
- state: state,
330
- xChannel: xChannel,
331
- yChannel: yChannel,
332
- zChannel: zChannel
333
- });
334
- return {
335
- colorAreaProps: {
336
- ...colorAreaLabellingProps,
337
- ...colorAreaInteractions,
338
- ...colorAreaStyleProps,
339
- role: 'group'
340
- },
341
- thumbProps: {
342
- ...thumbInteractions,
343
- ...thumbStyleProps,
344
- role: 'presentation'
345
- },
346
- xInputProps: {
347
- ...xInputLabellingProps,
348
- ...visuallyHiddenProps,
349
- ...xInputFocusProps,
350
- type: 'range',
351
- min: state.value.getChannelRange(xChannel).minValue,
352
- max: state.value.getChannelRange(xChannel).maxValue,
353
- step: xChannelStep,
354
- 'aria-roledescription': ariaRoleDescription,
355
- 'aria-valuetext': getAriaValueTextForChannel(xChannel),
356
- 'aria-orientation': 'horizontal',
357
- 'aria-describedby': props['aria-describedby'],
358
- 'aria-details': props['aria-details'],
359
- disabled: isDisabled,
360
- value: state.value.getChannelValue(xChannel),
361
- name: xName,
362
- form: form,
363
- tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
364
- /*
365
- So that only a single "2d slider" control shows up when listing form elements for screen readers,
366
- add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
367
- but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
368
- */ 'aria-hidden': isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true',
369
- onChange: onChange
370
- },
371
- yInputProps: {
372
- ...yInputLabellingProps,
373
- ...visuallyHiddenProps,
374
- ...yInputFocusProps,
375
- type: 'range',
376
- min: state.value.getChannelRange(yChannel).minValue,
377
- max: state.value.getChannelRange(yChannel).maxValue,
378
- step: yChannelStep,
379
- 'aria-roledescription': ariaRoleDescription,
380
- 'aria-valuetext': getAriaValueTextForChannel(yChannel),
381
- 'aria-orientation': 'vertical',
382
- 'aria-describedby': props['aria-describedby'],
383
- 'aria-details': props['aria-details'],
384
- disabled: isDisabled,
385
- value: state.value.getChannelValue(yChannel),
386
- name: yName,
387
- form: form,
388
- tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
389
- /*
390
- So that only a single "2d slider" control shows up when listing form elements for screen readers,
391
- add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
392
- but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
393
- */ 'aria-hidden': isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',
394
- onChange: onChange
395
- }
396
- };
397
- }
398
-
399
-
400
- //# sourceMappingURL=useColorArea.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsCM,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,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,aAAC,SAAS,UAAE,MAAM,EAAC,GAAG,CAAA,GAAA,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GAAG,mBAAmB;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,UAAW,YAAY,CAAC,gBAAgB,iBAAiB,MAAM,YAAY;YAC3E;;;;MAIA,GACA,eAAgB,YAAY,CAAC,gBAAgB,iBAAiB,OAAO,0BAA0B,YAAY;sBAC3G;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,UAAW,YAAY,iBAAiB,MAAM,YAAY;YAC1D;;;;MAIA,GACA,eAAgB,YAAY,iBAAiB,OAAO,0BAA0B,YAAY;sBAC1F;QACF;IACF;AACF","sources":["packages/@react-aria/color/src/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 {AriaColorAreaProps, ColorChannel} from '@react-types/color';\nimport {ColorAreaState} from '@react-stately/color';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';\nimport {useColorAreaGradient} from './useColorAreaGradient';\nimport {useFocus, useFocusWithin, useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\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.\n * Color area allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional 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((inputRef:RefObject<HTMLInputElement | null> = inputXRef) => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputXRef]);\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' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);\n dir = 'x';\n break;\n case 'End':\n direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : 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 = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;\n let deltaYValue = 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 = (colorArea: Element, id: number | null | undefined, clientX: number, clientY: number) => {\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 (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {\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 ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);\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(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n }\n })\n }, movePropsContainer);\n\n let thumbInteractions = isDisabled ? {} : mergeProps({\n ...(typeof PointerEvent !== 'undefined' ? {\n onPointerDown: (e: React.PointerEvent) => {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onThumbDown(e.pointerId);\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 }, focusWithinProps, keyboardProps, movePropsThumb);\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((channel:ColorChannel) => {\n const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;\n return `${\n isAfterInput ?\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)})\n :\n [\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale), value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)}),\n stringFormatter.format('colorNameAndValue', {name: value.getChannelName(zChannel, locale), value: value.formatChannelValue(zChannel, locale)})\n ].join(', ')\n }, ${value.getColorName(locale)}`;\n }, [locale, value, stringFormatter, valueChangedViaInputChangeEvent, valueChangedViaKeyboard, xChannel, yChannel, zChannel]);\n\n let colorPickerLabel = stringFormatter.format('colorPicker');\n\n let xInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel\n });\n\n let yInputLabellingProps = useLabels({\n ...props,\n 'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : 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({style: {\n opacity: '0.0001',\n width: '100%',\n height: '100%',\n pointerEvents: 'none'\n }});\n\n let {\n colorAreaStyleProps,\n thumbStyleProps\n } = 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': (isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : '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': (isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true'),\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useColorArea.main.js.map"}