@react-aria/color 3.0.0-beta.3 → 3.0.0-beta.31

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