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