@react-aria/color 3.1.5 → 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/zh-TW.module.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var $b0fef28529309aa6$exports = {};
|
|
2
|
-
$b0fef28529309aa6$exports = {
|
|
3
|
-
"colorInputLabel": (args)=>`${args.label}\u{FF0C}${args.channelLabel}`,
|
|
4
|
-
"colorNameAndValue": (args)=>`${args.name}\u{FF1A}${args.value}`,
|
|
5
|
-
"colorPicker": `\u{6AA2}\u{8272}\u{5668}`,
|
|
6
|
-
"colorSwatch": `\u{8272}\u{7968}`,
|
|
7
|
-
"transparent": `\u{900F}\u{660E}`,
|
|
8
|
-
"twoDimensionalSlider": `2D \u{6ED1}\u{687F}`
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export {$b0fef28529309aa6$exports as default};
|
|
13
|
-
//# sourceMappingURL=zh-TW.module.js.map
|
package/dist/zh-TW.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAAA,4BAAiB;IAAG,mBAAmB,CAAC,OAAS,GAAG,KAAK,KAAK,CAAC,QAAC,EAAE,KAAK,YAAY,EAAE;IACnF,qBAAqB,CAAC,OAAS,GAAG,KAAK,IAAI,CAAC,QAAC,EAAE,KAAK,KAAK,EAAE;IAC3D,eAAe,CAAC,wBAAG,CAAC;IACpB,eAAe,CAAC,gBAAE,CAAC;IACnB,eAAe,CAAC,gBAAE,CAAC;IACnB,wBAAwB,CAAC,mBAAK,CAAC;AACjC","sources":["packages/@react-aria/color/intl/zh-TW.json"],"sourcesContent":["{\n \"colorInputLabel\": \"{label},{channelLabel}\",\n \"colorNameAndValue\": \"{name}:{value}\",\n \"colorPicker\": \"檢色器\",\n \"colorSwatch\": \"色票\",\n \"transparent\": \"透明\",\n \"twoDimensionalSlider\": \"2D 滑桿\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
|
package/src/useColorArea.ts
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {AriaColorAreaProps, ColorChannel} from '@react-types/color';
|
|
14
|
-
import {ColorAreaState} from '@react-stately/color';
|
|
15
|
-
import {DOMAttributes, RefObject} from '@react-types/shared';
|
|
16
|
-
import {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useFormReset, useGlobalListeners, useLabels} from '@react-aria/utils';
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
import intlMessages from '../intl/*.json';
|
|
19
|
-
import React, {ChangeEvent, InputHTMLAttributes, useCallback, useRef, useState} from 'react';
|
|
20
|
-
import {useColorAreaGradient} from './useColorAreaGradient';
|
|
21
|
-
import {useFocus, useFocusWithin, useKeyboard, useMove} from '@react-aria/interactions';
|
|
22
|
-
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
23
|
-
import {useVisuallyHidden} from '@react-aria/visually-hidden';
|
|
24
|
-
|
|
25
|
-
export interface ColorAreaAria {
|
|
26
|
-
/** Props for the color area container element. */
|
|
27
|
-
colorAreaProps: DOMAttributes,
|
|
28
|
-
/** Props for the thumb element. */
|
|
29
|
-
thumbProps: DOMAttributes,
|
|
30
|
-
/** Props for the visually hidden horizontal range input element. */
|
|
31
|
-
xInputProps: InputHTMLAttributes<HTMLInputElement>,
|
|
32
|
-
/** Props for the visually hidden vertical range input element. */
|
|
33
|
-
yInputProps: InputHTMLAttributes<HTMLInputElement>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface AriaColorAreaOptions extends AriaColorAreaProps {
|
|
37
|
-
/** A ref to the input that represents the x axis of the color area. */
|
|
38
|
-
inputXRef: RefObject<HTMLInputElement | null>,
|
|
39
|
-
/** A ref to the input that represents the y axis of the color area. */
|
|
40
|
-
inputYRef: RefObject<HTMLInputElement | null>,
|
|
41
|
-
/** A ref to the color area containing element. */
|
|
42
|
-
containerRef: RefObject<Element | null>
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Provides the behavior and accessibility implementation for a color area component.
|
|
47
|
-
* Color area allows users to adjust two channels of an RGB, HSL or HSB color value against a two-dimensional gradient background.
|
|
48
|
-
*/
|
|
49
|
-
export function useColorArea(props: AriaColorAreaOptions, state: ColorAreaState): ColorAreaAria {
|
|
50
|
-
let {
|
|
51
|
-
isDisabled,
|
|
52
|
-
inputXRef,
|
|
53
|
-
inputYRef,
|
|
54
|
-
containerRef,
|
|
55
|
-
'aria-label': ariaLabel,
|
|
56
|
-
xName,
|
|
57
|
-
yName,
|
|
58
|
-
form
|
|
59
|
-
} = props;
|
|
60
|
-
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/color');
|
|
61
|
-
|
|
62
|
-
let {addGlobalListener, removeGlobalListener} = useGlobalListeners();
|
|
63
|
-
|
|
64
|
-
let {direction, locale} = useLocale();
|
|
65
|
-
|
|
66
|
-
let [focusedInput, setFocusedInput] = useState<'x' | 'y' | null>(null);
|
|
67
|
-
let focusInput = useCallback((inputRef:RefObject<HTMLInputElement | null> = inputXRef) => {
|
|
68
|
-
if (inputRef.current) {
|
|
69
|
-
focusWithoutScrolling(inputRef.current);
|
|
70
|
-
}
|
|
71
|
-
}, [inputXRef]);
|
|
72
|
-
|
|
73
|
-
useFormReset(inputXRef, state.defaultValue, state.setValue);
|
|
74
|
-
|
|
75
|
-
let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);
|
|
76
|
-
let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);
|
|
77
|
-
let {xChannel, yChannel, zChannel} = state.channels;
|
|
78
|
-
let xChannelStep = state.xChannelStep;
|
|
79
|
-
let yChannelStep = state.yChannelStep;
|
|
80
|
-
|
|
81
|
-
let currentPosition = useRef<{x: number, y: number} | null>(null);
|
|
82
|
-
|
|
83
|
-
let {keyboardProps} = useKeyboard({
|
|
84
|
-
onKeyDown(e) {
|
|
85
|
-
// these are the cases that useMove doesn't handle
|
|
86
|
-
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
87
|
-
e.continuePropagation();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
91
|
-
e.preventDefault();
|
|
92
|
-
// remember to set this and unset it so that onChangeEnd is fired
|
|
93
|
-
state.setDragging(true);
|
|
94
|
-
setValueChangedViaKeyboard(true);
|
|
95
|
-
let dir;
|
|
96
|
-
switch (e.key) {
|
|
97
|
-
case 'PageUp':
|
|
98
|
-
state.incrementY(state.yChannelPageStep);
|
|
99
|
-
dir = 'y';
|
|
100
|
-
break;
|
|
101
|
-
case 'PageDown':
|
|
102
|
-
state.decrementY(state.yChannelPageStep);
|
|
103
|
-
dir = 'y';
|
|
104
|
-
break;
|
|
105
|
-
case 'Home':
|
|
106
|
-
direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
|
|
107
|
-
dir = 'x';
|
|
108
|
-
break;
|
|
109
|
-
case 'End':
|
|
110
|
-
direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
|
|
111
|
-
dir = 'x';
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
state.setDragging(false);
|
|
115
|
-
if (dir) {
|
|
116
|
-
let input = dir === 'x' ? inputXRef : inputYRef;
|
|
117
|
-
focusInput(input);
|
|
118
|
-
setFocusedInput(dir);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
let moveHandler = {
|
|
124
|
-
onMoveStart() {
|
|
125
|
-
currentPosition.current = null;
|
|
126
|
-
state.setDragging(true);
|
|
127
|
-
},
|
|
128
|
-
onMove({deltaX, deltaY, pointerType, shiftKey}) {
|
|
129
|
-
let {
|
|
130
|
-
incrementX,
|
|
131
|
-
decrementX,
|
|
132
|
-
incrementY,
|
|
133
|
-
decrementY,
|
|
134
|
-
xChannelPageStep,
|
|
135
|
-
xChannelStep,
|
|
136
|
-
yChannelPageStep,
|
|
137
|
-
yChannelStep,
|
|
138
|
-
getThumbPosition,
|
|
139
|
-
setColorFromPoint
|
|
140
|
-
} = state;
|
|
141
|
-
if (currentPosition.current == null) {
|
|
142
|
-
currentPosition.current = getThumbPosition();
|
|
143
|
-
}
|
|
144
|
-
let {width, height} = containerRef.current?.getBoundingClientRect() || {width: 0, height: 0};
|
|
145
|
-
let valueChanged = deltaX !== 0 || deltaY !== 0;
|
|
146
|
-
if (pointerType === 'keyboard') {
|
|
147
|
-
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
148
|
-
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
149
|
-
if ((deltaX > 0 && direction === 'ltr') || (deltaX < 0 && direction === 'rtl')) {
|
|
150
|
-
incrementX(deltaXValue);
|
|
151
|
-
} else if ((deltaX < 0 && direction === 'ltr') || (deltaX > 0 && direction === 'rtl')) {
|
|
152
|
-
decrementX(deltaXValue);
|
|
153
|
-
} else if (deltaY > 0) {
|
|
154
|
-
decrementY(deltaYValue);
|
|
155
|
-
} else if (deltaY < 0) {
|
|
156
|
-
incrementY(deltaYValue);
|
|
157
|
-
}
|
|
158
|
-
setValueChangedViaKeyboard(valueChanged);
|
|
159
|
-
// set the focused input based on which axis has the greater delta
|
|
160
|
-
focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';
|
|
161
|
-
setFocusedInput(focusedInput);
|
|
162
|
-
} else {
|
|
163
|
-
currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width ;
|
|
164
|
-
currentPosition.current.y += deltaY / height;
|
|
165
|
-
setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
onMoveEnd() {
|
|
169
|
-
isOnColorArea.current = false;
|
|
170
|
-
state.setDragging(false);
|
|
171
|
-
let input = focusedInput === 'x' ? inputXRef : inputYRef;
|
|
172
|
-
focusInput(input);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
let {moveProps: movePropsThumb} = useMove(moveHandler);
|
|
176
|
-
|
|
177
|
-
let {focusWithinProps} = useFocusWithin({
|
|
178
|
-
onFocusWithinChange: (focusWithin:boolean) => {
|
|
179
|
-
if (!focusWithin) {
|
|
180
|
-
setValueChangedViaKeyboard(false);
|
|
181
|
-
setValueChangedViaInputChangeEvent(false);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
let currentPointer = useRef<number | null | undefined>(undefined);
|
|
187
|
-
let isOnColorArea = useRef<boolean>(false);
|
|
188
|
-
let {moveProps: movePropsContainer} = useMove({
|
|
189
|
-
onMoveStart() {
|
|
190
|
-
if (isOnColorArea.current) {
|
|
191
|
-
moveHandler.onMoveStart();
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
onMove(e) {
|
|
195
|
-
if (isOnColorArea.current) {
|
|
196
|
-
moveHandler.onMove(e);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
onMoveEnd() {
|
|
200
|
-
if (isOnColorArea.current) {
|
|
201
|
-
moveHandler.onMoveEnd();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
let onThumbDown = (id: number | null | undefined) => {
|
|
207
|
-
if (!state.isDragging) {
|
|
208
|
-
currentPointer.current = id;
|
|
209
|
-
setValueChangedViaKeyboard(false);
|
|
210
|
-
focusInput();
|
|
211
|
-
state.setDragging(true);
|
|
212
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
213
|
-
addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
214
|
-
} else {
|
|
215
|
-
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
216
|
-
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
let onThumbUp = (e) => {
|
|
222
|
-
let id = e.pointerId ?? e.changedTouches?.[0].identifier;
|
|
223
|
-
if (id === currentPointer.current) {
|
|
224
|
-
setValueChangedViaKeyboard(false);
|
|
225
|
-
focusInput();
|
|
226
|
-
state.setDragging(false);
|
|
227
|
-
currentPointer.current = undefined;
|
|
228
|
-
isOnColorArea.current = false;
|
|
229
|
-
|
|
230
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
231
|
-
removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
232
|
-
} else {
|
|
233
|
-
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
234
|
-
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
let onColorAreaDown = (colorArea: Element, id: number | null | undefined, clientX: number, clientY: number) => {
|
|
240
|
-
let rect = colorArea.getBoundingClientRect();
|
|
241
|
-
let {width, height} = rect;
|
|
242
|
-
let x = (clientX - rect.x) / width;
|
|
243
|
-
let y = (clientY - rect.y) / height;
|
|
244
|
-
if (direction === 'rtl') {
|
|
245
|
-
x = 1 - x;
|
|
246
|
-
}
|
|
247
|
-
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
248
|
-
isOnColorArea.current = true;
|
|
249
|
-
setValueChangedViaKeyboard(false);
|
|
250
|
-
currentPointer.current = id;
|
|
251
|
-
state.setColorFromPoint(x, y);
|
|
252
|
-
|
|
253
|
-
focusInput();
|
|
254
|
-
state.setDragging(true);
|
|
255
|
-
|
|
256
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
257
|
-
addGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
258
|
-
} else {
|
|
259
|
-
addGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
260
|
-
addGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
let onColorAreaUp = (e) => {
|
|
266
|
-
let id = e.pointerId ?? e.changedTouches?.[0].identifier;
|
|
267
|
-
if (isOnColorArea.current && id === currentPointer.current) {
|
|
268
|
-
isOnColorArea.current = false;
|
|
269
|
-
setValueChangedViaKeyboard(false);
|
|
270
|
-
currentPointer.current = undefined;
|
|
271
|
-
state.setDragging(false);
|
|
272
|
-
focusInput();
|
|
273
|
-
|
|
274
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
275
|
-
removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
276
|
-
} else {
|
|
277
|
-
removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
278
|
-
removeGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
let colorAreaInteractions = isDisabled ? {} : mergeProps({
|
|
284
|
-
...(typeof PointerEvent !== 'undefined' ? {
|
|
285
|
-
onPointerDown: (e: React.PointerEvent) => {
|
|
286
|
-
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
290
|
-
}} : {
|
|
291
|
-
onMouseDown: (e: React.MouseEvent) => {
|
|
292
|
-
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
296
|
-
},
|
|
297
|
-
onTouchStart: (e: React.TouchEvent) => {
|
|
298
|
-
onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
299
|
-
}
|
|
300
|
-
})
|
|
301
|
-
}, movePropsContainer);
|
|
302
|
-
|
|
303
|
-
let thumbInteractions = isDisabled ? {} : mergeProps({
|
|
304
|
-
...(typeof PointerEvent !== 'undefined' ? {
|
|
305
|
-
onPointerDown: (e: React.PointerEvent) => {
|
|
306
|
-
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
onThumbDown(e.pointerId);
|
|
310
|
-
}} : {
|
|
311
|
-
onMouseDown: (e: React.MouseEvent) => {
|
|
312
|
-
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
onThumbDown(undefined);
|
|
316
|
-
},
|
|
317
|
-
onTouchStart: (e: React.TouchEvent) => {
|
|
318
|
-
onThumbDown(e.changedTouches[0].identifier);
|
|
319
|
-
}
|
|
320
|
-
})
|
|
321
|
-
}, focusWithinProps, keyboardProps, movePropsThumb);
|
|
322
|
-
|
|
323
|
-
let {focusProps: xInputFocusProps} = useFocus({
|
|
324
|
-
onFocus: () => {
|
|
325
|
-
setFocusedInput('x');
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
let {focusProps: yInputFocusProps} = useFocus({
|
|
330
|
-
onFocus: () => {
|
|
331
|
-
setFocusedInput('y');
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
const onChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
336
|
-
const {target} = e;
|
|
337
|
-
setValueChangedViaInputChangeEvent(true);
|
|
338
|
-
if (target === inputXRef.current) {
|
|
339
|
-
state.setXValue(parseFloat(target.value));
|
|
340
|
-
} else if (target === inputYRef.current) {
|
|
341
|
-
state.setYValue(parseFloat(target.value));
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
let isMobile = isIOS() || isAndroid();
|
|
346
|
-
|
|
347
|
-
let value = state.getDisplayColor();
|
|
348
|
-
const getAriaValueTextForChannel = useCallback((channel:ColorChannel) => {
|
|
349
|
-
const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
|
|
350
|
-
return `${
|
|
351
|
-
isAfterInput ?
|
|
352
|
-
stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)})
|
|
353
|
-
:
|
|
354
|
-
[
|
|
355
|
-
stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel, locale), value: value.formatChannelValue(channel, locale)}),
|
|
356
|
-
stringFormatter.format('colorNameAndValue', {name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale), value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)}),
|
|
357
|
-
stringFormatter.format('colorNameAndValue', {name: value.getChannelName(zChannel, locale), value: value.formatChannelValue(zChannel, locale)})
|
|
358
|
-
].join(', ')
|
|
359
|
-
}, ${value.getColorName(locale)}`;
|
|
360
|
-
}, [locale, value, stringFormatter, valueChangedViaInputChangeEvent, valueChangedViaKeyboard, xChannel, yChannel, zChannel]);
|
|
361
|
-
|
|
362
|
-
let colorPickerLabel = stringFormatter.format('colorPicker');
|
|
363
|
-
|
|
364
|
-
let xInputLabellingProps = useLabels({
|
|
365
|
-
...props,
|
|
366
|
-
'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
let yInputLabellingProps = useLabels({
|
|
370
|
-
...props,
|
|
371
|
-
'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {label: ariaLabel, channelLabel: colorPickerLabel}) : colorPickerLabel
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
let colorAreaLabellingProps = useLabels(
|
|
375
|
-
{
|
|
376
|
-
...props,
|
|
377
|
-
'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
|
|
378
|
-
},
|
|
379
|
-
isMobile ? colorPickerLabel : undefined
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');
|
|
383
|
-
|
|
384
|
-
let {visuallyHiddenProps} = useVisuallyHidden({style: {
|
|
385
|
-
opacity: '0.0001',
|
|
386
|
-
width: '100%',
|
|
387
|
-
height: '100%',
|
|
388
|
-
pointerEvents: 'none'
|
|
389
|
-
}});
|
|
390
|
-
|
|
391
|
-
let {
|
|
392
|
-
colorAreaStyleProps,
|
|
393
|
-
thumbStyleProps
|
|
394
|
-
} = useColorAreaGradient({
|
|
395
|
-
direction,
|
|
396
|
-
state,
|
|
397
|
-
xChannel,
|
|
398
|
-
yChannel,
|
|
399
|
-
zChannel
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
return {
|
|
403
|
-
colorAreaProps: {
|
|
404
|
-
...colorAreaLabellingProps,
|
|
405
|
-
...colorAreaInteractions,
|
|
406
|
-
...colorAreaStyleProps,
|
|
407
|
-
role: 'group'
|
|
408
|
-
},
|
|
409
|
-
thumbProps: {
|
|
410
|
-
...thumbInteractions,
|
|
411
|
-
...thumbStyleProps,
|
|
412
|
-
role: 'presentation'
|
|
413
|
-
},
|
|
414
|
-
xInputProps: {
|
|
415
|
-
...xInputLabellingProps,
|
|
416
|
-
...visuallyHiddenProps,
|
|
417
|
-
...xInputFocusProps,
|
|
418
|
-
type: 'range',
|
|
419
|
-
min: state.value.getChannelRange(xChannel).minValue,
|
|
420
|
-
max: state.value.getChannelRange(xChannel).maxValue,
|
|
421
|
-
step: xChannelStep,
|
|
422
|
-
'aria-roledescription': ariaRoleDescription,
|
|
423
|
-
'aria-valuetext': getAriaValueTextForChannel(xChannel),
|
|
424
|
-
'aria-orientation': 'horizontal',
|
|
425
|
-
'aria-describedby': props['aria-describedby'],
|
|
426
|
-
'aria-details': props['aria-details'],
|
|
427
|
-
disabled: isDisabled,
|
|
428
|
-
value: state.value.getChannelValue(xChannel),
|
|
429
|
-
name: xName,
|
|
430
|
-
form,
|
|
431
|
-
tabIndex: (isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1),
|
|
432
|
-
/*
|
|
433
|
-
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
434
|
-
add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
|
|
435
|
-
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
436
|
-
*/
|
|
437
|
-
'aria-hidden': (isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true'),
|
|
438
|
-
onChange
|
|
439
|
-
},
|
|
440
|
-
yInputProps: {
|
|
441
|
-
...yInputLabellingProps,
|
|
442
|
-
...visuallyHiddenProps,
|
|
443
|
-
...yInputFocusProps,
|
|
444
|
-
type: 'range',
|
|
445
|
-
min: state.value.getChannelRange(yChannel).minValue,
|
|
446
|
-
max: state.value.getChannelRange(yChannel).maxValue,
|
|
447
|
-
step: yChannelStep,
|
|
448
|
-
'aria-roledescription': ariaRoleDescription,
|
|
449
|
-
'aria-valuetext': getAriaValueTextForChannel(yChannel),
|
|
450
|
-
'aria-orientation': 'vertical',
|
|
451
|
-
'aria-describedby': props['aria-describedby'],
|
|
452
|
-
'aria-details': props['aria-details'],
|
|
453
|
-
disabled: isDisabled,
|
|
454
|
-
value: state.value.getChannelValue(yChannel),
|
|
455
|
-
name: yName,
|
|
456
|
-
form,
|
|
457
|
-
tabIndex: (isMobile || focusedInput === 'y' ? undefined : -1),
|
|
458
|
-
/*
|
|
459
|
-
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
460
|
-
add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
|
|
461
|
-
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
462
|
-
*/
|
|
463
|
-
'aria-hidden': (isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true'),
|
|
464
|
-
onChange
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {Color, ColorChannel} from '@react-types/color';
|
|
14
|
-
import {ColorAreaState, parseColor} from '@react-stately/color';
|
|
15
|
-
import {CSSProperties, useMemo} from 'react';
|
|
16
|
-
|
|
17
|
-
const hue = (color: Color) => [0, 60, 120, 180, 240, 300, 360].map(hue => color.withChannelValue('hue', hue).toString('css')).join(', ');
|
|
18
|
-
const saturation = (color: Color) => `${color.withChannelValue('saturation', 0)}, transparent`;
|
|
19
|
-
|
|
20
|
-
const hslChannels = {
|
|
21
|
-
hue,
|
|
22
|
-
saturation,
|
|
23
|
-
lightness: () => 'black, transparent, white'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const hsbChannels = {
|
|
27
|
-
hue,
|
|
28
|
-
saturation,
|
|
29
|
-
brightness: () => 'black, transparent'
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
interface Gradients {
|
|
33
|
-
colorAreaStyleProps: {
|
|
34
|
-
style: CSSProperties
|
|
35
|
-
},
|
|
36
|
-
thumbStyleProps: {
|
|
37
|
-
style: CSSProperties
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ColorAreaGradientProps {
|
|
42
|
-
direction: 'ltr' | 'rtl',
|
|
43
|
-
state: ColorAreaState,
|
|
44
|
-
zChannel: ColorChannel,
|
|
45
|
-
xChannel: ColorChannel,
|
|
46
|
-
yChannel: ColorChannel
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function useColorAreaGradient({direction, state, zChannel, xChannel, yChannel}: ColorAreaGradientProps): Gradients {
|
|
50
|
-
let returnVal = useMemo<Gradients>(() => {
|
|
51
|
-
let end = direction === 'rtl' ? 'left' : 'right';
|
|
52
|
-
let colorAreaStyles = {};
|
|
53
|
-
let zValue = state.value.getChannelValue(zChannel);
|
|
54
|
-
|
|
55
|
-
switch (state.value.getColorSpace()) {
|
|
56
|
-
case 'rgb': {
|
|
57
|
-
let rgb = parseColor('rgb(0, 0, 0)');
|
|
58
|
-
colorAreaStyles = {
|
|
59
|
-
background: [
|
|
60
|
-
// The screen blend mode multiplies the inverse of each channel, e.g. 1 - (1 - a) * (1 - b).
|
|
61
|
-
// Create a layer for each channel, with the other channels as 0. After blending, this should
|
|
62
|
-
// result in the gradients being combined channel by channel.
|
|
63
|
-
`linear-gradient(to ${end}, ${rgb.withChannelValue(xChannel, 0)}, ${rgb.withChannelValue(xChannel, 255)})`,
|
|
64
|
-
`linear-gradient(to top, ${rgb.withChannelValue(yChannel, 0)}, ${rgb.withChannelValue(yChannel, 255)})`,
|
|
65
|
-
rgb.withChannelValue(zChannel, zValue)
|
|
66
|
-
].join(','),
|
|
67
|
-
backgroundBlendMode: 'screen'
|
|
68
|
-
};
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case 'hsl': {
|
|
72
|
-
let channels = state.value.getColorChannels();
|
|
73
|
-
let value = parseColor('hsl(0, 100%, 50%)').withChannelValue(zChannel, zValue);
|
|
74
|
-
|
|
75
|
-
let bg = channels
|
|
76
|
-
.filter(c => c !== zChannel)
|
|
77
|
-
.map(c => `linear-gradient(to ${c === xChannel ? end : 'top'}, ${hslChannels[c](value)})`)
|
|
78
|
-
.reverse();
|
|
79
|
-
if (zChannel === 'hue') {
|
|
80
|
-
bg.push(value.toString('css'));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
colorAreaStyles = {
|
|
84
|
-
background: bg.join(', ')
|
|
85
|
-
};
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case 'hsb': {
|
|
89
|
-
let channels = state.value.getColorChannels();
|
|
90
|
-
let value = parseColor('hsb(0, 100%, 100%)').withChannelValue(zChannel, zValue);
|
|
91
|
-
|
|
92
|
-
let bg = channels
|
|
93
|
-
.filter(c => c !== zChannel)
|
|
94
|
-
.map(c => `linear-gradient(to ${c === xChannel ? end : 'top'}, ${hsbChannels[c](value)})`)
|
|
95
|
-
.reverse();
|
|
96
|
-
if (zChannel === 'hue') {
|
|
97
|
-
bg.push(value.toString('css'));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
colorAreaStyles = {
|
|
101
|
-
background: bg.join(', ')
|
|
102
|
-
};
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let {x, y} = state.getThumbPosition();
|
|
108
|
-
|
|
109
|
-
if (direction === 'rtl') {
|
|
110
|
-
x = 1 - x;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
colorAreaStyleProps: {
|
|
117
|
-
style: {
|
|
118
|
-
position: 'relative',
|
|
119
|
-
touchAction: 'none',
|
|
120
|
-
...forcedColorAdjustNoneStyle,
|
|
121
|
-
...colorAreaStyles
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
thumbStyleProps: {
|
|
125
|
-
style: {
|
|
126
|
-
position: 'absolute',
|
|
127
|
-
left: `${x * 100}%`,
|
|
128
|
-
top: `${y * 100}%`,
|
|
129
|
-
transform: 'translate(-50%, -50%)',
|
|
130
|
-
touchAction: 'none',
|
|
131
|
-
...forcedColorAdjustNoneStyle
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}, [direction, state, zChannel, xChannel, yChannel]);
|
|
136
|
-
|
|
137
|
-
return returnVal;
|
|
138
|
-
}
|
|
139
|
-
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {AriaLabelingProps, RefObject} from '@react-types/shared';
|
|
14
|
-
import {ColorChannelFieldProps, ColorChannelFieldState} from '@react-stately/color';
|
|
15
|
-
import {NumberFieldAria, useNumberField} from '@react-aria/numberfield';
|
|
16
|
-
import {useLocale} from '@react-aria/i18n';
|
|
17
|
-
|
|
18
|
-
export interface AriaColorChannelFieldProps extends ColorChannelFieldProps, AriaLabelingProps {}
|
|
19
|
-
export interface ColorChannelFieldAria extends NumberFieldAria {}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Provides the behavior and accessibility implementation for a color channel field, allowing users to edit the
|
|
23
|
-
* value of an individual color channel.
|
|
24
|
-
*/
|
|
25
|
-
export function useColorChannelField(props: AriaColorChannelFieldProps, state: ColorChannelFieldState, inputRef: RefObject<HTMLInputElement | null>): ColorChannelFieldAria {
|
|
26
|
-
let {locale} = useLocale();
|
|
27
|
-
return useNumberField({
|
|
28
|
-
...props,
|
|
29
|
-
value: undefined,
|
|
30
|
-
defaultValue: undefined,
|
|
31
|
-
onChange: undefined,
|
|
32
|
-
validate: undefined,
|
|
33
|
-
// Provide a default aria-label if no other label is provided.
|
|
34
|
-
'aria-label': props['aria-label'] || (props.label || props['aria-labelledby'] ? undefined : state.colorValue.getChannelName(props.channel, locale))
|
|
35
|
-
}, state, inputRef);
|
|
36
|
-
}
|