@react-aria/color 3.0.0-beta.0 → 3.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1120 -460
- package/dist/main.js.map +1 -1
- package/dist/module.js +1123 -443
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +28 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -13
- package/src/index.ts +1 -0
- package/src/useColorArea.ts +447 -0
- package/src/useColorAreaGradient.ts +249 -0
- package/src/useColorField.ts +26 -13
- package/src/useColorWheel.ts +75 -50
package/dist/module.js
CHANGED
|
@@ -1,461 +1,1141 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useKeyboard, useMove } from "@react-aria/interactions";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
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
|
-
}
|
|
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, useFocus as $7KHxM$useFocus, 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";
|
|
62
9
|
|
|
63
|
-
|
|
64
|
-
|
|
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 + ")";
|
|
77
|
-
}
|
|
78
|
-
|
|
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 + ")";
|
|
89
|
-
}
|
|
90
|
-
|
|
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
|
-
};
|
|
10
|
+
function $parcel$interopDefault(a) {
|
|
11
|
+
return a && a.__esModule ? a.default : a;
|
|
122
12
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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();
|
|
175
|
-
}
|
|
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
|
-
}
|
|
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 = {};
|
|
186
17
|
|
|
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
|
-
}
|
|
18
|
+
$parcel$export($60bd7d6e45dcddfa$exports, "useColorArea", () => $60bd7d6e45dcddfa$export$2f92a7a615a014f6);
|
|
213
19
|
|
|
214
|
-
|
|
20
|
+
var $052cfdf4c32eb7c3$exports = {};
|
|
21
|
+
var $eccab2b0118aef08$exports = {};
|
|
22
|
+
$eccab2b0118aef08$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"أداة انتقاء اللون\",\"twoDimensionalSlider\":\"مُنزلق 2D\"}");
|
|
215
23
|
|
|
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
24
|
|
|
227
|
-
|
|
228
|
-
|
|
25
|
+
var $bf2b4507594e3d45$exports = {};
|
|
26
|
+
$bf2b4507594e3d45$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Средство за избиране на цвят\",\"twoDimensionalSlider\":\"2D плъзгач\"}");
|
|
229
27
|
|
|
230
|
-
let id = (_e$pointerId = e.pointerId) != null ? _e$pointerId : (_e$changedTouches = e.changedTouches) == null ? void 0 : _e$changedTouches[0].identifier;
|
|
231
28
|
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
};
|
|
29
|
+
var $01c08487af7ecd14$exports = {};
|
|
30
|
+
$01c08487af7ecd14$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Výběr barvy\",\"twoDimensionalSlider\":\"2D posuvník\"}");
|
|
260
31
|
|
|
261
|
-
let onTrackUp = e => {
|
|
262
|
-
var _e$pointerId2, _e$changedTouches2;
|
|
263
32
|
|
|
264
|
-
|
|
33
|
+
var $5e997db6ea0d10f6$exports = {};
|
|
34
|
+
$5e997db6ea0d10f6$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Farvevælger\",\"twoDimensionalSlider\":\"2D-skyder\"}");
|
|
265
35
|
|
|
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
36
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
37
|
+
var $fe5998f640a79fd2$exports = {};
|
|
38
|
+
$fe5998f640a79fd2$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Farbwähler\",\"twoDimensionalSlider\":\"2D-Schieberegler\"}");
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var $18e4d1d5b500a9ee$exports = {};
|
|
42
|
+
$18e4d1d5b500a9ee$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Επιλογέας χρωμάτων\",\"twoDimensionalSlider\":\"Ρυθμιστικό 2D\"}");
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var $bf90a11a7a42a0f7$exports = {};
|
|
46
|
+
$bf90a11a7a42a0f7$exports = JSON.parse("{\"colorPicker\":\"Color picker\",\"twoDimensionalSlider\":\"2D slider\",\"colorNameAndValue\":\"{name}: {value}\",\"colorInputLabel\":\"{label}, {channelLabel}\"}");
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
var $dd0d25f885b5c5f3$exports = {};
|
|
50
|
+
$dd0d25f885b5c5f3$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Selector de color\",\"twoDimensionalSlider\":\"Regulador 2D\"}");
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
var $d950967017e3485b$exports = {};
|
|
54
|
+
$d950967017e3485b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Värvivalija\",\"twoDimensionalSlider\":\"2D-liugur\"}");
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var $00a415a3f0ab315a$exports = {};
|
|
58
|
+
$00a415a3f0ab315a$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Värimuokkain\",\"twoDimensionalSlider\":\"2D-liukusäädin\"}");
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var $d80f30fe86c95741$exports = {};
|
|
62
|
+
$d80f30fe86c95741$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name} : {value}\",\"colorPicker\":\"Sélecteur de couleurs\",\"twoDimensionalSlider\":\"Curseur 2D\"}");
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
var $6912afb584340a2e$exports = {};
|
|
66
|
+
$6912afb584340a2e$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"בוחר הצבעים\",\"twoDimensionalSlider\":\"מחוון דו מימדי\"}");
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
var $7b97fcacd84ec90f$exports = {};
|
|
70
|
+
$7b97fcacd84ec90f$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Odabir boje\",\"twoDimensionalSlider\":\"2D klizač\"}");
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var $da9b443e89eebc6b$exports = {};
|
|
74
|
+
$da9b443e89eebc6b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Színválasztó\",\"twoDimensionalSlider\":\"2D-csúszka\"}");
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
var $35f135b45eb4d95b$exports = {};
|
|
78
|
+
$35f135b45eb4d95b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Selettore colore\",\"twoDimensionalSlider\":\"Cursore 2D\"}");
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
var $760b09448e39c6cd$exports = {};
|
|
82
|
+
$760b09448e39c6cd$exports = JSON.parse("{\"colorInputLabel\":\"{label}、{channelLabel}\",\"colorNameAndValue\":\"{name} : {value}\",\"colorPicker\":\"カラーピッカー\",\"twoDimensionalSlider\":\"2D スライダー\"}");
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
var $fc7b7d43be9703ec$exports = {};
|
|
86
|
+
$fc7b7d43be9703ec$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"색상 피커\",\"twoDimensionalSlider\":\"2D 슬라이더\"}");
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var $74918a1664156912$exports = {};
|
|
90
|
+
$74918a1664156912$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Spalvų parinkiklis\",\"twoDimensionalSlider\":\"2D slankiklis\"}");
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
var $4e6cde11c2bc9840$exports = {};
|
|
94
|
+
$4e6cde11c2bc9840$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Krāsu atlasītājs\",\"twoDimensionalSlider\":\"2D slīdnis\"}");
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
var $6faa3defebc3eb72$exports = {};
|
|
98
|
+
$6faa3defebc3eb72$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Fargevelger\",\"twoDimensionalSlider\":\"2D-glidebryter\"}");
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
var $6ac9b6b1b7e3ca12$exports = {};
|
|
102
|
+
$6ac9b6b1b7e3ca12$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Kleurkiezer\",\"twoDimensionalSlider\":\"2D-schuifregelaar\"}");
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
var $1be8b0ee8841f1e7$exports = {};
|
|
106
|
+
$1be8b0ee8841f1e7$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Próbnik kolorów\",\"twoDimensionalSlider\":\"Suwak 2D\"}");
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
var $f9507c2d404ed689$exports = {};
|
|
110
|
+
$f9507c2d404ed689$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Seletor de cores\",\"twoDimensionalSlider\":\"Controle deslizante 2D\"}");
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
var $8f872ea59c02d67e$exports = {};
|
|
114
|
+
$8f872ea59c02d67e$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Seletor de cores\",\"twoDimensionalSlider\":\"Controle deslizante 2D\"}");
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
var $b03b45b62a7ccae4$exports = {};
|
|
118
|
+
$b03b45b62a7ccae4$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Selector de culori\",\"twoDimensionalSlider\":\"Glisor 2D\"}");
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
var $f1107d94c09df9b8$exports = {};
|
|
122
|
+
$f1107d94c09df9b8$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Палитра цветов\",\"twoDimensionalSlider\":\"Ползунок 2D\"}");
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var $b61325f242fafc7c$exports = {};
|
|
126
|
+
$b61325f242fafc7c$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Výber farieb\",\"twoDimensionalSlider\":\"2D jazdec\"}");
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
var $f44b7cf39ac8f315$exports = {};
|
|
130
|
+
$f44b7cf39ac8f315$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Izbirnik barv\",\"twoDimensionalSlider\":\"2D drsnik\"}");
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
var $aa8cd83fc8d4982b$exports = {};
|
|
134
|
+
$aa8cd83fc8d4982b$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Birač boja\",\"twoDimensionalSlider\":\"2D klizač\"}");
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
var $7c4f4e5bb7c06f1e$exports = {};
|
|
138
|
+
$7c4f4e5bb7c06f1e$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Färgväljaren\",\"twoDimensionalSlider\":\"2D-reglage\"}");
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
var $8045cf930ef745aa$exports = {};
|
|
142
|
+
$8045cf930ef745aa$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Renk Seçici\",\"twoDimensionalSlider\":\"2D sürgü\"}");
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
var $ee2044a77f24b118$exports = {};
|
|
146
|
+
$ee2044a77f24b118$exports = JSON.parse("{\"colorInputLabel\":\"{label}, {channelLabel}\",\"colorNameAndValue\":\"{name}: {value}\",\"colorPicker\":\"Палітра кольорів\",\"twoDimensionalSlider\":\"Повзунок 2D\"}");
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
var $4e1dbc65a687dd93$exports = {};
|
|
150
|
+
$4e1dbc65a687dd93$exports = JSON.parse("{\"colorInputLabel\":\"{label}、{channelLabel}\",\"colorNameAndValue\":\"{name}:{value}\",\"colorPicker\":\"拾色器\",\"twoDimensionalSlider\":\"2D 滑块\"}");
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
var $b0fef28529309aa6$exports = {};
|
|
154
|
+
$b0fef28529309aa6$exports = JSON.parse("{\"colorInputLabel\":\"{label},{channelLabel}\",\"colorNameAndValue\":\"{name}:{value}\",\"colorPicker\":\"檢色器\",\"twoDimensionalSlider\":\"2D 滑桿\"}");
|
|
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(',')
|
|
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;
|
|
386
405
|
}
|
|
387
406
|
|
|
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
407
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
412
|
+
let { isDisabled: isDisabled , inputXRef: inputXRef , inputYRef: inputYRef , containerRef: containerRef , 'aria-label': ariaLabel } = 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
|
+
valueChangedViaKeyboard.current = true;
|
|
440
|
+
switch(e.key){
|
|
441
|
+
case 'PageUp':
|
|
442
|
+
stateRef.current.incrementY(stateRef.current.yChannelPageStep);
|
|
443
|
+
focusedInputRef.current = inputYRef.current;
|
|
444
|
+
break;
|
|
445
|
+
case 'PageDown':
|
|
446
|
+
stateRef.current.decrementY(stateRef.current.yChannelPageStep);
|
|
447
|
+
focusedInputRef.current = inputYRef.current;
|
|
448
|
+
break;
|
|
449
|
+
case 'Home':
|
|
450
|
+
direction === 'rtl' ? stateRef.current.incrementX(stateRef.current.xChannelPageStep) : stateRef.current.decrementX(stateRef.current.xChannelPageStep);
|
|
451
|
+
focusedInputRef.current = inputXRef.current;
|
|
452
|
+
break;
|
|
453
|
+
case 'End':
|
|
454
|
+
direction === 'rtl' ? stateRef.current.decrementX(stateRef.current.xChannelPageStep) : stateRef.current.incrementX(stateRef.current.xChannelPageStep);
|
|
455
|
+
focusedInputRef.current = inputXRef.current;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
stateRef.current.setDragging(false);
|
|
459
|
+
if (focusedInputRef.current) focusInput(focusedInputRef.current ? focusedInputRef : inputXRef);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
let moveHandler = {
|
|
463
|
+
onMoveStart () {
|
|
464
|
+
currentPosition.current = null;
|
|
465
|
+
stateRef.current.setDragging(true);
|
|
466
|
+
},
|
|
467
|
+
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType , shiftKey: shiftKey }) {
|
|
468
|
+
let { incrementX: incrementX , decrementX: decrementX , incrementY: incrementY , decrementY: decrementY , xChannelPageStep: xChannelPageStep , xChannelStep: xChannelStep , yChannelPageStep: yChannelPageStep , yChannelStep: yChannelStep , getThumbPosition: getThumbPosition , setColorFromPoint: setColorFromPoint } = stateRef.current;
|
|
469
|
+
if (currentPosition.current == null) currentPosition.current = getThumbPosition();
|
|
470
|
+
let { width: width , height: height } = containerRef.current.getBoundingClientRect();
|
|
471
|
+
let valueChanged = deltaX !== 0 || deltaY !== 0;
|
|
472
|
+
if (pointerType === 'keyboard') {
|
|
473
|
+
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
474
|
+
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
475
|
+
if (deltaX > 0 && direction === 'ltr' || deltaX < 0 && direction === 'rtl') incrementX(deltaXValue);
|
|
476
|
+
else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
|
|
477
|
+
else if (deltaY > 0) decrementY(deltaYValue);
|
|
478
|
+
else if (deltaY < 0) incrementY(deltaYValue);
|
|
479
|
+
valueChangedViaKeyboard.current = valueChanged;
|
|
480
|
+
// set the focused input based on which axis has the greater delta
|
|
481
|
+
focusedInputRef.current = valueChanged && 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
|
+
}
|
|
493
|
+
};
|
|
494
|
+
let { moveProps: movePropsThumb } = $7KHxM$useMove(moveHandler);
|
|
495
|
+
let valueChangedViaKeyboard = $7KHxM$useRef(false);
|
|
496
|
+
let { focusWithinProps: focusWithinProps } = $7KHxM$useFocusWithin({
|
|
497
|
+
onFocusWithinChange: (focusWithin)=>{
|
|
498
|
+
if (!focusWithin) {
|
|
499
|
+
valueChangedViaKeyboard.current = false;
|
|
500
|
+
focusedInputRef.current;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
let currentPointer = $7KHxM$useRef(undefined);
|
|
505
|
+
let isOnColorArea = $7KHxM$useRef(false);
|
|
506
|
+
let { moveProps: movePropsContainer } = $7KHxM$useMove({
|
|
507
|
+
onMoveStart () {
|
|
508
|
+
if (isOnColorArea.current) moveHandler.onMoveStart();
|
|
509
|
+
},
|
|
510
|
+
onMove (e) {
|
|
511
|
+
if (isOnColorArea.current) moveHandler.onMove(e);
|
|
512
|
+
},
|
|
513
|
+
onMoveEnd () {
|
|
514
|
+
if (isOnColorArea.current) moveHandler.onMoveEnd();
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
let onThumbDown = (id)=>{
|
|
518
|
+
if (!state.isDragging) {
|
|
519
|
+
currentPointer.current = id;
|
|
520
|
+
valueChangedViaKeyboard.current = false;
|
|
521
|
+
focusInput();
|
|
522
|
+
state.setDragging(true);
|
|
523
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
524
|
+
else {
|
|
525
|
+
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
526
|
+
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
let onThumbUp = (e)=>{
|
|
531
|
+
var ref;
|
|
532
|
+
var _pointerId;
|
|
533
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
534
|
+
if (id === currentPointer.current) {
|
|
535
|
+
valueChangedViaKeyboard.current = false;
|
|
536
|
+
focusInput();
|
|
537
|
+
state.setDragging(false);
|
|
538
|
+
currentPointer.current = undefined;
|
|
539
|
+
isOnColorArea.current = false;
|
|
540
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
541
|
+
else {
|
|
542
|
+
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
543
|
+
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
|
|
548
|
+
let rect = colorArea.getBoundingClientRect();
|
|
549
|
+
let { width: width , height: height } = rect;
|
|
550
|
+
let x = (clientX - rect.x) / width;
|
|
551
|
+
let y = (clientY - rect.y) / height;
|
|
552
|
+
if (direction === 'rtl') x = 1 - x;
|
|
553
|
+
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
554
|
+
isOnColorArea.current = true;
|
|
555
|
+
valueChangedViaKeyboard.current = false;
|
|
556
|
+
currentPointer.current = id;
|
|
557
|
+
state.setColorFromPoint(x, y);
|
|
558
|
+
focusInput();
|
|
559
|
+
state.setDragging(true);
|
|
560
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
561
|
+
else {
|
|
562
|
+
addGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
563
|
+
addGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
let onColorAreaUp = (e)=>{
|
|
568
|
+
var ref;
|
|
569
|
+
var _pointerId;
|
|
570
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
571
|
+
if (isOnColorArea.current && id === currentPointer.current) {
|
|
572
|
+
isOnColorArea.current = false;
|
|
573
|
+
valueChangedViaKeyboard.current = false;
|
|
574
|
+
currentPointer.current = undefined;
|
|
575
|
+
state.setDragging(false);
|
|
576
|
+
focusInput();
|
|
577
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
578
|
+
else {
|
|
579
|
+
removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
580
|
+
removeGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
let colorAreaInteractions = isDisabled ? {
|
|
585
|
+
} : $7KHxM$mergeProps({
|
|
586
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
587
|
+
onPointerDown: (e)=>{
|
|
588
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
589
|
+
onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
590
|
+
}
|
|
591
|
+
} : {
|
|
592
|
+
onMouseDown: (e)=>{
|
|
593
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
594
|
+
onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
595
|
+
},
|
|
596
|
+
onTouchStart: (e)=>{
|
|
597
|
+
onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}, movePropsContainer);
|
|
601
|
+
let thumbInteractions = isDisabled ? {
|
|
602
|
+
} : $7KHxM$mergeProps({
|
|
603
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
604
|
+
onPointerDown: (e)=>{
|
|
605
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
606
|
+
onThumbDown(e.pointerId);
|
|
607
|
+
}
|
|
608
|
+
} : {
|
|
609
|
+
onMouseDown: (e)=>{
|
|
610
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
611
|
+
onThumbDown(undefined);
|
|
612
|
+
},
|
|
613
|
+
onTouchStart: (e)=>{
|
|
614
|
+
onThumbDown(e.changedTouches[0].identifier);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}, focusWithinProps, keyboardProps, movePropsThumb);
|
|
618
|
+
let { focusProps: xInputFocusProps } = $7KHxM$useFocus({
|
|
619
|
+
onFocus: ()=>{
|
|
620
|
+
focusedInputRef.current = inputXRef.current;
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
let { focusProps: yInputFocusProps } = $7KHxM$useFocus({
|
|
624
|
+
onFocus: ()=>{
|
|
625
|
+
focusedInputRef.current = inputYRef.current;
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
let isMobile = $7KHxM$isIOS() || $7KHxM$isAndroid();
|
|
629
|
+
function getAriaValueTextForChannel(channel) {
|
|
630
|
+
return valueChangedViaKeyboard.current ? formatMessage('colorNameAndValue', {
|
|
631
|
+
name: state.value.getChannelName(channel, locale),
|
|
632
|
+
value: state.value.formatChannelValue(channel, locale)
|
|
633
|
+
}) : [
|
|
634
|
+
formatMessage('colorNameAndValue', {
|
|
635
|
+
name: state.value.getChannelName(channel, locale),
|
|
636
|
+
value: state.value.formatChannelValue(channel, locale)
|
|
637
|
+
}),
|
|
638
|
+
formatMessage('colorNameAndValue', {
|
|
639
|
+
name: state.value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
|
|
640
|
+
value: state.value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
|
|
641
|
+
})
|
|
642
|
+
].join(', ');
|
|
434
643
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
644
|
+
let colorPickerLabel = formatMessage('colorPicker');
|
|
645
|
+
let xInputLabellingProps = $7KHxM$useLabels({
|
|
646
|
+
...props,
|
|
647
|
+
'aria-label': ariaLabel ? formatMessage('colorInputLabel', {
|
|
648
|
+
label: ariaLabel,
|
|
649
|
+
channelLabel: colorPickerLabel
|
|
650
|
+
}) : colorPickerLabel
|
|
651
|
+
});
|
|
652
|
+
let yInputLabellingProps = $7KHxM$useLabels({
|
|
653
|
+
...props,
|
|
654
|
+
'aria-label': ariaLabel ? formatMessage('colorInputLabel', {
|
|
655
|
+
label: ariaLabel,
|
|
656
|
+
channelLabel: colorPickerLabel
|
|
657
|
+
}) : colorPickerLabel
|
|
658
|
+
});
|
|
659
|
+
let colorAriaLabellingProps = $7KHxM$useLabels({
|
|
660
|
+
...props,
|
|
661
|
+
'aria-label': ariaLabel ? `${ariaLabel} ${colorPickerLabel}` : undefined
|
|
662
|
+
}, isMobile ? colorPickerLabel : undefined);
|
|
663
|
+
let ariaRoleDescription = formatMessage('twoDimensionalSlider');
|
|
664
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = $7KHxM$useVisuallyHidden({
|
|
665
|
+
style: {
|
|
666
|
+
opacity: '0.0001',
|
|
667
|
+
width: '100%',
|
|
668
|
+
height: '100%',
|
|
669
|
+
pointerEvents: 'none'
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
let { colorAreaStyleProps: colorAreaStyleProps , gradientStyleProps: gradientStyleProps , thumbStyleProps: thumbStyleProps } = $40297c24c53588e6$export$dd62420467d245ca({
|
|
673
|
+
direction: direction,
|
|
674
|
+
state: state,
|
|
675
|
+
xChannel: xChannel,
|
|
676
|
+
zChannel: zChannel,
|
|
677
|
+
isDisabled: props.isDisabled
|
|
678
|
+
});
|
|
679
|
+
return {
|
|
680
|
+
colorAreaProps: {
|
|
681
|
+
...colorAriaLabellingProps,
|
|
682
|
+
...colorAreaInteractions,
|
|
683
|
+
...colorAreaStyleProps,
|
|
684
|
+
role: 'group'
|
|
685
|
+
},
|
|
686
|
+
gradientProps: {
|
|
687
|
+
...gradientStyleProps,
|
|
688
|
+
role: 'presentation'
|
|
689
|
+
},
|
|
690
|
+
thumbProps: {
|
|
691
|
+
...thumbInteractions,
|
|
692
|
+
...thumbStyleProps,
|
|
693
|
+
role: 'presentation'
|
|
694
|
+
},
|
|
695
|
+
xInputProps: {
|
|
696
|
+
...xInputLabellingProps,
|
|
697
|
+
...visuallyHiddenProps,
|
|
698
|
+
...xInputFocusProps,
|
|
699
|
+
type: 'range',
|
|
700
|
+
min: state.value.getChannelRange(xChannel).minValue,
|
|
701
|
+
max: state.value.getChannelRange(xChannel).maxValue,
|
|
702
|
+
step: xChannelStep1,
|
|
703
|
+
'aria-roledescription': ariaRoleDescription,
|
|
704
|
+
'aria-valuetext': getAriaValueTextForChannel(xChannel),
|
|
705
|
+
disabled: isDisabled,
|
|
706
|
+
value: state.value.getChannelValue(xChannel),
|
|
707
|
+
tabIndex: isMobile || !focusedInputRef.current || focusedInputRef.current === inputXRef.current ? undefined : -1,
|
|
708
|
+
/*
|
|
709
|
+
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
710
|
+
add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
|
|
711
|
+
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
712
|
+
*/ 'aria-hidden': !isMobile && focusedInputRef.current === inputYRef.current && !valueChangedViaKeyboard.current ? 'true' : undefined,
|
|
713
|
+
onChange: (e)=>{
|
|
714
|
+
state.setXValue(parseFloat(e.target.value));
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
yInputProps: {
|
|
718
|
+
...yInputLabellingProps,
|
|
719
|
+
...visuallyHiddenProps,
|
|
720
|
+
...yInputFocusProps,
|
|
721
|
+
type: 'range',
|
|
722
|
+
min: state.value.getChannelRange(yChannel).minValue,
|
|
723
|
+
max: state.value.getChannelRange(yChannel).maxValue,
|
|
724
|
+
step: yChannelStep1,
|
|
725
|
+
'aria-roledescription': ariaRoleDescription,
|
|
726
|
+
'aria-valuetext': getAriaValueTextForChannel(yChannel),
|
|
727
|
+
'aria-orientation': 'vertical',
|
|
728
|
+
disabled: isDisabled,
|
|
729
|
+
value: state.value.getChannelValue(yChannel),
|
|
730
|
+
tabIndex: isMobile || focusedInputRef.current === inputYRef.current ? undefined : -1,
|
|
731
|
+
/*
|
|
732
|
+
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
733
|
+
add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
|
|
734
|
+
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
735
|
+
*/ 'aria-hidden': isMobile || focusedInputRef.current === inputYRef.current || valueChangedViaKeyboard.current ? undefined : 'true',
|
|
736
|
+
onChange: (e)=>{
|
|
737
|
+
state.setYValue(parseFloat(e.target.value));
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
var $40af666d6c251e36$exports = {};
|
|
745
|
+
|
|
746
|
+
$parcel$export($40af666d6c251e36$exports, "useColorSlider", () => $40af666d6c251e36$export$106b7a4e66508f66);
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
|
|
751
|
+
let { trackRef: trackRef , inputRef: inputRef , orientation: orientation , channel: channel , 'aria-label': ariaLabel } = props;
|
|
752
|
+
let { locale: locale , direction: direction } = $7KHxM$useLocale();
|
|
753
|
+
// Provide a default aria-label if there is no other label provided.
|
|
754
|
+
if (!props.label && !ariaLabel && !props['aria-labelledby']) ariaLabel = state.value.getChannelName(channel, locale);
|
|
755
|
+
// @ts-ignore - ignore unused incompatible props
|
|
756
|
+
let { groupProps: groupProps , trackProps: trackProps , labelProps: labelProps , outputProps: outputProps } = $7KHxM$useSlider({
|
|
757
|
+
...props,
|
|
758
|
+
'aria-label': ariaLabel
|
|
759
|
+
}, state, trackRef);
|
|
760
|
+
let { inputProps: inputProps , thumbProps: thumbProps } = $7KHxM$useSliderThumb({
|
|
761
|
+
index: 0,
|
|
762
|
+
orientation: orientation,
|
|
763
|
+
isDisabled: props.isDisabled,
|
|
764
|
+
trackRef: trackRef,
|
|
765
|
+
inputRef: inputRef
|
|
766
|
+
}, state);
|
|
767
|
+
let generateBackground = ()=>{
|
|
768
|
+
let value = state.getDisplayColor();
|
|
769
|
+
let to;
|
|
770
|
+
if (orientation === 'vertical') to = 'top';
|
|
771
|
+
else if (direction === 'ltr') to = 'right';
|
|
772
|
+
else to = 'left';
|
|
773
|
+
switch(channel){
|
|
774
|
+
case 'hue':
|
|
775
|
+
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%)`;
|
|
776
|
+
case 'lightness':
|
|
777
|
+
{
|
|
778
|
+
// We have to add an extra color stop in the middle so that the hue shows up at all.
|
|
779
|
+
// Otherwise it will always just be black to white.
|
|
780
|
+
let min = state.getThumbMinValue(0);
|
|
781
|
+
let max = state.getThumbMaxValue(0);
|
|
782
|
+
let start = value.withChannelValue(channel, min).toString('css');
|
|
783
|
+
let middle = value.withChannelValue(channel, (max - min) / 2).toString('css');
|
|
784
|
+
let end = value.withChannelValue(channel, max).toString('css');
|
|
785
|
+
return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
|
|
786
|
+
}
|
|
787
|
+
case 'saturation':
|
|
788
|
+
case 'brightness':
|
|
789
|
+
case 'red':
|
|
790
|
+
case 'green':
|
|
791
|
+
case 'blue':
|
|
792
|
+
case 'alpha':
|
|
793
|
+
{
|
|
794
|
+
let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css');
|
|
795
|
+
let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css');
|
|
796
|
+
return `linear-gradient(to ${to}, ${start}, ${end})`;
|
|
797
|
+
}
|
|
798
|
+
default:
|
|
799
|
+
throw new Error('Unknown color channel: ' + channel);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
let thumbPosition = state.getThumbPercent(0);
|
|
803
|
+
if (orientation === 'vertical' || direction === 'rtl') thumbPosition = 1 - thumbPosition;
|
|
804
|
+
return {
|
|
805
|
+
trackProps: {
|
|
806
|
+
...$7KHxM$mergeProps(groupProps, trackProps),
|
|
807
|
+
style: {
|
|
808
|
+
position: 'relative',
|
|
809
|
+
touchAction: 'none',
|
|
810
|
+
background: generateBackground()
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
inputProps: inputProps,
|
|
814
|
+
thumbProps: {
|
|
815
|
+
...thumbProps,
|
|
816
|
+
style: {
|
|
817
|
+
touchAction: 'none',
|
|
818
|
+
position: 'absolute',
|
|
819
|
+
[orientation === 'vertical' ? 'top' : 'left']: `${thumbPosition * 100}%`,
|
|
820
|
+
transform: 'translate(-50%, -50%)'
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
labelProps: labelProps,
|
|
824
|
+
outputProps: outputProps
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
var $b4a0a4fdc900495e$exports = {};
|
|
830
|
+
|
|
831
|
+
$parcel$export($b4a0a4fdc900495e$exports, "useColorWheel", () => $b4a0a4fdc900495e$export$9064ff4e44b3729a);
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
|
|
837
|
+
let { isDisabled: isDisabled , innerRadius: innerRadius , outerRadius: outerRadius , 'aria-label': ariaLabel } = props;
|
|
838
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $7KHxM$useGlobalListeners();
|
|
839
|
+
let thumbRadius = (innerRadius + outerRadius) / 2;
|
|
840
|
+
let focusInput = $7KHxM$useCallback(()=>{
|
|
841
|
+
if (inputRef.current) $7KHxM$focusWithoutScrolling(inputRef.current);
|
|
842
|
+
}, [
|
|
843
|
+
inputRef
|
|
844
|
+
]);
|
|
845
|
+
let stateRef = $7KHxM$useRef(null);
|
|
846
|
+
stateRef.current = state;
|
|
847
|
+
let currentPosition = $7KHxM$useRef(null);
|
|
848
|
+
let { keyboardProps: keyboardProps } = $7KHxM$useKeyboard({
|
|
849
|
+
onKeyDown (e) {
|
|
850
|
+
// these are the cases that useMove doesn't handle
|
|
851
|
+
if (!/^(PageUp|PageDown)$/.test(e.key)) {
|
|
852
|
+
e.continuePropagation();
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
// same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
|
|
856
|
+
e.preventDefault();
|
|
857
|
+
// remember to set this and unset it so that onChangeEnd is fired
|
|
858
|
+
stateRef.current.setDragging(true);
|
|
859
|
+
switch(e.key){
|
|
860
|
+
case 'PageUp':
|
|
861
|
+
e.preventDefault();
|
|
862
|
+
state.increment(stateRef.current.pageStep);
|
|
863
|
+
break;
|
|
864
|
+
case 'PageDown':
|
|
865
|
+
e.preventDefault();
|
|
866
|
+
state.decrement(stateRef.current.pageStep);
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
stateRef.current.setDragging(false);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
let moveHandler = {
|
|
873
|
+
onMoveStart () {
|
|
874
|
+
currentPosition.current = null;
|
|
875
|
+
state.setDragging(true);
|
|
876
|
+
},
|
|
877
|
+
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType , shiftKey: shiftKey }) {
|
|
878
|
+
if (currentPosition.current == null) currentPosition.current = stateRef.current.getThumbPosition(thumbRadius);
|
|
879
|
+
currentPosition.current.x += deltaX;
|
|
880
|
+
currentPosition.current.y += deltaY;
|
|
881
|
+
if (pointerType === 'keyboard') {
|
|
882
|
+
if (deltaX > 0 || deltaY < 0) state.increment(shiftKey ? stateRef.current.pageStep : stateRef.current.step);
|
|
883
|
+
else if (deltaX < 0 || deltaY > 0) state.decrement(shiftKey ? stateRef.current.pageStep : stateRef.current.step);
|
|
884
|
+
} else stateRef.current.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
|
|
885
|
+
},
|
|
886
|
+
onMoveEnd () {
|
|
887
|
+
isOnTrack.current = undefined;
|
|
888
|
+
state.setDragging(false);
|
|
889
|
+
focusInput();
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
let { moveProps: movePropsThumb } = $7KHxM$useMove(moveHandler);
|
|
893
|
+
let currentPointer = $7KHxM$useRef(undefined);
|
|
894
|
+
let isOnTrack = $7KHxM$useRef(false);
|
|
895
|
+
let { moveProps: movePropsContainer } = $7KHxM$useMove({
|
|
896
|
+
onMoveStart () {
|
|
897
|
+
if (isOnTrack.current) moveHandler.onMoveStart();
|
|
898
|
+
},
|
|
899
|
+
onMove (e) {
|
|
900
|
+
if (isOnTrack.current) moveHandler.onMove(e);
|
|
901
|
+
},
|
|
902
|
+
onMoveEnd () {
|
|
903
|
+
if (isOnTrack.current) moveHandler.onMoveEnd();
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
let onThumbDown = (id)=>{
|
|
907
|
+
if (!state.isDragging) {
|
|
908
|
+
currentPointer.current = id;
|
|
909
|
+
focusInput();
|
|
910
|
+
state.setDragging(true);
|
|
911
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
912
|
+
else {
|
|
913
|
+
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
914
|
+
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
let onThumbUp = (e)=>{
|
|
919
|
+
var ref;
|
|
920
|
+
var _pointerId;
|
|
921
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
922
|
+
if (id === currentPointer.current) {
|
|
923
|
+
focusInput();
|
|
924
|
+
state.setDragging(false);
|
|
925
|
+
currentPointer.current = undefined;
|
|
926
|
+
isOnTrack.current = false;
|
|
927
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
928
|
+
else {
|
|
929
|
+
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
930
|
+
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
let onTrackDown = (track, id, pageX, pageY)=>{
|
|
935
|
+
let rect = track.getBoundingClientRect();
|
|
936
|
+
let x = pageX - rect.x - rect.width / 2;
|
|
937
|
+
let y = pageY - rect.y - rect.height / 2;
|
|
938
|
+
let radius = Math.sqrt(x * x + y * y);
|
|
939
|
+
if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
|
|
940
|
+
isOnTrack.current = true;
|
|
941
|
+
currentPointer.current = id;
|
|
942
|
+
stateRef.current.setHueFromPoint(x, y, radius);
|
|
943
|
+
focusInput();
|
|
944
|
+
state.setDragging(true);
|
|
945
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onTrackUp, false);
|
|
946
|
+
else {
|
|
947
|
+
addGlobalListener(window, 'mouseup', onTrackUp, false);
|
|
948
|
+
addGlobalListener(window, 'touchend', onTrackUp, false);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
let onTrackUp = (e)=>{
|
|
953
|
+
var ref;
|
|
954
|
+
var _pointerId;
|
|
955
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
956
|
+
if (isOnTrack.current && id === currentPointer.current) {
|
|
957
|
+
isOnTrack.current = false;
|
|
958
|
+
currentPointer.current = undefined;
|
|
959
|
+
state.setDragging(false);
|
|
960
|
+
focusInput();
|
|
961
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onTrackUp, false);
|
|
962
|
+
else {
|
|
963
|
+
removeGlobalListener(window, 'mouseup', onTrackUp, false);
|
|
964
|
+
removeGlobalListener(window, 'touchend', onTrackUp, false);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
let trackInteractions = isDisabled ? {
|
|
969
|
+
} : $7KHxM$mergeProps({
|
|
970
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
971
|
+
onPointerDown: (e)=>{
|
|
972
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
973
|
+
onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
974
|
+
}
|
|
975
|
+
} : {
|
|
976
|
+
onMouseDown: (e)=>{
|
|
977
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
978
|
+
onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);
|
|
979
|
+
},
|
|
980
|
+
onTouchStart: (e)=>{
|
|
981
|
+
onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}, movePropsContainer);
|
|
985
|
+
let thumbInteractions = isDisabled ? {
|
|
986
|
+
} : $7KHxM$mergeProps({
|
|
987
|
+
onMouseDown: (e)=>{
|
|
988
|
+
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
989
|
+
onThumbDown(undefined);
|
|
990
|
+
},
|
|
991
|
+
onPointerDown: (e)=>{
|
|
992
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
993
|
+
onThumbDown(e.pointerId);
|
|
994
|
+
},
|
|
995
|
+
onTouchStart: (e)=>{
|
|
996
|
+
onThumbDown(e.changedTouches[0].identifier);
|
|
997
|
+
}
|
|
998
|
+
}, keyboardProps, movePropsThumb);
|
|
999
|
+
let { x: x1 , y: y1 } = state.getThumbPosition(thumbRadius);
|
|
1000
|
+
// Provide a default aria-label if none is given
|
|
1001
|
+
let { locale: locale } = $7KHxM$useLocale();
|
|
1002
|
+
if (ariaLabel == null && props['aria-labelledby'] == null) ariaLabel = state.value.getChannelName('hue', locale);
|
|
1003
|
+
let inputLabellingProps = $7KHxM$useLabels({
|
|
1004
|
+
...props,
|
|
1005
|
+
'aria-label': ariaLabel
|
|
1006
|
+
});
|
|
1007
|
+
let { minValue: minValue , maxValue: maxValue , step: step } = state.value.getChannelRange('hue');
|
|
1008
|
+
return {
|
|
1009
|
+
trackProps: {
|
|
1010
|
+
...trackInteractions,
|
|
1011
|
+
style: {
|
|
1012
|
+
position: 'relative',
|
|
1013
|
+
touchAction: 'none',
|
|
1014
|
+
width: outerRadius * 2,
|
|
1015
|
+
height: outerRadius * 2,
|
|
1016
|
+
background: `
|
|
1017
|
+
conic-gradient(
|
|
1018
|
+
from 90deg,
|
|
1019
|
+
hsl(0, 100%, 50%),
|
|
1020
|
+
hsl(30, 100%, 50%),
|
|
1021
|
+
hsl(60, 100%, 50%),
|
|
1022
|
+
hsl(90, 100%, 50%),
|
|
1023
|
+
hsl(120, 100%, 50%),
|
|
1024
|
+
hsl(150, 100%, 50%),
|
|
1025
|
+
hsl(180, 100%, 50%),
|
|
1026
|
+
hsl(210, 100%, 50%),
|
|
1027
|
+
hsl(240, 100%, 50%),
|
|
1028
|
+
hsl(270, 100%, 50%),
|
|
1029
|
+
hsl(300, 100%, 50%),
|
|
1030
|
+
hsl(330, 100%, 50%),
|
|
1031
|
+
hsl(360, 100%, 50%)
|
|
1032
|
+
)
|
|
1033
|
+
`,
|
|
1034
|
+
clipPath: `path(evenodd, "${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, outerRadius)} ${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, innerRadius)}")`
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
thumbProps: {
|
|
1038
|
+
...thumbInteractions,
|
|
1039
|
+
style: {
|
|
1040
|
+
position: 'absolute',
|
|
1041
|
+
left: '50%',
|
|
1042
|
+
top: '50%',
|
|
1043
|
+
transform: `translate(calc(${x1}px - 50%), calc(${y1}px - 50%))`,
|
|
1044
|
+
touchAction: 'none'
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
inputProps: $7KHxM$mergeProps(inputLabellingProps, {
|
|
1048
|
+
type: 'range',
|
|
1049
|
+
min: String(minValue),
|
|
1050
|
+
max: String(maxValue),
|
|
1051
|
+
step: String(step),
|
|
1052
|
+
'aria-valuetext': state.value.formatChannelValue('hue', locale),
|
|
1053
|
+
disabled: isDisabled,
|
|
1054
|
+
value: `${state.value.getChannelValue('hue')}`,
|
|
1055
|
+
onChange: (e)=>{
|
|
1056
|
+
state.setHue(parseFloat(e.target.value));
|
|
1057
|
+
}
|
|
1058
|
+
})
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
// Creates an SVG path string for a circle.
|
|
1062
|
+
function $b4a0a4fdc900495e$var$circlePath(cx, cy, r) {
|
|
1063
|
+
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`;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
var $f6896b05b2ecad12$exports = {};
|
|
1068
|
+
|
|
1069
|
+
$parcel$export($f6896b05b2ecad12$exports, "useColorField", () => $f6896b05b2ecad12$export$77e32ca575a28fdf);
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
|
|
1076
|
+
let { isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired } = props;
|
|
1077
|
+
let { colorValue: colorValue , inputValue: inputValue , commit: commit , increment: increment , decrement: decrement , incrementToMax: incrementToMax , decrementToMin: decrementToMin } = state;
|
|
1078
|
+
let inputId = $7KHxM$useId();
|
|
1079
|
+
let { spinButtonProps: spinButtonProps } = $7KHxM$useSpinButton({
|
|
1080
|
+
isDisabled: isDisabled,
|
|
1081
|
+
isReadOnly: isReadOnly,
|
|
1082
|
+
isRequired: isRequired,
|
|
1083
|
+
maxValue: 16777215,
|
|
1084
|
+
minValue: 0,
|
|
1085
|
+
onIncrement: increment,
|
|
1086
|
+
onIncrementToMax: incrementToMax,
|
|
1087
|
+
onDecrement: decrement,
|
|
1088
|
+
onDecrementToMin: decrementToMin,
|
|
1089
|
+
value: colorValue ? colorValue.toHexInt() : undefined,
|
|
1090
|
+
textValue: colorValue ? colorValue.toString('hex') : undefined
|
|
1091
|
+
});
|
|
1092
|
+
let [focusWithin, setFocusWithin] = $7KHxM$useState(false);
|
|
1093
|
+
let { focusWithinProps: focusWithinProps } = $7KHxM$useFocusWithin({
|
|
1094
|
+
isDisabled: isDisabled,
|
|
1095
|
+
onFocusWithinChange: setFocusWithin
|
|
1096
|
+
});
|
|
1097
|
+
let onWheel = $7KHxM$useCallback((e)=>{
|
|
1098
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
|
|
1099
|
+
if (e.deltaY > 0) increment();
|
|
1100
|
+
else if (e.deltaY < 0) decrement();
|
|
1101
|
+
}, [
|
|
1102
|
+
decrement,
|
|
1103
|
+
increment
|
|
1104
|
+
]);
|
|
1105
|
+
// If the input isn't supposed to receive input, disable scrolling.
|
|
1106
|
+
let scrollingDisabled = isDisabled || isReadOnly || !focusWithin;
|
|
1107
|
+
$7KHxM$useScrollWheel({
|
|
1108
|
+
onScroll: onWheel,
|
|
1109
|
+
isDisabled: scrollingDisabled
|
|
1110
|
+
}, ref);
|
|
1111
|
+
let onChange = (value)=>{
|
|
1112
|
+
state.setInputValue(value);
|
|
1113
|
+
};
|
|
1114
|
+
let { labelProps: labelProps , inputProps: inputProps } = $7KHxM$useFormattedTextField($7KHxM$mergeProps(props, {
|
|
1115
|
+
id: inputId,
|
|
1116
|
+
value: inputValue,
|
|
1117
|
+
defaultValue: undefined,
|
|
1118
|
+
type: 'text',
|
|
1119
|
+
autoComplete: 'off',
|
|
1120
|
+
onChange: onChange
|
|
1121
|
+
}), state, ref);
|
|
1122
|
+
return {
|
|
1123
|
+
labelProps: labelProps,
|
|
1124
|
+
inputProps: $7KHxM$mergeProps(inputProps, spinButtonProps, focusWithinProps, {
|
|
1125
|
+
role: 'textbox',
|
|
1126
|
+
'aria-valuemax': null,
|
|
1127
|
+
'aria-valuemin': null,
|
|
1128
|
+
'aria-valuenow': null,
|
|
1129
|
+
'aria-valuetext': null,
|
|
1130
|
+
autoCorrect: 'off',
|
|
1131
|
+
spellCheck: 'false',
|
|
1132
|
+
onBlur: commit
|
|
1133
|
+
})
|
|
1134
|
+
};
|
|
460
1135
|
}
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
export {$60bd7d6e45dcddfa$export$2f92a7a615a014f6 as useColorArea, $40af666d6c251e36$export$106b7a4e66508f66 as useColorSlider, $b4a0a4fdc900495e$export$9064ff4e44b3729a as useColorWheel, $f6896b05b2ecad12$export$77e32ca575a28fdf as useColorField};
|
|
461
1141
|
//# sourceMappingURL=module.js.map
|