@react-aria/color 3.1.4 → 3.2.0
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/import.mjs +6 -8
- package/dist/main.js +11 -13
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -8
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +10 -0
- package/package.json +15 -23
- package/src/index.ts +11 -13
- package/dist/ar-AE.main.js +0 -11
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -13
- package/dist/ar-AE.module.js +0 -13
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -11
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -13
- package/dist/bg-BG.module.js +0 -13
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -11
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -13
- package/dist/cs-CZ.module.js +0 -13
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -11
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -13
- package/dist/da-DK.module.js +0 -13
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -11
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -13
- package/dist/de-DE.module.js +0 -13
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -11
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -13
- package/dist/el-GR.module.js +0 -13
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -11
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -13
- package/dist/en-US.module.js +0 -13
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -11
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -13
- package/dist/es-ES.module.js +0 -13
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -11
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -13
- package/dist/et-EE.module.js +0 -13
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -11
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -13
- package/dist/fi-FI.module.js +0 -13
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -11
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -13
- package/dist/fr-FR.module.js +0 -13
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -11
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -13
- package/dist/he-IL.module.js +0 -13
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -11
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -13
- package/dist/hr-HR.module.js +0 -13
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -11
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -13
- package/dist/hu-HU.module.js +0 -13
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -11
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -13
- package/dist/it-IT.module.js +0 -13
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -11
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -13
- package/dist/ja-JP.module.js +0 -13
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -11
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -13
- package/dist/ko-KR.module.js +0 -13
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -11
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -13
- package/dist/lt-LT.module.js +0 -13
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -11
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -13
- package/dist/lv-LV.module.js +0 -13
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -11
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -13
- package/dist/nb-NO.module.js +0 -13
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -11
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -13
- package/dist/nl-NL.module.js +0 -13
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -11
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -13
- package/dist/pl-PL.module.js +0 -13
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -11
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -13
- package/dist/pt-BR.module.js +0 -13
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -11
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -13
- package/dist/pt-PT.module.js +0 -13
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -11
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -13
- package/dist/ro-RO.module.js +0 -13
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -11
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -13
- package/dist/ru-RU.module.js +0 -13
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -11
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -13
- package/dist/sk-SK.module.js +0 -13
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -11
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -13
- package/dist/sl-SI.module.js +0 -13
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -11
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -13
- package/dist/sr-SP.module.js +0 -13
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -11
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -13
- package/dist/sv-SE.module.js +0 -13
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -11
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -13
- package/dist/tr-TR.module.js +0 -13
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -119
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -11
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -13
- package/dist/uk-UA.module.js +0 -13
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useColorArea.main.js +0 -400
- package/dist/useColorArea.main.js.map +0 -1
- package/dist/useColorArea.mjs +0 -395
- package/dist/useColorArea.module.js +0 -395
- package/dist/useColorArea.module.js.map +0 -1
- package/dist/useColorAreaGradient.main.js +0 -123
- package/dist/useColorAreaGradient.main.js.map +0 -1
- package/dist/useColorAreaGradient.mjs +0 -118
- package/dist/useColorAreaGradient.module.js +0 -118
- package/dist/useColorAreaGradient.module.js.map +0 -1
- package/dist/useColorChannelField.main.js +0 -36
- package/dist/useColorChannelField.main.js.map +0 -1
- package/dist/useColorChannelField.mjs +0 -31
- package/dist/useColorChannelField.module.js +0 -31
- package/dist/useColorChannelField.module.js.map +0 -1
- package/dist/useColorField.main.js +0 -101
- package/dist/useColorField.main.js.map +0 -1
- package/dist/useColorField.mjs +0 -96
- package/dist/useColorField.module.js +0 -96
- package/dist/useColorField.module.js.map +0 -1
- package/dist/useColorSlider.main.js +0 -133
- package/dist/useColorSlider.main.js.map +0 -1
- package/dist/useColorSlider.mjs +0 -128
- package/dist/useColorSlider.module.js +0 -128
- package/dist/useColorSlider.module.js.map +0 -1
- package/dist/useColorSwatch.main.js +0 -67
- package/dist/useColorSwatch.main.js.map +0 -1
- package/dist/useColorSwatch.mjs +0 -62
- package/dist/useColorSwatch.module.js +0 -62
- package/dist/useColorSwatch.module.js.map +0 -1
- package/dist/useColorWheel.main.js +0 -275
- package/dist/useColorWheel.main.js.map +0 -1
- package/dist/useColorWheel.mjs +0 -270
- package/dist/useColorWheel.module.js +0 -270
- package/dist/useColorWheel.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -11
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -13
- package/dist/zh-CN.module.js +0 -13
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -11
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -13
- package/dist/zh-TW.module.js +0 -13
- package/dist/zh-TW.module.js.map +0 -1
- package/src/useColorArea.ts +0 -467
- package/src/useColorAreaGradient.ts +0 -139
- package/src/useColorChannelField.ts +0 -36
- package/src/useColorField.ts +0 -142
- package/src/useColorSlider.ts +0 -151
- package/src/useColorSwatch.ts +0 -74
- package/src/useColorWheel.ts +0 -345
package/dist/useColorArea.mjs
DELETED
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
import $8t1z9$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
|
-
import {useColorAreaGradient as $40297c24c53588e6$export$dd62420467d245ca} from "./useColorAreaGradient.mjs";
|
|
3
|
-
import {useGlobalListeners as $8t1z9$useGlobalListeners, focusWithoutScrolling as $8t1z9$focusWithoutScrolling, useFormReset as $8t1z9$useFormReset, mergeProps as $8t1z9$mergeProps, isIOS as $8t1z9$isIOS, isAndroid as $8t1z9$isAndroid, useLabels as $8t1z9$useLabels} from "@react-aria/utils";
|
|
4
|
-
import {useState as $8t1z9$useState, useCallback as $8t1z9$useCallback, useRef as $8t1z9$useRef} from "react";
|
|
5
|
-
import {useKeyboard as $8t1z9$useKeyboard, useMove as $8t1z9$useMove, useFocusWithin as $8t1z9$useFocusWithin, useFocus as $8t1z9$useFocus} from "@react-aria/interactions";
|
|
6
|
-
import {useLocalizedStringFormatter as $8t1z9$useLocalizedStringFormatter, useLocale as $8t1z9$useLocale} from "@react-aria/i18n";
|
|
7
|
-
import {useVisuallyHidden as $8t1z9$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function $parcel$interopDefault(a) {
|
|
11
|
-
return a && a.__esModule ? a.default : a;
|
|
12
|
-
}
|
|
13
|
-
/*
|
|
14
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
-
*
|
|
19
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
-
* governing permissions and limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
31
|
-
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName, form: form } = props;
|
|
32
|
-
let stringFormatter = (0, $8t1z9$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8t1z9$intlStringsmodulejs))), '@react-aria/color');
|
|
33
|
-
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $8t1z9$useGlobalListeners)();
|
|
34
|
-
let { direction: direction, locale: locale } = (0, $8t1z9$useLocale)();
|
|
35
|
-
let [focusedInput, setFocusedInput] = (0, $8t1z9$useState)(null);
|
|
36
|
-
let focusInput = (0, $8t1z9$useCallback)((inputRef = inputXRef)=>{
|
|
37
|
-
if (inputRef.current) (0, $8t1z9$focusWithoutScrolling)(inputRef.current);
|
|
38
|
-
}, [
|
|
39
|
-
inputXRef
|
|
40
|
-
]);
|
|
41
|
-
(0, $8t1z9$useFormReset)(inputXRef, state.defaultValue, state.setValue);
|
|
42
|
-
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $8t1z9$useState)(false);
|
|
43
|
-
let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = (0, $8t1z9$useState)(false);
|
|
44
|
-
let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
|
|
45
|
-
let xChannelStep = state.xChannelStep;
|
|
46
|
-
let yChannelStep = state.yChannelStep;
|
|
47
|
-
let currentPosition = (0, $8t1z9$useRef)(null);
|
|
48
|
-
let { keyboardProps: keyboardProps } = (0, $8t1z9$useKeyboard)({
|
|
49
|
-
onKeyDown (e) {
|
|
50
|
-
// these are the cases that useMove doesn't handle
|
|
51
|
-
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
52
|
-
e.continuePropagation();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
// remember to set this and unset it so that onChangeEnd is fired
|
|
58
|
-
state.setDragging(true);
|
|
59
|
-
setValueChangedViaKeyboard(true);
|
|
60
|
-
let dir;
|
|
61
|
-
switch(e.key){
|
|
62
|
-
case 'PageUp':
|
|
63
|
-
state.incrementY(state.yChannelPageStep);
|
|
64
|
-
dir = 'y';
|
|
65
|
-
break;
|
|
66
|
-
case 'PageDown':
|
|
67
|
-
state.decrementY(state.yChannelPageStep);
|
|
68
|
-
dir = 'y';
|
|
69
|
-
break;
|
|
70
|
-
case 'Home':
|
|
71
|
-
direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
|
|
72
|
-
dir = 'x';
|
|
73
|
-
break;
|
|
74
|
-
case 'End':
|
|
75
|
-
direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
|
|
76
|
-
dir = 'x';
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
state.setDragging(false);
|
|
80
|
-
if (dir) {
|
|
81
|
-
let input = dir === 'x' ? inputXRef : inputYRef;
|
|
82
|
-
focusInput(input);
|
|
83
|
-
setFocusedInput(dir);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
let moveHandler = {
|
|
88
|
-
onMoveStart () {
|
|
89
|
-
currentPosition.current = null;
|
|
90
|
-
state.setDragging(true);
|
|
91
|
-
},
|
|
92
|
-
onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
|
|
93
|
-
var _containerRef_current;
|
|
94
|
-
let { incrementX: incrementX, decrementX: decrementX, incrementY: incrementY, decrementY: decrementY, xChannelPageStep: xChannelPageStep, xChannelStep: xChannelStep, yChannelPageStep: yChannelPageStep, yChannelStep: yChannelStep, getThumbPosition: getThumbPosition, setColorFromPoint: setColorFromPoint } = state;
|
|
95
|
-
if (currentPosition.current == null) currentPosition.current = getThumbPosition();
|
|
96
|
-
let { width: width, height: height } = ((_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect()) || {
|
|
97
|
-
width: 0,
|
|
98
|
-
height: 0
|
|
99
|
-
};
|
|
100
|
-
let valueChanged = deltaX !== 0 || deltaY !== 0;
|
|
101
|
-
if (pointerType === 'keyboard') {
|
|
102
|
-
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
103
|
-
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
104
|
-
if (deltaX > 0 && direction === 'ltr' || deltaX < 0 && direction === 'rtl') incrementX(deltaXValue);
|
|
105
|
-
else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
|
|
106
|
-
else if (deltaY > 0) decrementY(deltaYValue);
|
|
107
|
-
else if (deltaY < 0) incrementY(deltaYValue);
|
|
108
|
-
setValueChangedViaKeyboard(valueChanged);
|
|
109
|
-
// set the focused input based on which axis has the greater delta
|
|
110
|
-
focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';
|
|
111
|
-
setFocusedInput(focusedInput);
|
|
112
|
-
} else {
|
|
113
|
-
currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width;
|
|
114
|
-
currentPosition.current.y += deltaY / height;
|
|
115
|
-
setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
onMoveEnd () {
|
|
119
|
-
isOnColorArea.current = false;
|
|
120
|
-
state.setDragging(false);
|
|
121
|
-
let input = focusedInput === 'x' ? inputXRef : inputYRef;
|
|
122
|
-
focusInput(input);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
let { moveProps: movePropsThumb } = (0, $8t1z9$useMove)(moveHandler);
|
|
126
|
-
let { focusWithinProps: focusWithinProps } = (0, $8t1z9$useFocusWithin)({
|
|
127
|
-
onFocusWithinChange: (focusWithin)=>{
|
|
128
|
-
if (!focusWithin) {
|
|
129
|
-
setValueChangedViaKeyboard(false);
|
|
130
|
-
setValueChangedViaInputChangeEvent(false);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
let currentPointer = (0, $8t1z9$useRef)(undefined);
|
|
135
|
-
let isOnColorArea = (0, $8t1z9$useRef)(false);
|
|
136
|
-
let { moveProps: movePropsContainer } = (0, $8t1z9$useMove)({
|
|
137
|
-
onMoveStart () {
|
|
138
|
-
if (isOnColorArea.current) moveHandler.onMoveStart();
|
|
139
|
-
},
|
|
140
|
-
onMove (e) {
|
|
141
|
-
if (isOnColorArea.current) moveHandler.onMove(e);
|
|
142
|
-
},
|
|
143
|
-
onMoveEnd () {
|
|
144
|
-
if (isOnColorArea.current) moveHandler.onMoveEnd();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
let onThumbDown = (id)=>{
|
|
148
|
-
if (!state.isDragging) {
|
|
149
|
-
currentPointer.current = id;
|
|
150
|
-
setValueChangedViaKeyboard(false);
|
|
151
|
-
focusInput();
|
|
152
|
-
state.setDragging(true);
|
|
153
|
-
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
154
|
-
else {
|
|
155
|
-
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
156
|
-
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
let onThumbUp = (e)=>{
|
|
161
|
-
var _e_changedTouches;
|
|
162
|
-
var _e_pointerId;
|
|
163
|
-
let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
|
|
164
|
-
if (id === currentPointer.current) {
|
|
165
|
-
setValueChangedViaKeyboard(false);
|
|
166
|
-
focusInput();
|
|
167
|
-
state.setDragging(false);
|
|
168
|
-
currentPointer.current = undefined;
|
|
169
|
-
isOnColorArea.current = false;
|
|
170
|
-
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
171
|
-
else {
|
|
172
|
-
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
173
|
-
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
|
|
178
|
-
let rect = colorArea.getBoundingClientRect();
|
|
179
|
-
let { width: width, height: height } = rect;
|
|
180
|
-
let x = (clientX - rect.x) / width;
|
|
181
|
-
let y = (clientY - rect.y) / height;
|
|
182
|
-
if (direction === 'rtl') x = 1 - x;
|
|
183
|
-
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
184
|
-
isOnColorArea.current = true;
|
|
185
|
-
setValueChangedViaKeyboard(false);
|
|
186
|
-
currentPointer.current = id;
|
|
187
|
-
state.setColorFromPoint(x, y);
|
|
188
|
-
focusInput();
|
|
189
|
-
state.setDragging(true);
|
|
190
|
-
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
191
|
-
else {
|
|
192
|
-
addGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
193
|
-
addGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
let onColorAreaUp = (e)=>{
|
|
198
|
-
var _e_changedTouches;
|
|
199
|
-
var _e_pointerId;
|
|
200
|
-
let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
|
|
201
|
-
if (isOnColorArea.current && id === currentPointer.current) {
|
|
202
|
-
isOnColorArea.current = false;
|
|
203
|
-
setValueChangedViaKeyboard(false);
|
|
204
|
-
currentPointer.current = undefined;
|
|
205
|
-
state.setDragging(false);
|
|
206
|
-
focusInput();
|
|
207
|
-
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
208
|
-
else {
|
|
209
|
-
removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
210
|
-
removeGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
let colorAreaInteractions = isDisabled ? {} : (0, $8t1z9$mergeProps)({
|
|
215
|
-
...typeof PointerEvent !== 'undefined' ? {
|
|
216
|
-
onPointerDown: (e)=>{
|
|
217
|
-
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
218
|
-
onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
219
|
-
}
|
|
220
|
-
} : {
|
|
221
|
-
onMouseDown: (e)=>{
|
|
222
|
-
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
223
|
-
onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
224
|
-
},
|
|
225
|
-
onTouchStart: (e)=>{
|
|
226
|
-
onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}, movePropsContainer);
|
|
230
|
-
let thumbInteractions = isDisabled ? {} : (0, $8t1z9$mergeProps)({
|
|
231
|
-
...typeof PointerEvent !== 'undefined' ? {
|
|
232
|
-
onPointerDown: (e)=>{
|
|
233
|
-
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
234
|
-
onThumbDown(e.pointerId);
|
|
235
|
-
}
|
|
236
|
-
} : {
|
|
237
|
-
onMouseDown: (e)=>{
|
|
238
|
-
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
239
|
-
onThumbDown(undefined);
|
|
240
|
-
},
|
|
241
|
-
onTouchStart: (e)=>{
|
|
242
|
-
onThumbDown(e.changedTouches[0].identifier);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}, focusWithinProps, keyboardProps, movePropsThumb);
|
|
246
|
-
let { focusProps: xInputFocusProps } = (0, $8t1z9$useFocus)({
|
|
247
|
-
onFocus: ()=>{
|
|
248
|
-
setFocusedInput('x');
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
let { focusProps: yInputFocusProps } = (0, $8t1z9$useFocus)({
|
|
252
|
-
onFocus: ()=>{
|
|
253
|
-
setFocusedInput('y');
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
const onChange = (e)=>{
|
|
257
|
-
const { target: target } = e;
|
|
258
|
-
setValueChangedViaInputChangeEvent(true);
|
|
259
|
-
if (target === inputXRef.current) state.setXValue(parseFloat(target.value));
|
|
260
|
-
else if (target === inputYRef.current) state.setYValue(parseFloat(target.value));
|
|
261
|
-
};
|
|
262
|
-
let isMobile = (0, $8t1z9$isIOS)() || (0, $8t1z9$isAndroid)();
|
|
263
|
-
let value = state.getDisplayColor();
|
|
264
|
-
const getAriaValueTextForChannel = (0, $8t1z9$useCallback)((channel)=>{
|
|
265
|
-
const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
|
|
266
|
-
return `${isAfterInput ? stringFormatter.format('colorNameAndValue', {
|
|
267
|
-
name: value.getChannelName(channel, locale),
|
|
268
|
-
value: value.formatChannelValue(channel, locale)
|
|
269
|
-
}) : [
|
|
270
|
-
stringFormatter.format('colorNameAndValue', {
|
|
271
|
-
name: value.getChannelName(channel, locale),
|
|
272
|
-
value: value.formatChannelValue(channel, locale)
|
|
273
|
-
}),
|
|
274
|
-
stringFormatter.format('colorNameAndValue', {
|
|
275
|
-
name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
|
|
276
|
-
value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
|
|
277
|
-
}),
|
|
278
|
-
stringFormatter.format('colorNameAndValue', {
|
|
279
|
-
name: value.getChannelName(zChannel, locale),
|
|
280
|
-
value: value.formatChannelValue(zChannel, locale)
|
|
281
|
-
})
|
|
282
|
-
].join(', ')}, ${value.getColorName(locale)}`;
|
|
283
|
-
}, [
|
|
284
|
-
locale,
|
|
285
|
-
value,
|
|
286
|
-
stringFormatter,
|
|
287
|
-
valueChangedViaInputChangeEvent,
|
|
288
|
-
valueChangedViaKeyboard,
|
|
289
|
-
xChannel,
|
|
290
|
-
yChannel,
|
|
291
|
-
zChannel
|
|
292
|
-
]);
|
|
293
|
-
let colorPickerLabel = stringFormatter.format('colorPicker');
|
|
294
|
-
let xInputLabellingProps = (0, $8t1z9$useLabels)({
|
|
295
|
-
...props,
|
|
296
|
-
'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
|
|
297
|
-
label: ariaLabel,
|
|
298
|
-
channelLabel: colorPickerLabel
|
|
299
|
-
}) : colorPickerLabel
|
|
300
|
-
});
|
|
301
|
-
let yInputLabellingProps = (0, $8t1z9$useLabels)({
|
|
302
|
-
...props,
|
|
303
|
-
'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
|
|
304
|
-
label: ariaLabel,
|
|
305
|
-
channelLabel: colorPickerLabel
|
|
306
|
-
}) : colorPickerLabel
|
|
307
|
-
});
|
|
308
|
-
let colorAreaLabellingProps = (0, $8t1z9$useLabels)({
|
|
309
|
-
...props,
|
|
310
|
-
'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
|
|
311
|
-
}, isMobile ? colorPickerLabel : undefined);
|
|
312
|
-
let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');
|
|
313
|
-
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $8t1z9$useVisuallyHidden)({
|
|
314
|
-
style: {
|
|
315
|
-
opacity: '0.0001',
|
|
316
|
-
width: '100%',
|
|
317
|
-
height: '100%',
|
|
318
|
-
pointerEvents: 'none'
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
let { colorAreaStyleProps: colorAreaStyleProps, thumbStyleProps: thumbStyleProps } = (0, $40297c24c53588e6$export$dd62420467d245ca)({
|
|
322
|
-
direction: direction,
|
|
323
|
-
state: state,
|
|
324
|
-
xChannel: xChannel,
|
|
325
|
-
yChannel: yChannel,
|
|
326
|
-
zChannel: zChannel
|
|
327
|
-
});
|
|
328
|
-
return {
|
|
329
|
-
colorAreaProps: {
|
|
330
|
-
...colorAreaLabellingProps,
|
|
331
|
-
...colorAreaInteractions,
|
|
332
|
-
...colorAreaStyleProps,
|
|
333
|
-
role: 'group'
|
|
334
|
-
},
|
|
335
|
-
thumbProps: {
|
|
336
|
-
...thumbInteractions,
|
|
337
|
-
...thumbStyleProps,
|
|
338
|
-
role: 'presentation'
|
|
339
|
-
},
|
|
340
|
-
xInputProps: {
|
|
341
|
-
...xInputLabellingProps,
|
|
342
|
-
...visuallyHiddenProps,
|
|
343
|
-
...xInputFocusProps,
|
|
344
|
-
type: 'range',
|
|
345
|
-
min: state.value.getChannelRange(xChannel).minValue,
|
|
346
|
-
max: state.value.getChannelRange(xChannel).maxValue,
|
|
347
|
-
step: xChannelStep,
|
|
348
|
-
'aria-roledescription': ariaRoleDescription,
|
|
349
|
-
'aria-valuetext': getAriaValueTextForChannel(xChannel),
|
|
350
|
-
'aria-orientation': 'horizontal',
|
|
351
|
-
'aria-describedby': props['aria-describedby'],
|
|
352
|
-
'aria-details': props['aria-details'],
|
|
353
|
-
disabled: isDisabled,
|
|
354
|
-
value: state.value.getChannelValue(xChannel),
|
|
355
|
-
name: xName,
|
|
356
|
-
form: form,
|
|
357
|
-
tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
|
|
358
|
-
/*
|
|
359
|
-
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
360
|
-
add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
|
|
361
|
-
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
362
|
-
*/ 'aria-hidden': isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true',
|
|
363
|
-
onChange: onChange
|
|
364
|
-
},
|
|
365
|
-
yInputProps: {
|
|
366
|
-
...yInputLabellingProps,
|
|
367
|
-
...visuallyHiddenProps,
|
|
368
|
-
...yInputFocusProps,
|
|
369
|
-
type: 'range',
|
|
370
|
-
min: state.value.getChannelRange(yChannel).minValue,
|
|
371
|
-
max: state.value.getChannelRange(yChannel).maxValue,
|
|
372
|
-
step: yChannelStep,
|
|
373
|
-
'aria-roledescription': ariaRoleDescription,
|
|
374
|
-
'aria-valuetext': getAriaValueTextForChannel(yChannel),
|
|
375
|
-
'aria-orientation': 'vertical',
|
|
376
|
-
'aria-describedby': props['aria-describedby'],
|
|
377
|
-
'aria-details': props['aria-details'],
|
|
378
|
-
disabled: isDisabled,
|
|
379
|
-
value: state.value.getChannelValue(yChannel),
|
|
380
|
-
name: yName,
|
|
381
|
-
form: form,
|
|
382
|
-
tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
|
|
383
|
-
/*
|
|
384
|
-
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
385
|
-
add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
|
|
386
|
-
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
387
|
-
*/ 'aria-hidden': isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',
|
|
388
|
-
onChange: onChange
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
export {$60bd7d6e45dcddfa$export$2f92a7a615a014f6 as useColorArea};
|
|
395
|
-
//# sourceMappingURL=useColorArea.module.js.map
|