@react-aria/color 3.0.0-beta.1 → 3.0.0-beta.10

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