@react-aria/color 3.0.0-beta.6 → 3.0.0-beta.9
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 +884 -493
- package/dist/main.js.map +1 -1
- package/dist/module.js +898 -484
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +28 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/index.ts +1 -0
- package/src/useColorArea.ts +393 -0
- package/src/useColorField.ts +2 -1
- package/src/useColorWheel.ts +33 -24
package/dist/module.js
CHANGED
|
@@ -1,493 +1,907 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useKeyboard, useMove, useFocusWithin, useScrollWheel } from "@react-aria/interactions";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
import {useGlobalListeners as $7KHxM$useGlobalListeners, focusWithoutScrolling as $7KHxM$focusWithoutScrolling, mergeProps as $7KHxM$mergeProps, isIOS as $7KHxM$isIOS, isAndroid as $7KHxM$isAndroid, useLabels as $7KHxM$useLabels, useId as $7KHxM$useId} from "@react-aria/utils";
|
|
2
|
+
import {useRef as $7KHxM$useRef, useCallback as $7KHxM$useCallback, useState as $7KHxM$useState} from "react";
|
|
3
|
+
import {useKeyboard as $7KHxM$useKeyboard, useMove as $7KHxM$useMove, useFocusWithin as $7KHxM$useFocusWithin, useScrollWheel as $7KHxM$useScrollWheel} from "@react-aria/interactions";
|
|
4
|
+
import {useMessageFormatter as $7KHxM$useMessageFormatter, useLocale as $7KHxM$useLocale} from "@react-aria/i18n";
|
|
5
|
+
import {useVisuallyHidden as $7KHxM$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
6
|
+
import {useSlider as $7KHxM$useSlider, useSliderThumb as $7KHxM$useSliderThumb} from "@react-aria/slider";
|
|
7
|
+
import {useFormattedTextField as $7KHxM$useFormattedTextField} from "@react-aria/textfield";
|
|
8
|
+
import {useSpinButton as $7KHxM$useSpinButton} from "@react-aria/spinbutton";
|
|
9
|
+
|
|
10
|
+
function $parcel$interopDefault(a) {
|
|
11
|
+
return a && a.__esModule ? a.default : a;
|
|
12
|
+
}
|
|
13
|
+
function $parcel$export(e, n, v, s) {
|
|
14
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
15
|
+
}
|
|
16
|
+
var $60bd7d6e45dcddfa$exports = {};
|
|
17
|
+
|
|
18
|
+
$parcel$export($60bd7d6e45dcddfa$exports, "useColorArea", () => $60bd7d6e45dcddfa$export$2f92a7a615a014f6);
|
|
19
|
+
|
|
20
|
+
var $052cfdf4c32eb7c3$exports = {};
|
|
21
|
+
var $eccab2b0118aef08$exports = {};
|
|
22
|
+
$eccab2b0118aef08$exports = JSON.parse("{\"twoDimensionalSlider\":\"شريط تمرير ثنائي الأبعاد\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var $bf2b4507594e3d45$exports = {};
|
|
26
|
+
$bf2b4507594e3d45$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D плъзгач\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var $01c08487af7ecd14$exports = {};
|
|
30
|
+
$01c08487af7ecd14$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D posuvník\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var $5e997db6ea0d10f6$exports = {};
|
|
34
|
+
$5e997db6ea0d10f6$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-skyder\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var $fe5998f640a79fd2$exports = {};
|
|
38
|
+
$fe5998f640a79fd2$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-Schieberegler\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var $18e4d1d5b500a9ee$exports = {};
|
|
42
|
+
$18e4d1d5b500a9ee$exports = JSON.parse("{\"twoDimensionalSlider\":\"Ρυθμιστικό 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var $bf90a11a7a42a0f7$exports = {};
|
|
46
|
+
$bf90a11a7a42a0f7$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D slider\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
var $dd0d25f885b5c5f3$exports = {};
|
|
50
|
+
$dd0d25f885b5c5f3$exports = JSON.parse("{\"twoDimensionalSlider\":\"Control deslizante en 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
var $d950967017e3485b$exports = {};
|
|
54
|
+
$d950967017e3485b$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-liugur\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var $00a415a3f0ab315a$exports = {};
|
|
58
|
+
$00a415a3f0ab315a$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-liukusäädin\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var $d80f30fe86c95741$exports = {};
|
|
62
|
+
$d80f30fe86c95741$exports = JSON.parse("{\"twoDimensionalSlider\":\"Curseur 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
var $6912afb584340a2e$exports = {};
|
|
66
|
+
$6912afb584340a2e$exports = JSON.parse("{\"twoDimensionalSlider\":\"מחוון דו-ממדי\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
var $7b97fcacd84ec90f$exports = {};
|
|
70
|
+
$7b97fcacd84ec90f$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D kliznik\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var $da9b443e89eebc6b$exports = {};
|
|
74
|
+
$da9b443e89eebc6b$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D csúszka\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
var $35f135b45eb4d95b$exports = {};
|
|
78
|
+
$35f135b45eb4d95b$exports = JSON.parse("{\"twoDimensionalSlider\":\"Dispositivo di scorrimento 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
var $760b09448e39c6cd$exports = {};
|
|
82
|
+
$760b09448e39c6cd$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D スライダー\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
var $fc7b7d43be9703ec$exports = {};
|
|
86
|
+
$fc7b7d43be9703ec$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D 슬라이더\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var $74918a1664156912$exports = {};
|
|
90
|
+
$74918a1664156912$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D slankiklis\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
var $4e6cde11c2bc9840$exports = {};
|
|
94
|
+
$4e6cde11c2bc9840$exports = JSON.parse("{\"twoDimensionalSlider\":\"Plaknes slīdnis\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
var $6faa3defebc3eb72$exports = {};
|
|
98
|
+
$6faa3defebc3eb72$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-glidebryter\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
var $6ac9b6b1b7e3ca12$exports = {};
|
|
102
|
+
$6ac9b6b1b7e3ca12$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-schuifregelaar\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
var $1be8b0ee8841f1e7$exports = {};
|
|
106
|
+
$1be8b0ee8841f1e7$exports = JSON.parse("{\"twoDimensionalSlider\":\"Suwak 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
var $f9507c2d404ed689$exports = {};
|
|
110
|
+
$f9507c2d404ed689$exports = JSON.parse("{\"twoDimensionalSlider\":\"Controle deslizante 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
var $8f872ea59c02d67e$exports = {};
|
|
114
|
+
$8f872ea59c02d67e$exports = JSON.parse("{\"twoDimensionalSlider\":\"Controlo de deslize 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
78
115
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
116
|
+
|
|
117
|
+
var $b03b45b62a7ccae4$exports = {};
|
|
118
|
+
$b03b45b62a7ccae4$exports = JSON.parse("{\"twoDimensionalSlider\":\"Cursor 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
var $f1107d94c09df9b8$exports = {};
|
|
122
|
+
$f1107d94c09df9b8$exports = JSON.parse("{\"twoDimensionalSlider\":\"Двумерный ползунок\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var $b61325f242fafc7c$exports = {};
|
|
126
|
+
$b61325f242fafc7c$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D jazdec\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
var $f44b7cf39ac8f315$exports = {};
|
|
130
|
+
$f44b7cf39ac8f315$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-drsnik\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
var $aa8cd83fc8d4982b$exports = {};
|
|
134
|
+
$aa8cd83fc8d4982b$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D клизач\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
var $7c4f4e5bb7c06f1e$exports = {};
|
|
138
|
+
$7c4f4e5bb7c06f1e$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D-reglage\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
var $8045cf930ef745aa$exports = {};
|
|
142
|
+
$8045cf930ef745aa$exports = JSON.parse("{\"twoDimensionalSlider\":\"2B slayt gösterisi\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
var $ee2044a77f24b118$exports = {};
|
|
146
|
+
$ee2044a77f24b118$exports = JSON.parse("{\"twoDimensionalSlider\":\"Повзунок 2D\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
var $4e1dbc65a687dd93$exports = {};
|
|
150
|
+
$4e1dbc65a687dd93$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D 滑块\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
var $b0fef28529309aa6$exports = {};
|
|
154
|
+
$b0fef28529309aa6$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D 滑桿\",\"colorNameAndValue\":\"{name}: {value}\",\"x/y\":\"{x} / {y}\"}");
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
$052cfdf4c32eb7c3$exports = {
|
|
158
|
+
"ar-AE": $eccab2b0118aef08$exports,
|
|
159
|
+
"bg-BG": $bf2b4507594e3d45$exports,
|
|
160
|
+
"cs-CZ": $01c08487af7ecd14$exports,
|
|
161
|
+
"da-DK": $5e997db6ea0d10f6$exports,
|
|
162
|
+
"de-DE": $fe5998f640a79fd2$exports,
|
|
163
|
+
"el-GR": $18e4d1d5b500a9ee$exports,
|
|
164
|
+
"en-US": $bf90a11a7a42a0f7$exports,
|
|
165
|
+
"es-ES": $dd0d25f885b5c5f3$exports,
|
|
166
|
+
"et-EE": $d950967017e3485b$exports,
|
|
167
|
+
"fi-FI": $00a415a3f0ab315a$exports,
|
|
168
|
+
"fr-FR": $d80f30fe86c95741$exports,
|
|
169
|
+
"he-IL": $6912afb584340a2e$exports,
|
|
170
|
+
"hr-HR": $7b97fcacd84ec90f$exports,
|
|
171
|
+
"hu-HU": $da9b443e89eebc6b$exports,
|
|
172
|
+
"it-IT": $35f135b45eb4d95b$exports,
|
|
173
|
+
"ja-JP": $760b09448e39c6cd$exports,
|
|
174
|
+
"ko-KR": $fc7b7d43be9703ec$exports,
|
|
175
|
+
"lt-LT": $74918a1664156912$exports,
|
|
176
|
+
"lv-LV": $4e6cde11c2bc9840$exports,
|
|
177
|
+
"nb-NO": $6faa3defebc3eb72$exports,
|
|
178
|
+
"nl-NL": $6ac9b6b1b7e3ca12$exports,
|
|
179
|
+
"pl-PL": $1be8b0ee8841f1e7$exports,
|
|
180
|
+
"pt-BR": $f9507c2d404ed689$exports,
|
|
181
|
+
"pt-PT": $8f872ea59c02d67e$exports,
|
|
182
|
+
"ro-RO": $b03b45b62a7ccae4$exports,
|
|
183
|
+
"ru-RU": $f1107d94c09df9b8$exports,
|
|
184
|
+
"sk-SK": $b61325f242fafc7c$exports,
|
|
185
|
+
"sl-SI": $f44b7cf39ac8f315$exports,
|
|
186
|
+
"sr-SP": $aa8cd83fc8d4982b$exports,
|
|
187
|
+
"sv-SE": $7c4f4e5bb7c06f1e$exports,
|
|
188
|
+
"tr-TR": $8045cf930ef745aa$exports,
|
|
189
|
+
"uk-UA": $ee2044a77f24b118$exports,
|
|
190
|
+
"zh-CN": $4e1dbc65a687dd93$exports,
|
|
191
|
+
"zh-TW": $b0fef28529309aa6$exports
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
200
|
+
let { isDisabled: isDisabled , inputXRef: inputXRef , inputYRef: inputYRef , containerRef: containerRef } = props;
|
|
201
|
+
let formatMessage = $7KHxM$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($052cfdf4c32eb7c3$exports)));
|
|
202
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $7KHxM$useGlobalListeners();
|
|
203
|
+
let { direction: direction , locale: locale } = $7KHxM$useLocale();
|
|
204
|
+
let focusedInputRef = $7KHxM$useRef(null);
|
|
205
|
+
let focusInput = $7KHxM$useCallback((inputRef = inputXRef)=>{
|
|
206
|
+
if (inputRef.current) $7KHxM$focusWithoutScrolling(inputRef.current);
|
|
207
|
+
}, [
|
|
208
|
+
inputXRef
|
|
209
|
+
]);
|
|
210
|
+
let stateRef = $7KHxM$useRef(null);
|
|
211
|
+
stateRef.current = state;
|
|
212
|
+
let { xChannel: xChannel , yChannel: yChannel } = stateRef.current.channels;
|
|
213
|
+
let xChannelStep1 = stateRef.current.xChannelStep;
|
|
214
|
+
let yChannelStep1 = stateRef.current.xChannelStep;
|
|
215
|
+
let currentPosition = $7KHxM$useRef(null);
|
|
216
|
+
let { keyboardProps: keyboardProps } = $7KHxM$useKeyboard({
|
|
217
|
+
onKeyDown (e) {
|
|
218
|
+
// these are the cases that useMove doesn't handle
|
|
219
|
+
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
220
|
+
e.continuePropagation();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
// remember to set this and unset it so that onChangeEnd is fired
|
|
226
|
+
stateRef.current.setDragging(true);
|
|
227
|
+
switch(e.key){
|
|
228
|
+
case 'PageUp':
|
|
229
|
+
stateRef.current.incrementY(stateRef.current.yChannelPageStep);
|
|
230
|
+
focusedInputRef.current = inputYRef.current;
|
|
231
|
+
break;
|
|
232
|
+
case 'PageDown':
|
|
233
|
+
stateRef.current.decrementY(stateRef.current.yChannelPageStep);
|
|
234
|
+
focusedInputRef.current = inputYRef.current;
|
|
235
|
+
break;
|
|
236
|
+
case 'Home':
|
|
237
|
+
direction === 'rtl' ? stateRef.current.incrementX(stateRef.current.xChannelPageStep) : stateRef.current.decrementX(stateRef.current.xChannelPageStep);
|
|
238
|
+
focusedInputRef.current = inputXRef.current;
|
|
239
|
+
break;
|
|
240
|
+
case 'End':
|
|
241
|
+
direction === 'rtl' ? stateRef.current.decrementX(stateRef.current.xChannelPageStep) : stateRef.current.incrementX(stateRef.current.xChannelPageStep);
|
|
242
|
+
focusedInputRef.current = inputXRef.current;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
stateRef.current.setDragging(false);
|
|
246
|
+
if (focusedInputRef.current) {
|
|
247
|
+
focusInput(focusedInputRef.current ? focusedInputRef : inputXRef);
|
|
248
|
+
focusedInputRef.current = undefined;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
let moveHandler = {
|
|
253
|
+
onMoveStart () {
|
|
254
|
+
currentPosition.current = null;
|
|
255
|
+
stateRef.current.setDragging(true);
|
|
256
|
+
},
|
|
257
|
+
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType , shiftKey: shiftKey }) {
|
|
258
|
+
let { incrementX: incrementX , decrementX: decrementX , incrementY: incrementY , decrementY: decrementY , xChannelPageStep: xChannelPageStep , xChannelStep: xChannelStep , yChannelPageStep: yChannelPageStep , yChannelStep: yChannelStep , getThumbPosition: getThumbPosition , setColorFromPoint: setColorFromPoint } = stateRef.current;
|
|
259
|
+
if (currentPosition.current == null) currentPosition.current = getThumbPosition();
|
|
260
|
+
let { width: width , height: height } = containerRef.current.getBoundingClientRect();
|
|
261
|
+
if (pointerType === 'keyboard') {
|
|
262
|
+
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
263
|
+
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
264
|
+
if (deltaX > 0 && direction === 'ltr' || deltaX < 0 && direction === 'rtl') incrementX(deltaXValue);
|
|
265
|
+
else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
|
|
266
|
+
else if (deltaY > 0) decrementY(deltaYValue);
|
|
267
|
+
else if (deltaY < 0) incrementY(deltaYValue);
|
|
268
|
+
// set the focused input based on which axis has the greater delta
|
|
269
|
+
focusedInputRef.current = (deltaX !== 0 || deltaY !== 0) && Math.abs(deltaY) > Math.abs(deltaX) ? inputYRef.current : inputXRef.current;
|
|
270
|
+
} else {
|
|
271
|
+
currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width;
|
|
272
|
+
currentPosition.current.y += deltaY / height;
|
|
273
|
+
setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
onMoveEnd () {
|
|
277
|
+
isOnColorArea.current = undefined;
|
|
278
|
+
stateRef.current.setDragging(false);
|
|
279
|
+
focusInput(focusedInputRef.current ? focusedInputRef : inputXRef);
|
|
280
|
+
focusedInputRef.current = undefined;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
let { moveProps: movePropsThumb } = $7KHxM$useMove(moveHandler);
|
|
284
|
+
let currentPointer = $7KHxM$useRef(undefined);
|
|
285
|
+
let isOnColorArea = $7KHxM$useRef(false);
|
|
286
|
+
let { moveProps: movePropsContainer } = $7KHxM$useMove({
|
|
287
|
+
onMoveStart () {
|
|
288
|
+
if (isOnColorArea.current) moveHandler.onMoveStart();
|
|
289
|
+
},
|
|
290
|
+
onMove (e) {
|
|
291
|
+
if (isOnColorArea.current) moveHandler.onMove(e);
|
|
292
|
+
},
|
|
293
|
+
onMoveEnd () {
|
|
294
|
+
if (isOnColorArea.current) moveHandler.onMoveEnd();
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
let onThumbDown = (id)=>{
|
|
298
|
+
if (!state.isDragging) {
|
|
299
|
+
currentPointer.current = id;
|
|
300
|
+
focusInput();
|
|
301
|
+
state.setDragging(true);
|
|
302
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
303
|
+
else {
|
|
304
|
+
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
305
|
+
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
let onThumbUp = (e)=>{
|
|
310
|
+
var ref;
|
|
311
|
+
var _pointerId;
|
|
312
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
313
|
+
if (id === currentPointer.current) {
|
|
314
|
+
focusInput();
|
|
315
|
+
state.setDragging(false);
|
|
316
|
+
currentPointer.current = undefined;
|
|
317
|
+
isOnColorArea.current = false;
|
|
318
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
319
|
+
else {
|
|
320
|
+
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
321
|
+
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
322
|
+
}
|
|
89
323
|
}
|
|
324
|
+
};
|
|
325
|
+
let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
|
|
326
|
+
let rect = colorArea.getBoundingClientRect();
|
|
327
|
+
let { width: width , height: height } = rect;
|
|
328
|
+
let x = (clientX - rect.x) / width;
|
|
329
|
+
let y = (clientY - rect.y) / height;
|
|
330
|
+
if (direction === 'rtl') x = 1 - x;
|
|
331
|
+
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
332
|
+
isOnColorArea.current = true;
|
|
333
|
+
currentPointer.current = id;
|
|
334
|
+
state.setColorFromPoint(x, y);
|
|
335
|
+
focusInput();
|
|
336
|
+
state.setDragging(true);
|
|
337
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
338
|
+
else {
|
|
339
|
+
addGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
340
|
+
addGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
let onColorAreaUp = (e)=>{
|
|
345
|
+
var ref;
|
|
346
|
+
var _pointerId;
|
|
347
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
348
|
+
if (isOnColorArea.current && id === currentPointer.current) {
|
|
349
|
+
isOnColorArea.current = false;
|
|
350
|
+
currentPointer.current = undefined;
|
|
351
|
+
state.setDragging(false);
|
|
352
|
+
focusInput();
|
|
353
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
354
|
+
else {
|
|
355
|
+
removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
356
|
+
removeGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
let colorAreaInteractions = isDisabled ? {
|
|
361
|
+
} : $7KHxM$mergeProps({
|
|
362
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
363
|
+
onPointerDown: (e)=>{
|
|
364
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
365
|
+
onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
366
|
+
}
|
|
367
|
+
} : {
|
|
368
|
+
onMouseDown: (e)=>{
|
|
369
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
370
|
+
onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
371
|
+
},
|
|
372
|
+
onTouchStart: (e)=>{
|
|
373
|
+
onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}, movePropsContainer);
|
|
377
|
+
let thumbInteractions = isDisabled ? {
|
|
378
|
+
} : $7KHxM$mergeProps({
|
|
379
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
380
|
+
onPointerDown: (e)=>{
|
|
381
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
382
|
+
onThumbDown(e.pointerId);
|
|
383
|
+
}
|
|
384
|
+
} : {
|
|
385
|
+
onMouseDown: (e)=>{
|
|
386
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
387
|
+
onThumbDown(undefined);
|
|
388
|
+
},
|
|
389
|
+
onTouchStart: (e)=>{
|
|
390
|
+
onThumbDown(e.changedTouches[0].identifier);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}, keyboardProps, movePropsThumb);
|
|
394
|
+
let isMobile = $7KHxM$isIOS() || $7KHxM$isAndroid();
|
|
395
|
+
let xInputLabellingProps = $7KHxM$useLabels({
|
|
396
|
+
...props,
|
|
397
|
+
'aria-label': isMobile ? state.value.getChannelName(xChannel, locale) : formatMessage('x/y', {
|
|
398
|
+
x: state.value.getChannelName(xChannel, locale),
|
|
399
|
+
y: state.value.getChannelName(yChannel, locale)
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
let yInputLabellingProps = $7KHxM$useLabels({
|
|
403
|
+
...props,
|
|
404
|
+
'aria-label': isMobile ? state.value.getChannelName(yChannel, locale) : formatMessage('x/y', {
|
|
405
|
+
x: state.value.getChannelName(xChannel, locale),
|
|
406
|
+
y: state.value.getChannelName(yChannel, locale)
|
|
407
|
+
})
|
|
408
|
+
});
|
|
409
|
+
let colorAriaLabellingProps = $7KHxM$useLabels(props);
|
|
410
|
+
let getValueTitle = ()=>[
|
|
411
|
+
formatMessage('colorNameAndValue', {
|
|
412
|
+
name: state.value.getChannelName('red', locale),
|
|
413
|
+
value: state.value.formatChannelValue('red', locale)
|
|
414
|
+
}),
|
|
415
|
+
formatMessage('colorNameAndValue', {
|
|
416
|
+
name: state.value.getChannelName('green', locale),
|
|
417
|
+
value: state.value.formatChannelValue('green', locale)
|
|
418
|
+
}),
|
|
419
|
+
formatMessage('colorNameAndValue', {
|
|
420
|
+
name: state.value.getChannelName('blue', locale),
|
|
421
|
+
value: state.value.formatChannelValue('blue', locale)
|
|
422
|
+
})
|
|
423
|
+
].join(', ')
|
|
424
|
+
;
|
|
425
|
+
let ariaRoleDescription = isMobile ? null : formatMessage('twoDimensionalSlider');
|
|
426
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = $7KHxM$useVisuallyHidden({
|
|
427
|
+
style: {
|
|
428
|
+
opacity: '0.0001',
|
|
429
|
+
width: '100%',
|
|
430
|
+
height: '100%',
|
|
431
|
+
pointerEvents: 'none'
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
return {
|
|
435
|
+
colorAreaProps: {
|
|
436
|
+
...colorAriaLabellingProps,
|
|
437
|
+
...colorAreaInteractions,
|
|
438
|
+
role: 'group'
|
|
439
|
+
},
|
|
440
|
+
gradientProps: {
|
|
441
|
+
role: 'presentation'
|
|
442
|
+
},
|
|
443
|
+
thumbProps: {
|
|
444
|
+
...thumbInteractions,
|
|
445
|
+
role: 'presentation'
|
|
446
|
+
},
|
|
447
|
+
xInputProps: {
|
|
448
|
+
...xInputLabellingProps,
|
|
449
|
+
...visuallyHiddenProps,
|
|
450
|
+
type: 'range',
|
|
451
|
+
min: state.value.getChannelRange(xChannel).minValue,
|
|
452
|
+
max: state.value.getChannelRange(xChannel).maxValue,
|
|
453
|
+
step: xChannelStep1,
|
|
454
|
+
'aria-roledescription': ariaRoleDescription,
|
|
455
|
+
'aria-valuetext': isMobile ? formatMessage('colorNameAndValue', {
|
|
456
|
+
name: state.value.getChannelName(xChannel, locale),
|
|
457
|
+
value: state.value.formatChannelValue(xChannel, locale)
|
|
458
|
+
}) : [
|
|
459
|
+
formatMessage('colorNameAndValue', {
|
|
460
|
+
name: state.value.getChannelName(xChannel, locale),
|
|
461
|
+
value: state.value.formatChannelValue(xChannel, locale)
|
|
462
|
+
}),
|
|
463
|
+
formatMessage('colorNameAndValue', {
|
|
464
|
+
name: state.value.getChannelName(yChannel, locale),
|
|
465
|
+
value: state.value.formatChannelValue(yChannel, locale)
|
|
466
|
+
})
|
|
467
|
+
].join(', '),
|
|
468
|
+
title: getValueTitle(),
|
|
469
|
+
disabled: isDisabled,
|
|
470
|
+
value: state.value.getChannelValue(xChannel),
|
|
471
|
+
tabIndex: 0,
|
|
472
|
+
onChange: (e)=>{
|
|
473
|
+
state.setXValue(parseFloat(e.target.value));
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
yInputProps: {
|
|
477
|
+
...yInputLabellingProps,
|
|
478
|
+
...visuallyHiddenProps,
|
|
479
|
+
type: 'range',
|
|
480
|
+
min: state.value.getChannelRange(yChannel).minValue,
|
|
481
|
+
max: state.value.getChannelRange(yChannel).maxValue,
|
|
482
|
+
step: yChannelStep1,
|
|
483
|
+
'aria-roledescription': ariaRoleDescription,
|
|
484
|
+
'aria-valuetext': isMobile ? formatMessage('colorNameAndValue', {
|
|
485
|
+
name: state.value.getChannelName(yChannel, locale),
|
|
486
|
+
value: state.value.formatChannelValue(yChannel, locale)
|
|
487
|
+
}) : [
|
|
488
|
+
formatMessage('colorNameAndValue', {
|
|
489
|
+
name: state.value.getChannelName(yChannel, locale),
|
|
490
|
+
value: state.value.formatChannelValue(yChannel, locale)
|
|
491
|
+
}),
|
|
492
|
+
formatMessage('colorNameAndValue', {
|
|
493
|
+
name: state.value.getChannelName(xChannel, locale),
|
|
494
|
+
value: state.value.formatChannelValue(xChannel, locale)
|
|
495
|
+
})
|
|
496
|
+
].join(', '),
|
|
497
|
+
'aria-orientation': 'vertical',
|
|
498
|
+
title: getValueTitle(),
|
|
499
|
+
disabled: isDisabled,
|
|
500
|
+
value: state.value.getChannelValue(yChannel),
|
|
501
|
+
tabIndex: -1,
|
|
502
|
+
onChange: (e)=>{
|
|
503
|
+
state.setYValue(parseFloat(e.target.value));
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
}
|
|
90
508
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
509
|
+
|
|
510
|
+
var $40af666d6c251e36$exports = {};
|
|
511
|
+
|
|
512
|
+
$parcel$export($40af666d6c251e36$exports, "useColorSlider", () => $40af666d6c251e36$export$106b7a4e66508f66);
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
|
|
517
|
+
let { trackRef: trackRef , inputRef: inputRef , orientation: orientation , channel: channel , 'aria-label': ariaLabel } = props;
|
|
518
|
+
let { locale: locale , direction: direction } = $7KHxM$useLocale();
|
|
519
|
+
// Provide a default aria-label if there is no other label provided.
|
|
520
|
+
if (!props.label && !ariaLabel && !props['aria-labelledby']) ariaLabel = state.value.getChannelName(channel, locale);
|
|
521
|
+
// @ts-ignore - ignore unused incompatible props
|
|
522
|
+
let { groupProps: groupProps , trackProps: trackProps , labelProps: labelProps , outputProps: outputProps } = $7KHxM$useSlider({
|
|
523
|
+
...props,
|
|
524
|
+
'aria-label': ariaLabel
|
|
525
|
+
}, state, trackRef);
|
|
526
|
+
let { inputProps: inputProps , thumbProps: thumbProps } = $7KHxM$useSliderThumb({
|
|
527
|
+
index: 0,
|
|
528
|
+
orientation: orientation,
|
|
529
|
+
isDisabled: props.isDisabled,
|
|
530
|
+
trackRef: trackRef,
|
|
531
|
+
inputRef: inputRef
|
|
532
|
+
}, state);
|
|
533
|
+
let generateBackground = ()=>{
|
|
534
|
+
let value = state.getDisplayColor();
|
|
535
|
+
let to;
|
|
536
|
+
if (orientation === 'vertical') to = 'top';
|
|
537
|
+
else if (direction === 'ltr') to = 'right';
|
|
538
|
+
else to = 'left';
|
|
539
|
+
switch(channel){
|
|
540
|
+
case 'hue':
|
|
541
|
+
return `linear-gradient(to ${to}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
|
|
542
|
+
case 'lightness':
|
|
543
|
+
{
|
|
544
|
+
// We have to add an extra color stop in the middle so that the hue shows up at all.
|
|
545
|
+
// Otherwise it will always just be black to white.
|
|
546
|
+
let min = state.getThumbMinValue(0);
|
|
547
|
+
let max = state.getThumbMaxValue(0);
|
|
548
|
+
let start = value.withChannelValue(channel, min).toString('css');
|
|
549
|
+
let middle = value.withChannelValue(channel, (max - min) / 2).toString('css');
|
|
550
|
+
let end = value.withChannelValue(channel, max).toString('css');
|
|
551
|
+
return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
|
|
552
|
+
}
|
|
553
|
+
case 'saturation':
|
|
554
|
+
case 'brightness':
|
|
555
|
+
case 'red':
|
|
556
|
+
case 'green':
|
|
557
|
+
case 'blue':
|
|
558
|
+
case 'alpha':
|
|
559
|
+
{
|
|
560
|
+
let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css');
|
|
561
|
+
let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css');
|
|
562
|
+
return `linear-gradient(to ${to}, ${start}, ${end})`;
|
|
563
|
+
}
|
|
564
|
+
default:
|
|
565
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
let thumbPosition = state.getThumbPercent(0);
|
|
569
|
+
if (orientation === 'vertical' || direction === 'rtl') thumbPosition = 1 - thumbPosition;
|
|
570
|
+
return {
|
|
571
|
+
trackProps: {
|
|
572
|
+
...$7KHxM$mergeProps(groupProps, trackProps),
|
|
573
|
+
style: {
|
|
574
|
+
position: 'relative',
|
|
575
|
+
touchAction: 'none',
|
|
576
|
+
background: generateBackground()
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
inputProps: inputProps,
|
|
580
|
+
thumbProps: {
|
|
581
|
+
...thumbProps,
|
|
582
|
+
style: {
|
|
583
|
+
touchAction: 'none',
|
|
584
|
+
position: 'absolute',
|
|
585
|
+
[orientation === 'vertical' ? 'top' : 'left']: `${thumbPosition * 100}%`,
|
|
586
|
+
transform: 'translate(-50%, -50%)'
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
labelProps: labelProps,
|
|
590
|
+
outputProps: outputProps
|
|
591
|
+
};
|
|
122
592
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
innerRadius,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
var $b4a0a4fdc900495e$exports = {};
|
|
596
|
+
|
|
597
|
+
$parcel$export($b4a0a4fdc900495e$exports, "useColorWheel", () => $b4a0a4fdc900495e$export$9064ff4e44b3729a);
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
603
|
+
let { isDisabled: isDisabled , innerRadius: innerRadius , outerRadius: outerRadius , 'aria-label': ariaLabel } = props;
|
|
604
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $7KHxM$useGlobalListeners();
|
|
605
|
+
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
606
|
+
let focusInput = $7KHxM$useCallback(()=>{
|
|
607
|
+
if (inputRef.current) $7KHxM$focusWithoutScrolling(inputRef.current);
|
|
608
|
+
}, [
|
|
609
|
+
inputRef
|
|
610
|
+
]);
|
|
611
|
+
let stateRef = $7KHxM$useRef(null);
|
|
612
|
+
stateRef.current = state;
|
|
613
|
+
let currentPosition = $7KHxM$useRef(null);
|
|
614
|
+
let { keyboardProps: keyboardProps } = $7KHxM$useKeyboard({
|
|
615
|
+
onKeyDown (e) {
|
|
616
|
+
// these are the cases that useMove doesn't handle
|
|
617
|
+
if (!/^(PageUp|PageDown)$/.test(e.key)) {
|
|
618
|
+
e.continuePropagation();
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
622
|
+
e.preventDefault();
|
|
623
|
+
// remember to set this and unset it so that onChangeEnd is fired
|
|
624
|
+
stateRef.current.setDragging(true);
|
|
625
|
+
switch(e.key){
|
|
626
|
+
case 'PageUp':
|
|
627
|
+
e.preventDefault();
|
|
628
|
+
state.increment(stateRef.current.pageStep);
|
|
629
|
+
break;
|
|
630
|
+
case 'PageDown':
|
|
631
|
+
e.preventDefault();
|
|
632
|
+
state.decrement(stateRef.current.pageStep);
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
stateRef.current.setDragging(false);
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
let moveHandler = {
|
|
639
|
+
onMoveStart () {
|
|
640
|
+
currentPosition.current = null;
|
|
641
|
+
state.setDragging(true);
|
|
642
|
+
},
|
|
643
|
+
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType , shiftKey: shiftKey }) {
|
|
644
|
+
if (currentPosition.current == null) currentPosition.current = stateRef.current.getThumbPosition(thumbRadius);
|
|
645
|
+
currentPosition.current.x += deltaX;
|
|
646
|
+
currentPosition.current.y += deltaY;
|
|
647
|
+
if (pointerType === 'keyboard') {
|
|
648
|
+
if (deltaX > 0 || deltaY < 0) state.increment(shiftKey ? stateRef.current.pageStep : stateRef.current.step);
|
|
649
|
+
else if (deltaX < 0 || deltaY > 0) state.decrement(shiftKey ? stateRef.current.pageStep : stateRef.current.step);
|
|
650
|
+
} else stateRef.current.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
|
|
651
|
+
},
|
|
652
|
+
onMoveEnd () {
|
|
653
|
+
isOnTrack.current = undefined;
|
|
654
|
+
state.setDragging(false);
|
|
655
|
+
focusInput();
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
let { moveProps: movePropsThumb } = $7KHxM$useMove(moveHandler);
|
|
659
|
+
let currentPointer = $7KHxM$useRef(undefined);
|
|
660
|
+
let isOnTrack = $7KHxM$useRef(false);
|
|
661
|
+
let { moveProps: movePropsContainer } = $7KHxM$useMove({
|
|
662
|
+
onMoveStart () {
|
|
663
|
+
if (isOnTrack.current) moveHandler.onMoveStart();
|
|
664
|
+
},
|
|
665
|
+
onMove (e) {
|
|
666
|
+
if (isOnTrack.current) moveHandler.onMove(e);
|
|
667
|
+
},
|
|
668
|
+
onMoveEnd () {
|
|
669
|
+
if (isOnTrack.current) moveHandler.onMoveEnd();
|
|
175
670
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
let thumbInteractions = isDisabled ? {} : mergeProps({
|
|
332
|
-
onMouseDown: e => {
|
|
333
|
-
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
onThumbDown(undefined);
|
|
338
|
-
},
|
|
339
|
-
onPointerDown: e => {
|
|
340
|
-
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
onThumbDown(e.pointerId);
|
|
345
|
-
},
|
|
346
|
-
onTouchStart: e => {
|
|
347
|
-
onThumbDown(e.changedTouches[0].identifier);
|
|
348
|
-
}
|
|
349
|
-
}, movePropsThumb, keyboardProps);
|
|
350
|
-
let {
|
|
351
|
-
x,
|
|
352
|
-
y
|
|
353
|
-
} = state.getThumbPosition(thumbRadius); // Provide a default aria-label if none is given
|
|
354
|
-
|
|
355
|
-
let {
|
|
356
|
-
locale
|
|
357
|
-
} = useLocale();
|
|
358
|
-
|
|
359
|
-
if (ariaLabel == null && props['aria-labelledby'] == null) {
|
|
360
|
-
ariaLabel = state.value.getChannelName('hue', locale);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
let inputLabellingProps = useLabels(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
364
|
-
'aria-label': ariaLabel
|
|
365
|
-
}));
|
|
366
|
-
return {
|
|
367
|
-
trackProps: _babelRuntimeHelpersEsmExtends({}, trackInteractions, {
|
|
368
|
-
style: {
|
|
369
|
-
position: 'relative',
|
|
370
|
-
touchAction: 'none',
|
|
371
|
-
width: outerRadius * 2,
|
|
372
|
-
height: outerRadius * 2,
|
|
373
|
-
background: "\n conic-gradient(\n from 90deg,\n hsl(0, 100%, 50%),\n hsl(30, 100%, 50%),\n hsl(60, 100%, 50%),\n hsl(90, 100%, 50%),\n hsl(120, 100%, 50%),\n hsl(150, 100%, 50%),\n hsl(180, 100%, 50%),\n hsl(210, 100%, 50%),\n hsl(240, 100%, 50%),\n hsl(270, 100%, 50%),\n hsl(300, 100%, 50%),\n hsl(330, 100%, 50%),\n hsl(360, 100%, 50%)\n )\n ",
|
|
374
|
-
clipPath: "path(evenodd, \"" + $f98eba30513c5bc4d87f6c6540760e68$var$circlePath(outerRadius, outerRadius, outerRadius) + " " + $f98eba30513c5bc4d87f6c6540760e68$var$circlePath(outerRadius, outerRadius, innerRadius) + "\")"
|
|
375
|
-
}
|
|
376
|
-
}),
|
|
377
|
-
thumbProps: _babelRuntimeHelpersEsmExtends({}, thumbInteractions, {
|
|
378
|
-
style: {
|
|
379
|
-
position: 'absolute',
|
|
380
|
-
left: '50%',
|
|
381
|
-
top: '50%',
|
|
382
|
-
transform: "translate(calc(" + x + "px - 50%), calc(" + y + "px - 50%))",
|
|
383
|
-
touchAction: 'none'
|
|
384
|
-
}
|
|
385
|
-
}),
|
|
386
|
-
inputProps: mergeProps(inputLabellingProps, {
|
|
387
|
-
type: 'range',
|
|
388
|
-
min: '0',
|
|
389
|
-
max: '360',
|
|
390
|
-
step: String(step),
|
|
391
|
-
'aria-valuetext': state.value.formatChannelValue('hue', locale),
|
|
392
|
-
disabled: isDisabled,
|
|
393
|
-
value: "" + state.value.getChannelValue('hue'),
|
|
394
|
-
onChange: e => {
|
|
395
|
-
state.setHue(parseFloat(e.target.value));
|
|
396
|
-
}
|
|
397
|
-
})
|
|
398
|
-
};
|
|
399
|
-
} // Creates an SVG path string for a circle.
|
|
400
|
-
|
|
401
|
-
function $f98eba30513c5bc4d87f6c6540760e68$var$circlePath(cx, cy, r) {
|
|
402
|
-
return "M " + cx + ", " + cy + " m " + -r + ", 0 a " + r + ", " + r + ", 0, 1, 0, " + r * 2 + ", 0 a " + r + ", " + r + ", 0, 1, 0 " + -r * 2 + ", 0";
|
|
671
|
+
});
|
|
672
|
+
let onThumbDown = (id)=>{
|
|
673
|
+
if (!state.isDragging) {
|
|
674
|
+
currentPointer.current = id;
|
|
675
|
+
focusInput();
|
|
676
|
+
state.setDragging(true);
|
|
677
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
678
|
+
else {
|
|
679
|
+
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
680
|
+
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
let onThumbUp = (e)=>{
|
|
685
|
+
var ref;
|
|
686
|
+
var _pointerId;
|
|
687
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
688
|
+
if (id === currentPointer.current) {
|
|
689
|
+
focusInput();
|
|
690
|
+
state.setDragging(false);
|
|
691
|
+
currentPointer.current = undefined;
|
|
692
|
+
isOnTrack.current = false;
|
|
693
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
694
|
+
else {
|
|
695
|
+
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
696
|
+
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
let onTrackDown = (track, id, pageX, pageY)=>{
|
|
701
|
+
let rect = track.getBoundingClientRect();
|
|
702
|
+
let x = pageX - rect.x - rect.width / 2;
|
|
703
|
+
let y = pageY - rect.y - rect.height / 2;
|
|
704
|
+
let radius = Math.sqrt(x * x + y * y);
|
|
705
|
+
if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
|
|
706
|
+
isOnTrack.current = true;
|
|
707
|
+
currentPointer.current = id;
|
|
708
|
+
stateRef.current.setHueFromPoint(x, y, radius);
|
|
709
|
+
focusInput();
|
|
710
|
+
state.setDragging(true);
|
|
711
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onTrackUp, false);
|
|
712
|
+
else {
|
|
713
|
+
addGlobalListener(window, 'mouseup', onTrackUp, false);
|
|
714
|
+
addGlobalListener(window, 'touchend', onTrackUp, false);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
let onTrackUp = (e)=>{
|
|
719
|
+
var ref;
|
|
720
|
+
var _pointerId;
|
|
721
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
722
|
+
if (isOnTrack.current && id === currentPointer.current) {
|
|
723
|
+
isOnTrack.current = false;
|
|
724
|
+
currentPointer.current = undefined;
|
|
725
|
+
state.setDragging(false);
|
|
726
|
+
focusInput();
|
|
727
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onTrackUp, false);
|
|
728
|
+
else {
|
|
729
|
+
removeGlobalListener(window, 'mouseup', onTrackUp, false);
|
|
730
|
+
removeGlobalListener(window, 'touchend', onTrackUp, false);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
let trackInteractions = isDisabled ? {
|
|
735
|
+
} : $7KHxM$mergeProps({
|
|
736
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
737
|
+
onPointerDown: (e)=>{
|
|
738
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
739
|
+
onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
740
|
+
}
|
|
741
|
+
} : {
|
|
742
|
+
onMouseDown: (e)=>{
|
|
743
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
744
|
+
onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
745
|
+
},
|
|
746
|
+
onTouchStart: (e)=>{
|
|
747
|
+
onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}, movePropsContainer);
|
|
751
|
+
let thumbInteractions = isDisabled ? {
|
|
752
|
+
} : $7KHxM$mergeProps({
|
|
753
|
+
onMouseDown: (e)=>{
|
|
754
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
755
|
+
onThumbDown(undefined);
|
|
756
|
+
},
|
|
757
|
+
onPointerDown: (e)=>{
|
|
758
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
759
|
+
onThumbDown(e.pointerId);
|
|
760
|
+
},
|
|
761
|
+
onTouchStart: (e)=>{
|
|
762
|
+
onThumbDown(e.changedTouches[0].identifier);
|
|
763
|
+
}
|
|
764
|
+
}, keyboardProps, movePropsThumb);
|
|
765
|
+
let { x: x1 , y: y1 } = state.getThumbPosition(thumbRadius);
|
|
766
|
+
// Provide a default aria-label if none is given
|
|
767
|
+
let { locale: locale } = $7KHxM$useLocale();
|
|
768
|
+
if (ariaLabel == null && props['aria-labelledby'] == null) ariaLabel = state.value.getChannelName('hue', locale);
|
|
769
|
+
let inputLabellingProps = $7KHxM$useLabels({
|
|
770
|
+
...props,
|
|
771
|
+
'aria-label': ariaLabel
|
|
772
|
+
});
|
|
773
|
+
let { minValue: minValue , maxValue: maxValue , step: step } = state.value.getChannelRange('hue');
|
|
774
|
+
return {
|
|
775
|
+
trackProps: {
|
|
776
|
+
...trackInteractions,
|
|
777
|
+
style: {
|
|
778
|
+
position: 'relative',
|
|
779
|
+
touchAction: 'none',
|
|
780
|
+
width: outerRadius * 2,
|
|
781
|
+
height: outerRadius * 2,
|
|
782
|
+
background: `
|
|
783
|
+
conic-gradient(
|
|
784
|
+
from 90deg,
|
|
785
|
+
hsl(0, 100%, 50%),
|
|
786
|
+
hsl(30, 100%, 50%),
|
|
787
|
+
hsl(60, 100%, 50%),
|
|
788
|
+
hsl(90, 100%, 50%),
|
|
789
|
+
hsl(120, 100%, 50%),
|
|
790
|
+
hsl(150, 100%, 50%),
|
|
791
|
+
hsl(180, 100%, 50%),
|
|
792
|
+
hsl(210, 100%, 50%),
|
|
793
|
+
hsl(240, 100%, 50%),
|
|
794
|
+
hsl(270, 100%, 50%),
|
|
795
|
+
hsl(300, 100%, 50%),
|
|
796
|
+
hsl(330, 100%, 50%),
|
|
797
|
+
hsl(360, 100%, 50%)
|
|
798
|
+
)
|
|
799
|
+
`,
|
|
800
|
+
clipPath: `path(evenodd, "${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, outerRadius)} ${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, innerRadius)}")`
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
thumbProps: {
|
|
804
|
+
...thumbInteractions,
|
|
805
|
+
style: {
|
|
806
|
+
position: 'absolute',
|
|
807
|
+
left: '50%',
|
|
808
|
+
top: '50%',
|
|
809
|
+
transform: `translate(calc(${x1}px - 50%), calc(${y1}px - 50%))`,
|
|
810
|
+
touchAction: 'none'
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
inputProps: $7KHxM$mergeProps(inputLabellingProps, {
|
|
814
|
+
type: 'range',
|
|
815
|
+
min: String(minValue),
|
|
816
|
+
max: String(maxValue),
|
|
817
|
+
step: String(step),
|
|
818
|
+
'aria-valuetext': state.value.formatChannelValue('hue', locale),
|
|
819
|
+
disabled: isDisabled,
|
|
820
|
+
value: `${state.value.getChannelValue('hue')}`,
|
|
821
|
+
onChange: (e)=>{
|
|
822
|
+
state.setHue(parseFloat(e.target.value));
|
|
823
|
+
}
|
|
824
|
+
})
|
|
825
|
+
};
|
|
403
826
|
}
|
|
827
|
+
// Creates an SVG path string for a circle.
|
|
828
|
+
function $b4a0a4fdc900495e$var$circlePath(cx, cy, r) {
|
|
829
|
+
return `M ${cx}, ${cy} m ${-r}, 0 a ${r}, ${r}, 0, 1, 0, ${r * 2}, 0 a ${r}, ${r}, 0, 1, 0 ${-r * 2}, 0`;
|
|
830
|
+
}
|
|
831
|
+
|
|
404
832
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
} = props;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
isDisabled
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
id: inputId,
|
|
474
|
-
value: inputValue,
|
|
475
|
-
type: 'text',
|
|
476
|
-
autoComplete: 'off',
|
|
477
|
-
onChange
|
|
478
|
-
}), state, ref);
|
|
479
|
-
return {
|
|
480
|
-
labelProps,
|
|
481
|
-
inputProps: mergeProps(inputProps, spinButtonProps, focusWithinProps, {
|
|
482
|
-
role: 'textbox',
|
|
483
|
-
'aria-valuemax': null,
|
|
484
|
-
'aria-valuemin': null,
|
|
485
|
-
'aria-valuenow': null,
|
|
486
|
-
'aria-valuetext': null,
|
|
487
|
-
autoCorrect: 'off',
|
|
488
|
-
spellCheck: 'false',
|
|
489
|
-
onBlur: commit
|
|
490
|
-
})
|
|
491
|
-
};
|
|
833
|
+
var $f6896b05b2ecad12$exports = {};
|
|
834
|
+
|
|
835
|
+
$parcel$export($f6896b05b2ecad12$exports, "useColorField", () => $f6896b05b2ecad12$export$77e32ca575a28fdf);
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
842
|
+
let { isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired } = props;
|
|
843
|
+
let { colorValue: colorValue , inputValue: inputValue , commit: commit , increment: increment , decrement: decrement , incrementToMax: incrementToMax , decrementToMin: decrementToMin } = state;
|
|
844
|
+
let inputId = $7KHxM$useId();
|
|
845
|
+
let { spinButtonProps: spinButtonProps } = $7KHxM$useSpinButton({
|
|
846
|
+
isDisabled: isDisabled,
|
|
847
|
+
isReadOnly: isReadOnly,
|
|
848
|
+
isRequired: isRequired,
|
|
849
|
+
maxValue: 16777215,
|
|
850
|
+
minValue: 0,
|
|
851
|
+
onIncrement: increment,
|
|
852
|
+
onIncrementToMax: incrementToMax,
|
|
853
|
+
onDecrement: decrement,
|
|
854
|
+
onDecrementToMin: decrementToMin,
|
|
855
|
+
value: colorValue ? colorValue.toHexInt() : undefined,
|
|
856
|
+
textValue: colorValue ? colorValue.toString('hex') : undefined
|
|
857
|
+
});
|
|
858
|
+
let [focusWithin, setFocusWithin] = $7KHxM$useState(false);
|
|
859
|
+
let { focusWithinProps: focusWithinProps } = $7KHxM$useFocusWithin({
|
|
860
|
+
isDisabled: isDisabled,
|
|
861
|
+
onFocusWithinChange: setFocusWithin
|
|
862
|
+
});
|
|
863
|
+
let onWheel = $7KHxM$useCallback((e)=>{
|
|
864
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
865
|
+
if (e.deltaY > 0) increment();
|
|
866
|
+
else if (e.deltaY < 0) decrement();
|
|
867
|
+
}, [
|
|
868
|
+
decrement,
|
|
869
|
+
increment
|
|
870
|
+
]);
|
|
871
|
+
// If the input isn't supposed to receive input, disable scrolling.
|
|
872
|
+
let scrollingDisabled = isDisabled || isReadOnly || !focusWithin;
|
|
873
|
+
$7KHxM$useScrollWheel({
|
|
874
|
+
onScroll: onWheel,
|
|
875
|
+
isDisabled: scrollingDisabled
|
|
876
|
+
}, ref);
|
|
877
|
+
let onChange = (value)=>{
|
|
878
|
+
state.setInputValue(value);
|
|
879
|
+
};
|
|
880
|
+
let { labelProps: labelProps , inputProps: inputProps } = $7KHxM$useFormattedTextField($7KHxM$mergeProps(props, {
|
|
881
|
+
id: inputId,
|
|
882
|
+
value: inputValue,
|
|
883
|
+
defaultValue: undefined,
|
|
884
|
+
type: 'text',
|
|
885
|
+
autoComplete: 'off',
|
|
886
|
+
onChange: onChange
|
|
887
|
+
}), state, ref);
|
|
888
|
+
return {
|
|
889
|
+
labelProps: labelProps,
|
|
890
|
+
inputProps: $7KHxM$mergeProps(inputProps, spinButtonProps, focusWithinProps, {
|
|
891
|
+
role: 'textbox',
|
|
892
|
+
'aria-valuemax': null,
|
|
893
|
+
'aria-valuemin': null,
|
|
894
|
+
'aria-valuenow': null,
|
|
895
|
+
'aria-valuetext': null,
|
|
896
|
+
autoCorrect: 'off',
|
|
897
|
+
spellCheck: 'false',
|
|
898
|
+
onBlur: commit
|
|
899
|
+
})
|
|
900
|
+
};
|
|
492
901
|
}
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
export {$60bd7d6e45dcddfa$export$2f92a7a615a014f6 as useColorArea, $40af666d6c251e36$export$106b7a4e66508f66 as useColorSlider, $b4a0a4fdc900495e$export$9064ff4e44b3729a as useColorWheel, $f6896b05b2ecad12$export$77e32ca575a28fdf as useColorField};
|
|
493
907
|
//# sourceMappingURL=module.js.map
|