@react-aria/color 3.0.0-nightly.4555 → 3.0.0-nightly.4560

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
@@ -0,0 +1,224 @@
1
+ import {useMemo as $hLqEt$useMemo} from "react";
2
+
3
+ /*
4
+ * Copyright 2022 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ const $40297c24c53588e6$var$generateRGB_R = (orientation, dir, zValue)=>{
15
+ let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
16
+ let result = {
17
+ colorAreaStyles: {
18
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
19
+ },
20
+ gradientStyles: {
21
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
22
+ "WebkitMaskImage": maskImage,
23
+ maskImage: maskImage
24
+ }
25
+ };
26
+ return result;
27
+ };
28
+ const $40297c24c53588e6$var$generateRGB_G = (orientation, dir, zValue)=>{
29
+ let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
30
+ let result = {
31
+ colorAreaStyles: {
32
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
33
+ },
34
+ gradientStyles: {
35
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
36
+ "WebkitMaskImage": maskImage,
37
+ maskImage: maskImage
38
+ }
39
+ };
40
+ return result;
41
+ };
42
+ const $40297c24c53588e6$var$generateRGB_B = (orientation, dir, zValue)=>{
43
+ let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
44
+ let result = {
45
+ colorAreaStyles: {
46
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
47
+ },
48
+ gradientStyles: {
49
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
50
+ "WebkitMaskImage": maskImage,
51
+ maskImage: maskImage
52
+ }
53
+ };
54
+ return result;
55
+ };
56
+ const $40297c24c53588e6$var$generateHSL_H = (orientation, dir, zValue)=>{
57
+ let result = {
58
+ colorAreaStyles: {},
59
+ gradientStyles: {
60
+ background: [
61
+ `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%)`,
62
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
63
+ `hsl(${zValue}, 100%, 50%)`
64
+ ].join(",")
65
+ }
66
+ };
67
+ return result;
68
+ };
69
+ const $40297c24c53588e6$var$generateHSL_S = (orientation, dir, alphaValue)=>{
70
+ let result = {
71
+ colorAreaStyles: {},
72
+ gradientStyles: {
73
+ background: [
74
+ `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%)`,
75
+ `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}))`,
76
+ "hsl(0, 0%, 50%)"
77
+ ].join(",")
78
+ }
79
+ };
80
+ return result;
81
+ };
82
+ const $40297c24c53588e6$var$generateHSL_L = (orientation, dir, zValue)=>{
83
+ let result = {
84
+ colorAreaStyles: {},
85
+ gradientStyles: {
86
+ backgroundImage: [
87
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
88
+ `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}%))`
89
+ ].join(",")
90
+ }
91
+ };
92
+ return result;
93
+ };
94
+ const $40297c24c53588e6$var$generateHSB_H = (orientation, dir, zValue)=>{
95
+ let result = {
96
+ colorAreaStyles: {},
97
+ gradientStyles: {
98
+ background: [
99
+ `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
100
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
101
+ `hsl(${zValue}, 100%, 50%)`
102
+ ].join(",")
103
+ }
104
+ };
105
+ return result;
106
+ };
107
+ const $40297c24c53588e6$var$generateHSB_S = (orientation, dir, alphaValue)=>{
108
+ let result = {
109
+ colorAreaStyles: {},
110
+ gradientStyles: {
111
+ background: [
112
+ `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
113
+ `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}))`,
114
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
115
+ ].join(",")
116
+ }
117
+ };
118
+ return result;
119
+ };
120
+ const $40297c24c53588e6$var$generateHSB_B = (orientation, dir, alphaValue)=>{
121
+ let result = {
122
+ colorAreaStyles: {},
123
+ gradientStyles: {
124
+ background: [
125
+ `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
126
+ `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}))`,
127
+ "#000"
128
+ ].join(",")
129
+ }
130
+ };
131
+ return result;
132
+ };
133
+ function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, isDisabled: isDisabled }) {
134
+ let returnVal = (0, $hLqEt$useMemo)(()=>{
135
+ let orientation = [
136
+ "top",
137
+ direction === "rtl" ? "left" : "right"
138
+ ];
139
+ let dir = false;
140
+ let background = {
141
+ colorAreaStyles: {},
142
+ gradientStyles: {}
143
+ };
144
+ let zValue = state.value.getChannelValue(zChannel);
145
+ let { minValue: zMin, maxValue: zMax } = state.value.getChannelRange(zChannel);
146
+ let alphaValue = (zValue - zMin) / (zMax - zMin);
147
+ let isHSL = state.value.getColorSpace() === "hsl";
148
+ if (!isDisabled) switch(zChannel){
149
+ case "red":
150
+ dir = xChannel === "green";
151
+ background = $40297c24c53588e6$var$generateRGB_R(orientation, dir, zValue);
152
+ break;
153
+ case "green":
154
+ dir = xChannel === "red";
155
+ background = $40297c24c53588e6$var$generateRGB_G(orientation, dir, zValue);
156
+ break;
157
+ case "blue":
158
+ dir = xChannel === "red";
159
+ background = $40297c24c53588e6$var$generateRGB_B(orientation, dir, zValue);
160
+ break;
161
+ case "hue":
162
+ dir = xChannel !== "saturation";
163
+ if (isHSL) background = $40297c24c53588e6$var$generateHSL_H(orientation, dir, zValue);
164
+ else background = $40297c24c53588e6$var$generateHSB_H(orientation, dir, zValue);
165
+ break;
166
+ case "saturation":
167
+ dir = xChannel === "hue";
168
+ if (isHSL) background = $40297c24c53588e6$var$generateHSL_S(orientation, dir, alphaValue);
169
+ else background = $40297c24c53588e6$var$generateHSB_S(orientation, dir, alphaValue);
170
+ break;
171
+ case "brightness":
172
+ dir = xChannel === "hue";
173
+ background = $40297c24c53588e6$var$generateHSB_B(orientation, dir, alphaValue);
174
+ break;
175
+ case "lightness":
176
+ dir = xChannel === "hue";
177
+ background = $40297c24c53588e6$var$generateHSL_L(orientation, dir, zValue);
178
+ break;
179
+ }
180
+ let { x: x, y: y } = state.getThumbPosition();
181
+ if (direction === "rtl") x = 1 - x;
182
+ let forcedColorAdjustNoneStyle = {
183
+ forcedColorAdjust: "none"
184
+ };
185
+ return {
186
+ colorAreaStyleProps: {
187
+ style: {
188
+ position: "relative",
189
+ touchAction: "none",
190
+ ...forcedColorAdjustNoneStyle,
191
+ ...background.colorAreaStyles
192
+ }
193
+ },
194
+ gradientStyleProps: {
195
+ style: {
196
+ touchAction: "none",
197
+ ...forcedColorAdjustNoneStyle,
198
+ ...background.gradientStyles
199
+ }
200
+ },
201
+ thumbStyleProps: {
202
+ style: {
203
+ position: "absolute",
204
+ left: `${x * 100}%`,
205
+ top: `${y * 100}%`,
206
+ transform: "translate(0%, 0%)",
207
+ touchAction: "none",
208
+ ...forcedColorAdjustNoneStyle
209
+ }
210
+ }
211
+ };
212
+ }, [
213
+ direction,
214
+ state,
215
+ zChannel,
216
+ xChannel,
217
+ isDisabled
218
+ ]);
219
+ return returnVal;
220
+ }
221
+
222
+
223
+ export {$40297c24c53588e6$export$dd62420467d245ca as useColorAreaGradient};
224
+ //# sourceMappingURL=useColorAreaGradient.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;AAUA;AAIA,MAAM,sCAAgB,CAAC,aAAa,KAAc;IAChD,IAAI,YAAY,CAAC,mBAAmB,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC;IACrF,IAAI,SAAS;QACX,iBAAiB;YACf,iBAAiB,CAAC,mBAAmB,EAAE,WAAW,CAAC,OAAO,KAAK,CAAC,KAAK,EAAE,OAAO,UAAU,EAAE,OAAO,QAAQ,CAAC;QAC5G;QACA,gBAAgB;YACd,iBAAiB,CAAC,mBAAmB,EAAE,WAAW,CAAC,OAAO,KAAK,CAAC,KAAK,EAAE,OAAO,YAAY,EAAE,OAAO,UAAU,CAAC;YAC9G,mBAAmB;uBACnB;QACF;IACF;IACA,OAAO;AACT;AAEA,MAAM,sCAAgB,CAAC,aAAa,KAAc;IAChD,IAAI,YAAY,CAAC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AO;oBACL,aAAa;oBACb,GAAG,0BAA0B;oBAC7B,GAAG,WAAW,cAAc;gBAC9B;YACF;YACA,iBAAiB;gBACf,OAAO;oBACL,UAAU;oBACV,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;oBACnB,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;oBAClB,WAAW;oBACX,aAAa;oBACb,GAAG,0BAA0B;gBAC/B;YACF;QACF;IACF,GAAG;QAAC;QAAW;QAAO;QAAU;QAAU;KAAW;IAErD,OAAO;AACT","sources":["packages/@react-aria/color/src/useColorAreaGradient.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n*/\n\nimport {CSSProperties, useMemo} from 'react';\n\nconst generateRGB_R = (orientation, dir: boolean, zValue: number) => {\n let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;\n let result = {\n colorAreaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`\n },\n gradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n 'WebkitMaskImage': maskImage,\n maskImage\n }\n };\n return result;\n};\n\nconst generateRGB_G = (orientation, dir: boolean, zValue: number) => {\n let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;\n let result = {\n colorAreaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`\n },\n gradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n 'WebkitMaskImage': maskImage,\n maskImage\n }\n };\n return result;\n};\n\nconst generateRGB_B = (orientation, dir: boolean, zValue: number) => {\n let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;\n let result = {\n colorAreaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`\n },\n gradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n 'WebkitMaskImage': maskImage,\n maskImage\n }\n };\n return result;\n};\n\n\nconst generateHSL_H = (orientation, dir: boolean, zValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `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%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSL_S = (orientation, dir: boolean, alphaValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `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%)`,\n `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}))`,\n 'hsl(0, 0%, 50%)'\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSL_L = (orientation, dir: boolean, zValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `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}%))`\n ].join(',')\n }\n };\n return result;\n};\n\n\nconst generateHSB_H = (orientation, dir: boolean, zValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSB_S = (orientation, dir: boolean, alphaValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `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}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSB_B = (orientation, dir: boolean, alphaValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `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}))`,\n '#000'\n ].join(',')\n }\n };\n return result;\n};\n\n\ninterface Gradients {\n colorAreaStyleProps: {\n style: CSSProperties\n },\n gradientStyleProps: {\n style: CSSProperties\n },\n thumbStyleProps: {\n style: CSSProperties\n }\n}\n\nexport function useColorAreaGradient({direction, state, zChannel, xChannel, isDisabled}): Gradients {\n let returnVal = useMemo<Gradients>(() => {\n let orientation = ['top', direction === 'rtl' ? 'left' : 'right'];\n let dir = false;\n let background = {colorAreaStyles: {}, gradientStyles: {}};\n let zValue = state.value.getChannelValue(zChannel);\n let {minValue: zMin, maxValue: zMax} = state.value.getChannelRange(zChannel);\n let alphaValue = (zValue - zMin) / (zMax - zMin);\n let isHSL = state.value.getColorSpace() === 'hsl';\n if (!isDisabled) {\n switch (zChannel) {\n case 'red': {\n dir = xChannel === 'green';\n background = generateRGB_R(orientation, dir, zValue);\n break;\n }\n case 'green': {\n dir = xChannel === 'red';\n background = generateRGB_G(orientation, dir, zValue);\n break;\n }\n case 'blue': {\n dir = xChannel === 'red';\n background = generateRGB_B(orientation, dir, zValue);\n break;\n }\n case 'hue': {\n dir = xChannel !== 'saturation';\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue);\n } else {\n background = generateHSB_H(orientation, dir, zValue);\n }\n break;\n }\n case 'saturation': {\n dir = xChannel === 'hue';\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue);\n } else {\n background = generateHSB_S(orientation, dir, alphaValue);\n }\n break;\n }\n case 'brightness': {\n dir = xChannel === 'hue';\n background = generateHSB_B(orientation, dir, alphaValue);\n break;\n }\n case 'lightness': {\n dir = xChannel === 'hue';\n background = generateHSL_L(orientation, dir, zValue);\n break;\n }\n }\n }\n\n let {x, y} = state.getThumbPosition();\n\n if (direction === 'rtl') {\n x = 1 - x;\n }\n\n let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n return {\n colorAreaStyleProps: {\n style: {\n position: 'relative',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle,\n ...background.colorAreaStyles\n }\n },\n gradientStyleProps: {\n style: {\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle,\n ...background.gradientStyles\n }\n },\n thumbStyleProps: {\n style: {\n position: 'absolute',\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: 'translate(0%, 0%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n }\n };\n }, [direction, state, zChannel, xChannel, isDisabled]);\n\n return returnVal;\n}\n\n"],"names":[],"version":3,"file":"useColorAreaGradient.module.js.map"}
@@ -0,0 +1,97 @@
1
+ var $grujV$react = require("react");
2
+ var $grujV$reactariautils = require("@react-aria/utils");
3
+ var $grujV$reactstatelyform = require("@react-stately/form");
4
+ var $grujV$reactariainteractions = require("@react-aria/interactions");
5
+ var $grujV$reactariatextfield = require("@react-aria/textfield");
6
+ var $grujV$reactariaspinbutton = require("@react-aria/spinbutton");
7
+
8
+
9
+ function $parcel$export(e, n, v, s) {
10
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
+ }
12
+
13
+ $parcel$export(module.exports, "useColorField", () => $58c850037bc7a7ce$export$77e32ca575a28fdf);
14
+ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+
27
+
28
+
29
+
30
+ function $58c850037bc7a7ce$export$77e32ca575a28fdf(props, state, ref) {
31
+ let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = "aria" } = props;
32
+ let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
33
+ let inputId = (0, $grujV$reactariautils.useId)();
34
+ let { spinButtonProps: spinButtonProps } = (0, $grujV$reactariaspinbutton.useSpinButton)({
35
+ isDisabled: isDisabled,
36
+ isReadOnly: isReadOnly,
37
+ isRequired: isRequired,
38
+ maxValue: 0xFFFFFF,
39
+ minValue: 0,
40
+ onIncrement: increment,
41
+ onIncrementToMax: incrementToMax,
42
+ onDecrement: decrement,
43
+ onDecrementToMin: decrementToMin,
44
+ value: colorValue ? colorValue.toHexInt() : undefined,
45
+ textValue: colorValue ? colorValue.toString("hex") : undefined
46
+ });
47
+ let [focusWithin, setFocusWithin] = (0, $grujV$react.useState)(false);
48
+ let { focusWithinProps: focusWithinProps } = (0, $grujV$reactariainteractions.useFocusWithin)({
49
+ isDisabled: isDisabled,
50
+ onFocusWithinChange: setFocusWithin
51
+ });
52
+ let onWheel = (0, $grujV$react.useCallback)((e)=>{
53
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
54
+ if (e.deltaY > 0) increment();
55
+ else if (e.deltaY < 0) decrement();
56
+ }, [
57
+ decrement,
58
+ increment
59
+ ]);
60
+ // If the input isn't supposed to receive input, disable scrolling.
61
+ let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
62
+ (0, $grujV$reactariainteractions.useScrollWheel)({
63
+ onScroll: onWheel,
64
+ isDisabled: scrollingDisabled
65
+ }, ref);
66
+ let onChange = (value)=>{
67
+ if (state.validate(value)) state.setInputValue(value);
68
+ };
69
+ let { inputProps: inputProps, ...otherProps } = (0, $grujV$reactariatextfield.useFormattedTextField)((0, $grujV$reactariautils.mergeProps)(props, {
70
+ id: inputId,
71
+ value: inputValue,
72
+ defaultValue: undefined,
73
+ validate: undefined,
74
+ [(0, $grujV$reactstatelyform.privateValidationStateProp)]: state,
75
+ type: "text",
76
+ autoComplete: "off",
77
+ onChange: onChange
78
+ }), state, ref);
79
+ inputProps = (0, $grujV$reactariautils.mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
80
+ role: "textbox",
81
+ "aria-valuemax": null,
82
+ "aria-valuemin": null,
83
+ "aria-valuenow": null,
84
+ "aria-valuetext": null,
85
+ autoCorrect: "off",
86
+ spellCheck: "false",
87
+ onBlur: commit
88
+ });
89
+ if (validationBehavior === "native") inputProps["aria-required"] = undefined;
90
+ return {
91
+ inputProps: inputProps,
92
+ ...otherProps
93
+ };
94
+ }
95
+
96
+
97
+ //# sourceMappingURL=useColorField.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA6BM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAgC;IAEhC,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,sBACf,qBAAqB,QACtB,GAAG;IAEJ,IAAI,cACF,UAAU,cACV,UAAU,aACV,SAAS,aACT,SAAS,kBACT,cAAc,kBACd,cAAc,UACd,MAAM,EACP,GAAG;IAEJ,IAAI,UAAU,CAAA,GAAA,2BAAI;IAClB,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,wCAAY,EAClC;oBACE;oBACA;oBACA;QACA,UAAU;QACV,UAAU;QACV,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,kBAAkB;QAClB,OAAO,aAAa,WAAW,QAAQ,KAAK;QAC5C,WAAW,aAAa,WAAW,QAAQ,CAAC,SAAS;IACvD;IAGF,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC7C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;oBAAC;QAAY,qBAAqB;IAAc;IAExF,IAAI,UAAU,CAAA,GAAA,wBAAU,EAAE,CAAC;QACzB,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,KAAK,KAAK,GAAG,CAAC,EAAE,MAAM,GACzC;QAEF,IAAI,EAAE,MAAM,GAAG,GACb;aACK,IAAI,EAAE,MAAM,GAAG,GACpB;IAEJ,GAAG;QAAC;QAAW;KAAU;IACzB,mEAAmE;IACnE,IAAI,oBAAoB,mBAAmB,cAAc,cAAc,CAAC;IACxE,CAAA,GAAA,2CAAa,EAAE;QAAC,UAAU;QAAS,YAAY;IAAiB,GAAG;IAEnE,IAAI,WAAW,CAAA;QACb,IAAI,MAAM,QAAQ,CAAC,QACjB,MAAM,aAAa,CAAC;IAExB;IAEA,IAAI,cAAC,UAAU,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,+CAAoB,EACpD,CAAA,GAAA,gCAAS,EAAE,OAAO;QAChB,IAAI;QACJ,OAAO;QACP,cAAc;QACd,UAAU;QACV,CAAC,CAAA,GAAA,kDAAyB,EAAE,EAAE;QAC9B,MAAM;QACN,cAAc;kBACd;IACF,IAAI,OAAO;IAEb,aAAa,CAAA,GAAA,gCAAS,EAAE,YAAY,iBAAiB,kBAAkB;QACrE,MAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,kBAAkB;QAClB,aAAa;QACb,YAAY;QACZ,QAAQ;IACV;IAEA,IAAI,uBAAuB,UACzB,UAAU,CAAC,gBAAgB,GAAG;IAGhC,OAAO;oBACL;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/color/src/useColorField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorFieldProps} from '@react-types/color';\nimport {ColorFieldState} from '@react-stately/color';\nimport {\n HTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useState\n} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {useSpinButton} from '@react-aria/spinbutton';\nimport {ValidationResult} from '@react-types/shared';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: HTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria'\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xFFFFFF,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField(\n mergeProps(props, {\n id: inputId,\n value: inputValue,\n defaultValue: undefined,\n validate: undefined,\n [privateValidationStateProp]: state,\n type: 'text',\n autoComplete: 'off',\n onChange\n }), state, ref);\n\n inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n onBlur: commit\n });\n\n if (validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n return {\n inputProps,\n ...otherProps\n };\n}\n"],"names":[],"version":3,"file":"useColorField.main.js.map"}
@@ -0,0 +1,92 @@
1
+ import {useState as $f8mV7$useState, useCallback as $f8mV7$useCallback} from "react";
2
+ import {useId as $f8mV7$useId, mergeProps as $f8mV7$mergeProps} from "@react-aria/utils";
3
+ import {privateValidationStateProp as $f8mV7$privateValidationStateProp} from "@react-stately/form";
4
+ import {useFocusWithin as $f8mV7$useFocusWithin, useScrollWheel as $f8mV7$useScrollWheel} from "@react-aria/interactions";
5
+ import {useFormattedTextField as $f8mV7$useFormattedTextField} from "@react-aria/textfield";
6
+ import {useSpinButton as $f8mV7$useSpinButton} from "@react-aria/spinbutton";
7
+
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
25
+ let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = "aria" } = props;
26
+ let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
27
+ let inputId = (0, $f8mV7$useId)();
28
+ let { spinButtonProps: spinButtonProps } = (0, $f8mV7$useSpinButton)({
29
+ isDisabled: isDisabled,
30
+ isReadOnly: isReadOnly,
31
+ isRequired: isRequired,
32
+ maxValue: 0xFFFFFF,
33
+ minValue: 0,
34
+ onIncrement: increment,
35
+ onIncrementToMax: incrementToMax,
36
+ onDecrement: decrement,
37
+ onDecrementToMin: decrementToMin,
38
+ value: colorValue ? colorValue.toHexInt() : undefined,
39
+ textValue: colorValue ? colorValue.toString("hex") : undefined
40
+ });
41
+ let [focusWithin, setFocusWithin] = (0, $f8mV7$useState)(false);
42
+ let { focusWithinProps: focusWithinProps } = (0, $f8mV7$useFocusWithin)({
43
+ isDisabled: isDisabled,
44
+ onFocusWithinChange: setFocusWithin
45
+ });
46
+ let onWheel = (0, $f8mV7$useCallback)((e)=>{
47
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
48
+ if (e.deltaY > 0) increment();
49
+ else if (e.deltaY < 0) decrement();
50
+ }, [
51
+ decrement,
52
+ increment
53
+ ]);
54
+ // If the input isn't supposed to receive input, disable scrolling.
55
+ let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
56
+ (0, $f8mV7$useScrollWheel)({
57
+ onScroll: onWheel,
58
+ isDisabled: scrollingDisabled
59
+ }, ref);
60
+ let onChange = (value)=>{
61
+ if (state.validate(value)) state.setInputValue(value);
62
+ };
63
+ let { inputProps: inputProps, ...otherProps } = (0, $f8mV7$useFormattedTextField)((0, $f8mV7$mergeProps)(props, {
64
+ id: inputId,
65
+ value: inputValue,
66
+ defaultValue: undefined,
67
+ validate: undefined,
68
+ [(0, $f8mV7$privateValidationStateProp)]: state,
69
+ type: "text",
70
+ autoComplete: "off",
71
+ onChange: onChange
72
+ }), state, ref);
73
+ inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
74
+ role: "textbox",
75
+ "aria-valuemax": null,
76
+ "aria-valuemin": null,
77
+ "aria-valuenow": null,
78
+ "aria-valuetext": null,
79
+ autoCorrect: "off",
80
+ spellCheck: "false",
81
+ onBlur: commit
82
+ });
83
+ if (validationBehavior === "native") inputProps["aria-required"] = undefined;
84
+ return {
85
+ inputProps: inputProps,
86
+ ...otherProps
87
+ };
88
+ }
89
+
90
+
91
+ export {$f6896b05b2ecad12$export$77e32ca575a28fdf as useColorField};
92
+ //# sourceMappingURL=useColorField.mjs.map
@@ -0,0 +1,92 @@
1
+ import {useState as $f8mV7$useState, useCallback as $f8mV7$useCallback} from "react";
2
+ import {useId as $f8mV7$useId, mergeProps as $f8mV7$mergeProps} from "@react-aria/utils";
3
+ import {privateValidationStateProp as $f8mV7$privateValidationStateProp} from "@react-stately/form";
4
+ import {useFocusWithin as $f8mV7$useFocusWithin, useScrollWheel as $f8mV7$useScrollWheel} from "@react-aria/interactions";
5
+ import {useFormattedTextField as $f8mV7$useFormattedTextField} from "@react-aria/textfield";
6
+ import {useSpinButton as $f8mV7$useSpinButton} from "@react-aria/spinbutton";
7
+
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
25
+ let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = "aria" } = props;
26
+ let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
27
+ let inputId = (0, $f8mV7$useId)();
28
+ let { spinButtonProps: spinButtonProps } = (0, $f8mV7$useSpinButton)({
29
+ isDisabled: isDisabled,
30
+ isReadOnly: isReadOnly,
31
+ isRequired: isRequired,
32
+ maxValue: 0xFFFFFF,
33
+ minValue: 0,
34
+ onIncrement: increment,
35
+ onIncrementToMax: incrementToMax,
36
+ onDecrement: decrement,
37
+ onDecrementToMin: decrementToMin,
38
+ value: colorValue ? colorValue.toHexInt() : undefined,
39
+ textValue: colorValue ? colorValue.toString("hex") : undefined
40
+ });
41
+ let [focusWithin, setFocusWithin] = (0, $f8mV7$useState)(false);
42
+ let { focusWithinProps: focusWithinProps } = (0, $f8mV7$useFocusWithin)({
43
+ isDisabled: isDisabled,
44
+ onFocusWithinChange: setFocusWithin
45
+ });
46
+ let onWheel = (0, $f8mV7$useCallback)((e)=>{
47
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
48
+ if (e.deltaY > 0) increment();
49
+ else if (e.deltaY < 0) decrement();
50
+ }, [
51
+ decrement,
52
+ increment
53
+ ]);
54
+ // If the input isn't supposed to receive input, disable scrolling.
55
+ let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
56
+ (0, $f8mV7$useScrollWheel)({
57
+ onScroll: onWheel,
58
+ isDisabled: scrollingDisabled
59
+ }, ref);
60
+ let onChange = (value)=>{
61
+ if (state.validate(value)) state.setInputValue(value);
62
+ };
63
+ let { inputProps: inputProps, ...otherProps } = (0, $f8mV7$useFormattedTextField)((0, $f8mV7$mergeProps)(props, {
64
+ id: inputId,
65
+ value: inputValue,
66
+ defaultValue: undefined,
67
+ validate: undefined,
68
+ [(0, $f8mV7$privateValidationStateProp)]: state,
69
+ type: "text",
70
+ autoComplete: "off",
71
+ onChange: onChange
72
+ }), state, ref);
73
+ inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
74
+ role: "textbox",
75
+ "aria-valuemax": null,
76
+ "aria-valuemin": null,
77
+ "aria-valuenow": null,
78
+ "aria-valuetext": null,
79
+ autoCorrect: "off",
80
+ spellCheck: "false",
81
+ onBlur: commit
82
+ });
83
+ if (validationBehavior === "native") inputProps["aria-required"] = undefined;
84
+ return {
85
+ inputProps: inputProps,
86
+ ...otherProps
87
+ };
88
+ }
89
+
90
+
91
+ export {$f6896b05b2ecad12$export$77e32ca575a28fdf as useColorField};
92
+ //# sourceMappingURL=useColorField.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA6BM,SAAS,0CACd,KAA0B,EAC1B,KAAsB,EACtB,GAAgC;IAEhC,IAAI,cACF,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,sBACf,qBAAqB,QACtB,GAAG;IAEJ,IAAI,cACF,UAAU,cACV,UAAU,aACV,SAAS,aACT,SAAS,kBACT,cAAc,kBACd,cAAc,UACd,MAAM,EACP,GAAG;IAEJ,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,oBAAY,EAClC;oBACE;oBACA;oBACA;QACA,UAAU;QACV,UAAU;QACV,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,kBAAkB;QAClB,OAAO,aAAa,WAAW,QAAQ,KAAK;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reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaColorFieldProps} from '@react-types/color';\nimport {ColorFieldState} from '@react-stately/color';\nimport {\n HTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useState\n} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {useSpinButton} from '@react-aria/spinbutton';\nimport {ValidationResult} from '@react-types/shared';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: HTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a color field component.\n * Color fields allow users to enter and adjust a hex color value.\n */\nexport function useColorField(\n props: AriaColorFieldProps,\n state: ColorFieldState,\n ref: RefObject<HTMLInputElement>\n): ColorFieldAria {\n let {\n isDisabled,\n isReadOnly,\n isRequired,\n isWheelDisabled,\n validationBehavior = 'aria'\n } = props;\n\n let {\n colorValue,\n inputValue,\n increment,\n decrement,\n incrementToMax,\n decrementToMin,\n commit\n } = state;\n\n let inputId = useId();\n let {spinButtonProps} = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue: 0xFFFFFF,\n minValue: 0,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: colorValue ? colorValue.toHexInt() : undefined,\n textValue: colorValue ? colorValue.toString('hex') : undefined\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, ref);\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let {inputProps, ...otherProps} = useFormattedTextField(\n mergeProps(props, {\n id: inputId,\n value: inputValue,\n defaultValue: undefined,\n validate: undefined,\n [privateValidationStateProp]: state,\n type: 'text',\n autoComplete: 'off',\n onChange\n }), state, ref);\n\n inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {\n role: 'textbox',\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n onBlur: commit\n });\n\n if (validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n return {\n inputProps,\n ...otherProps\n };\n}\n"],"names":[],"version":3,"file":"useColorField.module.js.map"}