@react-stately/color 3.5.4-nightly.4555 → 3.5.4-nightly.4560
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Color.main.js +770 -0
- package/dist/Color.main.js.map +1 -0
- package/dist/Color.mjs +764 -0
- package/dist/Color.module.js +764 -0
- package/dist/Color.module.js.map +1 -0
- package/dist/ar-AE.main.js +2 -2
- package/dist/ar-AE.main.js.map +1 -1
- package/dist/ar-AE.mjs +3 -3
- package/dist/ar-AE.module.js +2 -2
- package/dist/ar-AE.module.js.map +1 -1
- package/dist/bg-BG.main.js +2 -2
- package/dist/bg-BG.main.js.map +1 -1
- package/dist/bg-BG.mjs +3 -3
- package/dist/bg-BG.module.js +2 -2
- package/dist/bg-BG.module.js.map +1 -1
- package/dist/cs-CZ.main.js +2 -2
- package/dist/cs-CZ.main.js.map +1 -1
- package/dist/cs-CZ.mjs +3 -3
- package/dist/cs-CZ.module.js +2 -2
- package/dist/cs-CZ.module.js.map +1 -1
- package/dist/da-DK.main.js +2 -2
- package/dist/da-DK.main.js.map +1 -1
- package/dist/da-DK.mjs +3 -3
- package/dist/da-DK.module.js +2 -2
- package/dist/da-DK.module.js.map +1 -1
- package/dist/de-DE.main.js +2 -2
- package/dist/de-DE.main.js.map +1 -1
- package/dist/de-DE.mjs +3 -3
- package/dist/de-DE.module.js +2 -2
- package/dist/de-DE.module.js.map +1 -1
- package/dist/el-GR.main.js +2 -2
- package/dist/el-GR.main.js.map +1 -1
- package/dist/el-GR.mjs +3 -3
- package/dist/el-GR.module.js +2 -2
- package/dist/el-GR.module.js.map +1 -1
- package/dist/en-US.main.js +2 -2
- package/dist/en-US.main.js.map +1 -1
- package/dist/en-US.mjs +3 -3
- package/dist/en-US.module.js +2 -2
- package/dist/en-US.module.js.map +1 -1
- package/dist/es-ES.main.js +2 -2
- package/dist/es-ES.main.js.map +1 -1
- package/dist/es-ES.mjs +3 -3
- package/dist/es-ES.module.js +2 -2
- package/dist/es-ES.module.js.map +1 -1
- package/dist/et-EE.main.js +2 -2
- package/dist/et-EE.main.js.map +1 -1
- package/dist/et-EE.mjs +3 -3
- package/dist/et-EE.module.js +2 -2
- package/dist/et-EE.module.js.map +1 -1
- package/dist/fi-FI.main.js +2 -2
- package/dist/fi-FI.main.js.map +1 -1
- package/dist/fi-FI.mjs +3 -3
- package/dist/fi-FI.module.js +2 -2
- package/dist/fi-FI.module.js.map +1 -1
- package/dist/fr-FR.main.js +2 -2
- package/dist/fr-FR.main.js.map +1 -1
- package/dist/fr-FR.mjs +3 -3
- package/dist/fr-FR.module.js +2 -2
- package/dist/fr-FR.module.js.map +1 -1
- package/dist/he-IL.main.js +2 -2
- package/dist/he-IL.main.js.map +1 -1
- package/dist/he-IL.mjs +3 -3
- package/dist/he-IL.module.js +2 -2
- package/dist/he-IL.module.js.map +1 -1
- package/dist/hr-HR.main.js +2 -2
- package/dist/hr-HR.main.js.map +1 -1
- package/dist/hr-HR.mjs +3 -3
- package/dist/hr-HR.module.js +2 -2
- package/dist/hr-HR.module.js.map +1 -1
- package/dist/hu-HU.main.js +2 -2
- package/dist/hu-HU.main.js.map +1 -1
- package/dist/hu-HU.mjs +3 -3
- package/dist/hu-HU.module.js +2 -2
- package/dist/hu-HU.module.js.map +1 -1
- package/dist/import.mjs +5 -1303
- 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 +2 -2
- package/dist/it-IT.main.js.map +1 -1
- package/dist/it-IT.mjs +3 -3
- package/dist/it-IT.module.js +2 -2
- package/dist/it-IT.module.js.map +1 -1
- package/dist/ja-JP.main.js +2 -2
- package/dist/ja-JP.main.js.map +1 -1
- package/dist/ja-JP.mjs +3 -3
- package/dist/ja-JP.module.js +2 -2
- package/dist/ja-JP.module.js.map +1 -1
- package/dist/ko-KR.main.js +2 -2
- package/dist/ko-KR.main.js.map +1 -1
- package/dist/ko-KR.mjs +3 -3
- package/dist/ko-KR.module.js +2 -2
- package/dist/ko-KR.module.js.map +1 -1
- package/dist/lt-LT.main.js +2 -2
- package/dist/lt-LT.main.js.map +1 -1
- package/dist/lt-LT.mjs +3 -3
- package/dist/lt-LT.module.js +2 -2
- package/dist/lt-LT.module.js.map +1 -1
- package/dist/lv-LV.main.js +2 -2
- package/dist/lv-LV.main.js.map +1 -1
- package/dist/lv-LV.mjs +3 -3
- package/dist/lv-LV.module.js +2 -2
- package/dist/lv-LV.module.js.map +1 -1
- package/dist/main.js +10 -1308
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -1303
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +2 -2
- package/dist/nb-NO.main.js.map +1 -1
- package/dist/nb-NO.mjs +3 -3
- package/dist/nb-NO.module.js +2 -2
- package/dist/nb-NO.module.js.map +1 -1
- package/dist/nl-NL.main.js +2 -2
- package/dist/nl-NL.main.js.map +1 -1
- package/dist/nl-NL.mjs +3 -3
- package/dist/nl-NL.module.js +2 -2
- package/dist/nl-NL.module.js.map +1 -1
- package/dist/pl-PL.main.js +2 -2
- package/dist/pl-PL.main.js.map +1 -1
- package/dist/pl-PL.mjs +3 -3
- package/dist/pl-PL.module.js +2 -2
- package/dist/pl-PL.module.js.map +1 -1
- package/dist/pt-BR.main.js +2 -2
- package/dist/pt-BR.main.js.map +1 -1
- package/dist/pt-BR.mjs +3 -3
- package/dist/pt-BR.module.js +2 -2
- package/dist/pt-BR.module.js.map +1 -1
- package/dist/pt-PT.main.js +2 -2
- package/dist/pt-PT.main.js.map +1 -1
- package/dist/pt-PT.mjs +3 -3
- package/dist/pt-PT.module.js +2 -2
- package/dist/pt-PT.module.js.map +1 -1
- package/dist/ro-RO.main.js +2 -2
- package/dist/ro-RO.main.js.map +1 -1
- package/dist/ro-RO.mjs +3 -3
- package/dist/ro-RO.module.js +2 -2
- package/dist/ro-RO.module.js.map +1 -1
- package/dist/ru-RU.main.js +2 -2
- package/dist/ru-RU.main.js.map +1 -1
- package/dist/ru-RU.mjs +3 -3
- package/dist/ru-RU.module.js +2 -2
- package/dist/ru-RU.module.js.map +1 -1
- package/dist/sk-SK.main.js +2 -2
- package/dist/sk-SK.main.js.map +1 -1
- package/dist/sk-SK.mjs +3 -3
- package/dist/sk-SK.module.js +2 -2
- package/dist/sk-SK.module.js.map +1 -1
- package/dist/sl-SI.main.js +2 -2
- package/dist/sl-SI.main.js.map +1 -1
- package/dist/sl-SI.mjs +3 -3
- package/dist/sl-SI.module.js +2 -2
- package/dist/sl-SI.module.js.map +1 -1
- package/dist/sr-SP.main.js +2 -2
- package/dist/sr-SP.main.js.map +1 -1
- package/dist/sr-SP.mjs +3 -3
- package/dist/sr-SP.module.js +2 -2
- package/dist/sr-SP.module.js.map +1 -1
- package/dist/sv-SE.main.js +2 -2
- package/dist/sv-SE.main.js.map +1 -1
- package/dist/sv-SE.mjs +3 -3
- package/dist/sv-SE.module.js +2 -2
- package/dist/sv-SE.module.js.map +1 -1
- package/dist/tr-TR.main.js +2 -2
- package/dist/tr-TR.main.js.map +1 -1
- package/dist/tr-TR.mjs +3 -3
- package/dist/tr-TR.module.js +2 -2
- package/dist/tr-TR.module.js.map +1 -1
- package/dist/uk-UA.main.js +2 -2
- package/dist/uk-UA.main.js.map +1 -1
- package/dist/uk-UA.mjs +3 -3
- package/dist/uk-UA.module.js +2 -2
- package/dist/uk-UA.module.js.map +1 -1
- package/dist/useColor.main.js +36 -0
- package/dist/useColor.main.js.map +1 -0
- package/dist/useColor.mjs +31 -0
- package/dist/useColor.module.js +31 -0
- package/dist/useColor.module.js.map +1 -0
- package/dist/useColorAreaState.main.js +124 -0
- package/dist/useColorAreaState.main.js.map +1 -0
- package/dist/useColorAreaState.mjs +119 -0
- package/dist/useColorAreaState.module.js +119 -0
- package/dist/useColorAreaState.module.js.map +1 -0
- package/dist/useColorFieldState.main.js +138 -0
- package/dist/useColorFieldState.main.js.map +1 -0
- package/dist/useColorFieldState.mjs +133 -0
- package/dist/useColorFieldState.module.js +133 -0
- package/dist/useColorFieldState.module.js.map +1 -0
- package/dist/useColorSliderState.main.js +75 -0
- package/dist/useColorSliderState.main.js.map +1 -0
- package/dist/useColorSliderState.mjs +70 -0
- package/dist/useColorSliderState.module.js +70 -0
- package/dist/useColorSliderState.module.js.map +1 -0
- package/dist/useColorWheelState.main.js +123 -0
- package/dist/useColorWheelState.main.js.map +1 -0
- package/dist/useColorWheelState.mjs +118 -0
- package/dist/useColorWheelState.module.js +118 -0
- package/dist/useColorWheelState.module.js.map +1 -0
- package/dist/zh-CN.main.js +2 -2
- package/dist/zh-CN.main.js.map +1 -1
- package/dist/zh-CN.mjs +3 -3
- package/dist/zh-CN.module.js +2 -2
- package/dist/zh-CN.module.js.map +1 -1
- package/dist/zh-TW.main.js +2 -2
- package/dist/zh-TW.main.js.map +1 -1
- package/dist/zh-TW.mjs +3 -3
- package/dist/zh-TW.module.js +2 -2
- package/dist/zh-TW.module.js.map +1 -1
- package/package.json +9 -9
- package/src/Color.ts +13 -10
package/dist/main.js
CHANGED
|
@@ -1,69 +1,20 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $1fcbdf9eaf6cc074$exports = require("./el-GR.main.js");
|
|
7
|
-
var $42d54be461715959$exports = require("./en-US.main.js");
|
|
8
|
-
var $911646bd5662c33d$exports = require("./es-ES.main.js");
|
|
9
|
-
var $6e8998796901e680$exports = require("./et-EE.main.js");
|
|
10
|
-
var $4503b4001036be6d$exports = require("./fi-FI.main.js");
|
|
11
|
-
var $721e7016769a7a7f$exports = require("./fr-FR.main.js");
|
|
12
|
-
var $dcc290e5792f9bab$exports = require("./he-IL.main.js");
|
|
13
|
-
var $d93d5aebdd12334c$exports = require("./hr-HR.main.js");
|
|
14
|
-
var $a3749e0ee87dbebc$exports = require("./hu-HU.main.js");
|
|
15
|
-
var $2fdb931b6c9652b9$exports = require("./it-IT.main.js");
|
|
16
|
-
var $219c839b59015b4f$exports = require("./ja-JP.main.js");
|
|
17
|
-
var $b7f67f414086d976$exports = require("./ko-KR.main.js");
|
|
18
|
-
var $f27b2ac7d517417c$exports = require("./lt-LT.main.js");
|
|
19
|
-
var $e92168db3cbe2797$exports = require("./lv-LV.main.js");
|
|
20
|
-
var $44b012e02982e825$exports = require("./nb-NO.main.js");
|
|
21
|
-
var $64fbd91459613d8b$exports = require("./nl-NL.main.js");
|
|
22
|
-
var $83fabdc4e0df6af9$exports = require("./pl-PL.main.js");
|
|
23
|
-
var $30b915257fa66ccf$exports = require("./pt-BR.main.js");
|
|
24
|
-
var $ce75e45ccbc92491$exports = require("./pt-PT.main.js");
|
|
25
|
-
var $225440ee53a1fecd$exports = require("./ro-RO.main.js");
|
|
26
|
-
var $cbc60c1dd4e689ff$exports = require("./ru-RU.main.js");
|
|
27
|
-
var $8612080ab5efe0cf$exports = require("./sk-SK.main.js");
|
|
28
|
-
var $99cc034ddd2b7d86$exports = require("./sl-SI.main.js");
|
|
29
|
-
var $dc671800d61be83e$exports = require("./sr-SP.main.js");
|
|
30
|
-
var $0f4790e2f696e63f$exports = require("./sv-SE.main.js");
|
|
31
|
-
var $deb5f82eb1998a3c$exports = require("./tr-TR.main.js");
|
|
32
|
-
var $99530e1782ca02cc$exports = require("./uk-UA.main.js");
|
|
33
|
-
var $a6e8f490b423d65e$exports = require("./zh-CN.main.js");
|
|
34
|
-
var $eba443dcc93cab9a$exports = require("./zh-TW.main.js");
|
|
35
|
-
var $4tN2K$reactstatelyutils = require("@react-stately/utils");
|
|
36
|
-
var $4tN2K$internationalizedstring = require("@internationalized/string");
|
|
37
|
-
var $4tN2K$internationalizednumber = require("@internationalized/number");
|
|
38
|
-
var $4tN2K$react = require("react");
|
|
39
|
-
var $4tN2K$reactstatelyslider = require("@react-stately/slider");
|
|
40
|
-
var $4tN2K$reactstatelyform = require("@react-stately/form");
|
|
1
|
+
var $83fe1a57d631223b$exports = require("./Color.main.js");
|
|
2
|
+
var $af2d7ac9990cfee2$exports = require("./useColorAreaState.main.js");
|
|
3
|
+
var $5386a492cfd3234c$exports = require("./useColorSliderState.main.js");
|
|
4
|
+
var $9d7d8736d45f74b8$exports = require("./useColorWheelState.main.js");
|
|
5
|
+
var $d59d0c2b2ce1568f$exports = require("./useColorFieldState.main.js");
|
|
41
6
|
|
|
42
7
|
|
|
43
8
|
function $parcel$export(e, n, v, s) {
|
|
44
9
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
45
10
|
}
|
|
46
11
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
$parcel$export(module.exports, "
|
|
52
|
-
$parcel$export(module.exports, "useColorAreaState", () => $af2d7ac9990cfee2$export$6df7f0e2cabc7eef);
|
|
53
|
-
$parcel$export(module.exports, "useColorSliderState", () => $5386a492cfd3234c$export$57bc203e1c9c6d44);
|
|
54
|
-
$parcel$export(module.exports, "useColorWheelState", () => $9d7d8736d45f74b8$export$f4301076d9336137);
|
|
55
|
-
$parcel$export(module.exports, "useColorFieldState", () => $d59d0c2b2ce1568f$export$d52a01683abdfcd6);
|
|
12
|
+
$parcel$export(module.exports, "parseColor", () => $83fe1a57d631223b$exports.parseColor);
|
|
13
|
+
$parcel$export(module.exports, "useColorAreaState", () => $af2d7ac9990cfee2$exports.useColorAreaState);
|
|
14
|
+
$parcel$export(module.exports, "useColorSliderState", () => $5386a492cfd3234c$exports.useColorSliderState);
|
|
15
|
+
$parcel$export(module.exports, "useColorWheelState", () => $9d7d8736d45f74b8$exports.useColorWheelState);
|
|
16
|
+
$parcel$export(module.exports, "useColorFieldState", () => $d59d0c2b2ce1568f$exports.useColorFieldState);
|
|
56
17
|
/*
|
|
57
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
58
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
59
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
60
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
61
|
-
*
|
|
62
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
63
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
64
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
65
|
-
* governing permissions and limitations under the License.
|
|
66
|
-
*/ /*
|
|
67
18
|
* Copyright 2020 Adobe. All rights reserved.
|
|
68
19
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
69
20
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -74,1257 +25,8 @@ $parcel$export(module.exports, "useColorFieldState", () => $d59d0c2b2ce1568f$exp
|
|
|
74
25
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
75
26
|
* governing permissions and limitations under the License.
|
|
76
27
|
*/
|
|
77
|
-
var $097dc310d9980f22$exports = {};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
28
|
|
|
106
29
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
$097dc310d9980f22$exports = {
|
|
113
|
-
"ar-AE": $b044e7150534af04$exports,
|
|
114
|
-
"bg-BG": $c8bf89547a4a9b3f$exports,
|
|
115
|
-
"cs-CZ": $8365d8dfc7e4c985$exports,
|
|
116
|
-
"da-DK": $8d95eeaa73699e56$exports,
|
|
117
|
-
"de-DE": $2dbbd166053d6d10$exports,
|
|
118
|
-
"el-GR": $1fcbdf9eaf6cc074$exports,
|
|
119
|
-
"en-US": $42d54be461715959$exports,
|
|
120
|
-
"es-ES": $911646bd5662c33d$exports,
|
|
121
|
-
"et-EE": $6e8998796901e680$exports,
|
|
122
|
-
"fi-FI": $4503b4001036be6d$exports,
|
|
123
|
-
"fr-FR": $721e7016769a7a7f$exports,
|
|
124
|
-
"he-IL": $dcc290e5792f9bab$exports,
|
|
125
|
-
"hr-HR": $d93d5aebdd12334c$exports,
|
|
126
|
-
"hu-HU": $a3749e0ee87dbebc$exports,
|
|
127
|
-
"it-IT": $2fdb931b6c9652b9$exports,
|
|
128
|
-
"ja-JP": $219c839b59015b4f$exports,
|
|
129
|
-
"ko-KR": $b7f67f414086d976$exports,
|
|
130
|
-
"lt-LT": $f27b2ac7d517417c$exports,
|
|
131
|
-
"lv-LV": $e92168db3cbe2797$exports,
|
|
132
|
-
"nb-NO": $44b012e02982e825$exports,
|
|
133
|
-
"nl-NL": $64fbd91459613d8b$exports,
|
|
134
|
-
"pl-PL": $83fabdc4e0df6af9$exports,
|
|
135
|
-
"pt-BR": $30b915257fa66ccf$exports,
|
|
136
|
-
"pt-PT": $ce75e45ccbc92491$exports,
|
|
137
|
-
"ro-RO": $225440ee53a1fecd$exports,
|
|
138
|
-
"ru-RU": $cbc60c1dd4e689ff$exports,
|
|
139
|
-
"sk-SK": $8612080ab5efe0cf$exports,
|
|
140
|
-
"sl-SI": $99cc034ddd2b7d86$exports,
|
|
141
|
-
"sr-SP": $dc671800d61be83e$exports,
|
|
142
|
-
"sv-SE": $0f4790e2f696e63f$exports,
|
|
143
|
-
"tr-TR": $deb5f82eb1998a3c$exports,
|
|
144
|
-
"uk-UA": $99530e1782ca02cc$exports,
|
|
145
|
-
"zh-CN": $a6e8f490b423d65e$exports,
|
|
146
|
-
"zh-TW": $eba443dcc93cab9a$exports
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let $83fe1a57d631223b$var$dictionary = new (0, $4tN2K$internationalizedstring.LocalizedStringDictionary)((0, (/*@__PURE__*/$parcel$interopDefault($097dc310d9980f22$exports))));
|
|
153
|
-
function $83fe1a57d631223b$export$6e865ea70d7724f(value) {
|
|
154
|
-
let res = $83fe1a57d631223b$var$RGBColor.parse(value) || $83fe1a57d631223b$var$HSBColor.parse(value) || $83fe1a57d631223b$var$HSLColor.parse(value);
|
|
155
|
-
if (res) return res;
|
|
156
|
-
throw new Error("Invalid color value: " + value);
|
|
157
|
-
}
|
|
158
|
-
function $83fe1a57d631223b$export$4cde5df63f53f473(v) {
|
|
159
|
-
if (typeof v === "string") return $83fe1a57d631223b$export$6e865ea70d7724f(v);
|
|
160
|
-
else return v;
|
|
161
|
-
}
|
|
162
|
-
// Lightness threshold between orange and brown.
|
|
163
|
-
const $83fe1a57d631223b$var$ORANGE_LIGHTNESS_THRESHOLD = 0.68;
|
|
164
|
-
// Lightness threshold between pure yellow and "yellow green".
|
|
165
|
-
const $83fe1a57d631223b$var$YELLOW_GREEN_LIGHTNESS_THRESHOLD = 0.85;
|
|
166
|
-
// The maximum lightness considered to be "dark".
|
|
167
|
-
const $83fe1a57d631223b$var$MAX_DARK_LIGHTNESS = 0.55;
|
|
168
|
-
// The chroma threshold between gray and color.
|
|
169
|
-
const $83fe1a57d631223b$var$GRAY_THRESHOLD = 0.001;
|
|
170
|
-
const $83fe1a57d631223b$var$OKLCH_HUES = [
|
|
171
|
-
[
|
|
172
|
-
0,
|
|
173
|
-
"pink"
|
|
174
|
-
],
|
|
175
|
-
[
|
|
176
|
-
15,
|
|
177
|
-
"red"
|
|
178
|
-
],
|
|
179
|
-
[
|
|
180
|
-
48,
|
|
181
|
-
"orange"
|
|
182
|
-
],
|
|
183
|
-
[
|
|
184
|
-
94,
|
|
185
|
-
"yellow"
|
|
186
|
-
],
|
|
187
|
-
[
|
|
188
|
-
135,
|
|
189
|
-
"green"
|
|
190
|
-
],
|
|
191
|
-
[
|
|
192
|
-
175,
|
|
193
|
-
"cyan"
|
|
194
|
-
],
|
|
195
|
-
[
|
|
196
|
-
264,
|
|
197
|
-
"blue"
|
|
198
|
-
],
|
|
199
|
-
[
|
|
200
|
-
284,
|
|
201
|
-
"purple"
|
|
202
|
-
],
|
|
203
|
-
[
|
|
204
|
-
320,
|
|
205
|
-
"magenta"
|
|
206
|
-
],
|
|
207
|
-
[
|
|
208
|
-
349,
|
|
209
|
-
"pink"
|
|
210
|
-
]
|
|
211
|
-
];
|
|
212
|
-
class $83fe1a57d631223b$var$Color {
|
|
213
|
-
toHexInt() {
|
|
214
|
-
return this.toFormat("rgb").toHexInt();
|
|
215
|
-
}
|
|
216
|
-
getChannelValue(channel) {
|
|
217
|
-
if (channel in this) return this[channel];
|
|
218
|
-
throw new Error("Unsupported color channel: " + channel);
|
|
219
|
-
}
|
|
220
|
-
withChannelValue(channel, value) {
|
|
221
|
-
if (channel in this) {
|
|
222
|
-
let x = this.clone();
|
|
223
|
-
x[channel] = value;
|
|
224
|
-
return x;
|
|
225
|
-
}
|
|
226
|
-
throw new Error("Unsupported color channel: " + channel);
|
|
227
|
-
}
|
|
228
|
-
getChannelName(channel, locale) {
|
|
229
|
-
let strings = (0, $4tN2K$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage("@react-stately/color") || $83fe1a57d631223b$var$dictionary;
|
|
230
|
-
return strings.getStringForLocale(channel, locale);
|
|
231
|
-
}
|
|
232
|
-
getColorSpaceAxes(xyChannels) {
|
|
233
|
-
let { xChannel: xChannel, yChannel: yChannel } = xyChannels;
|
|
234
|
-
let xCh = xChannel || this.getColorChannels().find((c)=>c !== yChannel);
|
|
235
|
-
let yCh = yChannel || this.getColorChannels().find((c)=>c !== xCh);
|
|
236
|
-
let zCh = this.getColorChannels().find((c)=>c !== xCh && c !== yCh);
|
|
237
|
-
return {
|
|
238
|
-
xChannel: xCh,
|
|
239
|
-
yChannel: yCh,
|
|
240
|
-
zChannel: zCh
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
getColorName(locale) {
|
|
244
|
-
// Convert to oklch color space, which has perceptually uniform lightness across all hues.
|
|
245
|
-
let [l, c, h] = $83fe1a57d631223b$var$toOKLCH(this);
|
|
246
|
-
let strings = (0, $4tN2K$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage("@react-stately/color") || $83fe1a57d631223b$var$dictionary;
|
|
247
|
-
if (l > 0.999) return strings.getStringForLocale("white", locale);
|
|
248
|
-
if (l < 0.001) return strings.getStringForLocale("black", locale);
|
|
249
|
-
let hue;
|
|
250
|
-
[hue, l] = this.getOklchHue(l, c, h, locale);
|
|
251
|
-
let lightness = "";
|
|
252
|
-
let chroma = "";
|
|
253
|
-
if (c <= 0.1 && c >= $83fe1a57d631223b$var$GRAY_THRESHOLD) {
|
|
254
|
-
if (l >= 0.7) chroma = "pale";
|
|
255
|
-
else chroma = "grayish";
|
|
256
|
-
} else if (c >= 0.15) chroma = "vibrant";
|
|
257
|
-
if (l < 0.3) lightness = "very dark";
|
|
258
|
-
else if (l < $83fe1a57d631223b$var$MAX_DARK_LIGHTNESS) lightness = "dark";
|
|
259
|
-
else if (l < 0.7) ;
|
|
260
|
-
else if (l < 0.85) lightness = "light";
|
|
261
|
-
else lightness = "very light";
|
|
262
|
-
if (chroma) chroma = strings.getStringForLocale(chroma, locale);
|
|
263
|
-
if (lightness) lightness = strings.getStringForLocale(lightness, locale);
|
|
264
|
-
let alpha = this.getChannelValue("alpha");
|
|
265
|
-
let formatter = new (0, $4tN2K$internationalizedstring.LocalizedStringFormatter)(locale, strings);
|
|
266
|
-
let transparency = "";
|
|
267
|
-
if (alpha < 1) {
|
|
268
|
-
let percent = new (0, $4tN2K$internationalizednumber.NumberFormatter)(locale, {
|
|
269
|
-
style: "percent"
|
|
270
|
-
}).format(1 - alpha);
|
|
271
|
-
transparency = formatter.format("transparency", {
|
|
272
|
-
percent: percent
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return formatter.format("colorName", {
|
|
276
|
-
lightness: lightness,
|
|
277
|
-
chroma: chroma,
|
|
278
|
-
hue: hue,
|
|
279
|
-
transparency: transparency
|
|
280
|
-
}).replace(/\s+/g, " ").trim();
|
|
281
|
-
}
|
|
282
|
-
getOklchHue(l, c, h, locale) {
|
|
283
|
-
let strings = (0, $4tN2K$internationalizedstring.LocalizedStringDictionary).getGlobalDictionaryForPackage("@react-stately/color") || $83fe1a57d631223b$var$dictionary;
|
|
284
|
-
if (c < $83fe1a57d631223b$var$GRAY_THRESHOLD) return [
|
|
285
|
-
strings.getStringForLocale("gray", locale),
|
|
286
|
-
l
|
|
287
|
-
];
|
|
288
|
-
for(let i = 0; i < $83fe1a57d631223b$var$OKLCH_HUES.length; i++){
|
|
289
|
-
let [hue, hueName] = $83fe1a57d631223b$var$OKLCH_HUES[i];
|
|
290
|
-
let [nextHue, nextHueName] = $83fe1a57d631223b$var$OKLCH_HUES[i + 1] || [
|
|
291
|
-
360,
|
|
292
|
-
"pink"
|
|
293
|
-
];
|
|
294
|
-
if (h >= hue && h < nextHue) {
|
|
295
|
-
// Split orange hue into brown/orange depending on lightness.
|
|
296
|
-
if (hueName === "orange") {
|
|
297
|
-
if (l < $83fe1a57d631223b$var$ORANGE_LIGHTNESS_THRESHOLD) hueName = "brown";
|
|
298
|
-
else // Adjust lightness.
|
|
299
|
-
l = l - $83fe1a57d631223b$var$ORANGE_LIGHTNESS_THRESHOLD + $83fe1a57d631223b$var$MAX_DARK_LIGHTNESS;
|
|
300
|
-
}
|
|
301
|
-
// If the hue is at least halfway to the next hue, add the next hue name as well.
|
|
302
|
-
if (h > hue + (nextHue - hue) / 2 && hueName !== nextHueName) hueName = `${hueName} ${nextHueName}`;
|
|
303
|
-
else if (hueName === "yellow" && l < $83fe1a57d631223b$var$YELLOW_GREEN_LIGHTNESS_THRESHOLD) // Yellow shifts toward green at lower lightnesses.
|
|
304
|
-
hueName = "yellow green";
|
|
305
|
-
let name = strings.getStringForLocale(hueName, locale).toLocaleLowerCase(locale);
|
|
306
|
-
return [
|
|
307
|
-
name,
|
|
308
|
-
l
|
|
309
|
-
];
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
throw new Error("Unexpected hue");
|
|
313
|
-
}
|
|
314
|
-
getHueName(locale) {
|
|
315
|
-
let [l, c, h] = $83fe1a57d631223b$var$toOKLCH(this);
|
|
316
|
-
let [name] = this.getOklchHue(l, c, h, locale);
|
|
317
|
-
return name;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
class $83fe1a57d631223b$var$RGBColor extends $83fe1a57d631223b$var$Color {
|
|
321
|
-
static parse(value) {
|
|
322
|
-
let colors = [];
|
|
323
|
-
// matching #rgb, #rgba, #rrggbb, #rrggbbaa
|
|
324
|
-
if (/^#[\da-f]+$/i.test(value) && [
|
|
325
|
-
4,
|
|
326
|
-
5,
|
|
327
|
-
7,
|
|
328
|
-
9
|
|
329
|
-
].includes(value.length)) {
|
|
330
|
-
const values = (value.length < 6 ? value.replace(/[^#]/gi, "$&$&") : value).slice(1).split("");
|
|
331
|
-
while(values.length > 0)colors.push(parseInt(values.splice(0, 2).join(""), 16));
|
|
332
|
-
colors[3] = colors[3] !== undefined ? colors[3] / 255 : undefined;
|
|
333
|
-
}
|
|
334
|
-
// matching rgb(rrr, ggg, bbb), rgba(rrr, ggg, bbb, 0.a)
|
|
335
|
-
const match = value.match(/^rgba?\((.*)\)$/);
|
|
336
|
-
if (match === null || match === void 0 ? void 0 : match[1]) {
|
|
337
|
-
colors = match[1].split(",").map((value)=>Number(value.trim()));
|
|
338
|
-
colors = colors.map((num, i)=>(0, $4tN2K$reactstatelyutils.clamp)(num, 0, i < 3 ? 255 : 1));
|
|
339
|
-
}
|
|
340
|
-
var _colors_;
|
|
341
|
-
return colors.length < 3 ? undefined : new $83fe1a57d631223b$var$RGBColor(colors[0], colors[1], colors[2], (_colors_ = colors[3]) !== null && _colors_ !== void 0 ? _colors_ : 1);
|
|
342
|
-
}
|
|
343
|
-
toString(format) {
|
|
344
|
-
switch(format){
|
|
345
|
-
case "hex":
|
|
346
|
-
return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0")).toUpperCase();
|
|
347
|
-
case "hexa":
|
|
348
|
-
return "#" + (this.red.toString(16).padStart(2, "0") + this.green.toString(16).padStart(2, "0") + this.blue.toString(16).padStart(2, "0") + Math.round(this.alpha * 255).toString(16).padStart(2, "0")).toUpperCase();
|
|
349
|
-
case "rgb":
|
|
350
|
-
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
351
|
-
case "css":
|
|
352
|
-
case "rgba":
|
|
353
|
-
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
|
|
354
|
-
default:
|
|
355
|
-
return this.toFormat(format).toString(format);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
toFormat(format) {
|
|
359
|
-
switch(format){
|
|
360
|
-
case "hex":
|
|
361
|
-
case "hexa":
|
|
362
|
-
case "rgb":
|
|
363
|
-
case "rgba":
|
|
364
|
-
return this;
|
|
365
|
-
case "hsb":
|
|
366
|
-
case "hsba":
|
|
367
|
-
return this.toHSB();
|
|
368
|
-
case "hsl":
|
|
369
|
-
case "hsla":
|
|
370
|
-
return this.toHSL();
|
|
371
|
-
default:
|
|
372
|
-
throw new Error("Unsupported color conversion: rgb -> " + format);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
toHexInt() {
|
|
376
|
-
return this.red << 16 | this.green << 8 | this.blue;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Converts an RGB color value to HSB.
|
|
380
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
381
|
-
* @returns An HSBColor object.
|
|
382
|
-
*/ toHSB() {
|
|
383
|
-
const red = this.red / 255;
|
|
384
|
-
const green = this.green / 255;
|
|
385
|
-
const blue = this.blue / 255;
|
|
386
|
-
const min = Math.min(red, green, blue);
|
|
387
|
-
const brightness = Math.max(red, green, blue);
|
|
388
|
-
const chroma = brightness - min;
|
|
389
|
-
const saturation = brightness === 0 ? 0 : chroma / brightness;
|
|
390
|
-
let hue = 0; // achromatic
|
|
391
|
-
if (chroma !== 0) {
|
|
392
|
-
switch(brightness){
|
|
393
|
-
case red:
|
|
394
|
-
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
395
|
-
break;
|
|
396
|
-
case green:
|
|
397
|
-
hue = (blue - red) / chroma + 2;
|
|
398
|
-
break;
|
|
399
|
-
case blue:
|
|
400
|
-
hue = (red - green) / chroma + 4;
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
hue /= 6;
|
|
404
|
-
}
|
|
405
|
-
return new $83fe1a57d631223b$var$HSBColor((0, $4tN2K$reactstatelyutils.toFixedNumber)(hue * 360, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(saturation * 100, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(brightness * 100, 2), this.alpha);
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Converts an RGB color value to HSL.
|
|
409
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
410
|
-
* @returns An HSLColor object.
|
|
411
|
-
*/ toHSL() {
|
|
412
|
-
const red = this.red / 255;
|
|
413
|
-
const green = this.green / 255;
|
|
414
|
-
const blue = this.blue / 255;
|
|
415
|
-
const min = Math.min(red, green, blue);
|
|
416
|
-
const max = Math.max(red, green, blue);
|
|
417
|
-
const lightness = (max + min) / 2;
|
|
418
|
-
const chroma = max - min;
|
|
419
|
-
let hue;
|
|
420
|
-
let saturation;
|
|
421
|
-
if (chroma === 0) hue = saturation = 0; // achromatic
|
|
422
|
-
else {
|
|
423
|
-
saturation = chroma / (lightness < .5 ? max + min : 2 - max - min);
|
|
424
|
-
switch(max){
|
|
425
|
-
case red:
|
|
426
|
-
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
427
|
-
break;
|
|
428
|
-
case green:
|
|
429
|
-
hue = (blue - red) / chroma + 2;
|
|
430
|
-
break;
|
|
431
|
-
case blue:
|
|
432
|
-
hue = (red - green) / chroma + 4;
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
hue /= 6;
|
|
436
|
-
}
|
|
437
|
-
return new $83fe1a57d631223b$var$HSLColor((0, $4tN2K$reactstatelyutils.toFixedNumber)(hue * 360, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(saturation * 100, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(lightness * 100, 2), this.alpha);
|
|
438
|
-
}
|
|
439
|
-
clone() {
|
|
440
|
-
return new $83fe1a57d631223b$var$RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
441
|
-
}
|
|
442
|
-
getChannelRange(channel) {
|
|
443
|
-
switch(channel){
|
|
444
|
-
case "red":
|
|
445
|
-
case "green":
|
|
446
|
-
case "blue":
|
|
447
|
-
return {
|
|
448
|
-
minValue: 0x0,
|
|
449
|
-
maxValue: 0xFF,
|
|
450
|
-
step: 0x1,
|
|
451
|
-
pageSize: 0x11
|
|
452
|
-
};
|
|
453
|
-
case "alpha":
|
|
454
|
-
return {
|
|
455
|
-
minValue: 0,
|
|
456
|
-
maxValue: 1,
|
|
457
|
-
step: 0.01,
|
|
458
|
-
pageSize: 0.1
|
|
459
|
-
};
|
|
460
|
-
default:
|
|
461
|
-
throw new Error("Unknown color channel: " + channel);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
formatChannelValue(channel, locale) {
|
|
465
|
-
let options;
|
|
466
|
-
let value = this.getChannelValue(channel);
|
|
467
|
-
switch(channel){
|
|
468
|
-
case "red":
|
|
469
|
-
case "green":
|
|
470
|
-
case "blue":
|
|
471
|
-
options = {
|
|
472
|
-
style: "decimal"
|
|
473
|
-
};
|
|
474
|
-
break;
|
|
475
|
-
case "alpha":
|
|
476
|
-
options = {
|
|
477
|
-
style: "percent"
|
|
478
|
-
};
|
|
479
|
-
break;
|
|
480
|
-
default:
|
|
481
|
-
throw new Error("Unknown color channel: " + channel);
|
|
482
|
-
}
|
|
483
|
-
return new (0, $4tN2K$internationalizednumber.NumberFormatter)(locale, options).format(value);
|
|
484
|
-
}
|
|
485
|
-
getColorSpace() {
|
|
486
|
-
return "rgb";
|
|
487
|
-
}
|
|
488
|
-
getColorChannels() {
|
|
489
|
-
return $83fe1a57d631223b$var$RGBColor.colorChannels;
|
|
490
|
-
}
|
|
491
|
-
constructor(red, green, blue, alpha){
|
|
492
|
-
super();
|
|
493
|
-
this.red = red;
|
|
494
|
-
this.green = green;
|
|
495
|
-
this.blue = blue;
|
|
496
|
-
this.alpha = alpha;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
$83fe1a57d631223b$var$RGBColor.colorChannels = [
|
|
500
|
-
"red",
|
|
501
|
-
"green",
|
|
502
|
-
"blue"
|
|
503
|
-
];
|
|
504
|
-
// X = <negative/positive number with/without decimal places>
|
|
505
|
-
// before/after a comma, 0 or more whitespaces are allowed
|
|
506
|
-
// - hsb(X, X%, X%)
|
|
507
|
-
// - hsba(X, X%, X%, X)
|
|
508
|
-
const $83fe1a57d631223b$var$HSB_REGEX = /hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
509
|
-
class $83fe1a57d631223b$var$HSBColor extends $83fe1a57d631223b$var$Color {
|
|
510
|
-
static parse(value) {
|
|
511
|
-
let m;
|
|
512
|
-
if (m = value.match($83fe1a57d631223b$var$HSB_REGEX)) {
|
|
513
|
-
var _m_;
|
|
514
|
-
const [h, s, b, a] = ((_m_ = m[1]) !== null && _m_ !== void 0 ? _m_ : m[2]).split(",").map((n)=>Number(n.trim().replace("%", "")));
|
|
515
|
-
return new $83fe1a57d631223b$var$HSBColor($83fe1a57d631223b$var$mod(h, 360), (0, $4tN2K$reactstatelyutils.clamp)(s, 0, 100), (0, $4tN2K$reactstatelyutils.clamp)(b, 0, 100), (0, $4tN2K$reactstatelyutils.clamp)(a !== null && a !== void 0 ? a : 1, 0, 1));
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
toString(format) {
|
|
519
|
-
switch(format){
|
|
520
|
-
case "css":
|
|
521
|
-
return this.toHSL().toString("css");
|
|
522
|
-
case "hex":
|
|
523
|
-
return this.toRGB().toString("hex");
|
|
524
|
-
case "hexa":
|
|
525
|
-
return this.toRGB().toString("hexa");
|
|
526
|
-
case "hsb":
|
|
527
|
-
return `hsb(${this.hue}, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.saturation, 2)}%, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.brightness, 2)}%)`;
|
|
528
|
-
case "hsba":
|
|
529
|
-
return `hsba(${this.hue}, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.saturation, 2)}%, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.brightness, 2)}%, ${this.alpha})`;
|
|
530
|
-
default:
|
|
531
|
-
return this.toFormat(format).toString(format);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
toFormat(format) {
|
|
535
|
-
switch(format){
|
|
536
|
-
case "hsb":
|
|
537
|
-
case "hsba":
|
|
538
|
-
return this;
|
|
539
|
-
case "hsl":
|
|
540
|
-
case "hsla":
|
|
541
|
-
return this.toHSL();
|
|
542
|
-
case "rgb":
|
|
543
|
-
case "rgba":
|
|
544
|
-
return this.toRGB();
|
|
545
|
-
default:
|
|
546
|
-
throw new Error("Unsupported color conversion: hsb -> " + format);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
/**
|
|
550
|
-
* Converts a HSB color to HSL.
|
|
551
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
|
|
552
|
-
* @returns An HSLColor object.
|
|
553
|
-
*/ toHSL() {
|
|
554
|
-
let saturation = this.saturation / 100;
|
|
555
|
-
let brightness = this.brightness / 100;
|
|
556
|
-
let lightness = brightness * (1 - saturation / 2);
|
|
557
|
-
saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
558
|
-
return new $83fe1a57d631223b$var$HSLColor((0, $4tN2K$reactstatelyutils.toFixedNumber)(this.hue, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(saturation * 100, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(lightness * 100, 2), this.alpha);
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* Converts a HSV color value to RGB.
|
|
562
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
|
|
563
|
-
* @returns An RGBColor object.
|
|
564
|
-
*/ toRGB() {
|
|
565
|
-
let hue = this.hue;
|
|
566
|
-
let saturation = this.saturation / 100;
|
|
567
|
-
let brightness = this.brightness / 100;
|
|
568
|
-
let fn = (n, k = (n + hue / 60) % 6)=>brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0);
|
|
569
|
-
return new $83fe1a57d631223b$var$RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha);
|
|
570
|
-
}
|
|
571
|
-
clone() {
|
|
572
|
-
return new $83fe1a57d631223b$var$HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
573
|
-
}
|
|
574
|
-
getChannelRange(channel) {
|
|
575
|
-
switch(channel){
|
|
576
|
-
case "hue":
|
|
577
|
-
return {
|
|
578
|
-
minValue: 0,
|
|
579
|
-
maxValue: 360,
|
|
580
|
-
step: 1,
|
|
581
|
-
pageSize: 15
|
|
582
|
-
};
|
|
583
|
-
case "saturation":
|
|
584
|
-
case "brightness":
|
|
585
|
-
return {
|
|
586
|
-
minValue: 0,
|
|
587
|
-
maxValue: 100,
|
|
588
|
-
step: 1,
|
|
589
|
-
pageSize: 10
|
|
590
|
-
};
|
|
591
|
-
case "alpha":
|
|
592
|
-
return {
|
|
593
|
-
minValue: 0,
|
|
594
|
-
maxValue: 1,
|
|
595
|
-
step: 0.01,
|
|
596
|
-
pageSize: 0.1
|
|
597
|
-
};
|
|
598
|
-
default:
|
|
599
|
-
throw new Error("Unknown color channel: " + channel);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
formatChannelValue(channel, locale) {
|
|
603
|
-
let options;
|
|
604
|
-
let value = this.getChannelValue(channel);
|
|
605
|
-
switch(channel){
|
|
606
|
-
case "hue":
|
|
607
|
-
options = {
|
|
608
|
-
style: "unit",
|
|
609
|
-
unit: "degree",
|
|
610
|
-
unitDisplay: "narrow"
|
|
611
|
-
};
|
|
612
|
-
break;
|
|
613
|
-
case "saturation":
|
|
614
|
-
case "brightness":
|
|
615
|
-
options = {
|
|
616
|
-
style: "percent"
|
|
617
|
-
};
|
|
618
|
-
value /= 100;
|
|
619
|
-
break;
|
|
620
|
-
case "alpha":
|
|
621
|
-
options = {
|
|
622
|
-
style: "percent"
|
|
623
|
-
};
|
|
624
|
-
break;
|
|
625
|
-
default:
|
|
626
|
-
throw new Error("Unknown color channel: " + channel);
|
|
627
|
-
}
|
|
628
|
-
return new (0, $4tN2K$internationalizednumber.NumberFormatter)(locale, options).format(value);
|
|
629
|
-
}
|
|
630
|
-
getColorSpace() {
|
|
631
|
-
return "hsb";
|
|
632
|
-
}
|
|
633
|
-
getColorChannels() {
|
|
634
|
-
return $83fe1a57d631223b$var$HSBColor.colorChannels;
|
|
635
|
-
}
|
|
636
|
-
constructor(hue, saturation, brightness, alpha){
|
|
637
|
-
super();
|
|
638
|
-
this.hue = hue;
|
|
639
|
-
this.saturation = saturation;
|
|
640
|
-
this.brightness = brightness;
|
|
641
|
-
this.alpha = alpha;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
$83fe1a57d631223b$var$HSBColor.colorChannels = [
|
|
645
|
-
"hue",
|
|
646
|
-
"saturation",
|
|
647
|
-
"brightness"
|
|
648
|
-
];
|
|
649
|
-
// X = <negative/positive number with/without decimal places>
|
|
650
|
-
// before/after a comma, 0 or more whitespaces are allowed
|
|
651
|
-
// - hsl(X, X%, X%)
|
|
652
|
-
// - hsla(X, X%, X%, X)
|
|
653
|
-
const $83fe1a57d631223b$var$HSL_REGEX = /hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
654
|
-
function $83fe1a57d631223b$var$mod(n, m) {
|
|
655
|
-
return (n % m + m) % m;
|
|
656
|
-
}
|
|
657
|
-
class $83fe1a57d631223b$var$HSLColor extends $83fe1a57d631223b$var$Color {
|
|
658
|
-
static parse(value) {
|
|
659
|
-
let m;
|
|
660
|
-
if (m = value.match($83fe1a57d631223b$var$HSL_REGEX)) {
|
|
661
|
-
var _m_;
|
|
662
|
-
const [h, s, l, a] = ((_m_ = m[1]) !== null && _m_ !== void 0 ? _m_ : m[2]).split(",").map((n)=>Number(n.trim().replace("%", "")));
|
|
663
|
-
return new $83fe1a57d631223b$var$HSLColor($83fe1a57d631223b$var$mod(h, 360), (0, $4tN2K$reactstatelyutils.clamp)(s, 0, 100), (0, $4tN2K$reactstatelyutils.clamp)(l, 0, 100), (0, $4tN2K$reactstatelyutils.clamp)(a !== null && a !== void 0 ? a : 1, 0, 1));
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
toString(format) {
|
|
667
|
-
switch(format){
|
|
668
|
-
case "hex":
|
|
669
|
-
return this.toRGB().toString("hex");
|
|
670
|
-
case "hexa":
|
|
671
|
-
return this.toRGB().toString("hexa");
|
|
672
|
-
case "hsl":
|
|
673
|
-
return `hsl(${this.hue}, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.saturation, 2)}%, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.lightness, 2)}%)`;
|
|
674
|
-
case "css":
|
|
675
|
-
case "hsla":
|
|
676
|
-
return `hsla(${this.hue}, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.saturation, 2)}%, ${(0, $4tN2K$reactstatelyutils.toFixedNumber)(this.lightness, 2)}%, ${this.alpha})`;
|
|
677
|
-
default:
|
|
678
|
-
return this.toFormat(format).toString(format);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
toFormat(format) {
|
|
682
|
-
switch(format){
|
|
683
|
-
case "hsl":
|
|
684
|
-
case "hsla":
|
|
685
|
-
return this;
|
|
686
|
-
case "hsb":
|
|
687
|
-
case "hsba":
|
|
688
|
-
return this.toHSB();
|
|
689
|
-
case "rgb":
|
|
690
|
-
case "rgba":
|
|
691
|
-
return this.toRGB();
|
|
692
|
-
default:
|
|
693
|
-
throw new Error("Unsupported color conversion: hsl -> " + format);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Converts a HSL color to HSB.
|
|
698
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
699
|
-
* @returns An HSBColor object.
|
|
700
|
-
*/ toHSB() {
|
|
701
|
-
let saturation = this.saturation / 100;
|
|
702
|
-
let lightness = this.lightness / 100;
|
|
703
|
-
let brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
704
|
-
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
705
|
-
return new $83fe1a57d631223b$var$HSBColor((0, $4tN2K$reactstatelyutils.toFixedNumber)(this.hue, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(saturation * 100, 2), (0, $4tN2K$reactstatelyutils.toFixedNumber)(brightness * 100, 2), this.alpha);
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Converts a HSL color to RGB.
|
|
709
|
-
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
710
|
-
* @returns An RGBColor object.
|
|
711
|
-
*/ toRGB() {
|
|
712
|
-
let hue = this.hue;
|
|
713
|
-
let saturation = this.saturation / 100;
|
|
714
|
-
let lightness = this.lightness / 100;
|
|
715
|
-
let a = saturation * Math.min(lightness, 1 - lightness);
|
|
716
|
-
let fn = (n, k = (n + hue / 30) % 12)=>lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
717
|
-
return new $83fe1a57d631223b$var$RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha);
|
|
718
|
-
}
|
|
719
|
-
clone() {
|
|
720
|
-
return new $83fe1a57d631223b$var$HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
721
|
-
}
|
|
722
|
-
getChannelRange(channel) {
|
|
723
|
-
switch(channel){
|
|
724
|
-
case "hue":
|
|
725
|
-
return {
|
|
726
|
-
minValue: 0,
|
|
727
|
-
maxValue: 360,
|
|
728
|
-
step: 1,
|
|
729
|
-
pageSize: 15
|
|
730
|
-
};
|
|
731
|
-
case "saturation":
|
|
732
|
-
case "lightness":
|
|
733
|
-
return {
|
|
734
|
-
minValue: 0,
|
|
735
|
-
maxValue: 100,
|
|
736
|
-
step: 1,
|
|
737
|
-
pageSize: 10
|
|
738
|
-
};
|
|
739
|
-
case "alpha":
|
|
740
|
-
return {
|
|
741
|
-
minValue: 0,
|
|
742
|
-
maxValue: 1,
|
|
743
|
-
step: 0.01,
|
|
744
|
-
pageSize: 0.1
|
|
745
|
-
};
|
|
746
|
-
default:
|
|
747
|
-
throw new Error("Unknown color channel: " + channel);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
formatChannelValue(channel, locale) {
|
|
751
|
-
let options;
|
|
752
|
-
let value = this.getChannelValue(channel);
|
|
753
|
-
switch(channel){
|
|
754
|
-
case "hue":
|
|
755
|
-
options = {
|
|
756
|
-
style: "unit",
|
|
757
|
-
unit: "degree",
|
|
758
|
-
unitDisplay: "narrow"
|
|
759
|
-
};
|
|
760
|
-
break;
|
|
761
|
-
case "saturation":
|
|
762
|
-
case "lightness":
|
|
763
|
-
options = {
|
|
764
|
-
style: "percent"
|
|
765
|
-
};
|
|
766
|
-
value /= 100;
|
|
767
|
-
break;
|
|
768
|
-
case "alpha":
|
|
769
|
-
options = {
|
|
770
|
-
style: "percent"
|
|
771
|
-
};
|
|
772
|
-
break;
|
|
773
|
-
default:
|
|
774
|
-
throw new Error("Unknown color channel: " + channel);
|
|
775
|
-
}
|
|
776
|
-
return new (0, $4tN2K$internationalizednumber.NumberFormatter)(locale, options).format(value);
|
|
777
|
-
}
|
|
778
|
-
getColorSpace() {
|
|
779
|
-
return "hsl";
|
|
780
|
-
}
|
|
781
|
-
getColorChannels() {
|
|
782
|
-
return $83fe1a57d631223b$var$HSLColor.colorChannels;
|
|
783
|
-
}
|
|
784
|
-
constructor(hue, saturation, lightness, alpha){
|
|
785
|
-
super();
|
|
786
|
-
this.hue = hue;
|
|
787
|
-
this.saturation = saturation;
|
|
788
|
-
this.lightness = lightness;
|
|
789
|
-
this.alpha = alpha;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
$83fe1a57d631223b$var$HSLColor.colorChannels = [
|
|
793
|
-
"hue",
|
|
794
|
-
"saturation",
|
|
795
|
-
"lightness"
|
|
796
|
-
];
|
|
797
|
-
// https://www.w3.org/TR/css-color-4/#color-conversion-code
|
|
798
|
-
function $83fe1a57d631223b$var$toOKLCH(color) {
|
|
799
|
-
let rgb = color.toFormat("rgb");
|
|
800
|
-
let red = rgb.getChannelValue("red") / 255;
|
|
801
|
-
let green = rgb.getChannelValue("green") / 255;
|
|
802
|
-
let blue = rgb.getChannelValue("blue") / 255;
|
|
803
|
-
[red, green, blue] = $83fe1a57d631223b$var$lin_sRGB(red, green, blue);
|
|
804
|
-
let [x, y, z] = $83fe1a57d631223b$var$lin_sRGB_to_XYZ(red, green, blue);
|
|
805
|
-
let [l, a, b] = $83fe1a57d631223b$var$XYZ_to_OKLab(x, y, z);
|
|
806
|
-
return $83fe1a57d631223b$var$OKLab_to_OKLCH(l, a, b);
|
|
807
|
-
}
|
|
808
|
-
function $83fe1a57d631223b$var$OKLab_to_OKLCH(l, a, b) {
|
|
809
|
-
var hue = Math.atan2(b, a) * 180 / Math.PI;
|
|
810
|
-
return [
|
|
811
|
-
l,
|
|
812
|
-
Math.sqrt(a ** 2 + b ** 2),
|
|
813
|
-
hue >= 0 ? hue : hue + 360 // Hue, in degrees [0 to 360)
|
|
814
|
-
];
|
|
815
|
-
}
|
|
816
|
-
function $83fe1a57d631223b$var$lin_sRGB(r, g, b) {
|
|
817
|
-
// convert an array of sRGB values
|
|
818
|
-
// where in-gamut values are in the range [0 - 1]
|
|
819
|
-
// to linear light (un-companded) form.
|
|
820
|
-
// https://en.wikipedia.org/wiki/SRGB
|
|
821
|
-
// Extended transfer function:
|
|
822
|
-
// for negative values, linear portion is extended on reflection of axis,
|
|
823
|
-
// then reflected power function is used.
|
|
824
|
-
return [
|
|
825
|
-
$83fe1a57d631223b$var$lin_sRGB_component(r),
|
|
826
|
-
$83fe1a57d631223b$var$lin_sRGB_component(g),
|
|
827
|
-
$83fe1a57d631223b$var$lin_sRGB_component(b)
|
|
828
|
-
];
|
|
829
|
-
}
|
|
830
|
-
function $83fe1a57d631223b$var$lin_sRGB_component(val) {
|
|
831
|
-
let sign = val < 0 ? -1 : 1;
|
|
832
|
-
let abs = Math.abs(val);
|
|
833
|
-
if (abs <= 0.04045) return val / 12.92;
|
|
834
|
-
return sign * Math.pow((abs + 0.055) / 1.055, 2.4);
|
|
835
|
-
}
|
|
836
|
-
function $83fe1a57d631223b$var$lin_sRGB_to_XYZ(r, g, b) {
|
|
837
|
-
// convert an array of linear-light sRGB values to CIE XYZ
|
|
838
|
-
// using sRGB's own white, D65 (no chromatic adaptation)
|
|
839
|
-
const M = [
|
|
840
|
-
506752 / 1228815,
|
|
841
|
-
87881 / 245763,
|
|
842
|
-
12673 / 70218,
|
|
843
|
-
87098 / 409605,
|
|
844
|
-
175762 / 245763,
|
|
845
|
-
12673 / 175545,
|
|
846
|
-
7918 / 409605,
|
|
847
|
-
87881 / 737289,
|
|
848
|
-
1001167 / 1053270
|
|
849
|
-
];
|
|
850
|
-
return $83fe1a57d631223b$var$multiplyMatrix(M, r, g, b);
|
|
851
|
-
}
|
|
852
|
-
function $83fe1a57d631223b$var$XYZ_to_OKLab(x, y, z) {
|
|
853
|
-
// Given XYZ relative to D65, convert to OKLab
|
|
854
|
-
const XYZtoLMS = [
|
|
855
|
-
0.8190224379967030,
|
|
856
|
-
0.3619062600528904,
|
|
857
|
-
-0.1288737815209879,
|
|
858
|
-
0.0329836539323885,
|
|
859
|
-
0.9292868615863434,
|
|
860
|
-
0.0361446663506424,
|
|
861
|
-
0.0481771893596242,
|
|
862
|
-
0.2642395317527308,
|
|
863
|
-
0.6335478284694309
|
|
864
|
-
];
|
|
865
|
-
const LMStoOKLab = [
|
|
866
|
-
0.2104542683093140,
|
|
867
|
-
0.7936177747023054,
|
|
868
|
-
-0.0040720430116193,
|
|
869
|
-
1.9779985324311684,
|
|
870
|
-
-2.42859224204858,
|
|
871
|
-
0.4505937096174110,
|
|
872
|
-
0.0259040424655478,
|
|
873
|
-
0.7827717124575296,
|
|
874
|
-
-0.8086757549230774
|
|
875
|
-
];
|
|
876
|
-
let [a, b, c] = $83fe1a57d631223b$var$multiplyMatrix(XYZtoLMS, x, y, z);
|
|
877
|
-
return $83fe1a57d631223b$var$multiplyMatrix(LMStoOKLab, Math.cbrt(a), Math.cbrt(b), Math.cbrt(c));
|
|
878
|
-
}
|
|
879
|
-
function $83fe1a57d631223b$var$multiplyMatrix(m, x, y, z) {
|
|
880
|
-
let a = m[0] * x + m[1] * y + m[2] * z;
|
|
881
|
-
let b = m[3] * x + m[4] * y + m[5] * z;
|
|
882
|
-
let c = m[6] * x + m[7] * y + m[8] * z;
|
|
883
|
-
return [
|
|
884
|
-
a,
|
|
885
|
-
b,
|
|
886
|
-
c
|
|
887
|
-
];
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
/*
|
|
892
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
893
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
894
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
895
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
896
|
-
*
|
|
897
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
898
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
899
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
900
|
-
* governing permissions and limitations under the License.
|
|
901
|
-
*/
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
const $af2d7ac9990cfee2$var$DEFAULT_COLOR = (0, $83fe1a57d631223b$export$6e865ea70d7724f)("#ffffff");
|
|
905
|
-
function $af2d7ac9990cfee2$export$6df7f0e2cabc7eef(props) {
|
|
906
|
-
let { value: value, defaultValue: defaultValue, xChannel: xChannel, yChannel: yChannel, onChange: onChange, onChangeEnd: onChangeEnd } = props;
|
|
907
|
-
if (!value && !defaultValue) defaultValue = $af2d7ac9990cfee2$var$DEFAULT_COLOR;
|
|
908
|
-
let [color, setColorState] = (0, $4tN2K$reactstatelyutils.useControlledState)(value && (0, $83fe1a57d631223b$export$4cde5df63f53f473)(value), defaultValue && (0, $83fe1a57d631223b$export$4cde5df63f53f473)(defaultValue), onChange);
|
|
909
|
-
let valueRef = (0, $4tN2K$react.useRef)(color);
|
|
910
|
-
let setColor = (color)=>{
|
|
911
|
-
valueRef.current = color;
|
|
912
|
-
setColorState(color);
|
|
913
|
-
};
|
|
914
|
-
let channels = (0, $4tN2K$react.useMemo)(()=>color.getColorSpaceAxes({
|
|
915
|
-
xChannel: xChannel,
|
|
916
|
-
yChannel: yChannel
|
|
917
|
-
}), [
|
|
918
|
-
color,
|
|
919
|
-
xChannel,
|
|
920
|
-
yChannel
|
|
921
|
-
]);
|
|
922
|
-
let xChannelRange = color.getChannelRange(channels.xChannel);
|
|
923
|
-
let yChannelRange = color.getChannelRange(channels.yChannel);
|
|
924
|
-
let { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
|
|
925
|
-
let { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
|
|
926
|
-
let [isDragging, setDragging] = (0, $4tN2K$react.useState)(false);
|
|
927
|
-
let isDraggingRef = (0, $4tN2K$react.useRef)(false);
|
|
928
|
-
let xValue = color.getChannelValue(channels.xChannel);
|
|
929
|
-
let yValue = color.getChannelValue(channels.yChannel);
|
|
930
|
-
let setXValue = (v)=>{
|
|
931
|
-
if (v === xValue) return;
|
|
932
|
-
let newColor = color.withChannelValue(channels.xChannel, v);
|
|
933
|
-
setColor(newColor);
|
|
934
|
-
};
|
|
935
|
-
let setYValue = (v)=>{
|
|
936
|
-
if (v === yValue) return;
|
|
937
|
-
let newColor = color.withChannelValue(channels.yChannel, v);
|
|
938
|
-
setColor(newColor);
|
|
939
|
-
};
|
|
940
|
-
return {
|
|
941
|
-
channels: channels,
|
|
942
|
-
xChannelStep: stepX,
|
|
943
|
-
yChannelStep: stepY,
|
|
944
|
-
xChannelPageStep: pageSizeX,
|
|
945
|
-
yChannelPageStep: pageSizeY,
|
|
946
|
-
value: color,
|
|
947
|
-
setValue (value) {
|
|
948
|
-
setColor((0, $83fe1a57d631223b$export$4cde5df63f53f473)(value));
|
|
949
|
-
},
|
|
950
|
-
xValue: xValue,
|
|
951
|
-
setXValue: setXValue,
|
|
952
|
-
yValue: yValue,
|
|
953
|
-
setYValue: setYValue,
|
|
954
|
-
setColorFromPoint (x, y) {
|
|
955
|
-
let newXValue = minValueX + (0, $4tN2K$reactstatelyutils.clamp)(x, 0, 1) * (maxValueX - minValueX);
|
|
956
|
-
let newYValue = minValueY + (1 - (0, $4tN2K$reactstatelyutils.clamp)(y, 0, 1)) * (maxValueY - minValueY);
|
|
957
|
-
let newColor;
|
|
958
|
-
if (newXValue !== xValue) {
|
|
959
|
-
// Round new value to multiple of step, clamp value between min and max
|
|
960
|
-
newXValue = (0, $4tN2K$reactstatelyutils.snapValueToStep)(newXValue, minValueX, maxValueX, stepX);
|
|
961
|
-
newColor = color.withChannelValue(channels.xChannel, newXValue);
|
|
962
|
-
}
|
|
963
|
-
if (newYValue !== yValue) {
|
|
964
|
-
// Round new value to multiple of step, clamp value between min and max
|
|
965
|
-
newYValue = (0, $4tN2K$reactstatelyutils.snapValueToStep)(newYValue, minValueY, maxValueY, stepY);
|
|
966
|
-
newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
|
|
967
|
-
}
|
|
968
|
-
if (newColor) setColor(newColor);
|
|
969
|
-
},
|
|
970
|
-
getThumbPosition () {
|
|
971
|
-
let x = (xValue - minValueX) / (maxValueX - minValueX);
|
|
972
|
-
let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
|
|
973
|
-
return {
|
|
974
|
-
x: x,
|
|
975
|
-
y: y
|
|
976
|
-
};
|
|
977
|
-
},
|
|
978
|
-
incrementX (stepSize) {
|
|
979
|
-
setXValue(xValue + stepSize > maxValueX ? maxValueX : (0, $4tN2K$reactstatelyutils.snapValueToStep)(xValue + stepSize, minValueX, maxValueX, stepX));
|
|
980
|
-
},
|
|
981
|
-
incrementY (stepSize) {
|
|
982
|
-
setYValue(yValue + stepSize > maxValueY ? maxValueY : (0, $4tN2K$reactstatelyutils.snapValueToStep)(yValue + stepSize, minValueY, maxValueY, stepY));
|
|
983
|
-
},
|
|
984
|
-
decrementX (stepSize) {
|
|
985
|
-
setXValue((0, $4tN2K$reactstatelyutils.snapValueToStep)(xValue - stepSize, minValueX, maxValueX, stepX));
|
|
986
|
-
},
|
|
987
|
-
decrementY (stepSize) {
|
|
988
|
-
setYValue((0, $4tN2K$reactstatelyutils.snapValueToStep)(yValue - stepSize, minValueY, maxValueY, stepY));
|
|
989
|
-
},
|
|
990
|
-
setDragging (isDragging) {
|
|
991
|
-
let wasDragging = isDraggingRef.current;
|
|
992
|
-
isDraggingRef.current = isDragging;
|
|
993
|
-
if (onChangeEnd && !isDragging && wasDragging) onChangeEnd(valueRef.current);
|
|
994
|
-
setDragging(isDragging);
|
|
995
|
-
},
|
|
996
|
-
isDragging: isDragging,
|
|
997
|
-
getDisplayColor () {
|
|
998
|
-
return color.withChannelValue("alpha", 1);
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
/*
|
|
1005
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
1006
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1007
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1008
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1009
|
-
*
|
|
1010
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1011
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1012
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1013
|
-
* governing permissions and limitations under the License.
|
|
1014
|
-
*/
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
function $5386a492cfd3234c$export$57bc203e1c9c6d44(props) {
|
|
1018
|
-
let { channel: channel, value: value, defaultValue: defaultValue, onChange: onChange, locale: locale, ...otherProps } = props;
|
|
1019
|
-
if (value == null && defaultValue == null) throw new Error("useColorSliderState requires a value or defaultValue");
|
|
1020
|
-
let [color, setColor] = (0, $4tN2K$reactstatelyutils.useControlledState)(value && (0, $83fe1a57d631223b$export$4cde5df63f53f473)(value), defaultValue && (0, $83fe1a57d631223b$export$4cde5df63f53f473)(defaultValue), onChange);
|
|
1021
|
-
let sliderState = (0, $4tN2K$reactstatelyslider.useSliderState)({
|
|
1022
|
-
...color.getChannelRange(channel),
|
|
1023
|
-
...otherProps,
|
|
1024
|
-
// Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.
|
|
1025
|
-
numberFormatter: null,
|
|
1026
|
-
value: color.getChannelValue(channel),
|
|
1027
|
-
onChange (v) {
|
|
1028
|
-
setColor(color.withChannelValue(channel, v));
|
|
1029
|
-
},
|
|
1030
|
-
onChangeEnd (v) {
|
|
1031
|
-
// onChange will have already been called with the right value, this is just to trigger onChangeEnd
|
|
1032
|
-
if (props.onChangeEnd) props.onChangeEnd(color.withChannelValue(channel, v));
|
|
1033
|
-
}
|
|
1034
|
-
});
|
|
1035
|
-
let { step: step, pageSize: pageSize } = color.getChannelRange(channel);
|
|
1036
|
-
return {
|
|
1037
|
-
...sliderState,
|
|
1038
|
-
value: color,
|
|
1039
|
-
setValue (value) {
|
|
1040
|
-
setColor((0, $83fe1a57d631223b$export$4cde5df63f53f473)(value));
|
|
1041
|
-
},
|
|
1042
|
-
getDisplayColor () {
|
|
1043
|
-
switch(channel){
|
|
1044
|
-
case "hue":
|
|
1045
|
-
return (0, $83fe1a57d631223b$export$6e865ea70d7724f)(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
|
|
1046
|
-
case "lightness":
|
|
1047
|
-
case "brightness":
|
|
1048
|
-
case "saturation":
|
|
1049
|
-
case "red":
|
|
1050
|
-
case "green":
|
|
1051
|
-
case "blue":
|
|
1052
|
-
return color.withChannelValue("alpha", 1);
|
|
1053
|
-
case "alpha":
|
|
1054
|
-
return color;
|
|
1055
|
-
default:
|
|
1056
|
-
throw new Error("Unknown color channel: " + channel);
|
|
1057
|
-
}
|
|
1058
|
-
},
|
|
1059
|
-
getThumbValueLabel () {
|
|
1060
|
-
return color.formatChannelValue(channel, locale);
|
|
1061
|
-
},
|
|
1062
|
-
step: step,
|
|
1063
|
-
pageSize: pageSize
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
/*
|
|
1069
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
1070
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1071
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1072
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1073
|
-
*
|
|
1074
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1075
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1076
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1077
|
-
* governing permissions and limitations under the License.
|
|
1078
|
-
*/
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
const $9d7d8736d45f74b8$var$DEFAULT_COLOR = (0, $83fe1a57d631223b$export$6e865ea70d7724f)("hsl(0, 100%, 50%)");
|
|
1082
|
-
function $9d7d8736d45f74b8$var$roundToStep(value, step) {
|
|
1083
|
-
return Math.round(value / step) * step;
|
|
1084
|
-
}
|
|
1085
|
-
function $9d7d8736d45f74b8$var$mod(n, m) {
|
|
1086
|
-
return (n % m + m) % m;
|
|
1087
|
-
}
|
|
1088
|
-
function $9d7d8736d45f74b8$var$roundDown(v) {
|
|
1089
|
-
let r = Math.floor(v);
|
|
1090
|
-
if (r === v) return v - 1;
|
|
1091
|
-
else return r;
|
|
1092
|
-
}
|
|
1093
|
-
function $9d7d8736d45f74b8$var$degToRad(deg) {
|
|
1094
|
-
return deg * Math.PI / 180;
|
|
1095
|
-
}
|
|
1096
|
-
function $9d7d8736d45f74b8$var$radToDeg(rad) {
|
|
1097
|
-
return rad * 180 / Math.PI;
|
|
1098
|
-
}
|
|
1099
|
-
// 0deg = 3 o'clock. increases clockwise
|
|
1100
|
-
function $9d7d8736d45f74b8$var$angleToCartesian(angle, radius) {
|
|
1101
|
-
let rad = $9d7d8736d45f74b8$var$degToRad(360 - angle + 90);
|
|
1102
|
-
let x = Math.sin(rad) * radius;
|
|
1103
|
-
let y = Math.cos(rad) * radius;
|
|
1104
|
-
return {
|
|
1105
|
-
x: x,
|
|
1106
|
-
y: y
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
function $9d7d8736d45f74b8$var$cartesianToAngle(x, y, radius) {
|
|
1110
|
-
let deg = $9d7d8736d45f74b8$var$radToDeg(Math.atan2(y / radius, x / radius));
|
|
1111
|
-
return (deg + 360) % 360;
|
|
1112
|
-
}
|
|
1113
|
-
function $9d7d8736d45f74b8$export$f4301076d9336137(props) {
|
|
1114
|
-
let { defaultValue: defaultValue, onChange: onChange, onChangeEnd: onChangeEnd } = props;
|
|
1115
|
-
if (!props.value && !defaultValue) defaultValue = $9d7d8736d45f74b8$var$DEFAULT_COLOR;
|
|
1116
|
-
let [value, setValueState] = (0, $4tN2K$reactstatelyutils.useControlledState)((0, $83fe1a57d631223b$export$4cde5df63f53f473)(props.value), (0, $83fe1a57d631223b$export$4cde5df63f53f473)(defaultValue), onChange);
|
|
1117
|
-
let valueRef = (0, $4tN2K$react.useRef)(value);
|
|
1118
|
-
let setValue = (value)=>{
|
|
1119
|
-
valueRef.current = value;
|
|
1120
|
-
setValueState(value);
|
|
1121
|
-
};
|
|
1122
|
-
let channelRange = value.getChannelRange("hue");
|
|
1123
|
-
let { minValue: minValueX, maxValue: maxValueX, step: step, pageSize: pageStep } = channelRange;
|
|
1124
|
-
let [isDragging, setDragging] = (0, $4tN2K$react.useState)(false);
|
|
1125
|
-
let isDraggingRef = (0, $4tN2K$react.useRef)(false);
|
|
1126
|
-
let hue = value.getChannelValue("hue");
|
|
1127
|
-
function setHue(v) {
|
|
1128
|
-
if (v > 360) // Make sure you can always get back to 0.
|
|
1129
|
-
v = 0;
|
|
1130
|
-
v = $9d7d8736d45f74b8$var$roundToStep($9d7d8736d45f74b8$var$mod(v, 360), step);
|
|
1131
|
-
if (hue !== v) {
|
|
1132
|
-
let color = value.withChannelValue("hue", v);
|
|
1133
|
-
setValue(color);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
return {
|
|
1137
|
-
value: value,
|
|
1138
|
-
step: step,
|
|
1139
|
-
pageStep: pageStep,
|
|
1140
|
-
setValue (v) {
|
|
1141
|
-
let color = (0, $83fe1a57d631223b$export$4cde5df63f53f473)(v);
|
|
1142
|
-
setValue(color);
|
|
1143
|
-
},
|
|
1144
|
-
hue: hue,
|
|
1145
|
-
setHue: setHue,
|
|
1146
|
-
setHueFromPoint (x, y, radius) {
|
|
1147
|
-
setHue($9d7d8736d45f74b8$var$cartesianToAngle(x, y, radius));
|
|
1148
|
-
},
|
|
1149
|
-
getThumbPosition (radius) {
|
|
1150
|
-
return $9d7d8736d45f74b8$var$angleToCartesian(value.getChannelValue("hue"), radius);
|
|
1151
|
-
},
|
|
1152
|
-
increment (stepSize = 1) {
|
|
1153
|
-
let s = Math.max(stepSize, step);
|
|
1154
|
-
let newValue = hue + s;
|
|
1155
|
-
if (newValue >= maxValueX) // Make sure you can always get back to 0.
|
|
1156
|
-
newValue = minValueX;
|
|
1157
|
-
setHue($9d7d8736d45f74b8$var$roundToStep($9d7d8736d45f74b8$var$mod(newValue, 360), s));
|
|
1158
|
-
},
|
|
1159
|
-
decrement (stepSize = 1) {
|
|
1160
|
-
let s = Math.max(stepSize, step);
|
|
1161
|
-
if (hue === 0) // We can't just subtract step because this might be the case:
|
|
1162
|
-
// |(previous step) - 0| < step size
|
|
1163
|
-
setHue($9d7d8736d45f74b8$var$roundDown(360 / s) * s);
|
|
1164
|
-
else setHue($9d7d8736d45f74b8$var$roundToStep($9d7d8736d45f74b8$var$mod(hue - s, 360), s));
|
|
1165
|
-
},
|
|
1166
|
-
setDragging (isDragging) {
|
|
1167
|
-
let wasDragging = isDraggingRef.current;
|
|
1168
|
-
isDraggingRef.current = isDragging;
|
|
1169
|
-
if (onChangeEnd && !isDragging && wasDragging) onChangeEnd(valueRef.current);
|
|
1170
|
-
setDragging(isDragging);
|
|
1171
|
-
},
|
|
1172
|
-
isDragging: isDragging,
|
|
1173
|
-
getDisplayColor () {
|
|
1174
|
-
return value.toFormat("hsl").withChannelValue("saturation", 100).withChannelValue("lightness", 50).withChannelValue("alpha", 1);
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
/*
|
|
1181
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
1182
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1183
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1184
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1185
|
-
*
|
|
1186
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1187
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1188
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1189
|
-
* governing permissions and limitations under the License.
|
|
1190
|
-
*/
|
|
1191
|
-
|
|
1192
|
-
/*
|
|
1193
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
1194
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1195
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1196
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1197
|
-
*
|
|
1198
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1199
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1200
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1201
|
-
* governing permissions and limitations under the License.
|
|
1202
|
-
*/
|
|
1203
|
-
|
|
1204
|
-
function $f8b3be23ba4462b1$export$5aadd9c0606af5c2(value) {
|
|
1205
|
-
return (0, $4tN2K$react.useMemo)(()=>{
|
|
1206
|
-
if (typeof value === "string") try {
|
|
1207
|
-
return (0, $83fe1a57d631223b$export$6e865ea70d7724f)(value);
|
|
1208
|
-
} catch (err) {
|
|
1209
|
-
return undefined;
|
|
1210
|
-
}
|
|
1211
|
-
return value;
|
|
1212
|
-
}, [
|
|
1213
|
-
value
|
|
1214
|
-
]);
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
const $d59d0c2b2ce1568f$var$MIN_COLOR = (0, $83fe1a57d631223b$export$6e865ea70d7724f)("#000000");
|
|
1221
|
-
const $d59d0c2b2ce1568f$var$MAX_COLOR = (0, $83fe1a57d631223b$export$6e865ea70d7724f)("#FFFFFF");
|
|
1222
|
-
const $d59d0c2b2ce1568f$var$MIN_COLOR_INT = $d59d0c2b2ce1568f$var$MIN_COLOR.toHexInt();
|
|
1223
|
-
const $d59d0c2b2ce1568f$var$MAX_COLOR_INT = $d59d0c2b2ce1568f$var$MAX_COLOR.toHexInt();
|
|
1224
|
-
function $d59d0c2b2ce1568f$export$d52a01683abdfcd6(props) {
|
|
1225
|
-
let { value: value, defaultValue: defaultValue, onChange: onChange } = props;
|
|
1226
|
-
let { step: step } = $d59d0c2b2ce1568f$var$MIN_COLOR.getChannelRange("red");
|
|
1227
|
-
let initialValue = (0, $f8b3be23ba4462b1$export$5aadd9c0606af5c2)(value);
|
|
1228
|
-
let initialDefaultValue = (0, $f8b3be23ba4462b1$export$5aadd9c0606af5c2)(defaultValue);
|
|
1229
|
-
let [colorValue, setColorValue] = (0, $4tN2K$reactstatelyutils.useControlledState)(initialValue, initialDefaultValue, onChange);
|
|
1230
|
-
let [inputValue, setInputValue] = (0, $4tN2K$react.useState)(()=>(value || defaultValue) && colorValue ? colorValue.toString("hex") : "");
|
|
1231
|
-
let validation = (0, $4tN2K$reactstatelyform.useFormValidationState)({
|
|
1232
|
-
...props,
|
|
1233
|
-
value: colorValue
|
|
1234
|
-
});
|
|
1235
|
-
let safelySetColorValue = (newColor)=>{
|
|
1236
|
-
if (!colorValue || !newColor) {
|
|
1237
|
-
setColorValue(newColor);
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
if (newColor.toHexInt() !== colorValue.toHexInt()) {
|
|
1241
|
-
setColorValue(newColor);
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
};
|
|
1245
|
-
let [prevValue, setPrevValue] = (0, $4tN2K$react.useState)(colorValue);
|
|
1246
|
-
if (prevValue !== colorValue) {
|
|
1247
|
-
setInputValue(colorValue ? colorValue.toString("hex") : "");
|
|
1248
|
-
setPrevValue(colorValue);
|
|
1249
|
-
}
|
|
1250
|
-
let parsedValue = (0, $4tN2K$react.useMemo)(()=>{
|
|
1251
|
-
let color;
|
|
1252
|
-
try {
|
|
1253
|
-
color = (0, $83fe1a57d631223b$export$6e865ea70d7724f)(inputValue.startsWith("#") ? inputValue : `#${inputValue}`);
|
|
1254
|
-
} catch (err) {
|
|
1255
|
-
color = null;
|
|
1256
|
-
}
|
|
1257
|
-
return color;
|
|
1258
|
-
}, [
|
|
1259
|
-
inputValue
|
|
1260
|
-
]);
|
|
1261
|
-
let commit = ()=>{
|
|
1262
|
-
// Set to empty state if input value is empty
|
|
1263
|
-
if (!inputValue.length) {
|
|
1264
|
-
safelySetColorValue(null);
|
|
1265
|
-
setInputValue(value === undefined ? "" : colorValue.toString("hex"));
|
|
1266
|
-
return;
|
|
1267
|
-
}
|
|
1268
|
-
// if it failed to parse, then reset input to formatted version of current number
|
|
1269
|
-
if (parsedValue == null) {
|
|
1270
|
-
setInputValue(colorValue ? colorValue.toString("hex") : "");
|
|
1271
|
-
return;
|
|
1272
|
-
}
|
|
1273
|
-
safelySetColorValue(parsedValue);
|
|
1274
|
-
// in a controlled state, the numberValue won't change, so we won't go back to our old input without help
|
|
1275
|
-
let newColorValue = "";
|
|
1276
|
-
if (colorValue) newColorValue = colorValue.toString("hex");
|
|
1277
|
-
setInputValue(newColorValue);
|
|
1278
|
-
};
|
|
1279
|
-
let increment = ()=>{
|
|
1280
|
-
let newValue = $d59d0c2b2ce1568f$var$addColorValue(parsedValue, step);
|
|
1281
|
-
// if we've arrived at the same value that was previously in the state, the
|
|
1282
|
-
// input value should be updated to match
|
|
1283
|
-
// ex type 4, press increment, highlight the number in the input, type 4 again, press increment
|
|
1284
|
-
// you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
|
|
1285
|
-
if (newValue === colorValue) setInputValue(newValue.toString("hex"));
|
|
1286
|
-
safelySetColorValue(newValue);
|
|
1287
|
-
validation.commitValidation();
|
|
1288
|
-
};
|
|
1289
|
-
let decrement = ()=>{
|
|
1290
|
-
let newValue = $d59d0c2b2ce1568f$var$addColorValue(parsedValue, -step);
|
|
1291
|
-
// if we've arrived at the same value that was previously in the state, the
|
|
1292
|
-
// input value should be updated to match
|
|
1293
|
-
// ex type 4, press increment, highlight the number in the input, type 4 again, press increment
|
|
1294
|
-
// you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
|
|
1295
|
-
if (newValue === colorValue) setInputValue(newValue.toString("hex"));
|
|
1296
|
-
safelySetColorValue(newValue);
|
|
1297
|
-
validation.commitValidation();
|
|
1298
|
-
};
|
|
1299
|
-
let incrementToMax = ()=>safelySetColorValue($d59d0c2b2ce1568f$var$MAX_COLOR);
|
|
1300
|
-
let decrementToMin = ()=>safelySetColorValue($d59d0c2b2ce1568f$var$MIN_COLOR);
|
|
1301
|
-
let validate = (value)=>{
|
|
1302
|
-
var _value_match;
|
|
1303
|
-
return value === "" || !!((_value_match = value.match(/^#?[0-9a-f]{0,6}$/i)) === null || _value_match === void 0 ? void 0 : _value_match[0]);
|
|
1304
|
-
};
|
|
1305
|
-
return {
|
|
1306
|
-
...validation,
|
|
1307
|
-
validate: validate,
|
|
1308
|
-
colorValue: colorValue,
|
|
1309
|
-
inputValue: inputValue,
|
|
1310
|
-
setInputValue: setInputValue,
|
|
1311
|
-
commit: commit,
|
|
1312
|
-
increment: increment,
|
|
1313
|
-
incrementToMax: incrementToMax,
|
|
1314
|
-
decrement: decrement,
|
|
1315
|
-
decrementToMin: decrementToMin
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
function $d59d0c2b2ce1568f$var$addColorValue(color, step) {
|
|
1319
|
-
let newColor = color ? color : $d59d0c2b2ce1568f$var$MIN_COLOR;
|
|
1320
|
-
let colorInt = newColor.toHexInt();
|
|
1321
|
-
let clampInt = Math.min(Math.max(colorInt + step, $d59d0c2b2ce1568f$var$MIN_COLOR_INT), $d59d0c2b2ce1568f$var$MAX_COLOR_INT);
|
|
1322
|
-
if (clampInt !== colorInt) {
|
|
1323
|
-
let newColorString = `#${clampInt.toString(16).padStart(6, "0").toUpperCase()}`;
|
|
1324
|
-
newColor = (0, $83fe1a57d631223b$export$6e865ea70d7724f)(newColorString);
|
|
1325
|
-
}
|
|
1326
|
-
return newColor;
|
|
1327
|
-
}
|
|
1328
30
|
|
|
1329
31
|
|
|
1330
32
|
|