@react-aria/color 3.0.0-nightly.4567 → 3.0.0-nightly.4578
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.
- package/dist/ar-AE.main.js +3 -1
- package/dist/ar-AE.main.js.map +1 -1
- package/dist/ar-AE.mjs +3 -1
- package/dist/ar-AE.module.js +3 -1
- package/dist/ar-AE.module.js.map +1 -1
- package/dist/bg-BG.main.js +3 -1
- package/dist/bg-BG.main.js.map +1 -1
- package/dist/bg-BG.mjs +3 -1
- package/dist/bg-BG.module.js +3 -1
- package/dist/bg-BG.module.js.map +1 -1
- package/dist/cs-CZ.main.js +3 -1
- package/dist/cs-CZ.main.js.map +1 -1
- package/dist/cs-CZ.mjs +3 -1
- package/dist/cs-CZ.module.js +3 -1
- package/dist/cs-CZ.module.js.map +1 -1
- package/dist/da-DK.main.js +3 -1
- package/dist/da-DK.main.js.map +1 -1
- package/dist/da-DK.mjs +3 -1
- package/dist/da-DK.module.js +3 -1
- package/dist/da-DK.module.js.map +1 -1
- package/dist/de-DE.main.js +3 -1
- package/dist/de-DE.main.js.map +1 -1
- package/dist/de-DE.mjs +3 -1
- package/dist/de-DE.module.js +3 -1
- package/dist/de-DE.module.js.map +1 -1
- package/dist/el-GR.main.js +3 -1
- package/dist/el-GR.main.js.map +1 -1
- package/dist/el-GR.mjs +3 -1
- package/dist/el-GR.module.js +3 -1
- package/dist/el-GR.module.js.map +1 -1
- package/dist/en-US.main.js +3 -1
- package/dist/en-US.main.js.map +1 -1
- package/dist/en-US.mjs +3 -1
- package/dist/en-US.module.js +3 -1
- package/dist/en-US.module.js.map +1 -1
- package/dist/es-ES.main.js +3 -1
- package/dist/es-ES.main.js.map +1 -1
- package/dist/es-ES.mjs +3 -1
- package/dist/es-ES.module.js +3 -1
- package/dist/es-ES.module.js.map +1 -1
- package/dist/et-EE.main.js +3 -1
- package/dist/et-EE.main.js.map +1 -1
- package/dist/et-EE.mjs +3 -1
- package/dist/et-EE.module.js +3 -1
- package/dist/et-EE.module.js.map +1 -1
- package/dist/fi-FI.main.js +3 -1
- package/dist/fi-FI.main.js.map +1 -1
- package/dist/fi-FI.mjs +3 -1
- package/dist/fi-FI.module.js +3 -1
- package/dist/fi-FI.module.js.map +1 -1
- package/dist/fr-FR.main.js +3 -1
- package/dist/fr-FR.main.js.map +1 -1
- package/dist/fr-FR.mjs +3 -1
- package/dist/fr-FR.module.js +3 -1
- package/dist/fr-FR.module.js.map +1 -1
- package/dist/he-IL.main.js +3 -1
- package/dist/he-IL.main.js.map +1 -1
- package/dist/he-IL.mjs +3 -1
- package/dist/he-IL.module.js +3 -1
- package/dist/he-IL.module.js.map +1 -1
- package/dist/hr-HR.main.js +3 -1
- package/dist/hr-HR.main.js.map +1 -1
- package/dist/hr-HR.mjs +3 -1
- package/dist/hr-HR.module.js +3 -1
- package/dist/hr-HR.module.js.map +1 -1
- package/dist/hu-HU.main.js +3 -1
- package/dist/hu-HU.main.js.map +1 -1
- package/dist/hu-HU.mjs +3 -1
- package/dist/hu-HU.module.js +3 -1
- package/dist/hu-HU.module.js.map +1 -1
- package/dist/import.mjs +5 -1
- package/dist/it-IT.main.js +3 -1
- package/dist/it-IT.main.js.map +1 -1
- package/dist/it-IT.mjs +3 -1
- package/dist/it-IT.module.js +3 -1
- package/dist/it-IT.module.js.map +1 -1
- package/dist/ja-JP.main.js +3 -1
- package/dist/ja-JP.main.js.map +1 -1
- package/dist/ja-JP.mjs +3 -1
- package/dist/ja-JP.module.js +3 -1
- package/dist/ja-JP.module.js.map +1 -1
- package/dist/ko-KR.main.js +3 -1
- package/dist/ko-KR.main.js.map +1 -1
- package/dist/ko-KR.mjs +3 -1
- package/dist/ko-KR.module.js +3 -1
- package/dist/ko-KR.module.js.map +1 -1
- package/dist/lt-LT.main.js +3 -1
- package/dist/lt-LT.main.js.map +1 -1
- package/dist/lt-LT.mjs +3 -1
- package/dist/lt-LT.module.js +3 -1
- package/dist/lt-LT.module.js.map +1 -1
- package/dist/lv-LV.main.js +3 -1
- package/dist/lv-LV.main.js.map +1 -1
- package/dist/lv-LV.mjs +3 -1
- package/dist/lv-LV.module.js +3 -1
- package/dist/lv-LV.module.js.map +1 -1
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -1
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +3 -1
- package/dist/nb-NO.main.js.map +1 -1
- package/dist/nb-NO.mjs +3 -1
- package/dist/nb-NO.module.js +3 -1
- package/dist/nb-NO.module.js.map +1 -1
- package/dist/nl-NL.main.js +3 -1
- package/dist/nl-NL.main.js.map +1 -1
- package/dist/nl-NL.mjs +3 -1
- package/dist/nl-NL.module.js +3 -1
- package/dist/nl-NL.module.js.map +1 -1
- package/dist/pl-PL.main.js +3 -1
- package/dist/pl-PL.main.js.map +1 -1
- package/dist/pl-PL.mjs +3 -1
- package/dist/pl-PL.module.js +3 -1
- package/dist/pl-PL.module.js.map +1 -1
- package/dist/pt-BR.main.js +3 -1
- package/dist/pt-BR.main.js.map +1 -1
- package/dist/pt-BR.mjs +3 -1
- package/dist/pt-BR.module.js +3 -1
- package/dist/pt-BR.module.js.map +1 -1
- package/dist/pt-PT.main.js +3 -1
- package/dist/pt-PT.main.js.map +1 -1
- package/dist/pt-PT.mjs +3 -1
- package/dist/pt-PT.module.js +3 -1
- package/dist/pt-PT.module.js.map +1 -1
- package/dist/ro-RO.main.js +3 -1
- package/dist/ro-RO.main.js.map +1 -1
- package/dist/ro-RO.mjs +3 -1
- package/dist/ro-RO.module.js +3 -1
- package/dist/ro-RO.module.js.map +1 -1
- package/dist/ru-RU.main.js +3 -1
- package/dist/ru-RU.main.js.map +1 -1
- package/dist/ru-RU.mjs +3 -1
- package/dist/ru-RU.module.js +3 -1
- package/dist/ru-RU.module.js.map +1 -1
- package/dist/sk-SK.main.js +3 -1
- package/dist/sk-SK.main.js.map +1 -1
- package/dist/sk-SK.mjs +3 -1
- package/dist/sk-SK.module.js +3 -1
- package/dist/sk-SK.module.js.map +1 -1
- package/dist/sl-SI.main.js +3 -1
- package/dist/sl-SI.main.js.map +1 -1
- package/dist/sl-SI.mjs +3 -1
- package/dist/sl-SI.module.js +3 -1
- package/dist/sl-SI.module.js.map +1 -1
- package/dist/sr-SP.main.js +3 -1
- package/dist/sr-SP.main.js.map +1 -1
- package/dist/sr-SP.mjs +3 -1
- package/dist/sr-SP.module.js +3 -1
- package/dist/sr-SP.module.js.map +1 -1
- package/dist/sv-SE.main.js +3 -1
- package/dist/sv-SE.main.js.map +1 -1
- package/dist/sv-SE.mjs +3 -1
- package/dist/sv-SE.module.js +3 -1
- package/dist/sv-SE.module.js.map +1 -1
- package/dist/tr-TR.main.js +3 -1
- package/dist/tr-TR.main.js.map +1 -1
- package/dist/tr-TR.mjs +3 -1
- package/dist/tr-TR.module.js +3 -1
- package/dist/tr-TR.module.js.map +1 -1
- package/dist/types.d.ts +41 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +3 -1
- package/dist/uk-UA.main.js.map +1 -1
- package/dist/uk-UA.mjs +3 -1
- package/dist/uk-UA.module.js +3 -1
- package/dist/uk-UA.module.js.map +1 -1
- package/dist/useColorArea.main.js +7 -7
- package/dist/useColorArea.main.js.map +1 -1
- package/dist/useColorArea.mjs +7 -7
- package/dist/useColorArea.module.js +7 -7
- package/dist/useColorArea.module.js.map +1 -1
- package/dist/useColorAreaGradient.main.js +65 -171
- package/dist/useColorAreaGradient.main.js.map +1 -1
- package/dist/useColorAreaGradient.mjs +65 -171
- package/dist/useColorAreaGradient.module.js +65 -171
- package/dist/useColorAreaGradient.module.js.map +1 -1
- package/dist/useColorChannelField.main.js +36 -0
- package/dist/useColorChannelField.main.js.map +1 -0
- package/dist/useColorChannelField.mjs +31 -0
- package/dist/useColorChannelField.module.js +31 -0
- package/dist/useColorChannelField.module.js.map +1 -0
- package/dist/useColorField.main.js +3 -2
- package/dist/useColorField.main.js.map +1 -1
- package/dist/useColorField.mjs +3 -2
- package/dist/useColorField.module.js +3 -2
- package/dist/useColorField.module.js.map +1 -1
- package/dist/useColorSlider.main.js +29 -2
- package/dist/useColorSlider.main.js.map +1 -1
- package/dist/useColorSlider.mjs +29 -2
- package/dist/useColorSlider.module.js +29 -2
- package/dist/useColorSlider.module.js.map +1 -1
- package/dist/useColorSwatch.main.js +67 -0
- package/dist/useColorSwatch.main.js.map +1 -0
- package/dist/useColorSwatch.mjs +62 -0
- package/dist/useColorSwatch.module.js +62 -0
- package/dist/useColorSwatch.module.js.map +1 -0
- package/dist/useColorWheel.main.js +18 -4
- package/dist/useColorWheel.main.js.map +1 -1
- package/dist/useColorWheel.mjs +18 -4
- package/dist/useColorWheel.module.js +18 -4
- package/dist/useColorWheel.module.js.map +1 -1
- package/dist/zh-CN.main.js +3 -1
- package/dist/zh-CN.main.js.map +1 -1
- package/dist/zh-CN.mjs +3 -1
- package/dist/zh-CN.module.js +3 -1
- package/dist/zh-CN.module.js.map +1 -1
- package/dist/zh-TW.main.js +3 -1
- package/dist/zh-TW.main.js.map +1 -1
- package/dist/zh-TW.mjs +3 -1
- package/dist/zh-TW.module.js +3 -1
- package/dist/zh-TW.module.js.map +1 -1
- package/package.json +14 -13
- package/src/index.ts +4 -0
- package/src/useColorArea.ts +6 -9
- package/src/useColorAreaGradient.ts +66 -189
- package/src/useColorChannelField.ts +37 -0
- package/src/useColorField.ts +18 -14
- package/src/useColorSlider.ts +21 -3
- package/src/useColorSwatch.ts +74 -0
- package/src/useColorWheel.ts +18 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {useMemo as $hLqEt$useMemo} from "react";
|
|
2
|
+
import {parseColor as $hLqEt$parseColor} from "@react-stately/color";
|
|
2
3
|
|
|
3
4
|
/*
|
|
4
5
|
* Copyright 2022 Adobe. All rights reserved.
|
|
@@ -11,171 +12,71 @@ import {useMemo as $hLqEt$useMemo} from "react";
|
|
|
11
12
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
13
|
* governing permissions and limitations under the License.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|
|
15
|
+
|
|
16
|
+
const $40297c24c53588e6$var$hue = (color)=>[
|
|
17
|
+
0,
|
|
18
|
+
60,
|
|
19
|
+
120,
|
|
20
|
+
180,
|
|
21
|
+
240,
|
|
22
|
+
300,
|
|
23
|
+
360
|
|
24
|
+
].map((hue)=>color.withChannelValue("hue", hue).toString("css")).join(", ");
|
|
25
|
+
const $40297c24c53588e6$var$saturation = (color)=>`${color.withChannelValue("saturation", 0)}, transparent`;
|
|
26
|
+
const $40297c24c53588e6$var$hslChannels = {
|
|
27
|
+
hue: $40297c24c53588e6$var$hue,
|
|
28
|
+
saturation: $40297c24c53588e6$var$saturation,
|
|
29
|
+
lightness: ()=>"black, transparent, white"
|
|
119
30
|
};
|
|
120
|
-
const $40297c24c53588e6$var$
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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;
|
|
31
|
+
const $40297c24c53588e6$var$hsbChannels = {
|
|
32
|
+
hue: $40297c24c53588e6$var$hue,
|
|
33
|
+
saturation: $40297c24c53588e6$var$saturation,
|
|
34
|
+
brightness: ()=>"black, transparent"
|
|
132
35
|
};
|
|
133
|
-
function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel,
|
|
36
|
+
function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, yChannel: yChannel }) {
|
|
134
37
|
let returnVal = (0, $hLqEt$useMemo)(()=>{
|
|
135
|
-
let
|
|
136
|
-
|
|
137
|
-
direction === "rtl" ? "left" : "right"
|
|
138
|
-
];
|
|
139
|
-
let dir = false;
|
|
140
|
-
let background = {
|
|
141
|
-
colorAreaStyles: {},
|
|
142
|
-
gradientStyles: {}
|
|
143
|
-
};
|
|
38
|
+
let end = direction === "rtl" ? "left" : "right";
|
|
39
|
+
let colorAreaStyles = {};
|
|
144
40
|
let zValue = state.value.getChannelValue(zChannel);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
41
|
+
switch(state.value.getColorSpace()){
|
|
42
|
+
case "rgb":
|
|
43
|
+
{
|
|
44
|
+
let rgb = (0, $hLqEt$parseColor)("rgb(0, 0, 0)");
|
|
45
|
+
colorAreaStyles = {
|
|
46
|
+
background: [
|
|
47
|
+
// The screen blend mode multiplies the inverse of each channel, e.g. 1 - (1 - a) * (1 - b).
|
|
48
|
+
// Create a layer for each channel, with the other channels as 0. After blending, this should
|
|
49
|
+
// result in the gradients being combined channel by channel.
|
|
50
|
+
`linear-gradient(to ${end}, ${rgb.withChannelValue(xChannel, 0)}, ${rgb.withChannelValue(xChannel, 255)})`,
|
|
51
|
+
`linear-gradient(to top, ${rgb.withChannelValue(yChannel, 0)}, ${rgb.withChannelValue(yChannel, 255)})`,
|
|
52
|
+
rgb.withChannelValue(zChannel, zValue)
|
|
53
|
+
].join(","),
|
|
54
|
+
backgroundBlendMode: "screen"
|
|
55
|
+
};
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "hsl":
|
|
59
|
+
{
|
|
60
|
+
let channels = state.value.getColorChannels();
|
|
61
|
+
let value = (0, $hLqEt$parseColor)("hsl(0, 100%, 50%)").withChannelValue(zChannel, zValue);
|
|
62
|
+
let bg = channels.filter((c)=>c !== zChannel).map((c)=>`linear-gradient(to ${c === xChannel ? end : "top"}, ${$40297c24c53588e6$var$hslChannels[c](value)})`).reverse();
|
|
63
|
+
if (zChannel === "hue") bg.push(value.toString("css"));
|
|
64
|
+
colorAreaStyles = {
|
|
65
|
+
background: bg.join(", ")
|
|
66
|
+
};
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case "hsb":
|
|
70
|
+
{
|
|
71
|
+
let channels = state.value.getColorChannels();
|
|
72
|
+
let value = (0, $hLqEt$parseColor)("hsb(0, 100%, 100%)").withChannelValue(zChannel, zValue);
|
|
73
|
+
let bg = channels.filter((c)=>c !== zChannel).map((c)=>`linear-gradient(to ${c === xChannel ? end : "top"}, ${$40297c24c53588e6$var$hsbChannels[c](value)})`).reverse();
|
|
74
|
+
if (zChannel === "hue") bg.push(value.toString("css"));
|
|
75
|
+
colorAreaStyles = {
|
|
76
|
+
background: bg.join(", ")
|
|
77
|
+
};
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
179
80
|
}
|
|
180
81
|
let { x: x, y: y } = state.getThumbPosition();
|
|
181
82
|
if (direction === "rtl") x = 1 - x;
|
|
@@ -188,14 +89,7 @@ function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state
|
|
|
188
89
|
position: "relative",
|
|
189
90
|
touchAction: "none",
|
|
190
91
|
...forcedColorAdjustNoneStyle,
|
|
191
|
-
...
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
gradientStyleProps: {
|
|
195
|
-
style: {
|
|
196
|
-
touchAction: "none",
|
|
197
|
-
...forcedColorAdjustNoneStyle,
|
|
198
|
-
...background.gradientStyles
|
|
92
|
+
...colorAreaStyles
|
|
199
93
|
}
|
|
200
94
|
},
|
|
201
95
|
thumbStyleProps: {
|
|
@@ -203,7 +97,7 @@ function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state
|
|
|
203
97
|
position: "absolute",
|
|
204
98
|
left: `${x * 100}%`,
|
|
205
99
|
top: `${y * 100}%`,
|
|
206
|
-
transform: "translate(
|
|
100
|
+
transform: "translate(-50%, -50%)",
|
|
207
101
|
touchAction: "none",
|
|
208
102
|
...forcedColorAdjustNoneStyle
|
|
209
103
|
}
|
|
@@ -214,7 +108,7 @@ function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state
|
|
|
214
108
|
state,
|
|
215
109
|
zChannel,
|
|
216
110
|
xChannel,
|
|
217
|
-
|
|
111
|
+
yChannel
|
|
218
112
|
]);
|
|
219
113
|
return returnVal;
|
|
220
114
|
}
|
|
@@ -1 +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,mBAAmB,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAA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BAC9B;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"}
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;AAUA;;AAMA,MAAM,4BAAM,CAAC,QAAiB;QAAC;QAAG;QAAI;QAAK;QAAK;QAAK;QAAK;KAAI,CAAC,GAAG,CAAC,CAAA,MAAO,MAAM,gBAAgB,CAAC,OAAO,KAAK,QAAQ,CAAC,QAAQ,IAAI,CAAC;AACnI,MAAM,mCAAa,CAAC,QAAiB,CAAC,EAAE,MAAM,gBAAgB,CAAC,cAAc,GAAG,aAAa,CAAC;AAE9F,MAAM,oCAAc;SAClB;gBACA;IACA,WAAW,IAAM;AACnB;AAEA,MAAM,oCAAc;SAClB;gBACA;IACA,YAAY,IAAM;AACpB;AAWO,SAAS,0CAAqB,aAAC,SAAS,SAAE,KAAK,YAAE,QAAQ,YAAE,QAAQ,YAAE,QAAQ,EAAC;IACnF,IAAI,YAAY,CAAA,GAAA,cAAM,EAAa;QACjC,IAAI,MAAM,cAAc,QAAQ,SAAS;QACzC,IAAI,kBAAkB,CAAC;QACvB,IAAI,SAAS,MAAM,KAAK,CAAC,eAAe,CAAC;QAEzC,OAAQ,MAAM,KAAK,CAAC,aAAa;YAC/B,KAAK;gBAAO;oBACV,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;oBACrB,kBAAkB;wB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IAAI,CAAC,MAAM,QAAQ,CAAC;oBAGzB,kBAAkB;wBAChB,YAAY,GAAG,IAAI,CAAC;oBACtB;oBACA;gBACF;QACF;QAEA,IAAI,KAAC,CAAC,KAAE,CAAC,EAAC,GAAG,MAAM,gBAAgB;QAEnC,IAAI,cAAc,OAChB,IAAI,IAAI;QAGV,IAAI,6BAA6B;YAAC,mBAAmB;QAAM;QAE3D,OAAO;YACL,qBAAqB;gBACnB,OAAO;oBACL,UAAU;oBACV,aAAa;oBACb,GAAG,0BAA0B;oBAC7B,GAAG,eAAe;gBACpB;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;KAAS;IAEnD,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 {Color} from '@react-types/color';\nimport {CSSProperties, useMemo} from 'react';\nimport {parseColor} from '@react-stately/color';\n\nconst hue = (color: Color) => [0, 60, 120, 180, 240, 300, 360].map(hue => color.withChannelValue('hue', hue).toString('css')).join(', ');\nconst saturation = (color: Color) => `${color.withChannelValue('saturation', 0)}, transparent`;\n\nconst hslChannels = {\n hue,\n saturation,\n lightness: () => 'black, transparent, white'\n};\n\nconst hsbChannels = {\n hue,\n saturation,\n brightness: () => 'black, transparent'\n};\n\ninterface Gradients {\n colorAreaStyleProps: {\n style: CSSProperties\n },\n thumbStyleProps: {\n style: CSSProperties\n }\n}\n\nexport function useColorAreaGradient({direction, state, zChannel, xChannel, yChannel}): Gradients {\n let returnVal = useMemo<Gradients>(() => {\n let end = direction === 'rtl' ? 'left' : 'right';\n let colorAreaStyles = {};\n let zValue = state.value.getChannelValue(zChannel);\n\n switch (state.value.getColorSpace()) {\n case 'rgb': {\n let rgb = parseColor('rgb(0, 0, 0)');\n colorAreaStyles = {\n background: [\n // The screen blend mode multiplies the inverse of each channel, e.g. 1 - (1 - a) * (1 - b).\n // Create a layer for each channel, with the other channels as 0. After blending, this should\n // result in the gradients being combined channel by channel.\n `linear-gradient(to ${end}, ${rgb.withChannelValue(xChannel, 0)}, ${rgb.withChannelValue(xChannel, 255)})`,\n `linear-gradient(to top, ${rgb.withChannelValue(yChannel, 0)}, ${rgb.withChannelValue(yChannel, 255)})`,\n rgb.withChannelValue(zChannel, zValue)\n ].join(','),\n backgroundBlendMode: 'screen'\n };\n break;\n }\n case 'hsl': {\n let channels = state.value.getColorChannels();\n let value = parseColor('hsl(0, 100%, 50%)').withChannelValue(zChannel, zValue);\n\n let bg = channels\n .filter(c => c !== zChannel)\n .map(c => `linear-gradient(to ${c === xChannel ? end : 'top'}, ${hslChannels[c](value)})`)\n .reverse();\n if (zChannel === 'hue') {\n bg.push(value.toString('css'));\n }\n \n colorAreaStyles = {\n background: bg.join(', ')\n };\n break;\n }\n case 'hsb': {\n let channels = state.value.getColorChannels();\n let value = parseColor('hsb(0, 100%, 100%)').withChannelValue(zChannel, zValue);\n\n let bg = channels\n .filter(c => c !== zChannel)\n .map(c => `linear-gradient(to ${c === xChannel ? end : 'top'}, ${hsbChannels[c](value)})`)\n .reverse();\n if (zChannel === 'hue') {\n bg.push(value.toString('css'));\n }\n \n colorAreaStyles = {\n background: bg.join(', ')\n };\n break;\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 ...colorAreaStyles\n }\n },\n thumbStyleProps: {\n style: {\n position: 'absolute',\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n }\n };\n }, [direction, state, zChannel, xChannel, yChannel]);\n\n return returnVal;\n}\n\n"],"names":[],"version":3,"file":"useColorAreaGradient.module.js.map"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var $bkgtN$reactarianumberfield = require("@react-aria/numberfield");
|
|
2
|
+
var $bkgtN$reactariai18n = require("@react-aria/i18n");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useColorChannelField", () => $d84c0c836f6e3601$export$e55dd820142d3131);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function $d84c0c836f6e3601$export$e55dd820142d3131(props, state, inputRef) {
|
|
23
|
+
let { locale: locale } = (0, $bkgtN$reactariai18n.useLocale)();
|
|
24
|
+
return (0, $bkgtN$reactarianumberfield.useNumberField)({
|
|
25
|
+
...props,
|
|
26
|
+
value: undefined,
|
|
27
|
+
defaultValue: undefined,
|
|
28
|
+
onChange: undefined,
|
|
29
|
+
validate: undefined,
|
|
30
|
+
// Provide a default aria-label if no other label is provided.
|
|
31
|
+
"aria-label": props["aria-label"] || (props.label || props["aria-labelledby"] ? undefined : state.colorValue.getChannelName(props.channel, locale))
|
|
32
|
+
}, state, inputRef);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=useColorChannelField.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAeM,SAAS,0CAAqB,KAAiC,EAAE,KAA6B,EAAE,QAAqC;IAC1I,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,8BAAQ;IACvB,OAAO,CAAA,GAAA,0CAAa,EAAE;QACpB,GAAG,KAAK;QACR,OAAO;QACP,cAAc;QACd,UAAU;QACV,UAAU;QACV,8DAA8D;QAC9D,cAAc,KAAK,CAAC,aAAa,IAAK,CAAA,MAAM,KAAK,IAAI,KAAK,CAAC,kBAAkB,GAAG,YAAY,MAAM,UAAU,CAAC,cAAc,CAAC,MAAM,OAAO,EAAE,OAAM;IACnJ,GAAG,OAAO;AACZ","sources":["packages/@react-aria/color/src/useColorChannelField.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps} from '@react-types/shared';\nimport {ColorChannelFieldProps, ColorChannelFieldState} from '@react-stately/color';\nimport {NumberFieldAria, useNumberField} from '@react-aria/numberfield';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaColorChannelFieldProps extends ColorChannelFieldProps, AriaLabelingProps {}\nexport interface ColorChannelFieldAria extends NumberFieldAria {}\n\n/**\n * Provides the behavior and accessibility implementation for a color channel field, allowing users to edit the\n * value of an individual color channel.\n */\nexport function useColorChannelField(props: AriaColorChannelFieldProps, state: ColorChannelFieldState, inputRef: RefObject<HTMLInputElement>): ColorChannelFieldAria {\n let {locale} = useLocale();\n return useNumberField({\n ...props,\n value: undefined,\n defaultValue: undefined,\n onChange: undefined,\n validate: undefined,\n // Provide a default aria-label if no other label is provided.\n 'aria-label': props['aria-label'] || (props.label || props['aria-labelledby'] ? undefined : state.colorValue.getChannelName(props.channel, locale))\n }, state, inputRef);\n}\n"],"names":[],"version":3,"file":"useColorChannelField.main.js.map"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {useNumberField as $5aC6d$useNumberField} from "@react-aria/numberfield";
|
|
2
|
+
import {useLocale as $5aC6d$useLocale} from "@react-aria/i18n";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $5e632d1ff0188f00$export$e55dd820142d3131(props, state, inputRef) {
|
|
17
|
+
let { locale: locale } = (0, $5aC6d$useLocale)();
|
|
18
|
+
return (0, $5aC6d$useNumberField)({
|
|
19
|
+
...props,
|
|
20
|
+
value: undefined,
|
|
21
|
+
defaultValue: undefined,
|
|
22
|
+
onChange: undefined,
|
|
23
|
+
validate: undefined,
|
|
24
|
+
// Provide a default aria-label if no other label is provided.
|
|
25
|
+
"aria-label": props["aria-label"] || (props.label || props["aria-labelledby"] ? undefined : state.colorValue.getChannelName(props.channel, locale))
|
|
26
|
+
}, state, inputRef);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export {$5e632d1ff0188f00$export$e55dd820142d3131 as useColorChannelField};
|
|
31
|
+
//# sourceMappingURL=useColorChannelField.mjs.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {useNumberField as $5aC6d$useNumberField} from "@react-aria/numberfield";
|
|
2
|
+
import {useLocale as $5aC6d$useLocale} from "@react-aria/i18n";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $5e632d1ff0188f00$export$e55dd820142d3131(props, state, inputRef) {
|
|
17
|
+
let { locale: locale } = (0, $5aC6d$useLocale)();
|
|
18
|
+
return (0, $5aC6d$useNumberField)({
|
|
19
|
+
...props,
|
|
20
|
+
value: undefined,
|
|
21
|
+
defaultValue: undefined,
|
|
22
|
+
onChange: undefined,
|
|
23
|
+
validate: undefined,
|
|
24
|
+
// Provide a default aria-label if no other label is provided.
|
|
25
|
+
"aria-label": props["aria-label"] || (props.label || props["aria-labelledby"] ? undefined : state.colorValue.getChannelName(props.channel, locale))
|
|
26
|
+
}, state, inputRef);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export {$5e632d1ff0188f00$export$e55dd820142d3131 as useColorChannelField};
|
|
31
|
+
//# sourceMappingURL=useColorChannelField.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAeM,SAAS,0CAAqB,KAAiC,EAAE,KAA6B,EAAE,QAAqC;IAC1I,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,gBAAQ;IACvB,OAAO,CAAA,GAAA,qBAAa,EAAE;QACpB,GAAG,KAAK;QACR,OAAO;QACP,cAAc;QACd,UAAU;QACV,UAAU;QACV,8DAA8D;QAC9D,cAAc,KAAK,CAAC,aAAa,IAAK,CAAA,MAAM,KAAK,IAAI,KAAK,CAAC,kBAAkB,GAAG,YAAY,MAAM,UAAU,CAAC,cAAc,CAAC,MAAM,OAAO,EAAE,OAAM;IACnJ,GAAG,OAAO;AACZ","sources":["packages/@react-aria/color/src/useColorChannelField.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaLabelingProps} from '@react-types/shared';\nimport {ColorChannelFieldProps, ColorChannelFieldState} from '@react-stately/color';\nimport {NumberFieldAria, useNumberField} from '@react-aria/numberfield';\nimport {RefObject} from 'react';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaColorChannelFieldProps extends ColorChannelFieldProps, AriaLabelingProps {}\nexport interface ColorChannelFieldAria extends NumberFieldAria {}\n\n/**\n * Provides the behavior and accessibility implementation for a color channel field, allowing users to edit the\n * value of an individual color channel.\n */\nexport function useColorChannelField(props: AriaColorChannelFieldProps, state: ColorChannelFieldState, inputRef: RefObject<HTMLInputElement>): ColorChannelFieldAria {\n let {locale} = useLocale();\n return useNumberField({\n ...props,\n value: undefined,\n defaultValue: undefined,\n onChange: undefined,\n validate: undefined,\n // Provide a default aria-label if no other label is provided.\n 'aria-label': props['aria-label'] || (props.label || props['aria-labelledby'] ? undefined : state.colorValue.getChannelName(props.channel, locale))\n }, state, inputRef);\n}\n"],"names":[],"version":3,"file":"useColorChannelField.module.js.map"}
|
|
@@ -66,7 +66,8 @@ function $58c850037bc7a7ce$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
66
66
|
let onChange = (value)=>{
|
|
67
67
|
if (state.validate(value)) state.setInputValue(value);
|
|
68
68
|
};
|
|
69
|
-
let { inputProps: inputProps, ...otherProps } = (0, $grujV$reactariatextfield.useFormattedTextField)(
|
|
69
|
+
let { inputProps: inputProps, ...otherProps } = (0, $grujV$reactariatextfield.useFormattedTextField)({
|
|
70
|
+
...props,
|
|
70
71
|
id: inputId,
|
|
71
72
|
value: inputValue,
|
|
72
73
|
defaultValue: undefined,
|
|
@@ -75,7 +76,7 @@ function $58c850037bc7a7ce$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
75
76
|
type: "text",
|
|
76
77
|
autoComplete: "off",
|
|
77
78
|
onChange: onChange
|
|
78
|
-
}
|
|
79
|
+
}, state, ref);
|
|
79
80
|
inputProps = (0, $grujV$reactariautils.mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
80
81
|
role: "textbox",
|
|
81
82
|
"aria-valuemax": null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;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AI,cAAC,UAAU,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,+CAAoB,EAAE;QACtD,GAAG,KAAK;QACR,IAAI;QACJ,OAAO;QACP,cAAc;QACd,UAAU;QACV,CAAC,CAAA,GAAA,kDAAyB,EAAE,EAAE;QAC9B,MAAM;QACN,cAAc;kBACd;IACF,GAAG,OAAO;IAEV,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 {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\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';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes\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 ...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"}
|
package/dist/useColorField.mjs
CHANGED
|
@@ -60,7 +60,8 @@ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
60
60
|
let onChange = (value)=>{
|
|
61
61
|
if (state.validate(value)) state.setInputValue(value);
|
|
62
62
|
};
|
|
63
|
-
let { inputProps: inputProps, ...otherProps } = (0, $f8mV7$useFormattedTextField)(
|
|
63
|
+
let { inputProps: inputProps, ...otherProps } = (0, $f8mV7$useFormattedTextField)({
|
|
64
|
+
...props,
|
|
64
65
|
id: inputId,
|
|
65
66
|
value: inputValue,
|
|
66
67
|
defaultValue: undefined,
|
|
@@ -69,7 +70,7 @@ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
69
70
|
type: "text",
|
|
70
71
|
autoComplete: "off",
|
|
71
72
|
onChange: onChange
|
|
72
|
-
}
|
|
73
|
+
}, state, ref);
|
|
73
74
|
inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
74
75
|
role: "textbox",
|
|
75
76
|
"aria-valuemax": null,
|
|
@@ -60,7 +60,8 @@ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
60
60
|
let onChange = (value)=>{
|
|
61
61
|
if (state.validate(value)) state.setInputValue(value);
|
|
62
62
|
};
|
|
63
|
-
let { inputProps: inputProps, ...otherProps } = (0, $f8mV7$useFormattedTextField)(
|
|
63
|
+
let { inputProps: inputProps, ...otherProps } = (0, $f8mV7$useFormattedTextField)({
|
|
64
|
+
...props,
|
|
64
65
|
id: inputId,
|
|
65
66
|
value: inputValue,
|
|
66
67
|
defaultValue: undefined,
|
|
@@ -69,7 +70,7 @@ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
|
69
70
|
type: "text",
|
|
70
71
|
autoComplete: "off",
|
|
71
72
|
onChange: onChange
|
|
72
|
-
}
|
|
73
|
+
}, state, ref);
|
|
73
74
|
inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
74
75
|
role: "textbox",
|
|
75
76
|
"aria-valuemax": null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAiCM,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;QAC5C,WAAW,aAAa,WAAW,QAAQ,CAAC,SAAS;IACvD;IAGF,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;oBAAC;QAAY,qBAAqB;IAAc;IAExF,IAAI,UAAU,CAAA,GAAA,kBAAU,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,qBAAa,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,4BAAoB,EAAE;QACtD,GAAG,KAAK;QACR,IAAI;QACJ,OAAO;QACP,cAAc;QACd,UAAU;QACV,CAAC,CAAA,GAAA,iCAAyB,EAAE,EAAE;QAC9B,MAAM;QACN,cAAc;kBACd;IACF,GAAG,OAAO;IAEV,aAAa,CAAA,GAAA,iBAAS,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 {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\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';\n\nexport interface ColorFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: DOMAttributes\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 ...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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var $edxco$reactariautils = require("@react-aria/utils");
|
|
2
2
|
var $edxco$reactariai18n = require("@react-aria/i18n");
|
|
3
3
|
var $edxco$reactariaslider = require("@react-aria/slider");
|
|
4
|
+
var $edxco$reactariavisuallyhidden = require("@react-aria/visually-hidden");
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
function $parcel$export(e, n, v, s) {
|
|
@@ -21,6 +22,7 @@ $parcel$export(module.exports, "useColorSlider", () => $afbb9647440a7f5b$export$
|
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
24
|
|
|
25
|
+
|
|
24
26
|
function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
25
27
|
let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
|
|
26
28
|
let { locale: locale, direction: direction } = (0, $edxco$reactariai18n.useLocale)();
|
|
@@ -47,7 +49,18 @@ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
|
47
49
|
else to = "left";
|
|
48
50
|
switch(channel){
|
|
49
51
|
case "hue":
|
|
50
|
-
|
|
52
|
+
{
|
|
53
|
+
let stops = [
|
|
54
|
+
0,
|
|
55
|
+
60,
|
|
56
|
+
120,
|
|
57
|
+
180,
|
|
58
|
+
240,
|
|
59
|
+
300,
|
|
60
|
+
360
|
|
61
|
+
].map((hue)=>value.withChannelValue("hue", hue).toString("css")).join(", ");
|
|
62
|
+
return `linear-gradient(to ${to}, ${stops})`;
|
|
63
|
+
}
|
|
51
64
|
case "lightness":
|
|
52
65
|
{
|
|
53
66
|
// We have to add an extra color stop in the middle so that the hue shows up at all.
|
|
@@ -79,6 +92,14 @@ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
|
79
92
|
};
|
|
80
93
|
if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
|
|
81
94
|
else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
|
|
95
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $edxco$reactariavisuallyhidden.useVisuallyHidden)({
|
|
96
|
+
style: {
|
|
97
|
+
opacity: "0.0001",
|
|
98
|
+
width: "100%",
|
|
99
|
+
height: "100%",
|
|
100
|
+
pointerEvents: "none"
|
|
101
|
+
}
|
|
102
|
+
});
|
|
82
103
|
return {
|
|
83
104
|
trackProps: {
|
|
84
105
|
...(0, $edxco$reactariautils.mergeProps)(groupProps, trackProps),
|
|
@@ -88,7 +109,13 @@ function $afbb9647440a7f5b$export$106b7a4e66508f66(props, state) {
|
|
|
88
109
|
background: generateBackground()
|
|
89
110
|
}
|
|
90
111
|
},
|
|
91
|
-
inputProps:
|
|
112
|
+
inputProps: {
|
|
113
|
+
...inputProps,
|
|
114
|
+
style: {
|
|
115
|
+
...inputProps.style,
|
|
116
|
+
...visuallyHiddenProps.style
|
|
117
|
+
}
|
|
118
|
+
},
|
|
92
119
|
thumbProps: {
|
|
93
120
|
...thumbProps,
|
|
94
121
|
style: {
|