@react-stately/color 3.0.0-alpha.0 → 3.0.0-beta.10
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/main.js +1020 -838
- package/dist/main.js.map +1 -1
- package/dist/module.js +1008 -811
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +67 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/Color.ts +243 -35
- package/src/index.ts +2 -1
- package/src/useColorAreaState.ts +184 -0
- package/src/useColorFieldState.ts +87 -48
- package/src/useColorSliderState.ts +6 -11
- package/src/useColorWheelState.ts +49 -30
package/dist/main.js
CHANGED
|
@@ -1,964 +1,1146 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _babelRuntimeHelpersObjectWithoutPropertiesLoose = $parcel$interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
16
|
-
|
|
17
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
18
|
-
|
|
19
|
-
var {
|
|
20
|
-
NumberFormatter
|
|
21
|
-
} = require("@internationalized/number");
|
|
22
|
-
|
|
23
|
-
var {
|
|
24
|
-
MessageDictionary
|
|
25
|
-
} = require("@internationalized/message");
|
|
26
|
-
|
|
27
|
-
var {
|
|
28
|
-
clamp
|
|
29
|
-
} = require("@react-aria/utils");
|
|
1
|
+
var $4tN2K$reactstatelyutils = require("@react-stately/utils");
|
|
2
|
+
var $4tN2K$internationalizedmessage = require("@internationalized/message");
|
|
3
|
+
var $4tN2K$internationalizednumber = require("@internationalized/number");
|
|
4
|
+
var $4tN2K$react = require("react");
|
|
5
|
+
var $4tN2K$reactstatelyslider = require("@react-stately/slider");
|
|
6
|
+
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
+
}
|
|
10
|
+
function $parcel$exportWildcard(dest, source) {
|
|
11
|
+
Object.keys(source).forEach(function(key) {
|
|
12
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
30
15
|
|
|
31
|
-
|
|
16
|
+
Object.defineProperty(dest, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return source[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
32
23
|
|
|
24
|
+
return dest;
|
|
25
|
+
}
|
|
33
26
|
function $parcel$interopDefault(a) {
|
|
34
27
|
return a && a.__esModule ? a.default : a;
|
|
35
28
|
}
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
var $bfb76047ec406c0239c2b8064c9b3ca$exports = {};
|
|
39
|
-
$bfb76047ec406c0239c2b8064c9b3ca$exports = JSON.parse("{\"hue\":\"تدرج اللون\",\"saturation\":\"الإشباع\",\"lightness\":\"الإضاءة\",\"brightness\":\"والقيمة\",\"red\":\"أحمر\",\"green\":\"أخضر\",\"blue\":\"أزرق\",\"alpha\":\"أولي\"}");
|
|
40
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/bg-BG.json
|
|
41
|
-
var $daebde84800f5aeee9aa172172d5b6f$exports = {};
|
|
42
|
-
$daebde84800f5aeee9aa172172d5b6f$exports = JSON.parse("{\"hue\":\"Нюанс\",\"saturation\":\"Наситеност\",\"lightness\":\"Осветеност\",\"brightness\":\"Яркост\",\"red\":\"Червено\",\"green\":\"Зелено\",\"blue\":\"Синьо\",\"alpha\":\"Алфа\"}");
|
|
43
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/cs-CZ.json
|
|
44
|
-
var $a4cfde59be1b5dcb6fbb06fb09589d$exports = {};
|
|
45
|
-
$a4cfde59be1b5dcb6fbb06fb09589d$exports = JSON.parse("{\"hue\":\"Odstín\",\"saturation\":\"Sytost\",\"lightness\":\"Světlost\",\"brightness\":\"Jas\",\"red\":\"Červená\",\"green\":\"Zelená\",\"blue\":\"Modrá\",\"alpha\":\"Alfa\"}");
|
|
46
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/da-DK.json
|
|
47
|
-
var $db43cffdd303de8bb2de21feafa35b91$exports = {};
|
|
48
|
-
$db43cffdd303de8bb2de21feafa35b91$exports = JSON.parse("{\"hue\":\"Nuance\",\"saturation\":\"Mætning\",\"lightness\":\"Lysstyrke\",\"brightness\":\"Værdi\",\"red\":\"Rød\",\"green\":\"Grøn\",\"blue\":\"Blå\",\"alpha\":\"Alfa\"}");
|
|
49
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/de-DE.json
|
|
50
|
-
var $be2be3d81ee825501b843aad02cb$exports = {};
|
|
51
|
-
$be2be3d81ee825501b843aad02cb$exports = JSON.parse("{\"hue\":\"Farbton\",\"saturation\":\"Sättigung\",\"lightness\":\"Leuchtkraft\",\"brightness\":\"Helligkeit\",\"red\":\"Rot\",\"green\":\"Grün\",\"blue\":\"Blau\",\"alpha\":\"Alpha\"}");
|
|
52
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/el-GR.json
|
|
53
|
-
var $c2fbd942c20b23aa5adc2f3f98bd779$exports = {};
|
|
54
|
-
$c2fbd942c20b23aa5adc2f3f98bd779$exports = JSON.parse("{\"hue\":\"Απόχρωση\",\"saturation\":\"Κορεσμού\",\"lightness\":\"Φωτεινότητα\",\"brightness\":\"Τιμή\",\"red\":\"Κόκκινο\",\"green\":\"Πράσινο\",\"blue\":\"Μπλε\",\"alpha\":\"Αλφα\"}");
|
|
55
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/en-US.json
|
|
56
|
-
var $abdeb3eeac24b96ea1b32ebcdc8bf175$exports = {};
|
|
57
|
-
$abdeb3eeac24b96ea1b32ebcdc8bf175$exports = JSON.parse("{\"hue\":\"Hue\",\"saturation\":\"Saturation\",\"lightness\":\"Lightness\",\"brightness\":\"Brightness\",\"red\":\"Red\",\"green\":\"Green\",\"blue\":\"Blue\",\"alpha\":\"Alpha\"}");
|
|
58
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/es-ES.json
|
|
59
|
-
var $b59ba9c40583ad49816c29f93cd734c9$exports = {};
|
|
60
|
-
$b59ba9c40583ad49816c29f93cd734c9$exports = JSON.parse("{\"hue\":\"Matiz\",\"saturation\":\"Saturación\",\"lightness\":\"Claridad\",\"brightness\":\"Brillo\",\"red\":\"Rojo\",\"green\":\"Verde\",\"blue\":\"Azul\",\"alpha\":\"Alfa\"}");
|
|
61
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/et-EE.json
|
|
62
|
-
var $c3d8ff3bd33905ba4a85bc554a90f3c6$exports = {};
|
|
63
|
-
$c3d8ff3bd33905ba4a85bc554a90f3c6$exports = JSON.parse("{\"hue\":\"Toon\",\"saturation\":\"Küllastus\",\"lightness\":\"Helendus\",\"brightness\":\"Väärtus\",\"red\":\"Punane\",\"green\":\"Roheline\",\"blue\":\"Sinine\",\"alpha\":\"Alfa\"}");
|
|
64
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/fi-FI.json
|
|
65
|
-
var $ccab754253a026877ee47cbc1cb03ca4$exports = {};
|
|
66
|
-
$ccab754253a026877ee47cbc1cb03ca4$exports = JSON.parse("{\"hue\":\"Värisävy\",\"saturation\":\"Kylläisyys\",\"lightness\":\"Valoisuus\",\"brightness\":\"Kirkkaus\",\"red\":\"Punainen\",\"green\":\"Vihreä\",\"blue\":\"Sininen\",\"alpha\":\"Alpha\"}");
|
|
67
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/fr-FR.json
|
|
68
|
-
var $ad0191b1c7bbd0c718e613a5db93445d$exports = {};
|
|
69
|
-
$ad0191b1c7bbd0c718e613a5db93445d$exports = JSON.parse("{\"hue\":\"Teinte\",\"saturation\":\"Saturation\",\"lightness\":\"Clarté\",\"brightness\":\"Luminosité\",\"red\":\"Rouge\",\"green\":\"Vert\",\"blue\":\"Bleu\",\"alpha\":\"Alpha\"}");
|
|
70
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/he-IL.json
|
|
71
|
-
var $b4ea486bd9841aabeecd5373b70dace5$exports = {};
|
|
72
|
-
$b4ea486bd9841aabeecd5373b70dace5$exports = JSON.parse("{\"hue\":\"גוון\",\"saturation\":\"רוויה\",\"lightness\":\"בהירות\",\"brightness\":\"וערך\",\"red\":\"אדום\",\"green\":\"ירוק\",\"blue\":\"כחול\",\"alpha\":\"אלפא\"}");
|
|
73
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/hr-HR.json
|
|
74
|
-
var $b99897eafdd92c74120ae6b4e0248b94$exports = {};
|
|
75
|
-
$b99897eafdd92c74120ae6b4e0248b94$exports = JSON.parse("{\"hue\":\"Nijansa\",\"saturation\":\"Zasićenje\",\"lightness\":\"Svjetlina\",\"brightness\":\"Vrijednost\",\"red\":\"Crvena\",\"green\":\"Zelena\",\"blue\":\"Plava\",\"alpha\":\"Alfa\"}");
|
|
76
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/hu-HU.json
|
|
77
|
-
var $a2609a148daf4c3ca1d5b0ce5ec6aa$exports = {};
|
|
78
|
-
$a2609a148daf4c3ca1d5b0ce5ec6aa$exports = JSON.parse("{\"hue\":\"Árnyalat\",\"saturation\":\"Telítettség\",\"lightness\":\"Fényerő\",\"brightness\":\"Értéke\",\"red\":\"Vörös\",\"green\":\"Zöld\",\"blue\":\"Kék\",\"alpha\":\"Alfa\"}");
|
|
79
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/it-IT.json
|
|
80
|
-
var $da5b478c1fd01a35d72944d9cb71a34e$exports = {};
|
|
81
|
-
$da5b478c1fd01a35d72944d9cb71a34e$exports = JSON.parse("{\"hue\":\"Tonalità\",\"saturation\":\"Saturazione\",\"lightness\":\"Luminosità\",\"brightness\":\"Lucentezza\",\"red\":\"Rosso\",\"green\":\"Verde\",\"blue\":\"Blu\",\"alpha\":\"Alfa\"}");
|
|
82
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ja-JP.json
|
|
83
|
-
var $dc461c55c88305a012147cc9fb7$exports = {};
|
|
84
|
-
$dc461c55c88305a012147cc9fb7$exports = JSON.parse("{\"hue\":\"色合い\",\"saturation\":\"鮮やかさ\",\"lightness\":\"輝度\",\"brightness\":\"明るさ\",\"red\":\"赤\",\"green\":\"緑\",\"blue\":\"青\",\"alpha\":\"アルファ\"}");
|
|
85
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ko-KR.json
|
|
86
|
-
var $b4684c3a5d9d860ab05adffe33fceab3$exports = {};
|
|
87
|
-
$b4684c3a5d9d860ab05adffe33fceab3$exports = JSON.parse("{\"hue\":\"색상\",\"saturation\":\"채도\",\"lightness\":\"명도\",\"brightness\":\"값\",\"red\":\"빨강\",\"green\":\"녹색\",\"blue\":\"파랑\",\"alpha\":\"알파\"}");
|
|
88
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/lt-LT.json
|
|
89
|
-
var $be917ddab49d0b151b9f62b823bba50$exports = {};
|
|
90
|
-
$be917ddab49d0b151b9f62b823bba50$exports = JSON.parse("{\"hue\":\"Atspalvis\",\"saturation\":\"Grynis\",\"lightness\":\"Skaistis\",\"brightness\":\"Ryškumas\",\"red\":\"Raudona\",\"green\":\"Žalia\",\"blue\":\"Mėlyna\",\"alpha\":\"Alfa\"}");
|
|
91
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/lv-LV.json
|
|
92
|
-
var $f17c13ae26a2d4d99928424c79$exports = {};
|
|
93
|
-
$f17c13ae26a2d4d99928424c79$exports = JSON.parse("{\"hue\":\"Nokrāsa\",\"saturation\":\"Piesātinājums\",\"lightness\":\"Vieglums\",\"brightness\":\"Spilgtums\",\"red\":\"Sarkana\",\"green\":\"Zaļa\",\"blue\":\"Zila\",\"alpha\":\"Alfa\"}");
|
|
94
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/nb-NO.json
|
|
95
|
-
var $e4b8847de3ab9d1344d713259cef878$exports = {};
|
|
96
|
-
$e4b8847de3ab9d1344d713259cef878$exports = JSON.parse("{\"hue\":\"Fargetone\",\"saturation\":\"Metning\",\"lightness\":\"Lyshet\",\"brightness\":\"Lysstyrke\",\"red\":\"Rød\",\"green\":\"Grønn\",\"blue\":\"Blå\",\"alpha\":\"Alfa\"}");
|
|
97
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/nl-NL.json
|
|
98
|
-
var $f077195d9918fb9d3561710aae4a62cc$exports = {};
|
|
99
|
-
$f077195d9918fb9d3561710aae4a62cc$exports = JSON.parse("{\"hue\":\"Tint\",\"saturation\":\"Verzadiging\",\"lightness\":\"Lichtheid\",\"brightness\":\"Helderheid\",\"red\":\"Rood\",\"green\":\"Groen\",\"blue\":\"Blauw\",\"alpha\":\"Alfa\"}");
|
|
100
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/pl-PL.json
|
|
101
|
-
var $d24a27ab79addeeea85ff5eb95318b06$exports = {};
|
|
102
|
-
$d24a27ab79addeeea85ff5eb95318b06$exports = JSON.parse("{\"hue\":\"Odcień\",\"saturation\":\"Nasycenie\",\"lightness\":\"Jasność\",\"brightness\":\"Jasność\",\"red\":\"Czerwony\",\"green\":\"Zielony\",\"blue\":\"Niebieski\",\"alpha\":\"Alfa\"}");
|
|
103
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/pt-BR.json
|
|
104
|
-
var $ceb70a725fde80d49dd1138e8ca9e306$exports = {};
|
|
105
|
-
$ceb70a725fde80d49dd1138e8ca9e306$exports = JSON.parse("{\"hue\":\"Matiz\",\"saturation\":\"Saturação\",\"lightness\":\"Luminosidade\",\"brightness\":\"Brilho\",\"red\":\"Vermelho\",\"green\":\"Verde\",\"blue\":\"Azul\",\"alpha\":\"Alfa\"}");
|
|
106
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ro-RO.json
|
|
107
|
-
var $f25ae63965bcad80a86787e16972$exports = {};
|
|
108
|
-
$f25ae63965bcad80a86787e16972$exports = JSON.parse("{\"hue\":\"Nuanță\",\"saturation\":\"Saturație\",\"lightness\":\"Luminozitate\",\"brightness\":\"Valoare\",\"red\":\"Roșu\",\"green\":\"Verde\",\"blue\":\"Albastru\",\"alpha\":\"Alfa\"}");
|
|
109
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/ru-RU.json
|
|
110
|
-
var $d131f7f35da9efbf3e5c4c90d88523$exports = {};
|
|
111
|
-
$d131f7f35da9efbf3e5c4c90d88523$exports = JSON.parse("{\"hue\":\"Оттенок\",\"saturation\":\"Насыщенность\",\"lightness\":\"Освещенность\",\"brightness\":\"Яркость\",\"red\":\"Красный\",\"green\":\"Зеленый\",\"blue\":\"Синий\",\"alpha\":\"Альфа\"}");
|
|
112
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sk-SK.json
|
|
113
|
-
var $bc31c73edcf6a69405580806e86a1580$exports = {};
|
|
114
|
-
$bc31c73edcf6a69405580806e86a1580$exports = JSON.parse("{\"hue\":\"Odtieň\",\"saturation\":\"Sýtosť\",\"lightness\":\"Svetlosť\",\"brightness\":\"Jas\",\"red\":\"Červená\",\"green\":\"Zelená\",\"blue\":\"Modrá\",\"alpha\":\"Alfa\"}");
|
|
115
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sl-SI.json
|
|
116
|
-
var $df72c407396964a6c780d567792cdd2$exports = {};
|
|
117
|
-
$df72c407396964a6c780d567792cdd2$exports = JSON.parse("{\"hue\":\"Odtenek\",\"saturation\":\"Nasičenost\",\"lightness\":\"Svetilnost\",\"brightness\":\"Svetlost\",\"red\":\"Rdeča\",\"green\":\"Zelena\",\"blue\":\"Modra\",\"alpha\":\"Alfa\"}");
|
|
118
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sr-SP.json
|
|
119
|
-
var $cad65e4825dd66e0bd6c1ff51bb48a91$exports = {};
|
|
120
|
-
$cad65e4825dd66e0bd6c1ff51bb48a91$exports = JSON.parse("{\"hue\":\"Нијанса\",\"saturation\":\"Засићење\",\"lightness\":\"Осветљење\",\"brightness\":\"Светлина\",\"red\":\"Црвена\",\"green\":\"Зелена\",\"blue\":\"Плава\",\"alpha\":\"Алфа\"}");
|
|
121
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/sv-SE.json
|
|
122
|
-
var $d7c0d1f1dc8ea1aa86708102c79a$exports = {};
|
|
123
|
-
$d7c0d1f1dc8ea1aa86708102c79a$exports = JSON.parse("{\"hue\":\"Nyans\",\"saturation\":\"Mättnad\",\"lightness\":\"Lätthet\",\"brightness\":\"Ljusstyrka\",\"red\":\"Röd\",\"green\":\"Grön\",\"blue\":\"Blå\",\"alpha\":\"Alfa\"}");
|
|
124
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/tr-TR.json
|
|
125
|
-
var $a0d6a531d06c52db2f4cd7c96356300e$exports = {};
|
|
126
|
-
$a0d6a531d06c52db2f4cd7c96356300e$exports = JSON.parse("{\"hue\":\"Ton\",\"saturation\":\"Doygunluk\",\"lightness\":\"Hafiflik\",\"brightness\":\"Parlaklık\",\"red\":\"Kırmızı\",\"green\":\"Yeşil\",\"blue\":\"Mavi\",\"alpha\":\"Alfa\"}");
|
|
127
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/uk-UA.json
|
|
128
|
-
var $a70877667b8705b2c85173d23d$exports = {};
|
|
129
|
-
$a70877667b8705b2c85173d23d$exports = JSON.parse("{\"hue\":\"Відтінок\",\"saturation\":\"Насиченість\",\"lightness\":\"Яскравість\",\"brightness\":\"Інтенсивність\",\"red\":\"Червоний\",\"green\":\"Зелений\",\"blue\":\"Синій\",\"alpha\":\"Альфа\"}");
|
|
130
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/zh-CN.json
|
|
131
|
-
var $c38ee15e302a37d9225987d335ad869e$exports = {};
|
|
132
|
-
$c38ee15e302a37d9225987d335ad869e$exports = JSON.parse("{\"hue\":\"色调\",\"saturation\":\"饱和度\",\"lightness\":\"光度\",\"brightness\":\"Brightness\",\"red\":\"红\",\"green\":\"绿\",\"blue\":\"蓝\",\"alpha\":\"Alpha\"}");
|
|
133
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-stately/color/intl/zh-TW.json
|
|
134
|
-
var $d2a1fa8d41cf433c2df57cdf8eba52a3$exports = {};
|
|
135
|
-
$d2a1fa8d41cf433c2df57cdf8eba52a3$exports = JSON.parse("{\"hue\":\"色調\",\"saturation\":\"飽和\",\"lightness\":\"光度\",\"brightness\":\"亮度\",\"red\":\"紅\",\"green\":\"綠\",\"blue\":\"藍\",\"alpha\":\"Alpha\"}");
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
const $b54655da051f787a04029ec3711$var$intlMessages = {
|
|
138
|
-
"ar-AE": _babelRuntimeHelpersInteropRequireDefault($bfb76047ec406c0239c2b8064c9b3ca$exports).default,
|
|
139
|
-
"bg-BG": _babelRuntimeHelpersInteropRequireDefault($daebde84800f5aeee9aa172172d5b6f$exports).default,
|
|
140
|
-
"cs-CZ": _babelRuntimeHelpersInteropRequireDefault($a4cfde59be1b5dcb6fbb06fb09589d$exports).default,
|
|
141
|
-
"da-DK": _babelRuntimeHelpersInteropRequireDefault($db43cffdd303de8bb2de21feafa35b91$exports).default,
|
|
142
|
-
"de-DE": _babelRuntimeHelpersInteropRequireDefault($be2be3d81ee825501b843aad02cb$exports).default,
|
|
143
|
-
"el-GR": _babelRuntimeHelpersInteropRequireDefault($c2fbd942c20b23aa5adc2f3f98bd779$exports).default,
|
|
144
|
-
"en-US": _babelRuntimeHelpersInteropRequireDefault($abdeb3eeac24b96ea1b32ebcdc8bf175$exports).default,
|
|
145
|
-
"es-ES": _babelRuntimeHelpersInteropRequireDefault($b59ba9c40583ad49816c29f93cd734c9$exports).default,
|
|
146
|
-
"et-EE": _babelRuntimeHelpersInteropRequireDefault($c3d8ff3bd33905ba4a85bc554a90f3c6$exports).default,
|
|
147
|
-
"fi-FI": _babelRuntimeHelpersInteropRequireDefault($ccab754253a026877ee47cbc1cb03ca4$exports).default,
|
|
148
|
-
"fr-FR": _babelRuntimeHelpersInteropRequireDefault($ad0191b1c7bbd0c718e613a5db93445d$exports).default,
|
|
149
|
-
"he-IL": _babelRuntimeHelpersInteropRequireDefault($b4ea486bd9841aabeecd5373b70dace5$exports).default,
|
|
150
|
-
"hr-HR": _babelRuntimeHelpersInteropRequireDefault($b99897eafdd92c74120ae6b4e0248b94$exports).default,
|
|
151
|
-
"hu-HU": _babelRuntimeHelpersInteropRequireDefault($a2609a148daf4c3ca1d5b0ce5ec6aa$exports).default,
|
|
152
|
-
"it-IT": _babelRuntimeHelpersInteropRequireDefault($da5b478c1fd01a35d72944d9cb71a34e$exports).default,
|
|
153
|
-
"ja-JP": _babelRuntimeHelpersInteropRequireDefault($dc461c55c88305a012147cc9fb7$exports).default,
|
|
154
|
-
"ko-KR": _babelRuntimeHelpersInteropRequireDefault($b4684c3a5d9d860ab05adffe33fceab3$exports).default,
|
|
155
|
-
"lt-LT": _babelRuntimeHelpersInteropRequireDefault($be917ddab49d0b151b9f62b823bba50$exports).default,
|
|
156
|
-
"lv-LV": _babelRuntimeHelpersInteropRequireDefault($f17c13ae26a2d4d99928424c79$exports).default,
|
|
157
|
-
"nb-NO": _babelRuntimeHelpersInteropRequireDefault($e4b8847de3ab9d1344d713259cef878$exports).default,
|
|
158
|
-
"nl-NL": _babelRuntimeHelpersInteropRequireDefault($f077195d9918fb9d3561710aae4a62cc$exports).default,
|
|
159
|
-
"pl-PL": _babelRuntimeHelpersInteropRequireDefault($d24a27ab79addeeea85ff5eb95318b06$exports).default,
|
|
160
|
-
"pt-BR": _babelRuntimeHelpersInteropRequireDefault($ceb70a725fde80d49dd1138e8ca9e306$exports).default,
|
|
161
|
-
"ro-RO": _babelRuntimeHelpersInteropRequireDefault($f25ae63965bcad80a86787e16972$exports).default,
|
|
162
|
-
"ru-RU": _babelRuntimeHelpersInteropRequireDefault($d131f7f35da9efbf3e5c4c90d88523$exports).default,
|
|
163
|
-
"sk-SK": _babelRuntimeHelpersInteropRequireDefault($bc31c73edcf6a69405580806e86a1580$exports).default,
|
|
164
|
-
"sl-SI": _babelRuntimeHelpersInteropRequireDefault($df72c407396964a6c780d567792cdd2$exports).default,
|
|
165
|
-
"sr-SP": _babelRuntimeHelpersInteropRequireDefault($cad65e4825dd66e0bd6c1ff51bb48a91$exports).default,
|
|
166
|
-
"sv-SE": _babelRuntimeHelpersInteropRequireDefault($d7c0d1f1dc8ea1aa86708102c79a$exports).default,
|
|
167
|
-
"tr-TR": _babelRuntimeHelpersInteropRequireDefault($a0d6a531d06c52db2f4cd7c96356300e$exports).default,
|
|
168
|
-
"uk-UA": _babelRuntimeHelpersInteropRequireDefault($a70877667b8705b2c85173d23d$exports).default,
|
|
169
|
-
"zh-CN": _babelRuntimeHelpersInteropRequireDefault($c38ee15e302a37d9225987d335ad869e$exports).default,
|
|
170
|
-
"zh-TW": _babelRuntimeHelpersInteropRequireDefault($d2a1fa8d41cf433c2df57cdf8eba52a3$exports).default
|
|
171
|
-
};
|
|
172
|
-
const $b54655da051f787a04029ec3711$var$messages = new MessageDictionary($b54655da051f787a04029ec3711$var$intlMessages);
|
|
30
|
+
$parcel$export(module.exports, "parseColor", () => $83fe1a57d631223b$export$6e865ea70d7724f);
|
|
173
31
|
|
|
174
|
-
|
|
175
|
-
|
|
32
|
+
var $c0b600cf8eafdee9$exports = {};
|
|
33
|
+
var $b044e7150534af04$exports = {};
|
|
34
|
+
$b044e7150534af04$exports = JSON.parse("{\"alpha\":\"ألفا\",\"blue\":\"أزرق\",\"brightness\":\"السطوع\",\"green\":\"أخضر\",\"hue\":\"درجة اللون\",\"lightness\":\"الإضاءة\",\"red\":\"أحمر\",\"saturation\":\"التشبع\"}");
|
|
176
35
|
|
|
177
|
-
if (res) {
|
|
178
|
-
return res;
|
|
179
|
-
}
|
|
180
36
|
|
|
181
|
-
|
|
182
|
-
}
|
|
37
|
+
var $c8bf89547a4a9b3f$exports = {};
|
|
38
|
+
$c8bf89547a4a9b3f$exports = JSON.parse("{\"alpha\":\"Алфа\",\"blue\":\"Синьо\",\"brightness\":\"Яркост\",\"green\":\"Зелено\",\"hue\":\"Оттенък\",\"lightness\":\"Лекота\",\"red\":\"Червено\",\"saturation\":\"Наситеност\"}");
|
|
183
39
|
|
|
184
|
-
exports.parseColor = parseColor;
|
|
185
40
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return this.toFormat('rgb').toHexInt();
|
|
189
|
-
}
|
|
41
|
+
var $8365d8dfc7e4c985$exports = {};
|
|
42
|
+
$8365d8dfc7e4c985$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Modrá\",\"brightness\":\"Jas\",\"green\":\"Zelená\",\"hue\":\"Odstín\",\"lightness\":\"Světlost\",\"red\":\"Červená\",\"saturation\":\"Sytost\"}");
|
|
190
43
|
|
|
191
|
-
getChannelValue(channel) {
|
|
192
|
-
if (channel in this) {
|
|
193
|
-
return this[channel];
|
|
194
|
-
}
|
|
195
44
|
|
|
196
|
-
|
|
197
|
-
|
|
45
|
+
var $8d95eeaa73699e56$exports = {};
|
|
46
|
+
$8d95eeaa73699e56$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blå\",\"brightness\":\"Lysstyrke\",\"green\":\"Grøn\",\"hue\":\"Tone\",\"lightness\":\"Lyshed\",\"red\":\"Rød\",\"saturation\":\"Farvemætning\"}");
|
|
198
47
|
|
|
199
|
-
withChannelValue(channel, value) {
|
|
200
|
-
if (channel in this) {
|
|
201
|
-
let x = this.clone();
|
|
202
|
-
x[channel] = value;
|
|
203
|
-
return x;
|
|
204
|
-
}
|
|
205
48
|
|
|
206
|
-
|
|
207
|
-
|
|
49
|
+
var $2dbbd166053d6d10$exports = {};
|
|
50
|
+
$2dbbd166053d6d10$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Blau\",\"brightness\":\"Helligkeit\",\"green\":\"Grün\",\"hue\":\"Farbton\",\"lightness\":\"Leuchtkraft\",\"red\":\"Rot\",\"saturation\":\"Sättigung\"}");
|
|
208
51
|
|
|
209
|
-
getChannelName(channel, locale) {
|
|
210
|
-
return $b54655da051f787a04029ec3711$var$messages.getStringForLocale(channel, locale);
|
|
211
|
-
}
|
|
212
52
|
|
|
213
|
-
}
|
|
53
|
+
var $1fcbdf9eaf6cc074$exports = {};
|
|
54
|
+
$1fcbdf9eaf6cc074$exports = JSON.parse("{\"alpha\":\"Άλφα\",\"blue\":\"Μπλε\",\"brightness\":\"Φωτεινότητα\",\"green\":\"Πράσινο\",\"hue\":\"Τόνος\",\"lightness\":\"Φωτεινότητα\",\"red\":\"Κόκκινο\",\"saturation\":\"Κορεσμός\"}");
|
|
214
55
|
|
|
215
|
-
const $b54655da051f787a04029ec3711$var$HEX_REGEX = /^#(?:([0-9a-f]{3})|([0-9a-f]{6}))$/i; // X = <negative/positive number with/without decimal places>
|
|
216
|
-
// before/after a comma, 0 or more whitespaces are allowed
|
|
217
|
-
// - rgb(X, X, X)
|
|
218
|
-
// - rgba(X, X, X, X)
|
|
219
56
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
class $b54655da051f787a04029ec3711$var$RGBColor extends $b54655da051f787a04029ec3711$var$Color {
|
|
223
|
-
constructor(red, green, blue, alpha) {
|
|
224
|
-
super();
|
|
225
|
-
this.red = red;
|
|
226
|
-
this.green = green;
|
|
227
|
-
this.blue = blue;
|
|
228
|
-
this.alpha = alpha;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
static parse(value) {
|
|
232
|
-
let m;
|
|
233
|
-
|
|
234
|
-
if (m = value.match($b54655da051f787a04029ec3711$var$HEX_REGEX)) {
|
|
235
|
-
if (m[1]) {
|
|
236
|
-
let r = parseInt(m[1][0] + m[1][0], 16);
|
|
237
|
-
let g = parseInt(m[1][1] + m[1][1], 16);
|
|
238
|
-
let b = parseInt(m[1][2] + m[1][2], 16);
|
|
239
|
-
return new $b54655da051f787a04029ec3711$var$RGBColor(r, g, b, 1);
|
|
240
|
-
} else if (m[2]) {
|
|
241
|
-
let r = parseInt(m[2][0] + m[2][1], 16);
|
|
242
|
-
let g = parseInt(m[2][2] + m[2][3], 16);
|
|
243
|
-
let b = parseInt(m[2][4] + m[2][5], 16);
|
|
244
|
-
return new $b54655da051f787a04029ec3711$var$RGBColor(r, g, b, 1);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
57
|
+
var $42d54be461715959$exports = {};
|
|
58
|
+
$42d54be461715959$exports = JSON.parse("{\"hue\":\"Hue\",\"saturation\":\"Saturation\",\"lightness\":\"Lightness\",\"brightness\":\"Brightness\",\"red\":\"Red\",\"green\":\"Green\",\"blue\":\"Blue\",\"alpha\":\"Alpha\"}");
|
|
247
59
|
|
|
248
|
-
if (m = value.match($b54655da051f787a04029ec3711$var$RGB_REGEX)) {
|
|
249
|
-
var _m$;
|
|
250
60
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
}
|
|
61
|
+
var $911646bd5662c33d$exports = {};
|
|
62
|
+
$911646bd5662c33d$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Azul\",\"brightness\":\"Brillo\",\"green\":\"Verde\",\"hue\":\"Tono\",\"lightness\":\"Luminosidad\",\"red\":\"Rojo\",\"saturation\":\"Saturación\"}");
|
|
255
63
|
|
|
256
|
-
toString(format) {
|
|
257
|
-
switch (format) {
|
|
258
|
-
case 'hex':
|
|
259
|
-
return '#' + (this.red.toString(16).padStart(2, '0') + this.green.toString(16).padStart(2, '0') + this.blue.toString(16).padStart(2, '0')).toUpperCase();
|
|
260
64
|
|
|
261
|
-
|
|
262
|
-
|
|
65
|
+
var $6e8998796901e680$exports = {};
|
|
66
|
+
$6e8998796901e680$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Sinine\",\"brightness\":\"Heledus\",\"green\":\"Roheline\",\"hue\":\"Värv\",\"lightness\":\"Valgus\",\"red\":\"Punane\",\"saturation\":\"Küllastus\"}");
|
|
263
67
|
|
|
264
|
-
case 'rgb':
|
|
265
|
-
return "rgb(" + this.red + ", " + this.green + ", " + this.blue + ")";
|
|
266
68
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
return "rgba(" + this.red + ", " + this.green + ", " + this.blue + ", " + this.alpha + ")";
|
|
69
|
+
var $4503b4001036be6d$exports = {};
|
|
70
|
+
$4503b4001036be6d$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Sininen\",\"brightness\":\"Kirkkaus\",\"green\":\"Vihreä\",\"hue\":\"Sävy\",\"lightness\":\"Valomäärä\",\"red\":\"Punainen\",\"saturation\":\"Värikylläisyys\"}");
|
|
270
71
|
|
|
271
|
-
default:
|
|
272
|
-
return this.toFormat(format).toString(format);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
72
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
case 'hex':
|
|
279
|
-
case 'hexa':
|
|
280
|
-
case 'rgb':
|
|
281
|
-
case 'rgba':
|
|
282
|
-
return this;
|
|
73
|
+
var $721e7016769a7a7f$exports = {};
|
|
74
|
+
$721e7016769a7a7f$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"Bleu\",\"brightness\":\"Luminosité\",\"green\":\"Vert\",\"hue\":\"Teinte\",\"lightness\":\"Luminosité\",\"red\":\"Rouge\",\"saturation\":\"Saturation\"}");
|
|
283
75
|
|
|
284
|
-
default:
|
|
285
|
-
throw new Error('Unsupported color conversion: rgb -> ' + format);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
76
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
77
|
+
var $dcc290e5792f9bab$exports = {};
|
|
78
|
+
$dcc290e5792f9bab$exports = JSON.parse("{\"alpha\":\"אלפא\",\"blue\":\"כחול\",\"brightness\":\"בהירות\",\"green\":\"ירוק\",\"hue\":\"גוון\",\"lightness\":\"כמות אור\",\"red\":\"אדום\",\"saturation\":\"רוויה\"}");
|
|
292
79
|
|
|
293
|
-
clone() {
|
|
294
|
-
return new $b54655da051f787a04029ec3711$var$RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
295
|
-
}
|
|
296
80
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
case 'red':
|
|
300
|
-
case 'green':
|
|
301
|
-
case 'blue':
|
|
302
|
-
return {
|
|
303
|
-
minValue: 0,
|
|
304
|
-
maxValue: 255,
|
|
305
|
-
step: 1
|
|
306
|
-
};
|
|
81
|
+
var $d93d5aebdd12334c$exports = {};
|
|
82
|
+
$d93d5aebdd12334c$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Plava\",\"brightness\":\"Svjetlina\",\"green\":\"Zelena\",\"hue\":\"Nijansa\",\"lightness\":\"Osvijetljenost\",\"red\":\"Crvena\",\"saturation\":\"Zasićenost\"}");
|
|
307
83
|
|
|
308
|
-
case 'alpha':
|
|
309
|
-
return {
|
|
310
|
-
minValue: 0,
|
|
311
|
-
maxValue: 1,
|
|
312
|
-
step: 0.01
|
|
313
|
-
};
|
|
314
84
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
}
|
|
85
|
+
var $a3749e0ee87dbebc$exports = {};
|
|
86
|
+
$a3749e0ee87dbebc$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Kék\",\"brightness\":\"Fényesség\",\"green\":\"Zöld\",\"hue\":\"Színárnyalat\",\"lightness\":\"Világosság\",\"red\":\"Piros\",\"saturation\":\"Telítettség\"}");
|
|
319
87
|
|
|
320
|
-
formatChannelValue(channel, locale) {
|
|
321
|
-
let options;
|
|
322
|
-
let value = this.getChannelValue(channel);
|
|
323
88
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
case 'green':
|
|
327
|
-
case 'blue':
|
|
328
|
-
options = {
|
|
329
|
-
style: 'decimal'
|
|
330
|
-
};
|
|
331
|
-
break;
|
|
89
|
+
var $2fdb931b6c9652b9$exports = {};
|
|
90
|
+
$2fdb931b6c9652b9$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blu\",\"brightness\":\"Luminosità\",\"green\":\"Verde\",\"hue\":\"Tonalità\",\"lightness\":\"Luminosità\",\"red\":\"Rosso\",\"saturation\":\"Saturazione\"}");
|
|
332
91
|
|
|
333
|
-
case 'alpha':
|
|
334
|
-
options = {
|
|
335
|
-
style: 'percent'
|
|
336
|
-
};
|
|
337
|
-
break;
|
|
338
92
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
93
|
+
var $219c839b59015b4f$exports = {};
|
|
94
|
+
$219c839b59015b4f$exports = JSON.parse("{\"alpha\":\"アルファ\",\"blue\":\"青\",\"brightness\":\"明るさ\",\"green\":\"緑\",\"hue\":\"色相\",\"lightness\":\"明度\",\"red\":\"赤\",\"saturation\":\"彩度\"}");
|
|
342
95
|
|
|
343
|
-
return new NumberFormatter(locale, options).format(value);
|
|
344
|
-
}
|
|
345
96
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
// - hsb(X, X%, X%)
|
|
349
|
-
// - hsba(X, X%, X%, X)
|
|
97
|
+
var $b7f67f414086d976$exports = {};
|
|
98
|
+
$b7f67f414086d976$exports = JSON.parse("{\"alpha\":\"알파\",\"blue\":\"파랑\",\"brightness\":\"명도\",\"green\":\"초록\",\"hue\":\"색조\",\"lightness\":\"밝기\",\"red\":\"빨강\",\"saturation\":\"채도\"}");
|
|
350
99
|
|
|
351
100
|
|
|
352
|
-
|
|
101
|
+
var $f27b2ac7d517417c$exports = {};
|
|
102
|
+
$f27b2ac7d517417c$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Mėlyna\",\"brightness\":\"Ryškumas\",\"green\":\"Žalia\",\"hue\":\"Atspalvis\",\"lightness\":\"Šviesumas\",\"red\":\"Raudona\",\"saturation\":\"Įsotinimas\"}");
|
|
353
103
|
|
|
354
|
-
class $b54655da051f787a04029ec3711$var$HSBColor extends $b54655da051f787a04029ec3711$var$Color {
|
|
355
|
-
constructor(hue, saturation, brightness, alpha) {
|
|
356
|
-
super();
|
|
357
|
-
this.hue = hue;
|
|
358
|
-
this.saturation = saturation;
|
|
359
|
-
this.brightness = brightness;
|
|
360
|
-
this.alpha = alpha;
|
|
361
|
-
}
|
|
362
104
|
|
|
363
|
-
|
|
364
|
-
|
|
105
|
+
var $e92168db3cbe2797$exports = {};
|
|
106
|
+
$e92168db3cbe2797$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Zila\",\"brightness\":\"Spilgtums\",\"green\":\"Zaļa\",\"hue\":\"Nokrāsa\",\"lightness\":\"Gaišums\",\"red\":\"Sarkana\",\"saturation\":\"Piesātinājums\"}");
|
|
365
107
|
|
|
366
|
-
if (m = value.match($b54655da051f787a04029ec3711$var$HSB_REGEX)) {
|
|
367
|
-
var _m$2;
|
|
368
108
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
}
|
|
109
|
+
var $44b012e02982e825$exports = {};
|
|
110
|
+
$44b012e02982e825$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blå\",\"brightness\":\"Lysstyrke\",\"green\":\"Grønn\",\"hue\":\"Fargetone\",\"lightness\":\"Lyshet\",\"red\":\"Rød\",\"saturation\":\"Metning\"}");
|
|
373
111
|
|
|
374
|
-
toString(format) {
|
|
375
|
-
switch (format) {
|
|
376
|
-
case 'css':
|
|
377
|
-
return this.toHSL().toString('css');
|
|
378
112
|
|
|
379
|
-
|
|
380
|
-
|
|
113
|
+
var $64fbd91459613d8b$exports = {};
|
|
114
|
+
$64fbd91459613d8b$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blauw\",\"brightness\":\"Helderheid\",\"green\":\"Groen\",\"hue\":\"Kleurtoon\",\"lightness\":\"Lichtsterkte\",\"red\":\"Rood\",\"saturation\":\"Verzadiging\"}");
|
|
381
115
|
|
|
382
|
-
case 'hsba':
|
|
383
|
-
return "hsba(" + this.hue + ", " + this.saturation + "%, " + this.brightness + "%, " + this.alpha + ")";
|
|
384
116
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
}
|
|
117
|
+
var $83fabdc4e0df6af9$exports = {};
|
|
118
|
+
$83fabdc4e0df6af9$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Niebieski\",\"brightness\":\"Jasność\",\"green\":\"Zielony\",\"hue\":\"Odcień\",\"lightness\":\"Jaskrawość\",\"red\":\"Czerwony\",\"saturation\":\"Nasycenie\"}");
|
|
389
119
|
|
|
390
|
-
toFormat(format) {
|
|
391
|
-
switch (format) {
|
|
392
|
-
case 'hsb':
|
|
393
|
-
case 'hsba':
|
|
394
|
-
return this;
|
|
395
120
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
return this.toHSL();
|
|
121
|
+
var $30b915257fa66ccf$exports = {};
|
|
122
|
+
$30b915257fa66ccf$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Azul\",\"brightness\":\"Brilho\",\"green\":\"Verde\",\"hue\":\"Matiz\",\"lightness\":\"Luminosidade\",\"red\":\"Vermelho\",\"saturation\":\"Saturação\"}");
|
|
399
123
|
|
|
400
|
-
default:
|
|
401
|
-
throw new Error('Unsupported color conversion: hsb -> ' + format);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
124
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
var l = (2 - this.saturation / 100) * this.brightness / 2; // store the HSL components
|
|
125
|
+
var $ce75e45ccbc92491$exports = {};
|
|
126
|
+
$ce75e45ccbc92491$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Azul\",\"brightness\":\"Luminosidade\",\"green\":\"Verde\",\"hue\":\"Tonalidade\",\"lightness\":\"Claridade\",\"red\":\"Vermelho\",\"saturation\":\"Saturação\"}");
|
|
408
127
|
|
|
409
|
-
let hue = this.hue;
|
|
410
|
-
let saturation = this.saturation * this.brightness / (l < 50 ? l * 2 : 200 - l * 2);
|
|
411
|
-
let lightness = l; // correct a division-by-zero error
|
|
412
128
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
129
|
+
var $225440ee53a1fecd$exports = {};
|
|
130
|
+
$225440ee53a1fecd$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Albastru\",\"brightness\":\"Luminozitate\",\"green\":\"Verde\",\"hue\":\"Nuanță\",\"lightness\":\"Luminozitate\",\"red\":\"Roșu\",\"saturation\":\"Saturație\"}");
|
|
416
131
|
|
|
417
|
-
return new $b54655da051f787a04029ec3711$var$HSLColor(hue, saturation, lightness, this.alpha);
|
|
418
|
-
}
|
|
419
132
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
133
|
+
var $cbc60c1dd4e689ff$exports = {};
|
|
134
|
+
$cbc60c1dd4e689ff$exports = JSON.parse("{\"alpha\":\"Альфа\",\"blue\":\"Синий\",\"brightness\":\"Яркость\",\"green\":\"Зеленый\",\"hue\":\"Оттенок\",\"lightness\":\"Освещенность\",\"red\":\"Красный\",\"saturation\":\"Насыщенность\"}");
|
|
423
135
|
|
|
424
|
-
getChannelRange(channel) {
|
|
425
|
-
switch (channel) {
|
|
426
|
-
case 'hue':
|
|
427
|
-
return {
|
|
428
|
-
minValue: 0,
|
|
429
|
-
maxValue: 360,
|
|
430
|
-
step: 1
|
|
431
|
-
};
|
|
432
136
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
return {
|
|
436
|
-
minValue: 0,
|
|
437
|
-
maxValue: 100,
|
|
438
|
-
step: 1
|
|
439
|
-
};
|
|
137
|
+
var $8612080ab5efe0cf$exports = {};
|
|
138
|
+
$8612080ab5efe0cf$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Modrá\",\"brightness\":\"Jas\",\"green\":\"Zelená\",\"hue\":\"Odtieň\",\"lightness\":\"Svetlosť\",\"red\":\"Červená\",\"saturation\":\"Sýtosť\"}");
|
|
440
139
|
|
|
441
|
-
case 'alpha':
|
|
442
|
-
return {
|
|
443
|
-
minValue: 0,
|
|
444
|
-
maxValue: 1,
|
|
445
|
-
step: 0.01
|
|
446
|
-
};
|
|
447
140
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
}
|
|
141
|
+
var $99cc034ddd2b7d86$exports = {};
|
|
142
|
+
$99cc034ddd2b7d86$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Modra\",\"brightness\":\"Svetlost\",\"green\":\"Zelena\",\"hue\":\"Barva\",\"lightness\":\"Lahkost\",\"red\":\"Rdeča\",\"saturation\":\"Nasičenost\"}");
|
|
452
143
|
|
|
453
|
-
formatChannelValue(channel, locale) {
|
|
454
|
-
let options;
|
|
455
|
-
let value = this.getChannelValue(channel);
|
|
456
144
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
options = {
|
|
460
|
-
style: 'unit',
|
|
461
|
-
unit: 'degree',
|
|
462
|
-
unitDisplay: 'narrow'
|
|
463
|
-
};
|
|
464
|
-
break;
|
|
145
|
+
var $dc671800d61be83e$exports = {};
|
|
146
|
+
$dc671800d61be83e$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Plava\",\"brightness\":\"Osvetljenost\",\"green\":\"Zelena\",\"hue\":\"Nijansa\",\"lightness\":\"Osvetljenje\",\"red\":\"Crvena\",\"saturation\":\"Zasićenje\"}");
|
|
465
147
|
|
|
466
|
-
case 'saturation':
|
|
467
|
-
case 'brightness':
|
|
468
|
-
options = {
|
|
469
|
-
style: 'percent'
|
|
470
|
-
};
|
|
471
|
-
value /= 100;
|
|
472
|
-
break;
|
|
473
148
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
style: 'percent'
|
|
477
|
-
};
|
|
478
|
-
break;
|
|
149
|
+
var $0f4790e2f696e63f$exports = {};
|
|
150
|
+
$0f4790e2f696e63f$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Blått\",\"brightness\":\"Ljusstyrka\",\"green\":\"Grönt\",\"hue\":\"Nyans\",\"lightness\":\"Ljushet\",\"red\":\"Rött\",\"saturation\":\"Mättnad\"}");
|
|
479
151
|
|
|
480
|
-
default:
|
|
481
|
-
throw new Error('Unknown color channel: ' + channel);
|
|
482
|
-
}
|
|
483
152
|
|
|
484
|
-
|
|
485
|
-
|
|
153
|
+
var $deb5f82eb1998a3c$exports = {};
|
|
154
|
+
$deb5f82eb1998a3c$exports = JSON.parse("{\"alpha\":\"Alfa\",\"blue\":\"Mavi\",\"brightness\":\"Parlaklık\",\"green\":\"Yeşil\",\"hue\":\"Ton\",\"lightness\":\"Canlılık\",\"red\":\"Kırmızı\",\"saturation\":\"Doygunluk\"}");
|
|
486
155
|
|
|
487
|
-
} // X = <negative/positive number with/without decimal places>
|
|
488
|
-
// before/after a comma, 0 or more whitespaces are allowed
|
|
489
|
-
// - hsl(X, X%, X%)
|
|
490
|
-
// - hsla(X, X%, X%, X)
|
|
491
156
|
|
|
157
|
+
var $99530e1782ca02cc$exports = {};
|
|
158
|
+
$99530e1782ca02cc$exports = JSON.parse("{\"alpha\":\"Альфа\",\"blue\":\"Синій\",\"brightness\":\"Яскравість\",\"green\":\"Зелений\",\"hue\":\"Тон\",\"lightness\":\"Освітленість\",\"red\":\"Червоний\",\"saturation\":\"Насиченість\"}");
|
|
492
159
|
|
|
493
|
-
const $b54655da051f787a04029ec3711$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+)?)\)/;
|
|
494
160
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
161
|
+
var $a6e8f490b423d65e$exports = {};
|
|
162
|
+
$a6e8f490b423d65e$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"蓝色\",\"brightness\":\"亮度\",\"green\":\"绿色\",\"hue\":\"色相\",\"lightness\":\"明亮度\",\"red\":\"红色\",\"saturation\":\"饱和度\"}");
|
|
498
163
|
|
|
499
164
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
super();
|
|
503
|
-
this.hue = hue;
|
|
504
|
-
this.saturation = saturation;
|
|
505
|
-
this.lightness = lightness;
|
|
506
|
-
this.alpha = alpha;
|
|
507
|
-
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
165
|
+
var $eba443dcc93cab9a$exports = {};
|
|
166
|
+
$eba443dcc93cab9a$exports = JSON.parse("{\"alpha\":\"Alpha\",\"blue\":\"藍色\",\"brightness\":\"亮度\",\"green\":\"綠色\",\"hue\":\"色相\",\"lightness\":\"明亮\",\"red\":\"紅色\",\"saturation\":\"飽和度\"}");
|
|
508
167
|
|
|
509
168
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
169
|
+
$c0b600cf8eafdee9$exports = {
|
|
170
|
+
"ar-AE": $b044e7150534af04$exports,
|
|
171
|
+
"bg-BG": $c8bf89547a4a9b3f$exports,
|
|
172
|
+
"cs-CZ": $8365d8dfc7e4c985$exports,
|
|
173
|
+
"da-DK": $8d95eeaa73699e56$exports,
|
|
174
|
+
"de-DE": $2dbbd166053d6d10$exports,
|
|
175
|
+
"el-GR": $1fcbdf9eaf6cc074$exports,
|
|
176
|
+
"en-US": $42d54be461715959$exports,
|
|
177
|
+
"es-ES": $911646bd5662c33d$exports,
|
|
178
|
+
"et-EE": $6e8998796901e680$exports,
|
|
179
|
+
"fi-FI": $4503b4001036be6d$exports,
|
|
180
|
+
"fr-FR": $721e7016769a7a7f$exports,
|
|
181
|
+
"he-IL": $dcc290e5792f9bab$exports,
|
|
182
|
+
"hr-HR": $d93d5aebdd12334c$exports,
|
|
183
|
+
"hu-HU": $a3749e0ee87dbebc$exports,
|
|
184
|
+
"it-IT": $2fdb931b6c9652b9$exports,
|
|
185
|
+
"ja-JP": $219c839b59015b4f$exports,
|
|
186
|
+
"ko-KR": $b7f67f414086d976$exports,
|
|
187
|
+
"lt-LT": $f27b2ac7d517417c$exports,
|
|
188
|
+
"lv-LV": $e92168db3cbe2797$exports,
|
|
189
|
+
"nb-NO": $44b012e02982e825$exports,
|
|
190
|
+
"nl-NL": $64fbd91459613d8b$exports,
|
|
191
|
+
"pl-PL": $83fabdc4e0df6af9$exports,
|
|
192
|
+
"pt-BR": $30b915257fa66ccf$exports,
|
|
193
|
+
"pt-PT": $ce75e45ccbc92491$exports,
|
|
194
|
+
"ro-RO": $225440ee53a1fecd$exports,
|
|
195
|
+
"ru-RU": $cbc60c1dd4e689ff$exports,
|
|
196
|
+
"sk-SK": $8612080ab5efe0cf$exports,
|
|
197
|
+
"sl-SI": $99cc034ddd2b7d86$exports,
|
|
198
|
+
"sr-SP": $dc671800d61be83e$exports,
|
|
199
|
+
"sv-SE": $0f4790e2f696e63f$exports,
|
|
200
|
+
"tr-TR": $deb5f82eb1998a3c$exports,
|
|
201
|
+
"uk-UA": $99530e1782ca02cc$exports,
|
|
202
|
+
"zh-CN": $a6e8f490b423d65e$exports,
|
|
203
|
+
"zh-TW": $eba443dcc93cab9a$exports
|
|
204
|
+
};
|
|
515
205
|
|
|
516
|
-
const [h, s, l, a] = ((_m$3 = m[1]) != null ? _m$3 : m[2]).split(',').map(n => Number(n.trim().replace('%', '')));
|
|
517
|
-
return new $b54655da051f787a04029ec3711$var$HSLColor($b54655da051f787a04029ec3711$var$mod(h, 360), clamp(s, 0, 100), clamp(l, 0, 100), clamp(a != null ? a : 1, 0, 1));
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
206
|
|
|
521
|
-
toString(format) {
|
|
522
|
-
switch (format) {
|
|
523
|
-
case 'hsl':
|
|
524
|
-
return "hsl(" + this.hue + ", " + this.saturation + "%, " + this.lightness + "%)";
|
|
525
207
|
|
|
526
|
-
case 'css':
|
|
527
|
-
case 'hsla':
|
|
528
|
-
return "hsla(" + this.hue + ", " + this.saturation + "%, " + this.lightness + "%, " + this.alpha + ")";
|
|
529
208
|
|
|
530
|
-
|
|
531
|
-
|
|
209
|
+
const $83fe1a57d631223b$var$messages = new $4tN2K$internationalizedmessage.MessageDictionary((/*@__PURE__*/$parcel$interopDefault($c0b600cf8eafdee9$exports)));
|
|
210
|
+
function $83fe1a57d631223b$export$6e865ea70d7724f(value) {
|
|
211
|
+
let res = $83fe1a57d631223b$var$RGBColor.parse(value) || $83fe1a57d631223b$var$HSBColor.parse(value) || $83fe1a57d631223b$var$HSLColor.parse(value);
|
|
212
|
+
if (res) return res;
|
|
213
|
+
throw new Error('Invalid color value: ' + value);
|
|
214
|
+
}
|
|
215
|
+
function $83fe1a57d631223b$export$4cde5df63f53f473(v) {
|
|
216
|
+
if (typeof v === 'string') return $83fe1a57d631223b$export$6e865ea70d7724f(v);
|
|
217
|
+
else return v;
|
|
218
|
+
}
|
|
219
|
+
class $83fe1a57d631223b$var$Color {
|
|
220
|
+
toHexInt() {
|
|
221
|
+
return this.toFormat('rgb').toHexInt();
|
|
532
222
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
switch (format) {
|
|
537
|
-
case 'hsl':
|
|
538
|
-
case 'hsla':
|
|
539
|
-
return this;
|
|
540
|
-
|
|
541
|
-
default:
|
|
542
|
-
throw new Error('Unsupported color conversion: hsl -> ' + format);
|
|
223
|
+
getChannelValue(channel) {
|
|
224
|
+
if (channel in this) return this[channel];
|
|
225
|
+
throw new Error('Unsupported color channel: ' + channel);
|
|
543
226
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
maxValue: 100,
|
|
564
|
-
step: 1
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
case 'alpha':
|
|
227
|
+
withChannelValue(channel, value) {
|
|
228
|
+
if (channel in this) {
|
|
229
|
+
let x = this.clone();
|
|
230
|
+
x[channel] = value;
|
|
231
|
+
return x;
|
|
232
|
+
}
|
|
233
|
+
throw new Error('Unsupported color channel: ' + channel);
|
|
234
|
+
}
|
|
235
|
+
getChannelName(channel, locale) {
|
|
236
|
+
return $83fe1a57d631223b$var$messages.getStringForLocale(channel, locale);
|
|
237
|
+
}
|
|
238
|
+
getColorSpaceAxes(xyChannels) {
|
|
239
|
+
let { xChannel: xChannel , yChannel: yChannel } = xyChannels;
|
|
240
|
+
let xCh = xChannel || this.getColorChannels().find((c)=>c !== yChannel
|
|
241
|
+
);
|
|
242
|
+
let yCh = yChannel || this.getColorChannels().find((c)=>c !== xCh
|
|
243
|
+
);
|
|
244
|
+
let zCh = this.getColorChannels().find((c)=>c !== xCh && c !== yCh
|
|
245
|
+
);
|
|
568
246
|
return {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
247
|
+
xChannel: xCh,
|
|
248
|
+
yChannel: yCh,
|
|
249
|
+
zChannel: zCh
|
|
572
250
|
};
|
|
573
|
-
|
|
574
|
-
default:
|
|
575
|
-
throw new Error('Unknown color channel: ' + channel);
|
|
576
251
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
252
|
+
}
|
|
253
|
+
const $83fe1a57d631223b$var$HEX_REGEX = /^#(?:([0-9a-f]{3})|([0-9a-f]{6}))$/i;
|
|
254
|
+
// X = <negative/positive number with/without decimal places>
|
|
255
|
+
// before/after a comma, 0 or more whitespaces are allowed
|
|
256
|
+
// - rgb(X, X, X)
|
|
257
|
+
// - rgba(X, X, X, X)
|
|
258
|
+
const $83fe1a57d631223b$var$RGB_REGEX = /rgb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?)\)|rgba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d(.\d+)?)\)/;
|
|
259
|
+
class $83fe1a57d631223b$var$RGBColor extends $83fe1a57d631223b$var$Color {
|
|
260
|
+
static parse(value) {
|
|
261
|
+
let m;
|
|
262
|
+
if (m = value.match($83fe1a57d631223b$var$HEX_REGEX)) {
|
|
263
|
+
if (m[1]) {
|
|
264
|
+
let r = parseInt(m[1][0] + m[1][0], 16);
|
|
265
|
+
let g = parseInt(m[1][1] + m[1][1], 16);
|
|
266
|
+
let b = parseInt(m[1][2] + m[1][2], 16);
|
|
267
|
+
return new $83fe1a57d631223b$var$RGBColor(r, g, b, 1);
|
|
268
|
+
} else if (m[2]) {
|
|
269
|
+
let r = parseInt(m[2][0] + m[2][1], 16);
|
|
270
|
+
let g = parseInt(m[2][2] + m[2][3], 16);
|
|
271
|
+
let b = parseInt(m[2][4] + m[2][5], 16);
|
|
272
|
+
return new $83fe1a57d631223b$var$RGBColor(r, g, b, 1);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (m = value.match($83fe1a57d631223b$var$RGB_REGEX)) {
|
|
276
|
+
var ref;
|
|
277
|
+
const [r, g, b, a] = ((ref = m[1]) !== null && ref !== void 0 ? ref : m[2]).split(',').map((n)=>Number(n.trim())
|
|
278
|
+
);
|
|
279
|
+
return new $83fe1a57d631223b$var$RGBColor($4tN2K$reactstatelyutils.clamp(r, 0, 255), $4tN2K$reactstatelyutils.clamp(g, 0, 255), $4tN2K$reactstatelyutils.clamp(b, 0, 255), $4tN2K$reactstatelyutils.clamp(a !== null && a !== void 0 ? a : 1, 0, 1));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
toString(format) {
|
|
283
|
+
switch(format){
|
|
284
|
+
case 'hex':
|
|
285
|
+
return '#' + (this.red.toString(16).padStart(2, '0') + this.green.toString(16).padStart(2, '0') + this.blue.toString(16).padStart(2, '0')).toUpperCase();
|
|
286
|
+
case 'hexa':
|
|
287
|
+
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();
|
|
288
|
+
case 'rgb':
|
|
289
|
+
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
290
|
+
case 'css':
|
|
291
|
+
case 'rgba':
|
|
292
|
+
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
|
|
293
|
+
default:
|
|
294
|
+
return this.toFormat(format).toString(format);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
toFormat(format) {
|
|
298
|
+
switch(format){
|
|
299
|
+
case 'hex':
|
|
300
|
+
case 'hexa':
|
|
301
|
+
case 'rgb':
|
|
302
|
+
case 'rgba':
|
|
303
|
+
return this;
|
|
304
|
+
case 'hsb':
|
|
305
|
+
case 'hsba':
|
|
306
|
+
return this.toHSB();
|
|
307
|
+
case 'hsl':
|
|
308
|
+
case 'hsla':
|
|
309
|
+
return this.toHSL();
|
|
310
|
+
default:
|
|
311
|
+
throw new Error('Unsupported color conversion: rgb -> ' + format);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
toHexInt() {
|
|
315
|
+
return this.red << 16 | this.green << 8 | this.blue;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Converts an RGB color value to HSB.
|
|
319
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
320
|
+
* @returns An HSBColor object.
|
|
321
|
+
*/ toHSB() {
|
|
322
|
+
const red = this.red / 255;
|
|
323
|
+
const green = this.green / 255;
|
|
324
|
+
const blue = this.blue / 255;
|
|
325
|
+
const min = Math.min(red, green, blue);
|
|
326
|
+
const brightness = Math.max(red, green, blue);
|
|
327
|
+
const chroma = brightness - min;
|
|
328
|
+
const saturation = brightness === 0 ? 0 : chroma / brightness;
|
|
329
|
+
let hue = 0; // achromatic
|
|
330
|
+
if (chroma !== 0) {
|
|
331
|
+
switch(brightness){
|
|
332
|
+
case red:
|
|
333
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
334
|
+
break;
|
|
335
|
+
case green:
|
|
336
|
+
hue = (blue - red) / chroma + 2;
|
|
337
|
+
break;
|
|
338
|
+
case blue:
|
|
339
|
+
hue = (red - green) / chroma + 4;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
hue /= 6;
|
|
343
|
+
}
|
|
344
|
+
return new $83fe1a57d631223b$var$HSBColor($4tN2K$reactstatelyutils.toFixedNumber(hue * 360, 2), $4tN2K$reactstatelyutils.toFixedNumber(saturation * 100, 2), $4tN2K$reactstatelyutils.toFixedNumber(brightness * 100, 2), this.alpha);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Converts an RGB color value to HSL.
|
|
348
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB.
|
|
349
|
+
* @returns An HSLColor object.
|
|
350
|
+
*/ toHSL() {
|
|
351
|
+
const red = this.red / 255;
|
|
352
|
+
const green = this.green / 255;
|
|
353
|
+
const blue = this.blue / 255;
|
|
354
|
+
const min = Math.min(red, green, blue);
|
|
355
|
+
const max = Math.max(red, green, blue);
|
|
356
|
+
const lightness = (max + min) / 2;
|
|
357
|
+
const chroma = max - min;
|
|
358
|
+
let hue;
|
|
359
|
+
let saturation;
|
|
360
|
+
if (chroma === 0) hue = saturation = 0; // achromatic
|
|
361
|
+
else {
|
|
362
|
+
saturation = chroma / (lightness < 0.5 ? max + min : 2 - max - min);
|
|
363
|
+
switch(max){
|
|
364
|
+
case red:
|
|
365
|
+
hue = (green - blue) / chroma + (green < blue ? 6 : 0);
|
|
366
|
+
break;
|
|
367
|
+
case green:
|
|
368
|
+
hue = (blue - red) / chroma + 2;
|
|
369
|
+
break;
|
|
370
|
+
case blue:
|
|
371
|
+
hue = (red - green) / chroma + 4;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
hue /= 6;
|
|
375
|
+
}
|
|
376
|
+
return new $83fe1a57d631223b$var$HSLColor($4tN2K$reactstatelyutils.toFixedNumber(hue * 360, 2), $4tN2K$reactstatelyutils.toFixedNumber(saturation * 100, 2), $4tN2K$reactstatelyutils.toFixedNumber(lightness * 100, 2), this.alpha);
|
|
377
|
+
}
|
|
378
|
+
clone() {
|
|
379
|
+
return new $83fe1a57d631223b$var$RGBColor(this.red, this.green, this.blue, this.alpha);
|
|
380
|
+
}
|
|
381
|
+
getChannelRange(channel) {
|
|
382
|
+
switch(channel){
|
|
383
|
+
case 'red':
|
|
384
|
+
case 'green':
|
|
385
|
+
case 'blue':
|
|
386
|
+
return {
|
|
387
|
+
minValue: 0,
|
|
388
|
+
maxValue: 255,
|
|
389
|
+
step: 1,
|
|
390
|
+
pageSize: 17
|
|
391
|
+
};
|
|
392
|
+
case 'alpha':
|
|
393
|
+
return {
|
|
394
|
+
minValue: 0,
|
|
395
|
+
maxValue: 1,
|
|
396
|
+
step: 0.01,
|
|
397
|
+
pageSize: 0.1
|
|
398
|
+
};
|
|
399
|
+
default:
|
|
400
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
formatChannelValue(channel, locale) {
|
|
404
|
+
let options;
|
|
405
|
+
let value = this.getChannelValue(channel);
|
|
406
|
+
switch(channel){
|
|
407
|
+
case 'red':
|
|
408
|
+
case 'green':
|
|
409
|
+
case 'blue':
|
|
410
|
+
options = {
|
|
411
|
+
style: 'decimal'
|
|
412
|
+
};
|
|
413
|
+
break;
|
|
414
|
+
case 'alpha':
|
|
415
|
+
options = {
|
|
416
|
+
style: 'percent'
|
|
417
|
+
};
|
|
418
|
+
break;
|
|
419
|
+
default:
|
|
420
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
421
|
+
}
|
|
422
|
+
return new $4tN2K$internationalizednumber.NumberFormatter(locale, options).format(value);
|
|
423
|
+
}
|
|
424
|
+
getColorSpace() {
|
|
425
|
+
return 'rgb';
|
|
426
|
+
}
|
|
427
|
+
getColorChannels() {
|
|
428
|
+
return $83fe1a57d631223b$var$RGBColor.colorChannels;
|
|
429
|
+
}
|
|
430
|
+
constructor(red, green, blue, alpha){
|
|
431
|
+
super();
|
|
432
|
+
this.red = red;
|
|
433
|
+
this.green = green;
|
|
434
|
+
this.blue = blue;
|
|
435
|
+
this.alpha = alpha;
|
|
608
436
|
}
|
|
609
|
-
|
|
610
|
-
return new NumberFormatter(locale, options).format(value);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
437
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
438
|
+
$83fe1a57d631223b$var$RGBColor.colorChannels = [
|
|
439
|
+
'red',
|
|
440
|
+
'green',
|
|
441
|
+
'blue'
|
|
442
|
+
];
|
|
443
|
+
// X = <negative/positive number with/without decimal places>
|
|
444
|
+
// before/after a comma, 0 or more whitespaces are allowed
|
|
445
|
+
// - hsb(X, X%, X%)
|
|
446
|
+
// - hsba(X, X%, X%, X)
|
|
447
|
+
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+)?)\)/;
|
|
448
|
+
class $83fe1a57d631223b$var$HSBColor extends $83fe1a57d631223b$var$Color {
|
|
449
|
+
static parse(value) {
|
|
450
|
+
let m;
|
|
451
|
+
if (m = value.match($83fe1a57d631223b$var$HSB_REGEX)) {
|
|
452
|
+
var ref;
|
|
453
|
+
const [h, s, b, a] = ((ref = m[1]) !== null && ref !== void 0 ? ref : m[2]).split(',').map((n)=>Number(n.trim().replace('%', ''))
|
|
454
|
+
);
|
|
455
|
+
return new $83fe1a57d631223b$var$HSBColor($83fe1a57d631223b$var$mod(h, 360), $4tN2K$reactstatelyutils.clamp(s, 0, 100), $4tN2K$reactstatelyutils.clamp(b, 0, 100), $4tN2K$reactstatelyutils.clamp(a !== null && a !== void 0 ? a : 1, 0, 1));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
toString(format) {
|
|
459
|
+
switch(format){
|
|
460
|
+
case 'css':
|
|
461
|
+
return this.toHSL().toString('css');
|
|
462
|
+
case 'hex':
|
|
463
|
+
return this.toRGB().toString('hex');
|
|
464
|
+
case 'hexa':
|
|
465
|
+
return this.toRGB().toString('hexa');
|
|
466
|
+
case 'hsb':
|
|
467
|
+
return `hsb(${this.hue}, ${$4tN2K$reactstatelyutils.toFixedNumber(this.saturation, 2)}%, ${$4tN2K$reactstatelyutils.toFixedNumber(this.brightness, 2)}%)`;
|
|
468
|
+
case 'hsba':
|
|
469
|
+
return `hsba(${this.hue}, ${$4tN2K$reactstatelyutils.toFixedNumber(this.saturation, 2)}%, ${$4tN2K$reactstatelyutils.toFixedNumber(this.brightness, 2)}%, ${this.alpha})`;
|
|
470
|
+
default:
|
|
471
|
+
return this.toFormat(format).toString(format);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
toFormat(format) {
|
|
475
|
+
switch(format){
|
|
476
|
+
case 'hsb':
|
|
477
|
+
case 'hsba':
|
|
478
|
+
return this;
|
|
479
|
+
case 'hsl':
|
|
480
|
+
case 'hsla':
|
|
481
|
+
return this.toHSL();
|
|
482
|
+
case 'rgb':
|
|
483
|
+
case 'rgba':
|
|
484
|
+
return this.toRGB();
|
|
485
|
+
default:
|
|
486
|
+
throw new Error('Unsupported color conversion: hsb -> ' + format);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Converts a HSB color to HSL.
|
|
491
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_HSL.
|
|
492
|
+
* @returns An HSLColor object.
|
|
493
|
+
*/ toHSL() {
|
|
494
|
+
let saturation = this.saturation / 100;
|
|
495
|
+
let brightness = this.brightness / 100;
|
|
496
|
+
let lightness = brightness * (1 - saturation / 2);
|
|
497
|
+
saturation = lightness === 0 || lightness === 1 ? 0 : (brightness - lightness) / Math.min(lightness, 1 - lightness);
|
|
498
|
+
return new $83fe1a57d631223b$var$HSLColor($4tN2K$reactstatelyutils.toFixedNumber(this.hue, 2), $4tN2K$reactstatelyutils.toFixedNumber(saturation * 100, 2), $4tN2K$reactstatelyutils.toFixedNumber(lightness * 100, 2), this.alpha);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Converts a HSV color value to RGB.
|
|
502
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB_alternative.
|
|
503
|
+
* @returns An RGBColor object.
|
|
504
|
+
*/ toRGB() {
|
|
505
|
+
let hue = this.hue;
|
|
506
|
+
let saturation = this.saturation / 100;
|
|
507
|
+
let brightness = this.brightness / 100;
|
|
508
|
+
let fn = (n, k = (n + hue / 60) % 6)=>brightness - saturation * brightness * Math.max(Math.min(k, 4 - k, 1), 0)
|
|
509
|
+
;
|
|
510
|
+
return new $83fe1a57d631223b$var$RGBColor(Math.round(fn(5) * 255), Math.round(fn(3) * 255), Math.round(fn(1) * 255), this.alpha);
|
|
511
|
+
}
|
|
512
|
+
clone() {
|
|
513
|
+
return new $83fe1a57d631223b$var$HSBColor(this.hue, this.saturation, this.brightness, this.alpha);
|
|
514
|
+
}
|
|
515
|
+
getChannelRange(channel) {
|
|
516
|
+
switch(channel){
|
|
517
|
+
case 'hue':
|
|
518
|
+
return {
|
|
519
|
+
minValue: 0,
|
|
520
|
+
maxValue: 360,
|
|
521
|
+
step: 1,
|
|
522
|
+
pageSize: 15
|
|
523
|
+
};
|
|
524
|
+
case 'saturation':
|
|
525
|
+
case 'brightness':
|
|
526
|
+
return {
|
|
527
|
+
minValue: 0,
|
|
528
|
+
maxValue: 100,
|
|
529
|
+
step: 1,
|
|
530
|
+
pageSize: 10
|
|
531
|
+
};
|
|
532
|
+
case 'alpha':
|
|
533
|
+
return {
|
|
534
|
+
minValue: 0,
|
|
535
|
+
maxValue: 1,
|
|
536
|
+
step: 0.01,
|
|
537
|
+
pageSize: 0.1
|
|
538
|
+
};
|
|
539
|
+
default:
|
|
540
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
formatChannelValue(channel, locale) {
|
|
544
|
+
let options;
|
|
545
|
+
let value = this.getChannelValue(channel);
|
|
546
|
+
switch(channel){
|
|
547
|
+
case 'hue':
|
|
548
|
+
options = {
|
|
549
|
+
style: 'unit',
|
|
550
|
+
unit: 'degree',
|
|
551
|
+
unitDisplay: 'narrow'
|
|
552
|
+
};
|
|
553
|
+
break;
|
|
554
|
+
case 'saturation':
|
|
555
|
+
case 'brightness':
|
|
556
|
+
options = {
|
|
557
|
+
style: 'percent'
|
|
558
|
+
};
|
|
559
|
+
value /= 100;
|
|
560
|
+
break;
|
|
561
|
+
case 'alpha':
|
|
562
|
+
options = {
|
|
563
|
+
style: 'percent'
|
|
564
|
+
};
|
|
565
|
+
break;
|
|
566
|
+
default:
|
|
567
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
568
|
+
}
|
|
569
|
+
return new $4tN2K$internationalizednumber.NumberFormatter(locale, options).format(value);
|
|
570
|
+
}
|
|
571
|
+
getColorSpace() {
|
|
572
|
+
return 'hsb';
|
|
573
|
+
}
|
|
574
|
+
getColorChannels() {
|
|
575
|
+
return $83fe1a57d631223b$var$HSBColor.colorChannels;
|
|
576
|
+
}
|
|
577
|
+
constructor(hue, saturation, brightness, alpha){
|
|
578
|
+
super();
|
|
579
|
+
this.hue = hue;
|
|
580
|
+
this.saturation = saturation;
|
|
581
|
+
this.brightness = brightness;
|
|
582
|
+
this.alpha = alpha;
|
|
583
|
+
}
|
|
621
584
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
585
|
+
$83fe1a57d631223b$var$HSBColor.colorChannels = [
|
|
586
|
+
'hue',
|
|
587
|
+
'saturation',
|
|
588
|
+
'brightness'
|
|
589
|
+
];
|
|
590
|
+
// X = <negative/positive number with/without decimal places>
|
|
591
|
+
// before/after a comma, 0 or more whitespaces are allowed
|
|
592
|
+
// - hsl(X, X%, X%)
|
|
593
|
+
// - hsla(X, X%, X%, X)
|
|
594
|
+
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+)?)\)/;
|
|
595
|
+
function $83fe1a57d631223b$var$mod(n, m) {
|
|
596
|
+
return (n % m + m) % m;
|
|
597
|
+
}
|
|
598
|
+
class $83fe1a57d631223b$var$HSLColor extends $83fe1a57d631223b$var$Color {
|
|
599
|
+
static parse(value) {
|
|
600
|
+
let m;
|
|
601
|
+
if (m = value.match($83fe1a57d631223b$var$HSL_REGEX)) {
|
|
602
|
+
var ref;
|
|
603
|
+
const [h, s, l, a] = ((ref = m[1]) !== null && ref !== void 0 ? ref : m[2]).split(',').map((n)=>Number(n.trim().replace('%', ''))
|
|
604
|
+
);
|
|
605
|
+
return new $83fe1a57d631223b$var$HSLColor($83fe1a57d631223b$var$mod(h, 360), $4tN2K$reactstatelyutils.clamp(s, 0, 100), $4tN2K$reactstatelyutils.clamp(l, 0, 100), $4tN2K$reactstatelyutils.clamp(a !== null && a !== void 0 ? a : 1, 0, 1));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
toString(format) {
|
|
609
|
+
switch(format){
|
|
610
|
+
case 'hex':
|
|
611
|
+
return this.toRGB().toString('hex');
|
|
612
|
+
case 'hexa':
|
|
613
|
+
return this.toRGB().toString('hexa');
|
|
614
|
+
case 'hsl':
|
|
615
|
+
return `hsl(${this.hue}, ${$4tN2K$reactstatelyutils.toFixedNumber(this.saturation, 2)}%, ${$4tN2K$reactstatelyutils.toFixedNumber(this.lightness, 2)}%)`;
|
|
616
|
+
case 'css':
|
|
617
|
+
case 'hsla':
|
|
618
|
+
return `hsla(${this.hue}, ${$4tN2K$reactstatelyutils.toFixedNumber(this.saturation, 2)}%, ${$4tN2K$reactstatelyutils.toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
|
|
619
|
+
default:
|
|
620
|
+
return this.toFormat(format).toString(format);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
toFormat(format) {
|
|
624
|
+
switch(format){
|
|
625
|
+
case 'hsl':
|
|
626
|
+
case 'hsla':
|
|
627
|
+
return this;
|
|
628
|
+
case 'hsb':
|
|
629
|
+
case 'hsba':
|
|
630
|
+
return this.toHSB();
|
|
631
|
+
case 'rgb':
|
|
632
|
+
case 'rgba':
|
|
633
|
+
return this.toRGB();
|
|
634
|
+
default:
|
|
635
|
+
throw new Error('Unsupported color conversion: hsl -> ' + format);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Converts a HSL color to HSB.
|
|
640
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_HSV.
|
|
641
|
+
* @returns An HSBColor object.
|
|
642
|
+
*/ toHSB() {
|
|
643
|
+
let saturation = this.saturation / 100;
|
|
644
|
+
let lightness = this.lightness / 100;
|
|
645
|
+
let brightness = lightness + saturation * Math.min(lightness, 1 - lightness);
|
|
646
|
+
saturation = brightness === 0 ? 0 : 2 * (1 - lightness / brightness);
|
|
647
|
+
return new $83fe1a57d631223b$var$HSBColor($4tN2K$reactstatelyutils.toFixedNumber(this.hue, 2), $4tN2K$reactstatelyutils.toFixedNumber(saturation * 100, 2), $4tN2K$reactstatelyutils.toFixedNumber(brightness * 100, 2), this.alpha);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Converts a HSL color to RGB.
|
|
651
|
+
* Conversion formula adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
|
|
652
|
+
* @returns An RGBColor object.
|
|
653
|
+
*/ toRGB() {
|
|
654
|
+
let hue = this.hue;
|
|
655
|
+
let saturation = this.saturation / 100;
|
|
656
|
+
let lightness = this.lightness / 100;
|
|
657
|
+
let a = saturation * Math.min(lightness, 1 - lightness);
|
|
658
|
+
let fn = (n, k = (n + hue / 30) % 12)=>lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)
|
|
659
|
+
;
|
|
660
|
+
return new $83fe1a57d631223b$var$RGBColor(Math.round(fn(0) * 255), Math.round(fn(8) * 255), Math.round(fn(4) * 255), this.alpha);
|
|
661
|
+
}
|
|
662
|
+
clone() {
|
|
663
|
+
return new $83fe1a57d631223b$var$HSLColor(this.hue, this.saturation, this.lightness, this.alpha);
|
|
664
|
+
}
|
|
665
|
+
getChannelRange(channel) {
|
|
666
|
+
switch(channel){
|
|
667
|
+
case 'hue':
|
|
668
|
+
return {
|
|
669
|
+
minValue: 0,
|
|
670
|
+
maxValue: 360,
|
|
671
|
+
step: 1,
|
|
672
|
+
pageSize: 15
|
|
673
|
+
};
|
|
674
|
+
case 'saturation':
|
|
675
|
+
case 'lightness':
|
|
676
|
+
return {
|
|
677
|
+
minValue: 0,
|
|
678
|
+
maxValue: 100,
|
|
679
|
+
step: 1,
|
|
680
|
+
pageSize: 10
|
|
681
|
+
};
|
|
682
|
+
case 'alpha':
|
|
683
|
+
return {
|
|
684
|
+
minValue: 0,
|
|
685
|
+
maxValue: 1,
|
|
686
|
+
step: 0.01,
|
|
687
|
+
pageSize: 0.1
|
|
688
|
+
};
|
|
689
|
+
default:
|
|
690
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
formatChannelValue(channel, locale) {
|
|
694
|
+
let options;
|
|
695
|
+
let value = this.getChannelValue(channel);
|
|
696
|
+
switch(channel){
|
|
697
|
+
case 'hue':
|
|
698
|
+
options = {
|
|
699
|
+
style: 'unit',
|
|
700
|
+
unit: 'degree',
|
|
701
|
+
unitDisplay: 'narrow'
|
|
702
|
+
};
|
|
703
|
+
break;
|
|
704
|
+
case 'saturation':
|
|
705
|
+
case 'lightness':
|
|
706
|
+
options = {
|
|
707
|
+
style: 'percent'
|
|
708
|
+
};
|
|
709
|
+
value /= 100;
|
|
710
|
+
break;
|
|
711
|
+
case 'alpha':
|
|
712
|
+
options = {
|
|
713
|
+
style: 'percent'
|
|
714
|
+
};
|
|
715
|
+
break;
|
|
716
|
+
default:
|
|
717
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
718
|
+
}
|
|
719
|
+
return new $4tN2K$internationalizednumber.NumberFormatter(locale, options).format(value);
|
|
720
|
+
}
|
|
721
|
+
getColorSpace() {
|
|
722
|
+
return 'hsl';
|
|
723
|
+
}
|
|
724
|
+
getColorChannels() {
|
|
725
|
+
return $83fe1a57d631223b$var$HSLColor.colorChannels;
|
|
726
|
+
}
|
|
727
|
+
constructor(hue, saturation, lightness, alpha){
|
|
728
|
+
super();
|
|
729
|
+
this.hue = hue;
|
|
730
|
+
this.saturation = saturation;
|
|
731
|
+
this.lightness = lightness;
|
|
732
|
+
this.alpha = alpha;
|
|
660
733
|
}
|
|
734
|
+
}
|
|
735
|
+
$83fe1a57d631223b$var$HSLColor.colorChannels = [
|
|
736
|
+
'hue',
|
|
737
|
+
'saturation',
|
|
738
|
+
'lightness'
|
|
739
|
+
];
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
var $af2d7ac9990cfee2$exports = {};
|
|
743
|
+
|
|
744
|
+
$parcel$export($af2d7ac9990cfee2$exports, "useColorAreaState", () => $af2d7ac9990cfee2$export$6df7f0e2cabc7eef);
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
const $af2d7ac9990cfee2$var$DEFAULT_COLOR = $83fe1a57d631223b$export$6e865ea70d7724f('#ffffff');
|
|
749
|
+
function $af2d7ac9990cfee2$export$6df7f0e2cabc7eef(props) {
|
|
750
|
+
let { value: value1 , defaultValue: defaultValue , xChannel: xChannel , yChannel: yChannel , onChange: onChange , onChangeEnd: onChangeEnd } = props;
|
|
751
|
+
if (!value1 && !defaultValue) defaultValue = $af2d7ac9990cfee2$var$DEFAULT_COLOR;
|
|
752
|
+
let [color, setColor] = $4tN2K$reactstatelyutils.useControlledState(value1 && $83fe1a57d631223b$export$4cde5df63f53f473(value1), defaultValue && $83fe1a57d631223b$export$4cde5df63f53f473(defaultValue), onChange);
|
|
753
|
+
let valueRef = $4tN2K$react.useRef(color);
|
|
754
|
+
valueRef.current = color;
|
|
755
|
+
let channels = $4tN2K$react.useMemo(()=>valueRef.current.getColorSpaceAxes({
|
|
756
|
+
xChannel: xChannel,
|
|
757
|
+
yChannel: yChannel
|
|
758
|
+
})
|
|
759
|
+
, [
|
|
760
|
+
xChannel,
|
|
761
|
+
yChannel
|
|
762
|
+
]);
|
|
763
|
+
let xChannelRange = color.getChannelRange(channels.xChannel);
|
|
764
|
+
let yChannelRange = color.getChannelRange(channels.yChannel);
|
|
765
|
+
let { minValue: minValueX , maxValue: maxValueX , step: stepX , pageSize: pageSizeX } = xChannelRange;
|
|
766
|
+
let { minValue: minValueY , maxValue: maxValueY , step: stepY , pageSize: pageSizeY } = yChannelRange;
|
|
767
|
+
let [isDragging1, setDragging] = $4tN2K$react.useState(false);
|
|
768
|
+
let isDraggingRef = $4tN2K$react.useRef(false).current;
|
|
769
|
+
let xValue = color.getChannelValue(channels.xChannel);
|
|
770
|
+
let yValue = color.getChannelValue(channels.yChannel);
|
|
771
|
+
let setXValue = (v)=>{
|
|
772
|
+
if (v === xValue) return;
|
|
773
|
+
valueRef.current = color.withChannelValue(channels.xChannel, v);
|
|
774
|
+
setColor(valueRef.current);
|
|
775
|
+
};
|
|
776
|
+
let setYValue = (v)=>{
|
|
777
|
+
if (v === yValue) return;
|
|
778
|
+
valueRef.current = color.withChannelValue(channels.yChannel, v);
|
|
779
|
+
setColor(valueRef.current);
|
|
780
|
+
};
|
|
781
|
+
return {
|
|
782
|
+
channels: channels,
|
|
783
|
+
xChannelStep: stepX,
|
|
784
|
+
yChannelStep: stepY,
|
|
785
|
+
xChannelPageStep: pageSizeX,
|
|
786
|
+
yChannelPageStep: pageSizeY,
|
|
787
|
+
value: color,
|
|
788
|
+
setValue (value) {
|
|
789
|
+
let c = $83fe1a57d631223b$export$4cde5df63f53f473(value);
|
|
790
|
+
valueRef.current = c;
|
|
791
|
+
setColor(c);
|
|
792
|
+
},
|
|
793
|
+
xValue: xValue,
|
|
794
|
+
setXValue: setXValue,
|
|
795
|
+
yValue: yValue,
|
|
796
|
+
setYValue: setYValue,
|
|
797
|
+
setColorFromPoint (x, y) {
|
|
798
|
+
let newXValue = minValueX + $4tN2K$reactstatelyutils.clamp(x, 0, 1) * (maxValueX - minValueX);
|
|
799
|
+
let newYValue = minValueY + (1 - $4tN2K$reactstatelyutils.clamp(y, 0, 1)) * (maxValueY - minValueY);
|
|
800
|
+
let newColor;
|
|
801
|
+
if (newXValue !== xValue) {
|
|
802
|
+
// Round new value to multiple of step, clamp value between min and max
|
|
803
|
+
newXValue = $4tN2K$reactstatelyutils.snapValueToStep(newXValue, minValueX, maxValueX, stepX);
|
|
804
|
+
newColor = color.withChannelValue(channels.xChannel, newXValue);
|
|
805
|
+
}
|
|
806
|
+
if (newYValue !== yValue) {
|
|
807
|
+
// Round new value to multiple of step, clamp value between min and max
|
|
808
|
+
newYValue = $4tN2K$reactstatelyutils.snapValueToStep(newYValue, minValueY, maxValueY, stepY);
|
|
809
|
+
newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
|
|
810
|
+
}
|
|
811
|
+
if (newColor) setColor(newColor);
|
|
812
|
+
},
|
|
813
|
+
getThumbPosition () {
|
|
814
|
+
let x = (xValue - minValueX) / (maxValueX - minValueX);
|
|
815
|
+
let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
|
|
816
|
+
return {
|
|
817
|
+
x: x,
|
|
818
|
+
y: y
|
|
819
|
+
};
|
|
820
|
+
},
|
|
821
|
+
incrementX (stepSize) {
|
|
822
|
+
setXValue(xValue + stepSize > maxValueX ? maxValueX : $4tN2K$reactstatelyutils.snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX));
|
|
823
|
+
},
|
|
824
|
+
incrementY (stepSize) {
|
|
825
|
+
setYValue(yValue + stepSize > maxValueY ? maxValueY : $4tN2K$reactstatelyutils.snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY));
|
|
826
|
+
},
|
|
827
|
+
decrementX (stepSize) {
|
|
828
|
+
setXValue($4tN2K$reactstatelyutils.snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX));
|
|
829
|
+
},
|
|
830
|
+
decrementY (stepSize) {
|
|
831
|
+
setYValue($4tN2K$reactstatelyutils.snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY));
|
|
832
|
+
},
|
|
833
|
+
setDragging (isDragging) {
|
|
834
|
+
let wasDragging = isDraggingRef;
|
|
835
|
+
isDraggingRef = isDragging;
|
|
836
|
+
if (onChangeEnd && !isDragging && wasDragging) onChangeEnd(valueRef.current);
|
|
837
|
+
setDragging(isDragging);
|
|
838
|
+
},
|
|
839
|
+
isDragging: isDragging1,
|
|
840
|
+
getDisplayColor () {
|
|
841
|
+
return color.withChannelValue('alpha', 1);
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
661
845
|
|
|
662
|
-
}));
|
|
663
|
-
return _babelRuntimeHelpersExtends({}, sliderState, {
|
|
664
|
-
value: color,
|
|
665
846
|
|
|
666
|
-
|
|
667
|
-
setColor($d78e953dd1c924c8b48953f9b24957b7$var$normalizeColor(value));
|
|
668
|
-
},
|
|
847
|
+
var $5386a492cfd3234c$exports = {};
|
|
669
848
|
|
|
670
|
-
|
|
671
|
-
switch (channel) {
|
|
672
|
-
case 'hue':
|
|
673
|
-
return parseColor("hsl(" + color.getChannelValue('hue') + ", 100%, 50%)");
|
|
849
|
+
$parcel$export($5386a492cfd3234c$exports, "useColorSliderState", () => $5386a492cfd3234c$export$57bc203e1c9c6d44);
|
|
674
850
|
|
|
675
|
-
case 'lightness':
|
|
676
|
-
case 'brightness':
|
|
677
|
-
case 'saturation':
|
|
678
|
-
case 'red':
|
|
679
|
-
case 'green':
|
|
680
|
-
case 'blue':
|
|
681
|
-
return color.withChannelValue('alpha', 1);
|
|
682
851
|
|
|
683
|
-
case 'alpha':
|
|
684
|
-
{
|
|
685
|
-
return color;
|
|
686
|
-
}
|
|
687
852
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
853
|
+
function $5386a492cfd3234c$export$57bc203e1c9c6d44(props) {
|
|
854
|
+
let { channel: channel , value: value1 , defaultValue: defaultValue , onChange: onChange , locale: locale , ...otherProps } = props;
|
|
855
|
+
if (value1 == null && defaultValue == null) throw new Error('useColorSliderState requires a value or defaultValue');
|
|
856
|
+
let [color, setColor] = $4tN2K$reactstatelyutils.useControlledState(value1 && $83fe1a57d631223b$export$4cde5df63f53f473(value1), defaultValue && $83fe1a57d631223b$export$4cde5df63f53f473(defaultValue), onChange);
|
|
857
|
+
let sliderState = $4tN2K$reactstatelyslider.useSliderState({
|
|
858
|
+
...color.getChannelRange(channel),
|
|
859
|
+
...otherProps,
|
|
860
|
+
// Unused except in getThumbValueLabel, which is overridden below. null to appease TypeScript.
|
|
861
|
+
numberFormatter: null,
|
|
862
|
+
value: [
|
|
863
|
+
color.getChannelValue(channel)
|
|
864
|
+
],
|
|
865
|
+
onChange ([v]) {
|
|
866
|
+
setColor(color.withChannelValue(channel, v));
|
|
867
|
+
},
|
|
868
|
+
onChangeEnd ([v]) {
|
|
869
|
+
// onChange will have already been called with the right value, this is just to trigger onChangeEnd
|
|
870
|
+
if (props.onChangeEnd) props.onChangeEnd(color.withChannelValue(channel, v));
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
let { step: step , pageSize: pageSize } = color.getChannelRange(channel);
|
|
874
|
+
return {
|
|
875
|
+
...sliderState,
|
|
876
|
+
value: color,
|
|
877
|
+
setValue (value) {
|
|
878
|
+
setColor($83fe1a57d631223b$export$4cde5df63f53f473(value));
|
|
879
|
+
},
|
|
880
|
+
getDisplayColor () {
|
|
881
|
+
switch(channel){
|
|
882
|
+
case 'hue':
|
|
883
|
+
return $83fe1a57d631223b$export$6e865ea70d7724f(`hsl(${color.getChannelValue('hue')}, 100%, 50%)`);
|
|
884
|
+
case 'lightness':
|
|
885
|
+
case 'brightness':
|
|
886
|
+
case 'saturation':
|
|
887
|
+
case 'red':
|
|
888
|
+
case 'green':
|
|
889
|
+
case 'blue':
|
|
890
|
+
return color.withChannelValue('alpha', 1);
|
|
891
|
+
case 'alpha':
|
|
892
|
+
return color;
|
|
893
|
+
default:
|
|
894
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
getThumbValueLabel () {
|
|
898
|
+
return color.formatChannelValue(channel, locale);
|
|
899
|
+
},
|
|
900
|
+
step: step,
|
|
901
|
+
pageSize: pageSize
|
|
902
|
+
};
|
|
903
|
+
}
|
|
692
904
|
|
|
693
|
-
getThumbValueLabel() {
|
|
694
|
-
return color.formatChannelValue(channel, locale);
|
|
695
|
-
}
|
|
696
905
|
|
|
697
|
-
|
|
698
|
-
}
|
|
906
|
+
var $9d7d8736d45f74b8$exports = {};
|
|
699
907
|
|
|
700
|
-
exports
|
|
908
|
+
$parcel$export($9d7d8736d45f74b8$exports, "useColorWheelState", () => $9d7d8736d45f74b8$export$f4301076d9336137);
|
|
701
909
|
|
|
702
|
-
function $dba59c0b8a82682c07fa6f5c72e73481$var$normalizeColor(v) {
|
|
703
|
-
if (typeof v === 'string') {
|
|
704
|
-
return parseColor(v);
|
|
705
|
-
} else {
|
|
706
|
-
return v;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
910
|
|
|
710
|
-
const $dba59c0b8a82682c07fa6f5c72e73481$var$DEFAULT_COLOR = parseColor('hsl(0, 100%, 50%)');
|
|
711
911
|
|
|
712
|
-
|
|
713
|
-
|
|
912
|
+
const $9d7d8736d45f74b8$var$DEFAULT_COLOR = $83fe1a57d631223b$export$6e865ea70d7724f('hsl(0, 100%, 50%)');
|
|
913
|
+
function $9d7d8736d45f74b8$var$roundToStep(value, step) {
|
|
914
|
+
return Math.round(value / step) * step;
|
|
714
915
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
return (n % m + m) % m;
|
|
916
|
+
function $9d7d8736d45f74b8$var$mod(n, m) {
|
|
917
|
+
return (n % m + m) % m;
|
|
718
918
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
if (r === v) {
|
|
724
|
-
return v - 1;
|
|
725
|
-
} else {
|
|
726
|
-
return r;
|
|
727
|
-
}
|
|
919
|
+
function $9d7d8736d45f74b8$var$roundDown(v) {
|
|
920
|
+
let r = Math.floor(v);
|
|
921
|
+
if (r === v) return v - 1;
|
|
922
|
+
else return r;
|
|
728
923
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
return deg * Math.PI / 180;
|
|
924
|
+
function $9d7d8736d45f74b8$var$degToRad(deg) {
|
|
925
|
+
return deg * Math.PI / 180;
|
|
732
926
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
return rad * 180 / Math.PI;
|
|
736
|
-
} // 0deg = 3 o'clock. increases clockwise
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
function $dba59c0b8a82682c07fa6f5c72e73481$var$angleToCartesian(angle, radius) {
|
|
740
|
-
let rad = $dba59c0b8a82682c07fa6f5c72e73481$var$degToRad(360 - angle + 90);
|
|
741
|
-
let x = Math.sin(rad) * radius;
|
|
742
|
-
let y = Math.cos(rad) * radius;
|
|
743
|
-
return {
|
|
744
|
-
x,
|
|
745
|
-
y
|
|
746
|
-
};
|
|
927
|
+
function $9d7d8736d45f74b8$var$radToDeg(rad) {
|
|
928
|
+
return rad * 180 / Math.PI;
|
|
747
929
|
}
|
|
748
|
-
|
|
749
|
-
function $
|
|
750
|
-
|
|
751
|
-
|
|
930
|
+
// 0deg = 3 o'clock. increases clockwise
|
|
931
|
+
function $9d7d8736d45f74b8$var$angleToCartesian(angle, radius) {
|
|
932
|
+
let rad = $9d7d8736d45f74b8$var$degToRad(360 - angle + 90);
|
|
933
|
+
let x = Math.sin(rad) * radius;
|
|
934
|
+
let y = Math.cos(rad) * radius;
|
|
935
|
+
return {
|
|
936
|
+
x: x,
|
|
937
|
+
y: y
|
|
938
|
+
};
|
|
752
939
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
*/
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
function useColorWheelState(props) {
|
|
760
|
-
let {
|
|
761
|
-
defaultValue,
|
|
762
|
-
onChange,
|
|
763
|
-
step = 1
|
|
764
|
-
} = props;
|
|
765
|
-
|
|
766
|
-
if (!props.value && !defaultValue) {
|
|
767
|
-
defaultValue = $dba59c0b8a82682c07fa6f5c72e73481$var$DEFAULT_COLOR;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
let [value, setValue] = useControlledState($dba59c0b8a82682c07fa6f5c72e73481$var$normalizeColor(props.value), $dba59c0b8a82682c07fa6f5c72e73481$var$normalizeColor(defaultValue), onChange);
|
|
771
|
-
let [isDragging, setDragging] = useState(false);
|
|
772
|
-
let hue = value.getChannelValue('hue');
|
|
773
|
-
|
|
774
|
-
function setHue(v) {
|
|
775
|
-
if (v > 360) {
|
|
776
|
-
// Make sure you can always get back to 0.
|
|
777
|
-
v = 0;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
v = $dba59c0b8a82682c07fa6f5c72e73481$var$roundToStep($dba59c0b8a82682c07fa6f5c72e73481$var$mod(v, 360), step);
|
|
781
|
-
|
|
782
|
-
if (hue !== v) {
|
|
783
|
-
setValue(value.withChannelValue('hue', v));
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
return {
|
|
788
|
-
value,
|
|
789
|
-
|
|
790
|
-
setValue(v) {
|
|
791
|
-
setValue($dba59c0b8a82682c07fa6f5c72e73481$var$normalizeColor(v));
|
|
792
|
-
},
|
|
793
|
-
|
|
794
|
-
hue,
|
|
795
|
-
setHue,
|
|
796
|
-
|
|
797
|
-
setHueFromPoint(x, y, radius) {
|
|
798
|
-
setHue($dba59c0b8a82682c07fa6f5c72e73481$var$cartesianToAngle(x, y, radius));
|
|
799
|
-
},
|
|
800
|
-
|
|
801
|
-
getThumbPosition(radius) {
|
|
802
|
-
return $dba59c0b8a82682c07fa6f5c72e73481$var$angleToCartesian(value.getChannelValue('hue'), radius);
|
|
803
|
-
},
|
|
804
|
-
|
|
805
|
-
increment(minStepSize) {
|
|
806
|
-
if (minStepSize === void 0) {
|
|
807
|
-
minStepSize = 0;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
let newValue = hue + Math.max(minStepSize, step);
|
|
811
|
-
|
|
812
|
-
if (newValue > 360) {
|
|
813
|
-
// Make sure you can always get back to 0.
|
|
814
|
-
newValue = 0;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
setHue(newValue);
|
|
818
|
-
},
|
|
819
|
-
|
|
820
|
-
decrement(minStepSize) {
|
|
821
|
-
if (minStepSize === void 0) {
|
|
822
|
-
minStepSize = 0;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
let s = Math.max(minStepSize, step);
|
|
826
|
-
|
|
827
|
-
if (hue === 0) {
|
|
828
|
-
// We can't just subtract step because this might be the case:
|
|
829
|
-
// |(previous step) - 0| < step size
|
|
830
|
-
setHue($dba59c0b8a82682c07fa6f5c72e73481$var$roundDown(360 / s) * s);
|
|
831
|
-
} else {
|
|
832
|
-
setHue(hue - s);
|
|
833
|
-
}
|
|
834
|
-
},
|
|
835
|
-
|
|
836
|
-
setDragging(value) {
|
|
837
|
-
setDragging(value);
|
|
838
|
-
},
|
|
839
|
-
|
|
840
|
-
isDragging
|
|
841
|
-
};
|
|
940
|
+
function $9d7d8736d45f74b8$var$cartesianToAngle(x, y, radius) {
|
|
941
|
+
let deg = $9d7d8736d45f74b8$var$radToDeg(Math.atan2(y / radius, x / radius));
|
|
942
|
+
return (deg + 360) % 360;
|
|
842
943
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
944
|
+
function $9d7d8736d45f74b8$export$f4301076d9336137(props) {
|
|
945
|
+
let { defaultValue: defaultValue , onChange: onChange , onChangeEnd: onChangeEnd } = props;
|
|
946
|
+
if (!props.value && !defaultValue) defaultValue = $9d7d8736d45f74b8$var$DEFAULT_COLOR;
|
|
947
|
+
let [value, setValue] = $4tN2K$reactstatelyutils.useControlledState($83fe1a57d631223b$export$4cde5df63f53f473(props.value), $83fe1a57d631223b$export$4cde5df63f53f473(defaultValue), onChange);
|
|
948
|
+
let valueRef = $4tN2K$react.useRef(value);
|
|
949
|
+
valueRef.current = value;
|
|
950
|
+
let channelRange = value.getChannelRange('hue');
|
|
951
|
+
let { minValue: minValueX , maxValue: maxValueX , step: step , pageSize: pageStep } = channelRange;
|
|
952
|
+
let [isDragging1, setDragging] = $4tN2K$react.useState(false);
|
|
953
|
+
let isDraggingRef = $4tN2K$react.useRef(false).current;
|
|
954
|
+
let hue = value.getChannelValue('hue');
|
|
955
|
+
function setHue(v) {
|
|
956
|
+
if (v > 360) // Make sure you can always get back to 0.
|
|
957
|
+
v = 0;
|
|
958
|
+
v = $9d7d8736d45f74b8$var$roundToStep($9d7d8736d45f74b8$var$mod(v, 360), step);
|
|
959
|
+
if (hue !== v) {
|
|
960
|
+
let color = value.withChannelValue('hue', v);
|
|
961
|
+
valueRef.current = color;
|
|
962
|
+
setValue(color);
|
|
963
|
+
}
|
|
854
964
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
965
|
+
return {
|
|
966
|
+
value: value,
|
|
967
|
+
step: step,
|
|
968
|
+
pageStep: pageStep,
|
|
969
|
+
setValue (v) {
|
|
970
|
+
let color = $83fe1a57d631223b$export$4cde5df63f53f473(v);
|
|
971
|
+
valueRef.current = color;
|
|
972
|
+
setValue(color);
|
|
973
|
+
},
|
|
974
|
+
hue: hue,
|
|
975
|
+
setHue: setHue,
|
|
976
|
+
setHueFromPoint (x, y, radius) {
|
|
977
|
+
setHue($9d7d8736d45f74b8$var$cartesianToAngle(x, y, radius));
|
|
978
|
+
},
|
|
979
|
+
getThumbPosition (radius) {
|
|
980
|
+
return $9d7d8736d45f74b8$var$angleToCartesian(value.getChannelValue('hue'), radius);
|
|
981
|
+
},
|
|
982
|
+
increment (stepSize = 1) {
|
|
983
|
+
let s = Math.max(stepSize, step);
|
|
984
|
+
let newValue = hue + s;
|
|
985
|
+
if (newValue >= maxValueX) // Make sure you can always get back to 0.
|
|
986
|
+
newValue = minValueX;
|
|
987
|
+
setHue($9d7d8736d45f74b8$var$roundToStep($9d7d8736d45f74b8$var$mod(newValue, 360), s));
|
|
988
|
+
},
|
|
989
|
+
decrement (stepSize = 1) {
|
|
990
|
+
let s = Math.max(stepSize, step);
|
|
991
|
+
if (hue === 0) // We can't just subtract step because this might be the case:
|
|
992
|
+
// |(previous step) - 0| < step size
|
|
993
|
+
setHue($9d7d8736d45f74b8$var$roundDown(360 / s) * s);
|
|
994
|
+
else setHue($9d7d8736d45f74b8$var$roundToStep($9d7d8736d45f74b8$var$mod(hue - s, 360), s));
|
|
995
|
+
},
|
|
996
|
+
setDragging (isDragging) {
|
|
997
|
+
let wasDragging = isDraggingRef;
|
|
998
|
+
isDraggingRef = isDragging;
|
|
999
|
+
if (onChangeEnd && !isDragging && wasDragging) onChangeEnd(valueRef.current);
|
|
1000
|
+
setDragging(isDragging);
|
|
1001
|
+
},
|
|
1002
|
+
isDragging: isDragging1,
|
|
1003
|
+
getDisplayColor () {
|
|
1004
|
+
return value.toFormat('hsl').withChannelValue('saturation', 100).withChannelValue('lightness', 50);
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
858
1007
|
}
|
|
859
1008
|
|
|
860
|
-
const $f59de409cf55723659fabb2f46aaa7a$var$MIN_COLOR = parseColor('#000000');
|
|
861
|
-
const $f59de409cf55723659fabb2f46aaa7a$var$MAX_COLOR = parseColor('#FFFFFF');
|
|
862
|
-
const $f59de409cf55723659fabb2f46aaa7a$var$MIN_COLOR_INT = $f59de409cf55723659fabb2f46aaa7a$var$MIN_COLOR.toHexInt();
|
|
863
|
-
const $f59de409cf55723659fabb2f46aaa7a$var$MAX_COLOR_INT = $f59de409cf55723659fabb2f46aaa7a$var$MAX_COLOR.toHexInt();
|
|
864
|
-
/**
|
|
865
|
-
* Provides state management for a color field component. Color fields allow
|
|
866
|
-
* users to enter and adjust a hex color value.
|
|
867
|
-
*/
|
|
868
|
-
|
|
869
|
-
function useColorFieldState(props) {
|
|
870
|
-
let {
|
|
871
|
-
step = 1,
|
|
872
|
-
value,
|
|
873
|
-
defaultValue,
|
|
874
|
-
onChange
|
|
875
|
-
} = props;
|
|
876
|
-
let initialValue = $b3b9a125af848b3d936c7c032125859$export$useColor(value);
|
|
877
|
-
let initialDefaultValue = $b3b9a125af848b3d936c7c032125859$export$useColor(defaultValue);
|
|
878
|
-
let [colorValue, setColorValue] = useControlledState(initialValue, initialDefaultValue, onChange);
|
|
879
|
-
let initialInputValue = (value || defaultValue) && colorValue ? colorValue.toString('hex') : '';
|
|
880
|
-
let [inputValue, setInputValue] = useState(initialInputValue);
|
|
881
|
-
useEffect(() => {
|
|
882
|
-
setInputValue(inputValue => {
|
|
883
|
-
// Parse color from current inputValue.
|
|
884
|
-
// Only update the input value if the parseColorValue is not equivalent.
|
|
885
|
-
if (!inputValue.length && colorValue) {
|
|
886
|
-
return colorValue.toString('hex');
|
|
887
|
-
}
|
|
888
1009
|
|
|
889
|
-
|
|
890
|
-
let currentColor = parseColor(inputValue.startsWith('#') ? inputValue : "#" + inputValue);
|
|
1010
|
+
var $d59d0c2b2ce1568f$exports = {};
|
|
891
1011
|
|
|
892
|
-
|
|
893
|
-
return colorValue ? colorValue.toString('hex') : '';
|
|
894
|
-
}
|
|
895
|
-
} catch (err) {// ignore
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
return inputValue;
|
|
899
|
-
});
|
|
900
|
-
}, [inputValue, colorValue, setInputValue]);
|
|
1012
|
+
$parcel$export($d59d0c2b2ce1568f$exports, "useColorFieldState", () => $d59d0c2b2ce1568f$export$d52a01683abdfcd6);
|
|
901
1013
|
|
|
902
|
-
let increment = () => setColorValue(prevColor => $f59de409cf55723659fabb2f46aaa7a$var$addColorValue(prevColor, step));
|
|
903
1014
|
|
|
904
|
-
let decrement = () => setColorValue(prevColor => $f59de409cf55723659fabb2f46aaa7a$var$addColorValue(prevColor, -step));
|
|
905
1015
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1016
|
+
function $f8b3be23ba4462b1$export$5aadd9c0606af5c2(value) {
|
|
1017
|
+
return $4tN2K$react.useMemo(()=>{
|
|
1018
|
+
if (typeof value === 'string') try {
|
|
1019
|
+
return $83fe1a57d631223b$export$6e865ea70d7724f(value);
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
return undefined;
|
|
1022
|
+
}
|
|
1023
|
+
return value;
|
|
1024
|
+
}, [
|
|
1025
|
+
value
|
|
1026
|
+
]);
|
|
1027
|
+
}
|
|
909
1028
|
|
|
910
|
-
let setFieldInputValue = value => {
|
|
911
|
-
var _value$match;
|
|
912
1029
|
|
|
913
|
-
value = (_value$match = value.match(/^#?[0-9a-f]{0,6}$/i)) == null ? void 0 : _value$match[0];
|
|
914
1030
|
|
|
915
|
-
if (value !== undefined) {
|
|
916
|
-
if (!value.length && colorValue) {
|
|
917
|
-
setColorValue(null);
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
1031
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1032
|
+
const $d59d0c2b2ce1568f$var$MIN_COLOR = $83fe1a57d631223b$export$6e865ea70d7724f('#000000');
|
|
1033
|
+
const $d59d0c2b2ce1568f$var$MAX_COLOR = $83fe1a57d631223b$export$6e865ea70d7724f('#FFFFFF');
|
|
1034
|
+
const $d59d0c2b2ce1568f$var$MIN_COLOR_INT = $d59d0c2b2ce1568f$var$MIN_COLOR.toHexInt();
|
|
1035
|
+
const $d59d0c2b2ce1568f$var$MAX_COLOR_INT = $d59d0c2b2ce1568f$var$MAX_COLOR.toHexInt();
|
|
1036
|
+
function $d59d0c2b2ce1568f$export$d52a01683abdfcd6(props) {
|
|
1037
|
+
let { value: value1 , defaultValue: defaultValue , onChange: onChange } = props;
|
|
1038
|
+
let { step: step } = $d59d0c2b2ce1568f$var$MIN_COLOR.getChannelRange('red');
|
|
1039
|
+
let initialValue = $f8b3be23ba4462b1$export$5aadd9c0606af5c2(value1);
|
|
1040
|
+
let initialDefaultValue = $f8b3be23ba4462b1$export$5aadd9c0606af5c2(defaultValue);
|
|
1041
|
+
let [colorValue, setColorValue] = $4tN2K$reactstatelyutils.useControlledState(initialValue, initialDefaultValue, onChange);
|
|
1042
|
+
let [inputValue, setInputValue] = $4tN2K$react.useState(()=>(value1 || defaultValue) && colorValue ? colorValue.toString('hex') : ''
|
|
1043
|
+
);
|
|
1044
|
+
let safelySetColorValue = (newColor)=>{
|
|
1045
|
+
if (!colorValue || !newColor) {
|
|
1046
|
+
setColorValue(newColor);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (newColor.toHexInt() !== colorValue.toHexInt()) {
|
|
1050
|
+
setColorValue(newColor);
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
let prevValue = $4tN2K$react.useRef(colorValue);
|
|
1055
|
+
if (prevValue.current !== colorValue) {
|
|
1056
|
+
setInputValue(colorValue ? colorValue.toString('hex') : '');
|
|
1057
|
+
prevValue.current = colorValue;
|
|
930
1058
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1059
|
+
let parsedValue = $4tN2K$react.useMemo(()=>{
|
|
1060
|
+
let color;
|
|
1061
|
+
try {
|
|
1062
|
+
color = $83fe1a57d631223b$export$6e865ea70d7724f(inputValue.startsWith('#') ? inputValue : `#${inputValue}`);
|
|
1063
|
+
} catch (err) {
|
|
1064
|
+
color = null;
|
|
1065
|
+
}
|
|
1066
|
+
return color;
|
|
1067
|
+
}, [
|
|
1068
|
+
inputValue
|
|
1069
|
+
]);
|
|
1070
|
+
let parsed = $4tN2K$react.useRef(null);
|
|
1071
|
+
parsed.current = parsedValue;
|
|
1072
|
+
let commit = ()=>{
|
|
1073
|
+
// Set to empty state if input value is empty
|
|
1074
|
+
if (!inputValue.length) {
|
|
1075
|
+
safelySetColorValue(null);
|
|
1076
|
+
setInputValue(value1 === undefined ? '' : colorValue.toString('hex'));
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
// if it failed to parse, then reset input to formatted version of current number
|
|
1080
|
+
if (parsed.current == null) {
|
|
1081
|
+
setInputValue(colorValue ? colorValue.toString('hex') : '');
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
safelySetColorValue(parsed.current);
|
|
1085
|
+
// in a controlled state, the numberValue won't change, so we won't go back to our old input without help
|
|
1086
|
+
let newColorValue = '';
|
|
1087
|
+
if (colorValue) newColorValue = colorValue.toString('hex');
|
|
1088
|
+
setInputValue(newColorValue);
|
|
1089
|
+
};
|
|
1090
|
+
let increment = ()=>{
|
|
1091
|
+
let newValue = $d59d0c2b2ce1568f$var$addColorValue(parsed.current, step);
|
|
1092
|
+
// if we've arrived at the same value that was previously in the state, the
|
|
1093
|
+
// input value should be updated to match
|
|
1094
|
+
// ex type 4, press increment, highlight the number in the input, type 4 again, press increment
|
|
1095
|
+
// you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
|
|
1096
|
+
if (newValue === colorValue) setInputValue(newValue.toString('hex'));
|
|
1097
|
+
safelySetColorValue(newValue);
|
|
1098
|
+
};
|
|
1099
|
+
let decrement = ()=>{
|
|
1100
|
+
let newValue = $d59d0c2b2ce1568f$var$addColorValue(parsed.current, -step);
|
|
1101
|
+
// if we've arrived at the same value that was previously in the state, the
|
|
1102
|
+
// input value should be updated to match
|
|
1103
|
+
// ex type 4, press increment, highlight the number in the input, type 4 again, press increment
|
|
1104
|
+
// you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
|
|
1105
|
+
if (newValue === colorValue) setInputValue(newValue.toString('hex'));
|
|
1106
|
+
safelySetColorValue(newValue);
|
|
1107
|
+
};
|
|
1108
|
+
let incrementToMax = ()=>safelySetColorValue($d59d0c2b2ce1568f$var$MAX_COLOR)
|
|
1109
|
+
;
|
|
1110
|
+
let decrementToMin = ()=>safelySetColorValue($d59d0c2b2ce1568f$var$MIN_COLOR)
|
|
1111
|
+
;
|
|
1112
|
+
let validate = (value)=>{
|
|
1113
|
+
var ref;
|
|
1114
|
+
return value === '' || !!((ref = value.match(/^#?[0-9a-f]{0,6}$/i)) === null || ref === void 0 ? void 0 : ref[0]);
|
|
1115
|
+
};
|
|
1116
|
+
return {
|
|
1117
|
+
validate: validate,
|
|
1118
|
+
colorValue: colorValue,
|
|
1119
|
+
inputValue: inputValue,
|
|
1120
|
+
setInputValue: setInputValue,
|
|
1121
|
+
commit: commit,
|
|
1122
|
+
increment: increment,
|
|
1123
|
+
incrementToMax: incrementToMax,
|
|
1124
|
+
decrement: decrement,
|
|
1125
|
+
decrementToMin: decrementToMin
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
function $d59d0c2b2ce1568f$var$addColorValue(color, step) {
|
|
1129
|
+
let newColor = color ? color : $d59d0c2b2ce1568f$var$MIN_COLOR;
|
|
1130
|
+
let colorInt = newColor.toHexInt();
|
|
1131
|
+
let clampInt = Math.min(Math.max(colorInt + step, $d59d0c2b2ce1568f$var$MIN_COLOR_INT), $d59d0c2b2ce1568f$var$MAX_COLOR_INT);
|
|
1132
|
+
if (clampInt !== colorInt) {
|
|
1133
|
+
let newColorString = `#${clampInt.toString(16).padStart(6, '0').toUpperCase()}`;
|
|
1134
|
+
newColor = $83fe1a57d631223b$export$6e865ea70d7724f(newColorString);
|
|
1135
|
+
}
|
|
1136
|
+
return newColor;
|
|
947
1137
|
}
|
|
948
1138
|
|
|
949
|
-
exports.useColorFieldState = useColorFieldState;
|
|
950
1139
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
let clampInt = Math.min(Math.max(colorInt + step, $f59de409cf55723659fabb2f46aaa7a$var$MIN_COLOR_INT), $f59de409cf55723659fabb2f46aaa7a$var$MAX_COLOR_INT);
|
|
1140
|
+
$parcel$exportWildcard(module.exports, $af2d7ac9990cfee2$exports);
|
|
1141
|
+
$parcel$exportWildcard(module.exports, $5386a492cfd3234c$exports);
|
|
1142
|
+
$parcel$exportWildcard(module.exports, $9d7d8736d45f74b8$exports);
|
|
1143
|
+
$parcel$exportWildcard(module.exports, $d59d0c2b2ce1568f$exports);
|
|
956
1144
|
|
|
957
|
-
if (clampInt !== colorInt) {
|
|
958
|
-
newColorString = "#" + clampInt.toString(16).padStart(6, '0').toUpperCase();
|
|
959
|
-
newColor = parseColor(newColorString);
|
|
960
|
-
}
|
|
961
1145
|
|
|
962
|
-
return newColor;
|
|
963
|
-
}
|
|
964
1146
|
//# sourceMappingURL=main.js.map
|