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