@react-aria/color 3.0.0-nightly.4552 → 3.0.0-nightly.4558
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/import.mjs +4 -1144
- 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.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/main.js +8 -1148
- package/dist/main.js.map +1 -1
- package/dist/module.js +4 -1144
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- 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 +229 -0
- package/dist/useColorAreaGradient.main.js.map +1 -0
- package/dist/useColorAreaGradient.mjs +224 -0
- package/dist/useColorAreaGradient.module.js +224 -0
- package/dist/useColorAreaGradient.module.js.map +1 -0
- package/dist/useColorField.main.js +97 -0
- package/dist/useColorField.main.js.map +1 -0
- package/dist/useColorField.mjs +92 -0
- package/dist/useColorField.module.js +92 -0
- package/dist/useColorField.module.js.map +1 -0
- package/dist/useColorSlider.main.js +105 -0
- package/dist/useColorSlider.main.js.map +1 -0
- package/dist/useColorSlider.mjs +100 -0
- package/dist/useColorSlider.module.js +100 -0
- package/dist/useColorSlider.module.js.map +1 -0
- package/dist/useColorWheel.main.js +260 -0
- package/dist/useColorWheel.main.js.map +1 -0
- package/dist/useColorWheel.mjs +255 -0
- package/dist/useColorWheel.module.js +255 -0
- package/dist/useColorWheel.module.js.map +1 -0
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +13 -13
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
var $9t8qo$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useColorAreaGradient", () => $99936ad0bf67c8c4$export$dd62420467d245ca);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
const $99936ad0bf67c8c4$var$generateRGB_R = (orientation, dir, zValue)=>{
|
|
21
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
22
|
+
let result = {
|
|
23
|
+
colorAreaStyles: {
|
|
24
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
25
|
+
},
|
|
26
|
+
gradientStyles: {
|
|
27
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
28
|
+
"WebkitMaskImage": maskImage,
|
|
29
|
+
maskImage: maskImage
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
const $99936ad0bf67c8c4$var$generateRGB_G = (orientation, dir, zValue)=>{
|
|
35
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
36
|
+
let result = {
|
|
37
|
+
colorAreaStyles: {
|
|
38
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
39
|
+
},
|
|
40
|
+
gradientStyles: {
|
|
41
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
42
|
+
"WebkitMaskImage": maskImage,
|
|
43
|
+
maskImage: maskImage
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
const $99936ad0bf67c8c4$var$generateRGB_B = (orientation, dir, zValue)=>{
|
|
49
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
50
|
+
let result = {
|
|
51
|
+
colorAreaStyles: {
|
|
52
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
53
|
+
},
|
|
54
|
+
gradientStyles: {
|
|
55
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
56
|
+
"WebkitMaskImage": maskImage,
|
|
57
|
+
maskImage: maskImage
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
const $99936ad0bf67c8c4$var$generateHSL_H = (orientation, dir, zValue)=>{
|
|
63
|
+
let result = {
|
|
64
|
+
colorAreaStyles: {},
|
|
65
|
+
gradientStyles: {
|
|
66
|
+
background: [
|
|
67
|
+
`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%)`,
|
|
68
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
69
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
70
|
+
].join(",")
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
75
|
+
const $99936ad0bf67c8c4$var$generateHSL_S = (orientation, dir, alphaValue)=>{
|
|
76
|
+
let result = {
|
|
77
|
+
colorAreaStyles: {},
|
|
78
|
+
gradientStyles: {
|
|
79
|
+
background: [
|
|
80
|
+
`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%)`,
|
|
81
|
+
`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}))`,
|
|
82
|
+
"hsl(0, 0%, 50%)"
|
|
83
|
+
].join(",")
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return result;
|
|
87
|
+
};
|
|
88
|
+
const $99936ad0bf67c8c4$var$generateHSL_L = (orientation, dir, zValue)=>{
|
|
89
|
+
let result = {
|
|
90
|
+
colorAreaStyles: {},
|
|
91
|
+
gradientStyles: {
|
|
92
|
+
backgroundImage: [
|
|
93
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
94
|
+
`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}%))`
|
|
95
|
+
].join(",")
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
const $99936ad0bf67c8c4$var$generateHSB_H = (orientation, dir, zValue)=>{
|
|
101
|
+
let result = {
|
|
102
|
+
colorAreaStyles: {},
|
|
103
|
+
gradientStyles: {
|
|
104
|
+
background: [
|
|
105
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
106
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
107
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
108
|
+
].join(",")
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
const $99936ad0bf67c8c4$var$generateHSB_S = (orientation, dir, alphaValue)=>{
|
|
114
|
+
let result = {
|
|
115
|
+
colorAreaStyles: {},
|
|
116
|
+
gradientStyles: {
|
|
117
|
+
background: [
|
|
118
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
119
|
+
`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}))`,
|
|
120
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
121
|
+
].join(",")
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return result;
|
|
125
|
+
};
|
|
126
|
+
const $99936ad0bf67c8c4$var$generateHSB_B = (orientation, dir, alphaValue)=>{
|
|
127
|
+
let result = {
|
|
128
|
+
colorAreaStyles: {},
|
|
129
|
+
gradientStyles: {
|
|
130
|
+
background: [
|
|
131
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
132
|
+
`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}))`,
|
|
133
|
+
"#000"
|
|
134
|
+
].join(",")
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
return result;
|
|
138
|
+
};
|
|
139
|
+
function $99936ad0bf67c8c4$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, isDisabled: isDisabled }) {
|
|
140
|
+
let returnVal = (0, $9t8qo$react.useMemo)(()=>{
|
|
141
|
+
let orientation = [
|
|
142
|
+
"top",
|
|
143
|
+
direction === "rtl" ? "left" : "right"
|
|
144
|
+
];
|
|
145
|
+
let dir = false;
|
|
146
|
+
let background = {
|
|
147
|
+
colorAreaStyles: {},
|
|
148
|
+
gradientStyles: {}
|
|
149
|
+
};
|
|
150
|
+
let zValue = state.value.getChannelValue(zChannel);
|
|
151
|
+
let { minValue: zMin, maxValue: zMax } = state.value.getChannelRange(zChannel);
|
|
152
|
+
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
153
|
+
let isHSL = state.value.getColorSpace() === "hsl";
|
|
154
|
+
if (!isDisabled) switch(zChannel){
|
|
155
|
+
case "red":
|
|
156
|
+
dir = xChannel === "green";
|
|
157
|
+
background = $99936ad0bf67c8c4$var$generateRGB_R(orientation, dir, zValue);
|
|
158
|
+
break;
|
|
159
|
+
case "green":
|
|
160
|
+
dir = xChannel === "red";
|
|
161
|
+
background = $99936ad0bf67c8c4$var$generateRGB_G(orientation, dir, zValue);
|
|
162
|
+
break;
|
|
163
|
+
case "blue":
|
|
164
|
+
dir = xChannel === "red";
|
|
165
|
+
background = $99936ad0bf67c8c4$var$generateRGB_B(orientation, dir, zValue);
|
|
166
|
+
break;
|
|
167
|
+
case "hue":
|
|
168
|
+
dir = xChannel !== "saturation";
|
|
169
|
+
if (isHSL) background = $99936ad0bf67c8c4$var$generateHSL_H(orientation, dir, zValue);
|
|
170
|
+
else background = $99936ad0bf67c8c4$var$generateHSB_H(orientation, dir, zValue);
|
|
171
|
+
break;
|
|
172
|
+
case "saturation":
|
|
173
|
+
dir = xChannel === "hue";
|
|
174
|
+
if (isHSL) background = $99936ad0bf67c8c4$var$generateHSL_S(orientation, dir, alphaValue);
|
|
175
|
+
else background = $99936ad0bf67c8c4$var$generateHSB_S(orientation, dir, alphaValue);
|
|
176
|
+
break;
|
|
177
|
+
case "brightness":
|
|
178
|
+
dir = xChannel === "hue";
|
|
179
|
+
background = $99936ad0bf67c8c4$var$generateHSB_B(orientation, dir, alphaValue);
|
|
180
|
+
break;
|
|
181
|
+
case "lightness":
|
|
182
|
+
dir = xChannel === "hue";
|
|
183
|
+
background = $99936ad0bf67c8c4$var$generateHSL_L(orientation, dir, zValue);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
let { x: x, y: y } = state.getThumbPosition();
|
|
187
|
+
if (direction === "rtl") x = 1 - x;
|
|
188
|
+
let forcedColorAdjustNoneStyle = {
|
|
189
|
+
forcedColorAdjust: "none"
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
colorAreaStyleProps: {
|
|
193
|
+
style: {
|
|
194
|
+
position: "relative",
|
|
195
|
+
touchAction: "none",
|
|
196
|
+
...forcedColorAdjustNoneStyle,
|
|
197
|
+
...background.colorAreaStyles
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
gradientStyleProps: {
|
|
201
|
+
style: {
|
|
202
|
+
touchAction: "none",
|
|
203
|
+
...forcedColorAdjustNoneStyle,
|
|
204
|
+
...background.gradientStyles
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
thumbStyleProps: {
|
|
208
|
+
style: {
|
|
209
|
+
position: "absolute",
|
|
210
|
+
left: `${x * 100}%`,
|
|
211
|
+
top: `${y * 100}%`,
|
|
212
|
+
transform: "translate(0%, 0%)",
|
|
213
|
+
touchAction: "none",
|
|
214
|
+
...forcedColorAdjustNoneStyle
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}, [
|
|
219
|
+
direction,
|
|
220
|
+
state,
|
|
221
|
+
zChannel,
|
|
222
|
+
xChannel,
|
|
223
|
+
isDisabled
|
|
224
|
+
]);
|
|
225
|
+
return returnVal;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=useColorAreaGradient.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;AAUA;AAIA,MAAM,sCAAgB,CAAC,aAAa,KAAc;IAChD,IAAI,YAAY,CAAC,mBAAmB,EAAE,WAAW,CAAC,OA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BACH,MAAM,aAAa;gBACnB,aAAa,oCAAc,aAAa,KAAK;gBAC7C;YAEF,KAAK;gBACH,MAAM,aAAa;gBACnB,aAAa,oCAAc,aAAa,KAAK;gBAC7C;QAEJ;QAGF,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,WAAW,eAAe;gBAC/B;YACF;YACA,oBAAoB;gBAClB,OAAO;oBACL,aAAa;oBACb,GAAG,0BAA0B;oBAC7B,GAAG,WAAW,cAAc;gBAC9B;YACF;YACA,iBAAiB;gBACf,OAAO;oBACL,UAAU;oBACV,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;oBACnB,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;oBAClB,WAAW;oBACX,aAAa;oBACb,GAAG,0BAA0B;gBAC/B;YACF;QACF;IACF,GAAG;QAAC;QAAW;QAAO;QAAU;QAAU;KAAW;IAErD,OAAO;AACT","sources":["packages/@react-aria/color/src/useColorAreaGradient.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n*/\n\nimport {CSSProperties, useMemo} from 'react';\n\nconst generateRGB_R = (orientation, dir: boolean, zValue: number) => {\n let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;\n let result = {\n colorAreaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`\n },\n gradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,\n 'WebkitMaskImage': maskImage,\n maskImage\n }\n };\n return result;\n};\n\nconst generateRGB_G = (orientation, dir: boolean, zValue: number) => {\n let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;\n let result = {\n colorAreaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`\n },\n gradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,\n 'WebkitMaskImage': maskImage,\n maskImage\n }\n };\n return result;\n};\n\nconst generateRGB_B = (orientation, dir: boolean, zValue: number) => {\n let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;\n let result = {\n colorAreaStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`\n },\n gradientStyles: {\n backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,\n 'WebkitMaskImage': maskImage,\n maskImage\n }\n };\n return result;\n};\n\n\nconst generateHSL_H = (orientation, dir: boolean, zValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,\n `hsl(${zValue}, 100%, 50%)`\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSL_S = (orientation, dir: boolean, alphaValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,\n `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n 'hsl(0, 0%, 50%)'\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSL_L = (orientation, dir: boolean, zValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n backgroundImage: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`\n ].join(',')\n }\n };\n return result;\n};\n\n\nconst generateHSB_H = (orientation, dir: boolean, zValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,\n `hsl(${zValue}, 100%, 50%)`\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSB_S = (orientation, dir: boolean, alphaValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,\n `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`\n ].join(',')\n }\n };\n return result;\n};\n\nconst generateHSB_B = (orientation, dir: boolean, alphaValue: number) => {\n let result = {\n colorAreaStyles: {},\n gradientStyles: {\n background: [\n `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,\n `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,\n '#000'\n ].join(',')\n }\n };\n return result;\n};\n\n\ninterface Gradients {\n colorAreaStyleProps: {\n style: CSSProperties\n },\n gradientStyleProps: {\n style: CSSProperties\n },\n thumbStyleProps: {\n style: CSSProperties\n }\n}\n\nexport function useColorAreaGradient({direction, state, zChannel, xChannel, isDisabled}): Gradients {\n let returnVal = useMemo<Gradients>(() => {\n let orientation = ['top', direction === 'rtl' ? 'left' : 'right'];\n let dir = false;\n let background = {colorAreaStyles: {}, gradientStyles: {}};\n let zValue = state.value.getChannelValue(zChannel);\n let {minValue: zMin, maxValue: zMax} = state.value.getChannelRange(zChannel);\n let alphaValue = (zValue - zMin) / (zMax - zMin);\n let isHSL = state.value.getColorSpace() === 'hsl';\n if (!isDisabled) {\n switch (zChannel) {\n case 'red': {\n dir = xChannel === 'green';\n background = generateRGB_R(orientation, dir, zValue);\n break;\n }\n case 'green': {\n dir = xChannel === 'red';\n background = generateRGB_G(orientation, dir, zValue);\n break;\n }\n case 'blue': {\n dir = xChannel === 'red';\n background = generateRGB_B(orientation, dir, zValue);\n break;\n }\n case 'hue': {\n dir = xChannel !== 'saturation';\n if (isHSL) {\n background = generateHSL_H(orientation, dir, zValue);\n } else {\n background = generateHSB_H(orientation, dir, zValue);\n }\n break;\n }\n case 'saturation': {\n dir = xChannel === 'hue';\n if (isHSL) {\n background = generateHSL_S(orientation, dir, alphaValue);\n } else {\n background = generateHSB_S(orientation, dir, alphaValue);\n }\n break;\n }\n case 'brightness': {\n dir = xChannel === 'hue';\n background = generateHSB_B(orientation, dir, alphaValue);\n break;\n }\n case 'lightness': {\n dir = xChannel === 'hue';\n background = generateHSL_L(orientation, dir, zValue);\n break;\n }\n }\n }\n\n let {x, y} = state.getThumbPosition();\n\n if (direction === 'rtl') {\n x = 1 - x;\n }\n\n let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n return {\n colorAreaStyleProps: {\n style: {\n position: 'relative',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle,\n ...background.colorAreaStyles\n }\n },\n gradientStyleProps: {\n style: {\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle,\n ...background.gradientStyles\n }\n },\n thumbStyleProps: {\n style: {\n position: 'absolute',\n left: `${x * 100}%`,\n top: `${y * 100}%`,\n transform: 'translate(0%, 0%)',\n touchAction: 'none',\n ...forcedColorAdjustNoneStyle\n }\n }\n };\n }, [direction, state, zChannel, xChannel, isDisabled]);\n\n return returnVal;\n}\n\n"],"names":[],"version":3,"file":"useColorAreaGradient.main.js.map"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {useMemo as $hLqEt$useMemo} from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
const $40297c24c53588e6$var$generateRGB_R = (orientation, dir, zValue)=>{
|
|
15
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
16
|
+
let result = {
|
|
17
|
+
colorAreaStyles: {
|
|
18
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
|
|
19
|
+
},
|
|
20
|
+
gradientStyles: {
|
|
21
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
|
|
22
|
+
"WebkitMaskImage": maskImage,
|
|
23
|
+
maskImage: maskImage
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
const $40297c24c53588e6$var$generateRGB_G = (orientation, dir, zValue)=>{
|
|
29
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
30
|
+
let result = {
|
|
31
|
+
colorAreaStyles: {
|
|
32
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
|
|
33
|
+
},
|
|
34
|
+
gradientStyles: {
|
|
35
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
|
|
36
|
+
"WebkitMaskImage": maskImage,
|
|
37
|
+
maskImage: maskImage
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
const $40297c24c53588e6$var$generateRGB_B = (orientation, dir, zValue)=>{
|
|
43
|
+
let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
|
|
44
|
+
let result = {
|
|
45
|
+
colorAreaStyles: {
|
|
46
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
|
|
47
|
+
},
|
|
48
|
+
gradientStyles: {
|
|
49
|
+
backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
|
|
50
|
+
"WebkitMaskImage": maskImage,
|
|
51
|
+
maskImage: maskImage
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
const $40297c24c53588e6$var$generateHSL_H = (orientation, dir, zValue)=>{
|
|
57
|
+
let result = {
|
|
58
|
+
colorAreaStyles: {},
|
|
59
|
+
gradientStyles: {
|
|
60
|
+
background: [
|
|
61
|
+
`linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
|
|
62
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
|
|
63
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
64
|
+
].join(",")
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
const $40297c24c53588e6$var$generateHSL_S = (orientation, dir, alphaValue)=>{
|
|
70
|
+
let result = {
|
|
71
|
+
colorAreaStyles: {},
|
|
72
|
+
gradientStyles: {
|
|
73
|
+
background: [
|
|
74
|
+
`linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
|
|
75
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
76
|
+
"hsl(0, 0%, 50%)"
|
|
77
|
+
].join(",")
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return result;
|
|
81
|
+
};
|
|
82
|
+
const $40297c24c53588e6$var$generateHSL_L = (orientation, dir, zValue)=>{
|
|
83
|
+
let result = {
|
|
84
|
+
colorAreaStyles: {},
|
|
85
|
+
gradientStyles: {
|
|
86
|
+
backgroundImage: [
|
|
87
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
|
|
88
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
|
|
89
|
+
].join(",")
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
|
+
const $40297c24c53588e6$var$generateHSB_H = (orientation, dir, zValue)=>{
|
|
95
|
+
let result = {
|
|
96
|
+
colorAreaStyles: {},
|
|
97
|
+
gradientStyles: {
|
|
98
|
+
background: [
|
|
99
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
|
|
100
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
|
|
101
|
+
`hsl(${zValue}, 100%, 50%)`
|
|
102
|
+
].join(",")
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
const $40297c24c53588e6$var$generateHSB_S = (orientation, dir, alphaValue)=>{
|
|
108
|
+
let result = {
|
|
109
|
+
colorAreaStyles: {},
|
|
110
|
+
gradientStyles: {
|
|
111
|
+
background: [
|
|
112
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
|
|
113
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
114
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
|
|
115
|
+
].join(",")
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
const $40297c24c53588e6$var$generateHSB_B = (orientation, dir, alphaValue)=>{
|
|
121
|
+
let result = {
|
|
122
|
+
colorAreaStyles: {},
|
|
123
|
+
gradientStyles: {
|
|
124
|
+
background: [
|
|
125
|
+
`linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
|
|
126
|
+
`linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
|
|
127
|
+
"#000"
|
|
128
|
+
].join(",")
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return result;
|
|
132
|
+
};
|
|
133
|
+
function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, isDisabled: isDisabled }) {
|
|
134
|
+
let returnVal = (0, $hLqEt$useMemo)(()=>{
|
|
135
|
+
let orientation = [
|
|
136
|
+
"top",
|
|
137
|
+
direction === "rtl" ? "left" : "right"
|
|
138
|
+
];
|
|
139
|
+
let dir = false;
|
|
140
|
+
let background = {
|
|
141
|
+
colorAreaStyles: {},
|
|
142
|
+
gradientStyles: {}
|
|
143
|
+
};
|
|
144
|
+
let zValue = state.value.getChannelValue(zChannel);
|
|
145
|
+
let { minValue: zMin, maxValue: zMax } = state.value.getChannelRange(zChannel);
|
|
146
|
+
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
147
|
+
let isHSL = state.value.getColorSpace() === "hsl";
|
|
148
|
+
if (!isDisabled) switch(zChannel){
|
|
149
|
+
case "red":
|
|
150
|
+
dir = xChannel === "green";
|
|
151
|
+
background = $40297c24c53588e6$var$generateRGB_R(orientation, dir, zValue);
|
|
152
|
+
break;
|
|
153
|
+
case "green":
|
|
154
|
+
dir = xChannel === "red";
|
|
155
|
+
background = $40297c24c53588e6$var$generateRGB_G(orientation, dir, zValue);
|
|
156
|
+
break;
|
|
157
|
+
case "blue":
|
|
158
|
+
dir = xChannel === "red";
|
|
159
|
+
background = $40297c24c53588e6$var$generateRGB_B(orientation, dir, zValue);
|
|
160
|
+
break;
|
|
161
|
+
case "hue":
|
|
162
|
+
dir = xChannel !== "saturation";
|
|
163
|
+
if (isHSL) background = $40297c24c53588e6$var$generateHSL_H(orientation, dir, zValue);
|
|
164
|
+
else background = $40297c24c53588e6$var$generateHSB_H(orientation, dir, zValue);
|
|
165
|
+
break;
|
|
166
|
+
case "saturation":
|
|
167
|
+
dir = xChannel === "hue";
|
|
168
|
+
if (isHSL) background = $40297c24c53588e6$var$generateHSL_S(orientation, dir, alphaValue);
|
|
169
|
+
else background = $40297c24c53588e6$var$generateHSB_S(orientation, dir, alphaValue);
|
|
170
|
+
break;
|
|
171
|
+
case "brightness":
|
|
172
|
+
dir = xChannel === "hue";
|
|
173
|
+
background = $40297c24c53588e6$var$generateHSB_B(orientation, dir, alphaValue);
|
|
174
|
+
break;
|
|
175
|
+
case "lightness":
|
|
176
|
+
dir = xChannel === "hue";
|
|
177
|
+
background = $40297c24c53588e6$var$generateHSL_L(orientation, dir, zValue);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
let { x: x, y: y } = state.getThumbPosition();
|
|
181
|
+
if (direction === "rtl") x = 1 - x;
|
|
182
|
+
let forcedColorAdjustNoneStyle = {
|
|
183
|
+
forcedColorAdjust: "none"
|
|
184
|
+
};
|
|
185
|
+
return {
|
|
186
|
+
colorAreaStyleProps: {
|
|
187
|
+
style: {
|
|
188
|
+
position: "relative",
|
|
189
|
+
touchAction: "none",
|
|
190
|
+
...forcedColorAdjustNoneStyle,
|
|
191
|
+
...background.colorAreaStyles
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
gradientStyleProps: {
|
|
195
|
+
style: {
|
|
196
|
+
touchAction: "none",
|
|
197
|
+
...forcedColorAdjustNoneStyle,
|
|
198
|
+
...background.gradientStyles
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
thumbStyleProps: {
|
|
202
|
+
style: {
|
|
203
|
+
position: "absolute",
|
|
204
|
+
left: `${x * 100}%`,
|
|
205
|
+
top: `${y * 100}%`,
|
|
206
|
+
transform: "translate(0%, 0%)",
|
|
207
|
+
touchAction: "none",
|
|
208
|
+
...forcedColorAdjustNoneStyle
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}, [
|
|
213
|
+
direction,
|
|
214
|
+
state,
|
|
215
|
+
zChannel,
|
|
216
|
+
xChannel,
|
|
217
|
+
isDisabled
|
|
218
|
+
]);
|
|
219
|
+
return returnVal;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
export {$40297c24c53588e6$export$dd62420467d245ca as useColorAreaGradient};
|
|
224
|
+
//# sourceMappingURL=useColorAreaGradient.mjs.map
|