@react-aria/color 3.0.0-beta.30 → 3.0.0-beta.32
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 +11 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +13 -0
- package/dist/ar-AE.module.js +13 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +11 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +13 -0
- package/dist/bg-BG.module.js +13 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +11 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +13 -0
- package/dist/cs-CZ.module.js +13 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +11 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +13 -0
- package/dist/da-DK.module.js +13 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +11 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +13 -0
- package/dist/de-DE.module.js +13 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +11 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +13 -0
- package/dist/el-GR.module.js +13 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +11 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +13 -0
- package/dist/en-US.module.js +13 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +11 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +13 -0
- package/dist/es-ES.module.js +13 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +11 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +13 -0
- package/dist/et-EE.module.js +13 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +11 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +13 -0
- package/dist/fi-FI.module.js +13 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +11 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +13 -0
- package/dist/fr-FR.module.js +13 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +11 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +13 -0
- package/dist/he-IL.module.js +13 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +11 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +13 -0
- package/dist/hr-HR.module.js +13 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +11 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +13 -0
- package/dist/hu-HU.module.js +13 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +7 -1357
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +11 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +13 -0
- package/dist/it-IT.module.js +13 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +11 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +13 -0
- package/dist/ja-JP.module.js +13 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +11 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +13 -0
- package/dist/ko-KR.module.js +13 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +11 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +13 -0
- package/dist/lt-LT.module.js +13 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +11 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +13 -0
- package/dist/lv-LV.module.js +13 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +12 -1360
- package/dist/main.js.map +1 -1
- package/dist/module.js +7 -1357
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +11 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +13 -0
- package/dist/nb-NO.module.js +13 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +11 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +13 -0
- package/dist/nl-NL.module.js +13 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +11 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +13 -0
- package/dist/pl-PL.module.js +13 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +11 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +13 -0
- package/dist/pt-BR.module.js +13 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +11 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +13 -0
- package/dist/pt-PT.module.js +13 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +11 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +13 -0
- package/dist/ro-RO.module.js +13 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +11 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +13 -0
- package/dist/ru-RU.module.js +13 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +11 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +13 -0
- package/dist/sk-SK.module.js +13 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +11 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +13 -0
- package/dist/sl-SI.module.js +13 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +11 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +13 -0
- package/dist/sr-SP.module.js +13 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +11 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +13 -0
- package/dist/sv-SE.module.js +13 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +11 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +13 -0
- package/dist/tr-TR.module.js +13 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +41 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +11 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +13 -0
- package/dist/uk-UA.module.js +13 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/useColorArea.main.js +404 -0
- package/dist/useColorArea.main.js.map +1 -0
- package/dist/useColorArea.mjs +399 -0
- package/dist/useColorArea.module.js +399 -0
- package/dist/useColorArea.module.js.map +1 -0
- package/dist/useColorAreaGradient.main.js +123 -0
- package/dist/useColorAreaGradient.main.js.map +1 -0
- package/dist/useColorAreaGradient.mjs +118 -0
- package/dist/useColorAreaGradient.module.js +118 -0
- package/dist/useColorAreaGradient.module.js.map +1 -0
- 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 +98 -0
- package/dist/useColorField.main.js.map +1 -0
- package/dist/useColorField.mjs +93 -0
- package/dist/useColorField.module.js +93 -0
- package/dist/useColorField.module.js.map +1 -0
- package/dist/useColorSlider.main.js +132 -0
- package/dist/useColorSlider.main.js.map +1 -0
- package/dist/useColorSlider.mjs +127 -0
- package/dist/useColorSlider.module.js +127 -0
- package/dist/useColorSlider.module.js.map +1 -0
- 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 +274 -0
- package/dist/useColorWheel.main.js.map +1 -0
- package/dist/useColorWheel.mjs +269 -0
- package/dist/useColorWheel.module.js +269 -0
- package/dist/useColorWheel.module.js.map +1 -0
- package/dist/zh-CN.main.js +11 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +13 -0
- package/dist/zh-CN.module.js +13 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +11 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +13 -0
- package/dist/zh-TW.module.js +13 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +14 -13
- package/src/index.ts +4 -0
- package/src/useColorArea.ts +32 -23
- package/src/useColorAreaGradient.ts +66 -189
- package/src/useColorChannelField.ts +37 -0
- package/src/useColorField.ts +18 -14
- package/src/useColorSlider.ts +28 -4
- package/src/useColorSwatch.ts +74 -0
- package/src/useColorWheel.ts +19 -5
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {useMemo as $hLqEt$useMemo} from "react";
|
|
2
|
+
import {parseColor as $hLqEt$parseColor} from "@react-stately/color";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2022 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
|
+
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"
|
|
30
|
+
};
|
|
31
|
+
const $40297c24c53588e6$var$hsbChannels = {
|
|
32
|
+
hue: $40297c24c53588e6$var$hue,
|
|
33
|
+
saturation: $40297c24c53588e6$var$saturation,
|
|
34
|
+
brightness: ()=>"black, transparent"
|
|
35
|
+
};
|
|
36
|
+
function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, yChannel: yChannel }) {
|
|
37
|
+
let returnVal = (0, $hLqEt$useMemo)(()=>{
|
|
38
|
+
let end = direction === "rtl" ? "left" : "right";
|
|
39
|
+
let colorAreaStyles = {};
|
|
40
|
+
let zValue = state.value.getChannelValue(zChannel);
|
|
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
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let { x: x, y: y } = state.getThumbPosition();
|
|
82
|
+
if (direction === "rtl") x = 1 - x;
|
|
83
|
+
let forcedColorAdjustNoneStyle = {
|
|
84
|
+
forcedColorAdjust: "none"
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
colorAreaStyleProps: {
|
|
88
|
+
style: {
|
|
89
|
+
position: "relative",
|
|
90
|
+
touchAction: "none",
|
|
91
|
+
...forcedColorAdjustNoneStyle,
|
|
92
|
+
...colorAreaStyles
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
thumbStyleProps: {
|
|
96
|
+
style: {
|
|
97
|
+
position: "absolute",
|
|
98
|
+
left: `${x * 100}%`,
|
|
99
|
+
top: `${y * 100}%`,
|
|
100
|
+
transform: "translate(-50%, -50%)",
|
|
101
|
+
touchAction: "none",
|
|
102
|
+
...forcedColorAdjustNoneStyle
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, [
|
|
107
|
+
direction,
|
|
108
|
+
state,
|
|
109
|
+
zChannel,
|
|
110
|
+
xChannel,
|
|
111
|
+
yChannel
|
|
112
|
+
]);
|
|
113
|
+
return returnVal;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
export {$40297c24c53588e6$export$dd62420467d245ca as useColorAreaGradient};
|
|
118
|
+
//# sourceMappingURL=useColorAreaGradient.mjs.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {useMemo as $hLqEt$useMemo} from "react";
|
|
2
|
+
import {parseColor as $hLqEt$parseColor} from "@react-stately/color";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2022 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
|
+
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"
|
|
30
|
+
};
|
|
31
|
+
const $40297c24c53588e6$var$hsbChannels = {
|
|
32
|
+
hue: $40297c24c53588e6$var$hue,
|
|
33
|
+
saturation: $40297c24c53588e6$var$saturation,
|
|
34
|
+
brightness: ()=>"black, transparent"
|
|
35
|
+
};
|
|
36
|
+
function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, yChannel: yChannel }) {
|
|
37
|
+
let returnVal = (0, $hLqEt$useMemo)(()=>{
|
|
38
|
+
let end = direction === "rtl" ? "left" : "right";
|
|
39
|
+
let colorAreaStyles = {};
|
|
40
|
+
let zValue = state.value.getChannelValue(zChannel);
|
|
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
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let { x: x, y: y } = state.getThumbPosition();
|
|
82
|
+
if (direction === "rtl") x = 1 - x;
|
|
83
|
+
let forcedColorAdjustNoneStyle = {
|
|
84
|
+
forcedColorAdjust: "none"
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
colorAreaStyleProps: {
|
|
88
|
+
style: {
|
|
89
|
+
position: "relative",
|
|
90
|
+
touchAction: "none",
|
|
91
|
+
...forcedColorAdjustNoneStyle,
|
|
92
|
+
...colorAreaStyles
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
thumbStyleProps: {
|
|
96
|
+
style: {
|
|
97
|
+
position: "absolute",
|
|
98
|
+
left: `${x * 100}%`,
|
|
99
|
+
top: `${y * 100}%`,
|
|
100
|
+
transform: "translate(-50%, -50%)",
|
|
101
|
+
touchAction: "none",
|
|
102
|
+
...forcedColorAdjustNoneStyle
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, [
|
|
107
|
+
direction,
|
|
108
|
+
state,
|
|
109
|
+
zChannel,
|
|
110
|
+
xChannel,
|
|
111
|
+
yChannel
|
|
112
|
+
]);
|
|
113
|
+
return returnVal;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
export {$40297c24c53588e6$export$dd62420467d245ca as useColorAreaGradient};
|
|
118
|
+
//# sourceMappingURL=useColorAreaGradient.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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)({
|
|
70
|
+
...props,
|
|
71
|
+
id: inputId,
|
|
72
|
+
value: inputValue,
|
|
73
|
+
defaultValue: undefined,
|
|
74
|
+
validate: undefined,
|
|
75
|
+
[(0, $grujV$reactstatelyform.privateValidationStateProp)]: state,
|
|
76
|
+
type: "text",
|
|
77
|
+
autoComplete: "off",
|
|
78
|
+
onChange: onChange
|
|
79
|
+
}, state, ref);
|
|
80
|
+
inputProps = (0, $grujV$reactariautils.mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
81
|
+
role: "textbox",
|
|
82
|
+
"aria-valuemax": null,
|
|
83
|
+
"aria-valuemin": null,
|
|
84
|
+
"aria-valuenow": null,
|
|
85
|
+
"aria-valuetext": null,
|
|
86
|
+
autoCorrect: "off",
|
|
87
|
+
spellCheck: "false",
|
|
88
|
+
onBlur: commit
|
|
89
|
+
});
|
|
90
|
+
if (validationBehavior === "native") inputProps["aria-required"] = undefined;
|
|
91
|
+
return {
|
|
92
|
+
inputProps: inputProps,
|
|
93
|
+
...otherProps
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=useColorField.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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,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"}
|
|
@@ -0,0 +1,93 @@
|
|
|
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)({
|
|
64
|
+
...props,
|
|
65
|
+
id: inputId,
|
|
66
|
+
value: inputValue,
|
|
67
|
+
defaultValue: undefined,
|
|
68
|
+
validate: undefined,
|
|
69
|
+
[(0, $f8mV7$privateValidationStateProp)]: state,
|
|
70
|
+
type: "text",
|
|
71
|
+
autoComplete: "off",
|
|
72
|
+
onChange: onChange
|
|
73
|
+
}, state, ref);
|
|
74
|
+
inputProps = (0, $f8mV7$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
|
|
75
|
+
role: "textbox",
|
|
76
|
+
"aria-valuemax": null,
|
|
77
|
+
"aria-valuemin": null,
|
|
78
|
+
"aria-valuenow": null,
|
|
79
|
+
"aria-valuetext": null,
|
|
80
|
+
autoCorrect: "off",
|
|
81
|
+
spellCheck: "false",
|
|
82
|
+
onBlur: commit
|
|
83
|
+
});
|
|
84
|
+
if (validationBehavior === "native") inputProps["aria-required"] = undefined;
|
|
85
|
+
return {
|
|
86
|
+
inputProps: inputProps,
|
|
87
|
+
...otherProps
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
export {$f6896b05b2ecad12$export$77e32ca575a28fdf as useColorField};
|
|
93
|
+
//# sourceMappingURL=useColorField.mjs.map
|