@react-aria/color 3.0.0-beta.10 → 3.0.0-beta.13
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 +109 -92
- package/dist/main.js.map +1 -1
- package/dist/module.js +110 -93
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/useColorArea.ts +76 -44
package/dist/module.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
import {useRef as $7KHxM$useRef, useCallback as $7KHxM$useCallback, useMemo as $7KHxM$useMemo, 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";
|
|
3
|
+
import {useKeyboard as $7KHxM$useKeyboard, useMove as $7KHxM$useMove, useFocusWithin as $7KHxM$useFocusWithin, useFocus as $7KHxM$useFocus, useScrollWheel as $7KHxM$useScrollWheel} from "@react-aria/interactions";
|
|
4
4
|
import {useMessageFormatter as $7KHxM$useMessageFormatter, useLocale as $7KHxM$useLocale} from "@react-aria/i18n";
|
|
5
5
|
import {useVisuallyHidden as $7KHxM$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
6
6
|
import {useSlider as $7KHxM$useSlider, useSliderThumb as $7KHxM$useSliderThumb} from "@react-aria/slider";
|
|
@@ -19,139 +19,139 @@ $parcel$export($60bd7d6e45dcddfa$exports, "useColorArea", () => $60bd7d6e45dcddf
|
|
|
19
19
|
|
|
20
20
|
var $052cfdf4c32eb7c3$exports = {};
|
|
21
21
|
var $eccab2b0118aef08$exports = {};
|
|
22
|
-
$eccab2b0118aef08$exports = JSON.parse("{\"
|
|
22
|
+
$eccab2b0118aef08$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"أداة انتقاء اللون\",\"twoDimensionalSlider\":\"مُنزلق 2D\"}");
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
var $bf2b4507594e3d45$exports = {};
|
|
26
|
-
$bf2b4507594e3d45$exports = JSON.parse("{\"
|
|
26
|
+
$bf2b4507594e3d45$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Средство за избиране на цвят\",\"twoDimensionalSlider\":\"2D плъзгач\"}");
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
var $01c08487af7ecd14$exports = {};
|
|
30
|
-
$01c08487af7ecd14$exports = JSON.parse("{\"
|
|
30
|
+
$01c08487af7ecd14$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Výběr barvy\",\"twoDimensionalSlider\":\"2D posuvník\"}");
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var $5e997db6ea0d10f6$exports = {};
|
|
34
|
-
$5e997db6ea0d10f6$exports = JSON.parse("{\"
|
|
34
|
+
$5e997db6ea0d10f6$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Farvevælger\",\"twoDimensionalSlider\":\"2D-skyder\"}");
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
var $fe5998f640a79fd2$exports = {};
|
|
38
|
-
$fe5998f640a79fd2$exports = JSON.parse("{\"
|
|
38
|
+
$fe5998f640a79fd2$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Farbwähler\",\"twoDimensionalSlider\":\"2D-Schieberegler\"}");
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
var $18e4d1d5b500a9ee$exports = {};
|
|
42
|
-
$18e4d1d5b500a9ee$exports = JSON.parse("{\"
|
|
42
|
+
$18e4d1d5b500a9ee$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Επιλογέας χρωμάτων\",\"twoDimensionalSlider\":\"Ρυθμιστικό 2D\"}");
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
var $bf90a11a7a42a0f7$exports = {};
|
|
46
|
-
$bf90a11a7a42a0f7$exports = JSON.parse("{\"twoDimensionalSlider\":\"2D slider\",\"colorNameAndValue\":\"{name}: {value}\",\"
|
|
46
|
+
$bf90a11a7a42a0f7$exports = JSON.parse("{\"colorPicker\":\"Color picker\",\"twoDimensionalSlider\":\"2D slider\",\"colorNameAndValue\":\"{name}: {value}\",\"colorInputLabel\":\"{label}, {channelLabel}\"}");
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
var $dd0d25f885b5c5f3$exports = {};
|
|
50
|
-
$dd0d25f885b5c5f3$exports = JSON.parse("{\"
|
|
50
|
+
$dd0d25f885b5c5f3$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Selector de color\",\"twoDimensionalSlider\":\"Regulador 2D\"}");
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
var $d950967017e3485b$exports = {};
|
|
54
|
-
$d950967017e3485b$exports = JSON.parse("{\"
|
|
54
|
+
$d950967017e3485b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Värvivalija\",\"twoDimensionalSlider\":\"2D-liugur\"}");
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
var $00a415a3f0ab315a$exports = {};
|
|
58
|
-
$00a415a3f0ab315a$exports = JSON.parse("{\"
|
|
58
|
+
$00a415a3f0ab315a$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Värimuokkain\",\"twoDimensionalSlider\":\"2D-liukusäädin\"}");
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
var $d80f30fe86c95741$exports = {};
|
|
62
|
-
$d80f30fe86c95741$exports = JSON.parse("{\"
|
|
62
|
+
$d80f30fe86c95741$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name} : {value}\",\"colorPicker\":\"Sélecteur de couleurs\",\"twoDimensionalSlider\":\"Curseur 2D\"}");
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
var $6912afb584340a2e$exports = {};
|
|
66
|
-
$6912afb584340a2e$exports = JSON.parse("{\"
|
|
66
|
+
$6912afb584340a2e$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"בוחר הצבעים\",\"twoDimensionalSlider\":\"מחוון דו מימדי\"}");
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
var $7b97fcacd84ec90f$exports = {};
|
|
70
|
-
$7b97fcacd84ec90f$exports = JSON.parse("{\"
|
|
70
|
+
$7b97fcacd84ec90f$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Odabir boje\",\"twoDimensionalSlider\":\"2D klizač\"}");
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
var $da9b443e89eebc6b$exports = {};
|
|
74
|
-
$da9b443e89eebc6b$exports = JSON.parse("{\"
|
|
74
|
+
$da9b443e89eebc6b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Színválasztó\",\"twoDimensionalSlider\":\"2D-csúszka\"}");
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
var $35f135b45eb4d95b$exports = {};
|
|
78
|
-
$35f135b45eb4d95b$exports = JSON.parse("{\"
|
|
78
|
+
$35f135b45eb4d95b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Selettore colore\",\"twoDimensionalSlider\":\"Cursore 2D\"}");
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
var $760b09448e39c6cd$exports = {};
|
|
82
|
-
$760b09448e39c6cd$exports = JSON.parse("{\"
|
|
82
|
+
$760b09448e39c6cd$exports = JSON.parse("{\"colorInputLabel\":\"{label}、{channelLabel}\",\"colorNameAndValue\":\"{name} : {value}\",\"colorPicker\":\"カラーピッカー\",\"twoDimensionalSlider\":\"2D スライダー\"}");
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
var $fc7b7d43be9703ec$exports = {};
|
|
86
|
-
$fc7b7d43be9703ec$exports = JSON.parse("{\"
|
|
86
|
+
$fc7b7d43be9703ec$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"색상 피커\",\"twoDimensionalSlider\":\"2D 슬라이더\"}");
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
var $74918a1664156912$exports = {};
|
|
90
|
-
$74918a1664156912$exports = JSON.parse("{\"
|
|
90
|
+
$74918a1664156912$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Spalvų parinkiklis\",\"twoDimensionalSlider\":\"2D slankiklis\"}");
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
var $4e6cde11c2bc9840$exports = {};
|
|
94
|
-
$4e6cde11c2bc9840$exports = JSON.parse("{\"
|
|
94
|
+
$4e6cde11c2bc9840$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Krāsu atlasītājs\",\"twoDimensionalSlider\":\"2D slīdnis\"}");
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
var $6faa3defebc3eb72$exports = {};
|
|
98
|
-
$6faa3defebc3eb72$exports = JSON.parse("{\"
|
|
98
|
+
$6faa3defebc3eb72$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Fargevelger\",\"twoDimensionalSlider\":\"2D-glidebryter\"}");
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
var $6ac9b6b1b7e3ca12$exports = {};
|
|
102
|
-
$6ac9b6b1b7e3ca12$exports = JSON.parse("{\"
|
|
102
|
+
$6ac9b6b1b7e3ca12$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Kleurkiezer\",\"twoDimensionalSlider\":\"2D-schuifregelaar\"}");
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
var $1be8b0ee8841f1e7$exports = {};
|
|
106
|
-
$1be8b0ee8841f1e7$exports = JSON.parse("{\"
|
|
106
|
+
$1be8b0ee8841f1e7$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Próbnik kolorów\",\"twoDimensionalSlider\":\"Suwak 2D\"}");
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
var $f9507c2d404ed689$exports = {};
|
|
110
|
-
$f9507c2d404ed689$exports = JSON.parse("{\"
|
|
110
|
+
$f9507c2d404ed689$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Seletor de cores\",\"twoDimensionalSlider\":\"Controle deslizante 2D\"}");
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
var $8f872ea59c02d67e$exports = {};
|
|
114
|
-
$8f872ea59c02d67e$exports = JSON.parse("{\"
|
|
114
|
+
$8f872ea59c02d67e$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Seletor de cores\",\"twoDimensionalSlider\":\"Controle deslizante 2D\"}");
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
var $b03b45b62a7ccae4$exports = {};
|
|
118
|
-
$b03b45b62a7ccae4$exports = JSON.parse("{\"
|
|
118
|
+
$b03b45b62a7ccae4$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Selector de culori\",\"twoDimensionalSlider\":\"Glisor 2D\"}");
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
var $f1107d94c09df9b8$exports = {};
|
|
122
|
-
$f1107d94c09df9b8$exports = JSON.parse("{\"
|
|
122
|
+
$f1107d94c09df9b8$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Палитра цветов\",\"twoDimensionalSlider\":\"Ползунок 2D\"}");
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
var $b61325f242fafc7c$exports = {};
|
|
126
|
-
$b61325f242fafc7c$exports = JSON.parse("{\"
|
|
126
|
+
$b61325f242fafc7c$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Výber farieb\",\"twoDimensionalSlider\":\"2D jazdec\"}");
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
var $f44b7cf39ac8f315$exports = {};
|
|
130
|
-
$f44b7cf39ac8f315$exports = JSON.parse("{\"
|
|
130
|
+
$f44b7cf39ac8f315$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Izbirnik barv\",\"twoDimensionalSlider\":\"2D drsnik\"}");
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
var $aa8cd83fc8d4982b$exports = {};
|
|
134
|
-
$aa8cd83fc8d4982b$exports = JSON.parse("{\"
|
|
134
|
+
$aa8cd83fc8d4982b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Birač boja\",\"twoDimensionalSlider\":\"2D klizač\"}");
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
var $7c4f4e5bb7c06f1e$exports = {};
|
|
138
|
-
$7c4f4e5bb7c06f1e$exports = JSON.parse("{\"
|
|
138
|
+
$7c4f4e5bb7c06f1e$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Färgväljaren\",\"twoDimensionalSlider\":\"2D-reglage\"}");
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
var $8045cf930ef745aa$exports = {};
|
|
142
|
-
$8045cf930ef745aa$exports = JSON.parse("{\"
|
|
142
|
+
$8045cf930ef745aa$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Renk Seçici\",\"twoDimensionalSlider\":\"2D sürgü\"}");
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
var $ee2044a77f24b118$exports = {};
|
|
146
|
-
$ee2044a77f24b118$exports = JSON.parse("{\"
|
|
146
|
+
$ee2044a77f24b118$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Палітра кольорів\",\"twoDimensionalSlider\":\"Повзунок 2D\"}");
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
var $4e1dbc65a687dd93$exports = {};
|
|
150
|
-
$4e1dbc65a687dd93$exports = JSON.parse("{\"
|
|
150
|
+
$4e1dbc65a687dd93$exports = JSON.parse("{\"colorInputLabel\":\"{label}、{channelLabel}\",\"colorNameAndValue\":\"{name}:{value}\",\"colorPicker\":\"拾色器\",\"twoDimensionalSlider\":\"2D 滑块\"}");
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
var $b0fef28529309aa6$exports = {};
|
|
154
|
-
$b0fef28529309aa6$exports = JSON.parse("{\"
|
|
154
|
+
$b0fef28529309aa6$exports = JSON.parse("{\"colorInputLabel\":\"{label},{channelLabel}\",\"colorNameAndValue\":\"{name}:{value}\",\"colorPicker\":\"檢色器\",\"twoDimensionalSlider\":\"2D 滑桿\"}");
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
$052cfdf4c32eb7c3$exports = {
|
|
@@ -409,7 +409,7 @@ function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction , stat
|
|
|
409
409
|
|
|
410
410
|
|
|
411
411
|
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
412
|
-
let { isDisabled: isDisabled , inputXRef: inputXRef , inputYRef: inputYRef , containerRef: containerRef } = props;
|
|
412
|
+
let { isDisabled: isDisabled , inputXRef: inputXRef , inputYRef: inputYRef , containerRef: containerRef , 'aria-label': ariaLabel } = props;
|
|
413
413
|
let formatMessage = $7KHxM$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($052cfdf4c32eb7c3$exports)));
|
|
414
414
|
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $7KHxM$useGlobalListeners();
|
|
415
415
|
let { direction: direction , locale: locale } = $7KHxM$useLocale();
|
|
@@ -436,6 +436,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
436
436
|
e.preventDefault();
|
|
437
437
|
// remember to set this and unset it so that onChangeEnd is fired
|
|
438
438
|
stateRef.current.setDragging(true);
|
|
439
|
+
valueChangedViaKeyboard.current = true;
|
|
439
440
|
switch(e.key){
|
|
440
441
|
case 'PageUp':
|
|
441
442
|
stateRef.current.incrementY(stateRef.current.yChannelPageStep);
|
|
@@ -455,10 +456,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
455
456
|
break;
|
|
456
457
|
}
|
|
457
458
|
stateRef.current.setDragging(false);
|
|
458
|
-
if (focusedInputRef.current)
|
|
459
|
-
focusInput(focusedInputRef.current ? focusedInputRef : inputXRef);
|
|
460
|
-
focusedInputRef.current = undefined;
|
|
461
|
-
}
|
|
459
|
+
if (focusedInputRef.current) focusInput(focusedInputRef.current ? focusedInputRef : inputXRef);
|
|
462
460
|
}
|
|
463
461
|
});
|
|
464
462
|
let moveHandler = {
|
|
@@ -470,6 +468,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
470
468
|
let { incrementX: incrementX , decrementX: decrementX , incrementY: incrementY , decrementY: decrementY , xChannelPageStep: xChannelPageStep , xChannelStep: xChannelStep , yChannelPageStep: yChannelPageStep , yChannelStep: yChannelStep , getThumbPosition: getThumbPosition , setColorFromPoint: setColorFromPoint } = stateRef.current;
|
|
471
469
|
if (currentPosition.current == null) currentPosition.current = getThumbPosition();
|
|
472
470
|
let { width: width , height: height } = containerRef.current.getBoundingClientRect();
|
|
471
|
+
let valueChanged = deltaX !== 0 || deltaY !== 0;
|
|
473
472
|
if (pointerType === 'keyboard') {
|
|
474
473
|
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
475
474
|
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
@@ -477,8 +476,9 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
477
476
|
else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
|
|
478
477
|
else if (deltaY > 0) decrementY(deltaYValue);
|
|
479
478
|
else if (deltaY < 0) incrementY(deltaYValue);
|
|
479
|
+
valueChangedViaKeyboard.current = valueChanged;
|
|
480
480
|
// set the focused input based on which axis has the greater delta
|
|
481
|
-
focusedInputRef.current =
|
|
481
|
+
focusedInputRef.current = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? inputYRef.current : inputXRef.current;
|
|
482
482
|
} else {
|
|
483
483
|
currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width;
|
|
484
484
|
currentPosition.current.y += deltaY / height;
|
|
@@ -489,10 +489,18 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
489
489
|
isOnColorArea.current = undefined;
|
|
490
490
|
stateRef.current.setDragging(false);
|
|
491
491
|
focusInput(focusedInputRef.current ? focusedInputRef : inputXRef);
|
|
492
|
-
focusedInputRef.current = undefined;
|
|
493
492
|
}
|
|
494
493
|
};
|
|
495
494
|
let { moveProps: movePropsThumb } = $7KHxM$useMove(moveHandler);
|
|
495
|
+
let valueChangedViaKeyboard = $7KHxM$useRef(false);
|
|
496
|
+
let { focusWithinProps: focusWithinProps } = $7KHxM$useFocusWithin({
|
|
497
|
+
onFocusWithinChange: (focusWithin)=>{
|
|
498
|
+
if (!focusWithin) {
|
|
499
|
+
valueChangedViaKeyboard.current = false;
|
|
500
|
+
focusedInputRef.current;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
496
504
|
let currentPointer = $7KHxM$useRef(undefined);
|
|
497
505
|
let isOnColorArea = $7KHxM$useRef(false);
|
|
498
506
|
let { moveProps: movePropsContainer } = $7KHxM$useMove({
|
|
@@ -509,6 +517,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
509
517
|
let onThumbDown = (id)=>{
|
|
510
518
|
if (!state.isDragging) {
|
|
511
519
|
currentPointer.current = id;
|
|
520
|
+
valueChangedViaKeyboard.current = false;
|
|
512
521
|
focusInput();
|
|
513
522
|
state.setDragging(true);
|
|
514
523
|
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
@@ -523,6 +532,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
523
532
|
var _pointerId;
|
|
524
533
|
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
525
534
|
if (id === currentPointer.current) {
|
|
535
|
+
valueChangedViaKeyboard.current = false;
|
|
526
536
|
focusInput();
|
|
527
537
|
state.setDragging(false);
|
|
528
538
|
currentPointer.current = undefined;
|
|
@@ -542,6 +552,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
542
552
|
if (direction === 'rtl') x = 1 - x;
|
|
543
553
|
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
544
554
|
isOnColorArea.current = true;
|
|
555
|
+
valueChangedViaKeyboard.current = false;
|
|
545
556
|
currentPointer.current = id;
|
|
546
557
|
state.setColorFromPoint(x, y);
|
|
547
558
|
focusInput();
|
|
@@ -559,6 +570,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
559
570
|
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
560
571
|
if (isOnColorArea.current && id === currentPointer.current) {
|
|
561
572
|
isOnColorArea.current = false;
|
|
573
|
+
valueChangedViaKeyboard.current = false;
|
|
562
574
|
currentPointer.current = undefined;
|
|
563
575
|
state.setDragging(false);
|
|
564
576
|
focusInput();
|
|
@@ -602,34 +614,53 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
602
614
|
onThumbDown(e.changedTouches[0].identifier);
|
|
603
615
|
}
|
|
604
616
|
}
|
|
605
|
-
}, keyboardProps, movePropsThumb);
|
|
617
|
+
}, focusWithinProps, keyboardProps, movePropsThumb);
|
|
618
|
+
let { focusProps: xInputFocusProps } = $7KHxM$useFocus({
|
|
619
|
+
onFocus: ()=>{
|
|
620
|
+
focusedInputRef.current = inputXRef.current;
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
let { focusProps: yInputFocusProps } = $7KHxM$useFocus({
|
|
624
|
+
onFocus: ()=>{
|
|
625
|
+
focusedInputRef.current = inputYRef.current;
|
|
626
|
+
}
|
|
627
|
+
});
|
|
606
628
|
let isMobile = $7KHxM$isIOS() || $7KHxM$isAndroid();
|
|
629
|
+
function getAriaValueTextForChannel(channel) {
|
|
630
|
+
return valueChangedViaKeyboard.current ? formatMessage('colorNameAndValue', {
|
|
631
|
+
name: state.value.getChannelName(channel, locale),
|
|
632
|
+
value: state.value.formatChannelValue(channel, locale)
|
|
633
|
+
}) : [
|
|
634
|
+
formatMessage('colorNameAndValue', {
|
|
635
|
+
name: state.value.getChannelName(channel, locale),
|
|
636
|
+
value: state.value.formatChannelValue(channel, locale)
|
|
637
|
+
}),
|
|
638
|
+
formatMessage('colorNameAndValue', {
|
|
639
|
+
name: state.value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
|
|
640
|
+
value: state.value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
|
|
641
|
+
})
|
|
642
|
+
].join(', ');
|
|
643
|
+
}
|
|
644
|
+
let colorPickerLabel = formatMessage('colorPicker');
|
|
607
645
|
let xInputLabellingProps = $7KHxM$useLabels({
|
|
608
646
|
...props,
|
|
609
|
-
'aria-label':
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
})
|
|
647
|
+
'aria-label': ariaLabel ? formatMessage('colorInputLabel', {
|
|
648
|
+
label: ariaLabel,
|
|
649
|
+
channelLabel: colorPickerLabel
|
|
650
|
+
}) : colorPickerLabel
|
|
613
651
|
});
|
|
614
652
|
let yInputLabellingProps = $7KHxM$useLabels({
|
|
615
653
|
...props,
|
|
616
|
-
'aria-label':
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
})
|
|
654
|
+
'aria-label': ariaLabel ? formatMessage('colorInputLabel', {
|
|
655
|
+
label: ariaLabel,
|
|
656
|
+
channelLabel: colorPickerLabel
|
|
657
|
+
}) : colorPickerLabel
|
|
620
658
|
});
|
|
621
|
-
let colorAriaLabellingProps = $7KHxM$useLabels(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
name: state.value.getChannelName(channel, locale),
|
|
627
|
-
value: state.value.formatChannelValue(channel, locale)
|
|
628
|
-
}))
|
|
629
|
-
);
|
|
630
|
-
return colorNamesAndValues.length ? colorNamesAndValues.join(', ') : null;
|
|
631
|
-
};
|
|
632
|
-
let ariaRoleDescription = isMobile ? null : formatMessage('twoDimensionalSlider');
|
|
659
|
+
let colorAriaLabellingProps = $7KHxM$useLabels({
|
|
660
|
+
...props,
|
|
661
|
+
'aria-label': ariaLabel ? `${ariaLabel} ${colorPickerLabel}` : undefined
|
|
662
|
+
}, isMobile ? colorPickerLabel : undefined);
|
|
663
|
+
let ariaRoleDescription = formatMessage('twoDimensionalSlider');
|
|
633
664
|
let { visuallyHiddenProps: visuallyHiddenProps } = $7KHxM$useVisuallyHidden({
|
|
634
665
|
style: {
|
|
635
666
|
opacity: '0.0001',
|
|
@@ -664,28 +695,21 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
664
695
|
xInputProps: {
|
|
665
696
|
...xInputLabellingProps,
|
|
666
697
|
...visuallyHiddenProps,
|
|
698
|
+
...xInputFocusProps,
|
|
667
699
|
type: 'range',
|
|
668
700
|
min: state.value.getChannelRange(xChannel).minValue,
|
|
669
701
|
max: state.value.getChannelRange(xChannel).maxValue,
|
|
670
702
|
step: xChannelStep1,
|
|
671
703
|
'aria-roledescription': ariaRoleDescription,
|
|
672
|
-
'aria-valuetext':
|
|
673
|
-
name: state.value.getChannelName(xChannel, locale),
|
|
674
|
-
value: state.value.formatChannelValue(xChannel, locale)
|
|
675
|
-
}) : [
|
|
676
|
-
formatMessage('colorNameAndValue', {
|
|
677
|
-
name: state.value.getChannelName(xChannel, locale),
|
|
678
|
-
value: state.value.formatChannelValue(xChannel, locale)
|
|
679
|
-
}),
|
|
680
|
-
formatMessage('colorNameAndValue', {
|
|
681
|
-
name: state.value.getChannelName(yChannel, locale),
|
|
682
|
-
value: state.value.formatChannelValue(yChannel, locale)
|
|
683
|
-
})
|
|
684
|
-
].join(', '),
|
|
685
|
-
title: getValueTitle(),
|
|
704
|
+
'aria-valuetext': getAriaValueTextForChannel(xChannel),
|
|
686
705
|
disabled: isDisabled,
|
|
687
706
|
value: state.value.getChannelValue(xChannel),
|
|
688
|
-
tabIndex:
|
|
707
|
+
tabIndex: isMobile || !focusedInputRef.current || focusedInputRef.current === inputXRef.current ? undefined : -1,
|
|
708
|
+
/*
|
|
709
|
+
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
710
|
+
add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
|
|
711
|
+
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
712
|
+
*/ 'aria-hidden': !isMobile && focusedInputRef.current === inputYRef.current && !valueChangedViaKeyboard.current ? 'true' : undefined,
|
|
689
713
|
onChange: (e)=>{
|
|
690
714
|
state.setXValue(parseFloat(e.target.value));
|
|
691
715
|
}
|
|
@@ -693,29 +717,22 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
693
717
|
yInputProps: {
|
|
694
718
|
...yInputLabellingProps,
|
|
695
719
|
...visuallyHiddenProps,
|
|
720
|
+
...yInputFocusProps,
|
|
696
721
|
type: 'range',
|
|
697
722
|
min: state.value.getChannelRange(yChannel).minValue,
|
|
698
723
|
max: state.value.getChannelRange(yChannel).maxValue,
|
|
699
724
|
step: yChannelStep1,
|
|
700
725
|
'aria-roledescription': ariaRoleDescription,
|
|
701
|
-
'aria-valuetext':
|
|
702
|
-
name: state.value.getChannelName(yChannel, locale),
|
|
703
|
-
value: state.value.formatChannelValue(yChannel, locale)
|
|
704
|
-
}) : [
|
|
705
|
-
formatMessage('colorNameAndValue', {
|
|
706
|
-
name: state.value.getChannelName(yChannel, locale),
|
|
707
|
-
value: state.value.formatChannelValue(yChannel, locale)
|
|
708
|
-
}),
|
|
709
|
-
formatMessage('colorNameAndValue', {
|
|
710
|
-
name: state.value.getChannelName(xChannel, locale),
|
|
711
|
-
value: state.value.formatChannelValue(xChannel, locale)
|
|
712
|
-
})
|
|
713
|
-
].join(', '),
|
|
726
|
+
'aria-valuetext': getAriaValueTextForChannel(yChannel),
|
|
714
727
|
'aria-orientation': 'vertical',
|
|
715
|
-
title: getValueTitle(),
|
|
716
728
|
disabled: isDisabled,
|
|
717
729
|
value: state.value.getChannelValue(yChannel),
|
|
718
|
-
tabIndex: -1,
|
|
730
|
+
tabIndex: isMobile || focusedInputRef.current === inputYRef.current ? undefined : -1,
|
|
731
|
+
/*
|
|
732
|
+
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
733
|
+
add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
|
|
734
|
+
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
735
|
+
*/ 'aria-hidden': isMobile || focusedInputRef.current === inputYRef.current || valueChangedViaKeyboard.current ? undefined : 'true',
|
|
719
736
|
onChange: (e)=>{
|
|
720
737
|
state.setYValue(parseFloat(e.target.value));
|
|
721
738
|
}
|