@react-aria/color 3.0.0-nightly.4552 → 3.0.0-nightly.4558

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 (70) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +4 -1144
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +8 -1148
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +4 -1144
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/uk-UA.mjs +1 -1
  43. package/dist/useColorArea.main.js +404 -0
  44. package/dist/useColorArea.main.js.map +1 -0
  45. package/dist/useColorArea.mjs +399 -0
  46. package/dist/useColorArea.module.js +399 -0
  47. package/dist/useColorArea.module.js.map +1 -0
  48. package/dist/useColorAreaGradient.main.js +229 -0
  49. package/dist/useColorAreaGradient.main.js.map +1 -0
  50. package/dist/useColorAreaGradient.mjs +224 -0
  51. package/dist/useColorAreaGradient.module.js +224 -0
  52. package/dist/useColorAreaGradient.module.js.map +1 -0
  53. package/dist/useColorField.main.js +97 -0
  54. package/dist/useColorField.main.js.map +1 -0
  55. package/dist/useColorField.mjs +92 -0
  56. package/dist/useColorField.module.js +92 -0
  57. package/dist/useColorField.module.js.map +1 -0
  58. package/dist/useColorSlider.main.js +105 -0
  59. package/dist/useColorSlider.main.js.map +1 -0
  60. package/dist/useColorSlider.mjs +100 -0
  61. package/dist/useColorSlider.module.js +100 -0
  62. package/dist/useColorSlider.module.js.map +1 -0
  63. package/dist/useColorWheel.main.js +260 -0
  64. package/dist/useColorWheel.main.js.map +1 -0
  65. package/dist/useColorWheel.mjs +255 -0
  66. package/dist/useColorWheel.module.js +255 -0
  67. package/dist/useColorWheel.module.js.map +1 -0
  68. package/dist/zh-CN.mjs +1 -1
  69. package/dist/zh-TW.mjs +1 -1
  70. package/package.json +13 -13
package/dist/module.js CHANGED
@@ -1,62 +1,9 @@
1
- import $eccab2b0118aef08$exports from "./ar-AE.module.js";
2
- import $bf2b4507594e3d45$exports from "./bg-BG.module.js";
3
- import $01c08487af7ecd14$exports from "./cs-CZ.module.js";
4
- import $5e997db6ea0d10f6$exports from "./da-DK.module.js";
5
- import $fe5998f640a79fd2$exports from "./de-DE.module.js";
6
- import $18e4d1d5b500a9ee$exports from "./el-GR.module.js";
7
- import $bf90a11a7a42a0f7$exports from "./en-US.module.js";
8
- import $dd0d25f885b5c5f3$exports from "./es-ES.module.js";
9
- import $d950967017e3485b$exports from "./et-EE.module.js";
10
- import $00a415a3f0ab315a$exports from "./fi-FI.module.js";
11
- import $d80f30fe86c95741$exports from "./fr-FR.module.js";
12
- import $6912afb584340a2e$exports from "./he-IL.module.js";
13
- import $7b97fcacd84ec90f$exports from "./hr-HR.module.js";
14
- import $da9b443e89eebc6b$exports from "./hu-HU.module.js";
15
- import $35f135b45eb4d95b$exports from "./it-IT.module.js";
16
- import $760b09448e39c6cd$exports from "./ja-JP.module.js";
17
- import $fc7b7d43be9703ec$exports from "./ko-KR.module.js";
18
- import $74918a1664156912$exports from "./lt-LT.module.js";
19
- import $4e6cde11c2bc9840$exports from "./lv-LV.module.js";
20
- import $6faa3defebc3eb72$exports from "./nb-NO.module.js";
21
- import $6ac9b6b1b7e3ca12$exports from "./nl-NL.module.js";
22
- import $1be8b0ee8841f1e7$exports from "./pl-PL.module.js";
23
- import $f9507c2d404ed689$exports from "./pt-BR.module.js";
24
- import $8f872ea59c02d67e$exports from "./pt-PT.module.js";
25
- import $b03b45b62a7ccae4$exports from "./ro-RO.module.js";
26
- import $f1107d94c09df9b8$exports from "./ru-RU.module.js";
27
- import $b61325f242fafc7c$exports from "./sk-SK.module.js";
28
- import $f44b7cf39ac8f315$exports from "./sl-SI.module.js";
29
- import $aa8cd83fc8d4982b$exports from "./sr-SP.module.js";
30
- import $7c4f4e5bb7c06f1e$exports from "./sv-SE.module.js";
31
- import $8045cf930ef745aa$exports from "./tr-TR.module.js";
32
- import $ee2044a77f24b118$exports from "./uk-UA.module.js";
33
- import $4e1dbc65a687dd93$exports from "./zh-CN.module.js";
34
- import $b0fef28529309aa6$exports from "./zh-TW.module.js";
35
- import {useGlobalListeners as $7KHxM$useGlobalListeners, focusWithoutScrolling as $7KHxM$focusWithoutScrolling, useFormReset as $7KHxM$useFormReset, mergeProps as $7KHxM$mergeProps, isIOS as $7KHxM$isIOS, isAndroid as $7KHxM$isAndroid, useLabels as $7KHxM$useLabels, useId as $7KHxM$useId} from "@react-aria/utils";
36
- import {useState as $7KHxM$useState, useCallback as $7KHxM$useCallback, useRef as $7KHxM$useRef, useMemo as $7KHxM$useMemo} from "react";
37
- import {useKeyboard as $7KHxM$useKeyboard, useMove as $7KHxM$useMove, useFocusWithin as $7KHxM$useFocusWithin, useFocus as $7KHxM$useFocus, useScrollWheel as $7KHxM$useScrollWheel} from "@react-aria/interactions";
38
- import {useLocalizedStringFormatter as $7KHxM$useLocalizedStringFormatter, useLocale as $7KHxM$useLocale} from "@react-aria/i18n";
39
- import {useVisuallyHidden as $7KHxM$useVisuallyHidden} from "@react-aria/visually-hidden";
40
- import {useSlider as $7KHxM$useSlider, useSliderThumb as $7KHxM$useSliderThumb} from "@react-aria/slider";
41
- import {privateValidationStateProp as $7KHxM$privateValidationStateProp} from "@react-stately/form";
42
- import {useFormattedTextField as $7KHxM$useFormattedTextField} from "@react-aria/textfield";
43
- import {useSpinButton as $7KHxM$useSpinButton} from "@react-aria/spinbutton";
1
+ import {useColorArea as $60bd7d6e45dcddfa$export$2f92a7a615a014f6} from "./useColorArea.module.js";
2
+ import {useColorSlider as $40af666d6c251e36$export$106b7a4e66508f66} from "./useColorSlider.module.js";
3
+ import {useColorWheel as $b4a0a4fdc900495e$export$9064ff4e44b3729a} from "./useColorWheel.module.js";
4
+ import {useColorField as $f6896b05b2ecad12$export$77e32ca575a28fdf} from "./useColorField.module.js";
44
5
 
45
-
46
- function $parcel$interopDefault(a) {
47
- return a && a.__esModule ? a.default : a;
48
- }
49
6
  /*
50
- * Copyright 2020 Adobe. All rights reserved.
51
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
52
- * you may not use this file except in compliance with the License. You may obtain a copy
53
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
54
- *
55
- * Unless required by applicable law or agreed to in writing, software distributed under
56
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
57
- * OF ANY KIND, either express or implied. See the License for the specific language
58
- * governing permissions and limitations under the License.
59
- */ /*
60
7
  * Copyright 2020 Adobe. All rights reserved.
61
8
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
62
9
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -67,1094 +14,7 @@ function $parcel$interopDefault(a) {
67
14
  * OF ANY KIND, either express or implied. See the License for the specific language
68
15
  * governing permissions and limitations under the License.
69
16
  */
70
- var $3493a52097159720$exports = {};
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
- $3493a52097159720$exports = {
106
- "ar-AE": $eccab2b0118aef08$exports,
107
- "bg-BG": $bf2b4507594e3d45$exports,
108
- "cs-CZ": $01c08487af7ecd14$exports,
109
- "da-DK": $5e997db6ea0d10f6$exports,
110
- "de-DE": $fe5998f640a79fd2$exports,
111
- "el-GR": $18e4d1d5b500a9ee$exports,
112
- "en-US": $bf90a11a7a42a0f7$exports,
113
- "es-ES": $dd0d25f885b5c5f3$exports,
114
- "et-EE": $d950967017e3485b$exports,
115
- "fi-FI": $00a415a3f0ab315a$exports,
116
- "fr-FR": $d80f30fe86c95741$exports,
117
- "he-IL": $6912afb584340a2e$exports,
118
- "hr-HR": $7b97fcacd84ec90f$exports,
119
- "hu-HU": $da9b443e89eebc6b$exports,
120
- "it-IT": $35f135b45eb4d95b$exports,
121
- "ja-JP": $760b09448e39c6cd$exports,
122
- "ko-KR": $fc7b7d43be9703ec$exports,
123
- "lt-LT": $74918a1664156912$exports,
124
- "lv-LV": $4e6cde11c2bc9840$exports,
125
- "nb-NO": $6faa3defebc3eb72$exports,
126
- "nl-NL": $6ac9b6b1b7e3ca12$exports,
127
- "pl-PL": $1be8b0ee8841f1e7$exports,
128
- "pt-BR": $f9507c2d404ed689$exports,
129
- "pt-PT": $8f872ea59c02d67e$exports,
130
- "ro-RO": $b03b45b62a7ccae4$exports,
131
- "ru-RU": $f1107d94c09df9b8$exports,
132
- "sk-SK": $b61325f242fafc7c$exports,
133
- "sl-SI": $f44b7cf39ac8f315$exports,
134
- "sr-SP": $aa8cd83fc8d4982b$exports,
135
- "sv-SE": $7c4f4e5bb7c06f1e$exports,
136
- "tr-TR": $8045cf930ef745aa$exports,
137
- "uk-UA": $ee2044a77f24b118$exports,
138
- "zh-CN": $4e1dbc65a687dd93$exports,
139
- "zh-TW": $b0fef28529309aa6$exports
140
- };
141
-
142
-
143
-
144
- /*
145
- * Copyright 2022 Adobe. All rights reserved.
146
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
147
- * you may not use this file except in compliance with the License. You may obtain a copy
148
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
149
- *
150
- * Unless required by applicable law or agreed to in writing, software distributed under
151
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
152
- * OF ANY KIND, either express or implied. See the License for the specific language
153
- * governing permissions and limitations under the License.
154
- */
155
- const $40297c24c53588e6$var$generateRGB_R = (orientation, dir, zValue)=>{
156
- let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
157
- let result = {
158
- colorAreaStyles: {
159
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
160
- },
161
- gradientStyles: {
162
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
163
- "WebkitMaskImage": maskImage,
164
- maskImage: maskImage
165
- }
166
- };
167
- return result;
168
- };
169
- const $40297c24c53588e6$var$generateRGB_G = (orientation, dir, zValue)=>{
170
- let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
171
- let result = {
172
- colorAreaStyles: {
173
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
174
- },
175
- gradientStyles: {
176
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
177
- "WebkitMaskImage": maskImage,
178
- maskImage: maskImage
179
- }
180
- };
181
- return result;
182
- };
183
- const $40297c24c53588e6$var$generateRGB_B = (orientation, dir, zValue)=>{
184
- let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
185
- let result = {
186
- colorAreaStyles: {
187
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
188
- },
189
- gradientStyles: {
190
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
191
- "WebkitMaskImage": maskImage,
192
- maskImage: maskImage
193
- }
194
- };
195
- return result;
196
- };
197
- const $40297c24c53588e6$var$generateHSL_H = (orientation, dir, zValue)=>{
198
- let result = {
199
- colorAreaStyles: {},
200
- gradientStyles: {
201
- background: [
202
- `linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
203
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
204
- `hsl(${zValue}, 100%, 50%)`
205
- ].join(",")
206
- }
207
- };
208
- return result;
209
- };
210
- const $40297c24c53588e6$var$generateHSL_S = (orientation, dir, alphaValue)=>{
211
- let result = {
212
- colorAreaStyles: {},
213
- gradientStyles: {
214
- background: [
215
- `linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
216
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
217
- "hsl(0, 0%, 50%)"
218
- ].join(",")
219
- }
220
- };
221
- return result;
222
- };
223
- const $40297c24c53588e6$var$generateHSL_L = (orientation, dir, zValue)=>{
224
- let result = {
225
- colorAreaStyles: {},
226
- gradientStyles: {
227
- backgroundImage: [
228
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
229
- `linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
230
- ].join(",")
231
- }
232
- };
233
- return result;
234
- };
235
- const $40297c24c53588e6$var$generateHSB_H = (orientation, dir, zValue)=>{
236
- let result = {
237
- colorAreaStyles: {},
238
- gradientStyles: {
239
- background: [
240
- `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
241
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
242
- `hsl(${zValue}, 100%, 50%)`
243
- ].join(",")
244
- }
245
- };
246
- return result;
247
- };
248
- const $40297c24c53588e6$var$generateHSB_S = (orientation, dir, alphaValue)=>{
249
- let result = {
250
- colorAreaStyles: {},
251
- gradientStyles: {
252
- background: [
253
- `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
254
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
255
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
256
- ].join(",")
257
- }
258
- };
259
- return result;
260
- };
261
- const $40297c24c53588e6$var$generateHSB_B = (orientation, dir, alphaValue)=>{
262
- let result = {
263
- colorAreaStyles: {},
264
- gradientStyles: {
265
- background: [
266
- `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
267
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
268
- "#000"
269
- ].join(",")
270
- }
271
- };
272
- return result;
273
- };
274
- function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, isDisabled: isDisabled }) {
275
- let returnVal = (0, $7KHxM$useMemo)(()=>{
276
- let orientation = [
277
- "top",
278
- direction === "rtl" ? "left" : "right"
279
- ];
280
- let dir = false;
281
- let background = {
282
- colorAreaStyles: {},
283
- gradientStyles: {}
284
- };
285
- let zValue = state.value.getChannelValue(zChannel);
286
- let { minValue: zMin, maxValue: zMax } = state.value.getChannelRange(zChannel);
287
- let alphaValue = (zValue - zMin) / (zMax - zMin);
288
- let isHSL = state.value.getColorSpace() === "hsl";
289
- if (!isDisabled) switch(zChannel){
290
- case "red":
291
- dir = xChannel === "green";
292
- background = $40297c24c53588e6$var$generateRGB_R(orientation, dir, zValue);
293
- break;
294
- case "green":
295
- dir = xChannel === "red";
296
- background = $40297c24c53588e6$var$generateRGB_G(orientation, dir, zValue);
297
- break;
298
- case "blue":
299
- dir = xChannel === "red";
300
- background = $40297c24c53588e6$var$generateRGB_B(orientation, dir, zValue);
301
- break;
302
- case "hue":
303
- dir = xChannel !== "saturation";
304
- if (isHSL) background = $40297c24c53588e6$var$generateHSL_H(orientation, dir, zValue);
305
- else background = $40297c24c53588e6$var$generateHSB_H(orientation, dir, zValue);
306
- break;
307
- case "saturation":
308
- dir = xChannel === "hue";
309
- if (isHSL) background = $40297c24c53588e6$var$generateHSL_S(orientation, dir, alphaValue);
310
- else background = $40297c24c53588e6$var$generateHSB_S(orientation, dir, alphaValue);
311
- break;
312
- case "brightness":
313
- dir = xChannel === "hue";
314
- background = $40297c24c53588e6$var$generateHSB_B(orientation, dir, alphaValue);
315
- break;
316
- case "lightness":
317
- dir = xChannel === "hue";
318
- background = $40297c24c53588e6$var$generateHSL_L(orientation, dir, zValue);
319
- break;
320
- }
321
- let { x: x, y: y } = state.getThumbPosition();
322
- if (direction === "rtl") x = 1 - x;
323
- let forcedColorAdjustNoneStyle = {
324
- forcedColorAdjust: "none"
325
- };
326
- return {
327
- colorAreaStyleProps: {
328
- style: {
329
- position: "relative",
330
- touchAction: "none",
331
- ...forcedColorAdjustNoneStyle,
332
- ...background.colorAreaStyles
333
- }
334
- },
335
- gradientStyleProps: {
336
- style: {
337
- touchAction: "none",
338
- ...forcedColorAdjustNoneStyle,
339
- ...background.gradientStyles
340
- }
341
- },
342
- thumbStyleProps: {
343
- style: {
344
- position: "absolute",
345
- left: `${x * 100}%`,
346
- top: `${y * 100}%`,
347
- transform: "translate(0%, 0%)",
348
- touchAction: "none",
349
- ...forcedColorAdjustNoneStyle
350
- }
351
- }
352
- };
353
- }, [
354
- direction,
355
- state,
356
- zChannel,
357
- xChannel,
358
- isDisabled
359
- ]);
360
- return returnVal;
361
- }
362
-
363
-
364
-
365
-
366
-
367
- function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
368
- let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, "aria-label": ariaLabel, xName: xName, yName: yName } = props;
369
- let stringFormatter = (0, $7KHxM$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3493a52097159720$exports))), "@react-aria/color");
370
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $7KHxM$useGlobalListeners)();
371
- let { direction: direction, locale: locale } = (0, $7KHxM$useLocale)();
372
- let [focusedInput, setFocusedInput] = (0, $7KHxM$useState)(null);
373
- let focusInput = (0, $7KHxM$useCallback)((inputRef = inputXRef)=>{
374
- if (inputRef.current) (0, $7KHxM$focusWithoutScrolling)(inputRef.current);
375
- }, [
376
- inputXRef
377
- ]);
378
- (0, $7KHxM$useFormReset)(inputXRef, [
379
- state.xValue,
380
- state.yValue
381
- ], ([x, y])=>{
382
- let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
383
- state.setValue(newColor);
384
- });
385
- let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $7KHxM$useState)(false);
386
- let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $7KHxM$useState)(false);
387
- let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
388
- let xChannelStep = state.xChannelStep;
389
- let yChannelStep = state.yChannelStep;
390
- let currentPosition = (0, $7KHxM$useRef)(null);
391
- let { keyboardProps: keyboardProps } = (0, $7KHxM$useKeyboard)({
392
- onKeyDown (e) {
393
- // these are the cases that useMove doesn't handle
394
- if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
395
- e.continuePropagation();
396
- return;
397
- }
398
- // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
399
- e.preventDefault();
400
- // remember to set this and unset it so that onChangeEnd is fired
401
- state.setDragging(true);
402
- setValueChangedViaKeyboard(true);
403
- let dir;
404
- switch(e.key){
405
- case "PageUp":
406
- state.incrementY(state.yChannelPageStep);
407
- dir = "y";
408
- break;
409
- case "PageDown":
410
- state.decrementY(state.yChannelPageStep);
411
- dir = "y";
412
- break;
413
- case "Home":
414
- direction === "rtl" ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
415
- dir = "x";
416
- break;
417
- case "End":
418
- direction === "rtl" ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
419
- dir = "x";
420
- break;
421
- }
422
- state.setDragging(false);
423
- if (dir) {
424
- let input = dir === "x" ? inputXRef : inputYRef;
425
- focusInput(input);
426
- setFocusedInput(dir);
427
- }
428
- }
429
- });
430
- let moveHandler = {
431
- onMoveStart () {
432
- currentPosition.current = null;
433
- state.setDragging(true);
434
- },
435
- onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
436
- var _containerRef_current;
437
- let { incrementX: incrementX, decrementX: decrementX, incrementY: incrementY, decrementY: decrementY, xChannelPageStep: xChannelPageStep, xChannelStep: xChannelStep, yChannelPageStep: yChannelPageStep, yChannelStep: yChannelStep, getThumbPosition: getThumbPosition, setColorFromPoint: setColorFromPoint } = state;
438
- if (currentPosition.current == null) currentPosition.current = getThumbPosition();
439
- let { width: width, height: height } = ((_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect()) || {
440
- width: 0,
441
- height: 0
442
- };
443
- let valueChanged = deltaX !== 0 || deltaY !== 0;
444
- if (pointerType === "keyboard") {
445
- let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
446
- let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
447
- if (deltaX > 0 && direction === "ltr" || deltaX < 0 && direction === "rtl") incrementX(deltaXValue);
448
- else if (deltaX < 0 && direction === "ltr" || deltaX > 0 && direction === "rtl") decrementX(deltaXValue);
449
- else if (deltaY > 0) decrementY(deltaYValue);
450
- else if (deltaY < 0) incrementY(deltaYValue);
451
- setValueChangedViaKeyboard(valueChanged);
452
- // set the focused input based on which axis has the greater delta
453
- focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? "y" : "x";
454
- setFocusedInput(focusedInput);
455
- } else {
456
- currentPosition.current.x += (direction === "rtl" ? -1 : 1) * deltaX / width;
457
- currentPosition.current.y += deltaY / height;
458
- setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
459
- }
460
- },
461
- onMoveEnd () {
462
- isOnColorArea.current = false;
463
- state.setDragging(false);
464
- let input = focusedInput === "x" ? inputXRef : inputYRef;
465
- focusInput(input);
466
- }
467
- };
468
- let { moveProps: movePropsThumb } = (0, $7KHxM$useMove)(moveHandler);
469
- let { focusWithinProps: focusWithinProps } = (0, $7KHxM$useFocusWithin)({
470
- onFocusWithinChange: (focusWithin)=>{
471
- if (!focusWithin) {
472
- setValueChangedViaKeyboard(false);
473
- setValueChangedViaInputChangeEvent(false);
474
- }
475
- }
476
- });
477
- let currentPointer = (0, $7KHxM$useRef)(undefined);
478
- let isOnColorArea = (0, $7KHxM$useRef)(false);
479
- let { moveProps: movePropsContainer } = (0, $7KHxM$useMove)({
480
- onMoveStart () {
481
- if (isOnColorArea.current) moveHandler.onMoveStart();
482
- },
483
- onMove (e) {
484
- if (isOnColorArea.current) moveHandler.onMove(e);
485
- },
486
- onMoveEnd () {
487
- if (isOnColorArea.current) moveHandler.onMoveEnd();
488
- }
489
- });
490
- let onThumbDown = (id)=>{
491
- if (!state.isDragging) {
492
- currentPointer.current = id;
493
- setValueChangedViaKeyboard(false);
494
- focusInput();
495
- state.setDragging(true);
496
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
497
- else {
498
- addGlobalListener(window, "mouseup", onThumbUp, false);
499
- addGlobalListener(window, "touchend", onThumbUp, false);
500
- }
501
- }
502
- };
503
- let onThumbUp = (e)=>{
504
- var _e_changedTouches;
505
- var _e_pointerId;
506
- 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;
507
- if (id === currentPointer.current) {
508
- setValueChangedViaKeyboard(false);
509
- focusInput();
510
- state.setDragging(false);
511
- currentPointer.current = undefined;
512
- isOnColorArea.current = false;
513
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
514
- else {
515
- removeGlobalListener(window, "mouseup", onThumbUp, false);
516
- removeGlobalListener(window, "touchend", onThumbUp, false);
517
- }
518
- }
519
- };
520
- let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
521
- let rect = colorArea.getBoundingClientRect();
522
- let { width: width, height: height } = rect;
523
- let x = (clientX - rect.x) / width;
524
- let y = (clientY - rect.y) / height;
525
- if (direction === "rtl") x = 1 - x;
526
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
527
- isOnColorArea.current = true;
528
- setValueChangedViaKeyboard(false);
529
- currentPointer.current = id;
530
- state.setColorFromPoint(x, y);
531
- focusInput();
532
- state.setDragging(true);
533
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onColorAreaUp, false);
534
- else {
535
- addGlobalListener(window, "mouseup", onColorAreaUp, false);
536
- addGlobalListener(window, "touchend", onColorAreaUp, false);
537
- }
538
- }
539
- };
540
- let onColorAreaUp = (e)=>{
541
- var _e_changedTouches;
542
- var _e_pointerId;
543
- 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;
544
- if (isOnColorArea.current && id === currentPointer.current) {
545
- isOnColorArea.current = false;
546
- setValueChangedViaKeyboard(false);
547
- currentPointer.current = undefined;
548
- state.setDragging(false);
549
- focusInput();
550
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onColorAreaUp, false);
551
- else {
552
- removeGlobalListener(window, "mouseup", onColorAreaUp, false);
553
- removeGlobalListener(window, "touchend", onColorAreaUp, false);
554
- }
555
- }
556
- };
557
- let colorAreaInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
558
- ...typeof PointerEvent !== "undefined" ? {
559
- onPointerDown: (e)=>{
560
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
561
- onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
562
- }
563
- } : {
564
- onMouseDown: (e)=>{
565
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
566
- onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
567
- },
568
- onTouchStart: (e)=>{
569
- onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
570
- }
571
- }
572
- }, movePropsContainer);
573
- let thumbInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
574
- ...typeof PointerEvent !== "undefined" ? {
575
- onPointerDown: (e)=>{
576
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
577
- onThumbDown(e.pointerId);
578
- }
579
- } : {
580
- onMouseDown: (e)=>{
581
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
582
- onThumbDown(undefined);
583
- },
584
- onTouchStart: (e)=>{
585
- onThumbDown(e.changedTouches[0].identifier);
586
- }
587
- }
588
- }, focusWithinProps, keyboardProps, movePropsThumb);
589
- let { focusProps: xInputFocusProps } = (0, $7KHxM$useFocus)({
590
- onFocus: ()=>{
591
- setFocusedInput("x");
592
- }
593
- });
594
- let { focusProps: yInputFocusProps } = (0, $7KHxM$useFocus)({
595
- onFocus: ()=>{
596
- setFocusedInput("y");
597
- }
598
- });
599
- const onChange = (e)=>{
600
- const { target: target } = e;
601
- setValueChangedViaInputChangeEvent(true);
602
- if (target === inputXRef.current) state.setXValue(parseFloat(target.value));
603
- else if (target === inputYRef.current) state.setYValue(parseFloat(target.value));
604
- };
605
- let isMobile = (0, $7KHxM$isIOS)() || (0, $7KHxM$isAndroid)();
606
- let value = state.getDisplayColor();
607
- const getAriaValueTextForChannel = (0, $7KHxM$useCallback)((channel)=>{
608
- const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
609
- return `${isAfterInput ? stringFormatter.format("colorNameAndValue", {
610
- name: value.getChannelName(channel, locale),
611
- value: value.formatChannelValue(channel, locale)
612
- }) : [
613
- stringFormatter.format("colorNameAndValue", {
614
- name: value.getChannelName(channel, locale),
615
- value: value.formatChannelValue(channel, locale)
616
- }),
617
- stringFormatter.format("colorNameAndValue", {
618
- name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
619
- value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
620
- }),
621
- stringFormatter.format("colorNameAndValue", {
622
- name: value.getChannelName(zChannel, locale),
623
- value: value.formatChannelValue(zChannel, locale)
624
- })
625
- ].join(", ")}, ${value.getColorName(locale)}`;
626
- }, [
627
- locale,
628
- value,
629
- stringFormatter,
630
- valueChangedViaInputChangeEvent,
631
- valueChangedViaKeyboard,
632
- xChannel,
633
- yChannel,
634
- zChannel
635
- ]);
636
- let colorPickerLabel = stringFormatter.format("colorPicker");
637
- let xInputLabellingProps = (0, $7KHxM$useLabels)({
638
- ...props,
639
- "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
640
- label: ariaLabel,
641
- channelLabel: colorPickerLabel
642
- }) : colorPickerLabel
643
- });
644
- let yInputLabellingProps = (0, $7KHxM$useLabels)({
645
- ...props,
646
- "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
647
- label: ariaLabel,
648
- channelLabel: colorPickerLabel
649
- }) : colorPickerLabel
650
- });
651
- let colorAreaLabellingProps = (0, $7KHxM$useLabels)({
652
- ...props,
653
- "aria-label": ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
654
- }, isMobile ? colorPickerLabel : undefined);
655
- let ariaRoleDescription = stringFormatter.format("twoDimensionalSlider");
656
- let { visuallyHiddenProps: visuallyHiddenProps } = (0, $7KHxM$useVisuallyHidden)({
657
- style: {
658
- opacity: "0.0001",
659
- width: "100%",
660
- height: "100%",
661
- pointerEvents: "none"
662
- }
663
- });
664
- let { colorAreaStyleProps: colorAreaStyleProps, gradientStyleProps: gradientStyleProps, thumbStyleProps: thumbStyleProps } = (0, $40297c24c53588e6$export$dd62420467d245ca)({
665
- direction: direction,
666
- state: state,
667
- xChannel: xChannel,
668
- zChannel: zChannel,
669
- isDisabled: props.isDisabled
670
- });
671
- return {
672
- colorAreaProps: {
673
- ...colorAreaLabellingProps,
674
- ...colorAreaInteractions,
675
- ...colorAreaStyleProps,
676
- role: "group"
677
- },
678
- gradientProps: {
679
- ...gradientStyleProps,
680
- role: "presentation"
681
- },
682
- thumbProps: {
683
- ...thumbInteractions,
684
- ...thumbStyleProps,
685
- role: "presentation"
686
- },
687
- xInputProps: {
688
- ...xInputLabellingProps,
689
- ...visuallyHiddenProps,
690
- ...xInputFocusProps,
691
- type: "range",
692
- min: state.value.getChannelRange(xChannel).minValue,
693
- max: state.value.getChannelRange(xChannel).maxValue,
694
- step: xChannelStep,
695
- "aria-roledescription": ariaRoleDescription,
696
- "aria-valuetext": getAriaValueTextForChannel(xChannel),
697
- "aria-orientation": "horizontal",
698
- disabled: isDisabled,
699
- value: state.value.getChannelValue(xChannel),
700
- name: xName,
701
- tabIndex: isMobile || !focusedInput || focusedInput === "x" ? undefined : -1,
702
- /*
703
- So that only a single "2d slider" control shows up when listing form elements for screen readers,
704
- add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
705
- but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
706
- */ "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? undefined : "true",
707
- onChange: onChange
708
- },
709
- yInputProps: {
710
- ...yInputLabellingProps,
711
- ...visuallyHiddenProps,
712
- ...yInputFocusProps,
713
- type: "range",
714
- min: state.value.getChannelRange(yChannel).minValue,
715
- max: state.value.getChannelRange(yChannel).maxValue,
716
- step: yChannelStep,
717
- "aria-roledescription": ariaRoleDescription,
718
- "aria-valuetext": getAriaValueTextForChannel(yChannel),
719
- "aria-orientation": "vertical",
720
- disabled: isDisabled,
721
- value: state.value.getChannelValue(yChannel),
722
- name: yName,
723
- tabIndex: isMobile || focusedInput === "y" ? undefined : -1,
724
- /*
725
- So that only a single "2d slider" control shows up when listing form elements for screen readers,
726
- add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
727
- but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
728
- */ "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? undefined : "true",
729
- onChange: onChange
730
- }
731
- };
732
- }
733
-
734
-
735
- /*
736
- * Copyright 2020 Adobe. All rights reserved.
737
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
738
- * you may not use this file except in compliance with the License. You may obtain a copy
739
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
740
- *
741
- * Unless required by applicable law or agreed to in writing, software distributed under
742
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
743
- * OF ANY KIND, either express or implied. See the License for the specific language
744
- * governing permissions and limitations under the License.
745
- */
746
-
747
-
748
- function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
749
- let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
750
- let { locale: locale, direction: direction } = (0, $7KHxM$useLocale)();
751
- // Provide a default aria-label if there is no other label provided.
752
- if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
753
- // @ts-ignore - ignore unused incompatible props
754
- let { groupProps: groupProps, trackProps: trackProps, labelProps: labelProps, outputProps: outputProps } = (0, $7KHxM$useSlider)({
755
- ...props,
756
- "aria-label": ariaLabel
757
- }, state, trackRef);
758
- let { inputProps: inputProps, thumbProps: thumbProps } = (0, $7KHxM$useSliderThumb)({
759
- index: 0,
760
- orientation: orientation,
761
- isDisabled: props.isDisabled,
762
- name: name,
763
- trackRef: trackRef,
764
- inputRef: inputRef
765
- }, state);
766
- let value = state.getDisplayColor();
767
- let generateBackground = ()=>{
768
- let to;
769
- if (orientation === "vertical") to = "top";
770
- else if (direction === "ltr") to = "right";
771
- else to = "left";
772
- switch(channel){
773
- case "hue":
774
- return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
775
- case "lightness":
776
- {
777
- // We have to add an extra color stop in the middle so that the hue shows up at all.
778
- // Otherwise it will always just be black to white.
779
- let min = state.getThumbMinValue(0);
780
- let max = state.getThumbMaxValue(0);
781
- let start = value.withChannelValue(channel, min).toString("css");
782
- let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
783
- let end = value.withChannelValue(channel, max).toString("css");
784
- return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
785
- }
786
- case "saturation":
787
- case "brightness":
788
- case "red":
789
- case "green":
790
- case "blue":
791
- case "alpha":
792
- {
793
- let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
794
- let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
795
- return `linear-gradient(to ${to}, ${start}, ${end})`;
796
- }
797
- default:
798
- throw new Error("Unknown color channel: " + channel);
799
- }
800
- };
801
- let forcedColorAdjustNoneStyle = {
802
- forcedColorAdjust: "none"
803
- };
804
- if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
805
- else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
806
- return {
807
- trackProps: {
808
- ...(0, $7KHxM$mergeProps)(groupProps, trackProps),
809
- style: {
810
- ...trackProps.style,
811
- ...forcedColorAdjustNoneStyle,
812
- background: generateBackground()
813
- }
814
- },
815
- inputProps: inputProps,
816
- thumbProps: {
817
- ...thumbProps,
818
- style: {
819
- ...thumbProps.style,
820
- ...forcedColorAdjustNoneStyle
821
- }
822
- },
823
- labelProps: labelProps,
824
- outputProps: outputProps
825
- };
826
- }
827
-
828
-
829
- /*
830
- * Copyright 2020 Adobe. All rights reserved.
831
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
832
- * you may not use this file except in compliance with the License. You may obtain a copy
833
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
834
- *
835
- * Unless required by applicable law or agreed to in writing, software distributed under
836
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
837
- * OF ANY KIND, either express or implied. See the License for the specific language
838
- * governing permissions and limitations under the License.
839
- */
840
-
841
-
842
-
843
- function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
844
- let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, "aria-label": ariaLabel, name: name } = props;
845
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $7KHxM$useGlobalListeners)();
846
- let thumbRadius = (innerRadius + outerRadius) / 2;
847
- let focusInput = (0, $7KHxM$useCallback)(()=>{
848
- if (inputRef.current) (0, $7KHxM$focusWithoutScrolling)(inputRef.current);
849
- }, [
850
- inputRef
851
- ]);
852
- (0, $7KHxM$useFormReset)(inputRef, state.hue, state.setHue);
853
- let currentPosition = (0, $7KHxM$useRef)(null);
854
- let { keyboardProps: keyboardProps } = (0, $7KHxM$useKeyboard)({
855
- onKeyDown (e) {
856
- // these are the cases that useMove doesn't handle
857
- if (!/^(PageUp|PageDown)$/.test(e.key)) {
858
- e.continuePropagation();
859
- return;
860
- }
861
- // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
862
- e.preventDefault();
863
- // remember to set this and unset it so that onChangeEnd is fired
864
- state.setDragging(true);
865
- switch(e.key){
866
- case "PageUp":
867
- e.preventDefault();
868
- state.increment(state.pageStep);
869
- break;
870
- case "PageDown":
871
- e.preventDefault();
872
- state.decrement(state.pageStep);
873
- break;
874
- }
875
- state.setDragging(false);
876
- }
877
- });
878
- let moveHandler = {
879
- onMoveStart () {
880
- currentPosition.current = null;
881
- state.setDragging(true);
882
- },
883
- onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
884
- if (currentPosition.current == null) currentPosition.current = state.getThumbPosition(thumbRadius);
885
- currentPosition.current.x += deltaX;
886
- currentPosition.current.y += deltaY;
887
- if (pointerType === "keyboard") {
888
- if (deltaX > 0 || deltaY < 0) state.increment(shiftKey ? state.pageStep : state.step);
889
- else if (deltaX < 0 || deltaY > 0) state.decrement(shiftKey ? state.pageStep : state.step);
890
- } else state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
891
- },
892
- onMoveEnd () {
893
- isOnTrack.current = false;
894
- state.setDragging(false);
895
- focusInput();
896
- }
897
- };
898
- let { moveProps: movePropsThumb } = (0, $7KHxM$useMove)(moveHandler);
899
- let currentPointer = (0, $7KHxM$useRef)(undefined);
900
- let isOnTrack = (0, $7KHxM$useRef)(false);
901
- let { moveProps: movePropsContainer } = (0, $7KHxM$useMove)({
902
- onMoveStart () {
903
- if (isOnTrack.current) moveHandler.onMoveStart();
904
- },
905
- onMove (e) {
906
- if (isOnTrack.current) moveHandler.onMove(e);
907
- },
908
- onMoveEnd () {
909
- if (isOnTrack.current) moveHandler.onMoveEnd();
910
- }
911
- });
912
- let onThumbDown = (id)=>{
913
- if (!state.isDragging) {
914
- currentPointer.current = id;
915
- focusInput();
916
- state.setDragging(true);
917
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
918
- else {
919
- addGlobalListener(window, "mouseup", onThumbUp, false);
920
- addGlobalListener(window, "touchend", onThumbUp, false);
921
- }
922
- }
923
- };
924
- let onThumbUp = (e)=>{
925
- var _e_changedTouches;
926
- var _e_pointerId;
927
- 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;
928
- if (id === currentPointer.current) {
929
- focusInput();
930
- state.setDragging(false);
931
- currentPointer.current = undefined;
932
- isOnTrack.current = false;
933
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
934
- else {
935
- removeGlobalListener(window, "mouseup", onThumbUp, false);
936
- removeGlobalListener(window, "touchend", onThumbUp, false);
937
- }
938
- }
939
- };
940
- let onTrackDown = (track, id, pageX, pageY)=>{
941
- let rect = track.getBoundingClientRect();
942
- let x = pageX - rect.x - rect.width / 2;
943
- let y = pageY - rect.y - rect.height / 2;
944
- let radius = Math.sqrt(x * x + y * y);
945
- if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
946
- isOnTrack.current = true;
947
- currentPointer.current = id;
948
- state.setHueFromPoint(x, y, radius);
949
- focusInput();
950
- state.setDragging(true);
951
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onTrackUp, false);
952
- else {
953
- addGlobalListener(window, "mouseup", onTrackUp, false);
954
- addGlobalListener(window, "touchend", onTrackUp, false);
955
- }
956
- }
957
- };
958
- let onTrackUp = (e)=>{
959
- var _e_changedTouches;
960
- var _e_pointerId;
961
- 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;
962
- if (isOnTrack.current && id === currentPointer.current) {
963
- isOnTrack.current = false;
964
- currentPointer.current = undefined;
965
- state.setDragging(false);
966
- focusInput();
967
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onTrackUp, false);
968
- else {
969
- removeGlobalListener(window, "mouseup", onTrackUp, false);
970
- removeGlobalListener(window, "touchend", onTrackUp, false);
971
- }
972
- }
973
- };
974
- let trackInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
975
- ...typeof PointerEvent !== "undefined" ? {
976
- onPointerDown: (e)=>{
977
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
978
- onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
979
- }
980
- } : {
981
- onMouseDown: (e)=>{
982
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
983
- onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);
984
- },
985
- onTouchStart: (e)=>{
986
- onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
987
- }
988
- }
989
- }, movePropsContainer);
990
- let thumbInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
991
- onMouseDown: (e)=>{
992
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
993
- onThumbDown(undefined);
994
- },
995
- onPointerDown: (e)=>{
996
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
997
- onThumbDown(e.pointerId);
998
- },
999
- onTouchStart: (e)=>{
1000
- onThumbDown(e.changedTouches[0].identifier);
1001
- }
1002
- }, keyboardProps, movePropsThumb);
1003
- let { x: x, y: y } = state.getThumbPosition(thumbRadius);
1004
- // Provide a default aria-label if none is given
1005
- let { locale: locale } = (0, $7KHxM$useLocale)();
1006
- if (ariaLabel == null && props["aria-labelledby"] == null) ariaLabel = state.value.getChannelName("hue", locale);
1007
- let inputLabellingProps = (0, $7KHxM$useLabels)({
1008
- ...props,
1009
- "aria-label": ariaLabel
1010
- });
1011
- let { minValue: minValue, maxValue: maxValue, step: step } = state.value.getChannelRange("hue");
1012
- let forcedColorAdjustNoneStyle = {
1013
- forcedColorAdjust: "none"
1014
- };
1015
- return {
1016
- trackProps: {
1017
- ...trackInteractions,
1018
- style: {
1019
- position: "relative",
1020
- touchAction: "none",
1021
- width: outerRadius * 2,
1022
- height: outerRadius * 2,
1023
- background: `
1024
- conic-gradient(
1025
- from 90deg,
1026
- hsl(0, 100%, 50%),
1027
- hsl(30, 100%, 50%),
1028
- hsl(60, 100%, 50%),
1029
- hsl(90, 100%, 50%),
1030
- hsl(120, 100%, 50%),
1031
- hsl(150, 100%, 50%),
1032
- hsl(180, 100%, 50%),
1033
- hsl(210, 100%, 50%),
1034
- hsl(240, 100%, 50%),
1035
- hsl(270, 100%, 50%),
1036
- hsl(300, 100%, 50%),
1037
- hsl(330, 100%, 50%),
1038
- hsl(360, 100%, 50%)
1039
- )
1040
- `,
1041
- clipPath: `path(evenodd, "${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, outerRadius)} ${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, innerRadius)}")`,
1042
- ...forcedColorAdjustNoneStyle
1043
- }
1044
- },
1045
- thumbProps: {
1046
- ...thumbInteractions,
1047
- style: {
1048
- position: "absolute",
1049
- left: "50%",
1050
- top: "50%",
1051
- transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,
1052
- touchAction: "none",
1053
- ...forcedColorAdjustNoneStyle
1054
- }
1055
- },
1056
- inputProps: (0, $7KHxM$mergeProps)(inputLabellingProps, {
1057
- type: "range",
1058
- min: String(minValue),
1059
- max: String(maxValue),
1060
- step: String(step),
1061
- "aria-valuetext": `${state.value.formatChannelValue("hue", locale)}, ${state.value.getHueName(locale)}`,
1062
- disabled: isDisabled,
1063
- value: `${state.value.getChannelValue("hue")}`,
1064
- name: name,
1065
- onChange: (e)=>{
1066
- state.setHue(parseFloat(e.target.value));
1067
- }
1068
- })
1069
- };
1070
- }
1071
- // Creates an SVG path string for a circle.
1072
- function $b4a0a4fdc900495e$var$circlePath(cx, cy, r) {
1073
- return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;
1074
- }
1075
-
1076
-
1077
- /*
1078
- * Copyright 2020 Adobe. All rights reserved.
1079
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1080
- * you may not use this file except in compliance with the License. You may obtain a copy
1081
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1082
- *
1083
- * Unless required by applicable law or agreed to in writing, software distributed under
1084
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1085
- * OF ANY KIND, either express or implied. See the License for the specific language
1086
- * governing permissions and limitations under the License.
1087
- */
1088
-
1089
-
1090
-
1091
-
1092
17
 
1093
- function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
1094
- let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = "aria" } = props;
1095
- let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
1096
- let inputId = (0, $7KHxM$useId)();
1097
- let { spinButtonProps: spinButtonProps } = (0, $7KHxM$useSpinButton)({
1098
- isDisabled: isDisabled,
1099
- isReadOnly: isReadOnly,
1100
- isRequired: isRequired,
1101
- maxValue: 0xFFFFFF,
1102
- minValue: 0,
1103
- onIncrement: increment,
1104
- onIncrementToMax: incrementToMax,
1105
- onDecrement: decrement,
1106
- onDecrementToMin: decrementToMin,
1107
- value: colorValue ? colorValue.toHexInt() : undefined,
1108
- textValue: colorValue ? colorValue.toString("hex") : undefined
1109
- });
1110
- let [focusWithin, setFocusWithin] = (0, $7KHxM$useState)(false);
1111
- let { focusWithinProps: focusWithinProps } = (0, $7KHxM$useFocusWithin)({
1112
- isDisabled: isDisabled,
1113
- onFocusWithinChange: setFocusWithin
1114
- });
1115
- let onWheel = (0, $7KHxM$useCallback)((e)=>{
1116
- if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
1117
- if (e.deltaY > 0) increment();
1118
- else if (e.deltaY < 0) decrement();
1119
- }, [
1120
- decrement,
1121
- increment
1122
- ]);
1123
- // If the input isn't supposed to receive input, disable scrolling.
1124
- let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
1125
- (0, $7KHxM$useScrollWheel)({
1126
- onScroll: onWheel,
1127
- isDisabled: scrollingDisabled
1128
- }, ref);
1129
- let onChange = (value)=>{
1130
- if (state.validate(value)) state.setInputValue(value);
1131
- };
1132
- let { inputProps: inputProps, ...otherProps } = (0, $7KHxM$useFormattedTextField)((0, $7KHxM$mergeProps)(props, {
1133
- id: inputId,
1134
- value: inputValue,
1135
- defaultValue: undefined,
1136
- validate: undefined,
1137
- [(0, $7KHxM$privateValidationStateProp)]: state,
1138
- type: "text",
1139
- autoComplete: "off",
1140
- onChange: onChange
1141
- }), state, ref);
1142
- inputProps = (0, $7KHxM$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
1143
- role: "textbox",
1144
- "aria-valuemax": null,
1145
- "aria-valuemin": null,
1146
- "aria-valuenow": null,
1147
- "aria-valuetext": null,
1148
- autoCorrect: "off",
1149
- spellCheck: "false",
1150
- onBlur: commit
1151
- });
1152
- if (validationBehavior === "native") inputProps["aria-required"] = undefined;
1153
- return {
1154
- inputProps: inputProps,
1155
- ...otherProps
1156
- };
1157
- }
1158
18
 
1159
19
 
1160
20