@react-aria/color 3.0.0-beta.3 → 3.0.0-beta.30

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,475 +1,1377 @@
1
- import { useSpinButton } from "@react-aria/spinbutton";
2
- import { useFormattedTextField } from "@react-aria/textfield";
3
- import { useKeyboard, useMove, useFocusWithin, useScrollWheel } from "@react-aria/interactions";
4
- import { useCallback, useRef, useState } 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
- }
1
+ import {useGlobalListeners as $7KHxM$useGlobalListeners, focusWithoutScrolling as $7KHxM$focusWithoutScrolling, useFormReset as $7KHxM$useFormReset, 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 {useState as $7KHxM$useState, useCallback as $7KHxM$useCallback, useRef as $7KHxM$useRef, useMemo as $7KHxM$useMemo} 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 {useLocalizedStringFormatter as $7KHxM$useLocalizedStringFormatter, 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 {privateValidationStateProp as $7KHxM$privateValidationStateProp} from "@react-stately/form";
8
+ import {useFormattedTextField as $7KHxM$useFormattedTextField} from "@react-aria/textfield";
9
+ import {useSpinButton as $7KHxM$useSpinButton} from "@react-aria/spinbutton";
62
10
 
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 + ")";
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
- };
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
122
14
  }
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();
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
- }
15
+ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */ /*
26
+ * Copyright 2020 Adobe. All rights reserved.
27
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
+ * you may not use this file except in compliance with the License. You may obtain a copy
29
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
30
+ *
31
+ * Unless required by applicable law or agreed to in writing, software distributed under
32
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
33
+ * OF ANY KIND, either express or implied. See the License for the specific language
34
+ * governing permissions and limitations under the License.
35
+ */
36
+ var $3493a52097159720$exports = {};
37
+ var $eccab2b0118aef08$exports = {};
38
+ $eccab2b0118aef08$exports = {
39
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
40
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
41
+ "colorPicker": `\u{623}\u{62F}\u{627}\u{629} \u{627}\u{646}\u{62A}\u{642}\u{627}\u{621} \u{627}\u{644}\u{644}\u{648}\u{646}`,
42
+ "twoDimensionalSlider": `\u{645}\u{64F}\u{646}\u{632}\u{644}\u{642} 2D`
43
+ };
186
44
 
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
45
 
214
- });
46
+ var $bf2b4507594e3d45$exports = {};
47
+ $bf2b4507594e3d45$exports = {
48
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
49
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
50
+ "colorPicker": `\u{421}\u{440}\u{435}\u{434}\u{441}\u{442}\u{432}\u{43E} \u{437}\u{430} \u{438}\u{437}\u{431}\u{438}\u{440}\u{430}\u{43D}\u{435} \u{43D}\u{430} \u{446}\u{432}\u{44F}\u{442}`,
51
+ "twoDimensionalSlider": `2D \u{43F}\u{43B}\u{44A}\u{437}\u{433}\u{430}\u{447}`
52
+ };
215
53
 
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
54
 
227
- let onThumbUp = e => {
228
- var _e$pointerId, _e$changedTouches;
55
+ var $01c08487af7ecd14$exports = {};
56
+ $01c08487af7ecd14$exports = {
57
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
58
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
59
+ "colorPicker": `V\xfdb\u{11B}r barvy`,
60
+ "twoDimensionalSlider": `2D posuvn\xedk`
61
+ };
229
62
 
230
- let id = (_e$pointerId = e.pointerId) != null ? _e$pointerId : (_e$changedTouches = e.changedTouches) == null ? void 0 : _e$changedTouches[0].identifier;
231
63
 
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
- };
64
+ var $5e997db6ea0d10f6$exports = {};
65
+ $5e997db6ea0d10f6$exports = {
66
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
67
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
68
+ "colorPicker": `Farvev\xe6lger`,
69
+ "twoDimensionalSlider": `2D-skyder`
70
+ };
260
71
 
261
- let onTrackUp = e => {
262
- var _e$pointerId2, _e$changedTouches2;
263
72
 
264
- let id = (_e$pointerId2 = e.pointerId) != null ? _e$pointerId2 : (_e$changedTouches2 = e.changedTouches) == null ? void 0 : _e$changedTouches2[0].identifier;
73
+ var $fe5998f640a79fd2$exports = {};
74
+ $fe5998f640a79fd2$exports = {
75
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
76
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
77
+ "colorPicker": `Farbw\xe4hler`,
78
+ "twoDimensionalSlider": `2D-Schieberegler`
79
+ };
265
80
 
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
81
 
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";
82
+ var $18e4d1d5b500a9ee$exports = {};
83
+ $18e4d1d5b500a9ee$exports = {
84
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
85
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
86
+ "colorPicker": `\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3BF}\u{3B3}\u{3AD}\u{3B1}\u{3C2} \u{3C7}\u{3C1}\u{3C9}\u{3BC}\u{3AC}\u{3C4}\u{3C9}\u{3BD}`,
87
+ "twoDimensionalSlider": `\u{3A1}\u{3C5}\u{3B8}\u{3BC}\u{3B9}\u{3C3}\u{3C4}\u{3B9}\u{3BA}\u{3CC} 2D`
88
+ };
89
+
90
+
91
+ var $bf90a11a7a42a0f7$exports = {};
92
+ $bf90a11a7a42a0f7$exports = {
93
+ "colorPicker": `Color picker`,
94
+ "twoDimensionalSlider": `2D slider`,
95
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
96
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`
97
+ };
98
+
99
+
100
+ var $dd0d25f885b5c5f3$exports = {};
101
+ $dd0d25f885b5c5f3$exports = {
102
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
103
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
104
+ "colorPicker": `Selector de color`,
105
+ "twoDimensionalSlider": `Regulador 2D`
106
+ };
107
+
108
+
109
+ var $d950967017e3485b$exports = {};
110
+ $d950967017e3485b$exports = {
111
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
112
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
113
+ "colorPicker": `V\xe4rvivalija`,
114
+ "twoDimensionalSlider": `2D-liugur`
115
+ };
116
+
117
+
118
+ var $00a415a3f0ab315a$exports = {};
119
+ $00a415a3f0ab315a$exports = {
120
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
121
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
122
+ "colorPicker": `V\xe4rimuokkain`,
123
+ "twoDimensionalSlider": `2D-liukus\xe4\xe4din`
124
+ };
125
+
126
+
127
+ var $d80f30fe86c95741$exports = {};
128
+ $d80f30fe86c95741$exports = {
129
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
130
+ "colorNameAndValue": (args)=>`${args.name}\xa0: ${args.value}`,
131
+ "colorPicker": `S\xe9lecteur de couleurs`,
132
+ "twoDimensionalSlider": `Curseur\xa02D`
133
+ };
134
+
135
+
136
+ var $6912afb584340a2e$exports = {};
137
+ $6912afb584340a2e$exports = {
138
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
139
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
140
+ "colorPicker": `\u{5D1}\u{5D5}\u{5D7}\u{5E8} \u{5D4}\u{5E6}\u{5D1}\u{5E2}\u{5D9}\u{5DD}`,
141
+ "twoDimensionalSlider": `\u{5DE}\u{5D7}\u{5D5}\u{5D5}\u{5DF} \u{5D3}\u{5D5} \u{5DE}\u{5D9}\u{5DE}\u{5D3}\u{5D9}`
142
+ };
143
+
144
+
145
+ var $7b97fcacd84ec90f$exports = {};
146
+ $7b97fcacd84ec90f$exports = {
147
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
148
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
149
+ "colorPicker": `Odabir boje`,
150
+ "twoDimensionalSlider": `2D kliza\u{10D}`
151
+ };
152
+
153
+
154
+ var $da9b443e89eebc6b$exports = {};
155
+ $da9b443e89eebc6b$exports = {
156
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
157
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
158
+ "colorPicker": `Sz\xednv\xe1laszt\xf3`,
159
+ "twoDimensionalSlider": `2D-cs\xfaszka`
160
+ };
161
+
162
+
163
+ var $35f135b45eb4d95b$exports = {};
164
+ $35f135b45eb4d95b$exports = {
165
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
166
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
167
+ "colorPicker": `Selettore colore`,
168
+ "twoDimensionalSlider": `Cursore 2D`
169
+ };
170
+
171
+
172
+ var $760b09448e39c6cd$exports = {};
173
+ $760b09448e39c6cd$exports = {
174
+ "colorInputLabel": (args)=>`${args.label}\u{3001}${args.channelLabel}`,
175
+ "colorNameAndValue": (args)=>`${args.name} : ${args.value}`,
176
+ "colorPicker": `\u{30AB}\u{30E9}\u{30FC}\u{30D4}\u{30C3}\u{30AB}\u{30FC}`,
177
+ "twoDimensionalSlider": `2D \u{30B9}\u{30E9}\u{30A4}\u{30C0}\u{30FC}`
178
+ };
179
+
180
+
181
+ var $fc7b7d43be9703ec$exports = {};
182
+ $fc7b7d43be9703ec$exports = {
183
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
184
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
185
+ "colorPicker": `\u{C0C9}\u{C0C1} \u{D53C}\u{CEE4}`,
186
+ "twoDimensionalSlider": `2D \u{C2AC}\u{B77C}\u{C774}\u{B354}`
187
+ };
188
+
189
+
190
+ var $74918a1664156912$exports = {};
191
+ $74918a1664156912$exports = {
192
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
193
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
194
+ "colorPicker": `Spalv\u{173} parinkiklis`,
195
+ "twoDimensionalSlider": `2D slankiklis`
196
+ };
197
+
198
+
199
+ var $4e6cde11c2bc9840$exports = {};
200
+ $4e6cde11c2bc9840$exports = {
201
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
202
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
203
+ "colorPicker": `Kr\u{101}su atlas\u{12B}t\u{101}js`,
204
+ "twoDimensionalSlider": `2D sl\u{12B}dnis`
205
+ };
206
+
207
+
208
+ var $6faa3defebc3eb72$exports = {};
209
+ $6faa3defebc3eb72$exports = {
210
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
211
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
212
+ "colorPicker": `Fargevelger`,
213
+ "twoDimensionalSlider": `2D-glidebryter`
214
+ };
215
+
216
+
217
+ var $6ac9b6b1b7e3ca12$exports = {};
218
+ $6ac9b6b1b7e3ca12$exports = {
219
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
220
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
221
+ "colorPicker": `Kleurkiezer`,
222
+ "twoDimensionalSlider": `2D-schuifregelaar`
223
+ };
224
+
225
+
226
+ var $1be8b0ee8841f1e7$exports = {};
227
+ $1be8b0ee8841f1e7$exports = {
228
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
229
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
230
+ "colorPicker": `Pr\xf3bnik kolor\xf3w`,
231
+ "twoDimensionalSlider": `Suwak 2D`
232
+ };
233
+
234
+
235
+ var $f9507c2d404ed689$exports = {};
236
+ $f9507c2d404ed689$exports = {
237
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
238
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
239
+ "colorPicker": `Seletor de cores`,
240
+ "twoDimensionalSlider": `Controle deslizante 2D`
241
+ };
242
+
243
+
244
+ var $8f872ea59c02d67e$exports = {};
245
+ $8f872ea59c02d67e$exports = {
246
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
247
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
248
+ "colorPicker": `Seletor de cores`,
249
+ "twoDimensionalSlider": `Controle deslizante 2D`
250
+ };
251
+
252
+
253
+ var $b03b45b62a7ccae4$exports = {};
254
+ $b03b45b62a7ccae4$exports = {
255
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
256
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
257
+ "colorPicker": `Selector de culori`,
258
+ "twoDimensionalSlider": `Glisor 2D`
259
+ };
260
+
261
+
262
+ var $f1107d94c09df9b8$exports = {};
263
+ $f1107d94c09df9b8$exports = {
264
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
265
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
266
+ "colorPicker": `\u{41F}\u{430}\u{43B}\u{438}\u{442}\u{440}\u{430} \u{446}\u{432}\u{435}\u{442}\u{43E}\u{432}`,
267
+ "twoDimensionalSlider": `\u{41F}\u{43E}\u{43B}\u{437}\u{443}\u{43D}\u{43E}\u{43A} 2D`
268
+ };
269
+
270
+
271
+ var $b61325f242fafc7c$exports = {};
272
+ $b61325f242fafc7c$exports = {
273
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
274
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
275
+ "colorPicker": `V\xfdber farieb`,
276
+ "twoDimensionalSlider": `2D jazdec`
277
+ };
278
+
279
+
280
+ var $f44b7cf39ac8f315$exports = {};
281
+ $f44b7cf39ac8f315$exports = {
282
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
283
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
284
+ "colorPicker": `Izbirnik barv`,
285
+ "twoDimensionalSlider": `2D drsnik`
286
+ };
287
+
288
+
289
+ var $aa8cd83fc8d4982b$exports = {};
290
+ $aa8cd83fc8d4982b$exports = {
291
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
292
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
293
+ "colorPicker": `Bira\u{10D} boja`,
294
+ "twoDimensionalSlider": `2D kliza\u{10D}`
295
+ };
296
+
297
+
298
+ var $7c4f4e5bb7c06f1e$exports = {};
299
+ $7c4f4e5bb7c06f1e$exports = {
300
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
301
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
302
+ "colorPicker": `F\xe4rgv\xe4ljaren`,
303
+ "twoDimensionalSlider": `2D-reglage`
304
+ };
305
+
306
+
307
+ var $8045cf930ef745aa$exports = {};
308
+ $8045cf930ef745aa$exports = {
309
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
310
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
311
+ "colorPicker": `Renk Se\xe7ici`,
312
+ "twoDimensionalSlider": `2D s\xfcrg\xfc`
313
+ };
314
+
315
+
316
+ var $ee2044a77f24b118$exports = {};
317
+ $ee2044a77f24b118$exports = {
318
+ "colorInputLabel": (args)=>`${args.label}, ${args.channelLabel}`,
319
+ "colorNameAndValue": (args)=>`${args.name}: ${args.value}`,
320
+ "colorPicker": `\u{41F}\u{430}\u{43B}\u{456}\u{442}\u{440}\u{430} \u{43A}\u{43E}\u{43B}\u{44C}\u{43E}\u{440}\u{456}\u{432}`,
321
+ "twoDimensionalSlider": `\u{41F}\u{43E}\u{432}\u{437}\u{443}\u{43D}\u{43E}\u{43A} 2D`
322
+ };
323
+
324
+
325
+ var $4e1dbc65a687dd93$exports = {};
326
+ $4e1dbc65a687dd93$exports = {
327
+ "colorInputLabel": (args)=>`${args.label}\u{3001}${args.channelLabel}`,
328
+ "colorNameAndValue": (args)=>`${args.name}\u{FF1A}${args.value}`,
329
+ "colorPicker": `\u{62FE}\u{8272}\u{5668}`,
330
+ "twoDimensionalSlider": `2D \u{6ED1}\u{5757}`
331
+ };
332
+
333
+
334
+ var $b0fef28529309aa6$exports = {};
335
+ $b0fef28529309aa6$exports = {
336
+ "colorInputLabel": (args)=>`${args.label}\u{FF0C}${args.channelLabel}`,
337
+ "colorNameAndValue": (args)=>`${args.name}\u{FF1A}${args.value}`,
338
+ "colorPicker": `\u{6AA2}\u{8272}\u{5668}`,
339
+ "twoDimensionalSlider": `2D \u{6ED1}\u{687F}`
340
+ };
341
+
342
+
343
+ $3493a52097159720$exports = {
344
+ "ar-AE": $eccab2b0118aef08$exports,
345
+ "bg-BG": $bf2b4507594e3d45$exports,
346
+ "cs-CZ": $01c08487af7ecd14$exports,
347
+ "da-DK": $5e997db6ea0d10f6$exports,
348
+ "de-DE": $fe5998f640a79fd2$exports,
349
+ "el-GR": $18e4d1d5b500a9ee$exports,
350
+ "en-US": $bf90a11a7a42a0f7$exports,
351
+ "es-ES": $dd0d25f885b5c5f3$exports,
352
+ "et-EE": $d950967017e3485b$exports,
353
+ "fi-FI": $00a415a3f0ab315a$exports,
354
+ "fr-FR": $d80f30fe86c95741$exports,
355
+ "he-IL": $6912afb584340a2e$exports,
356
+ "hr-HR": $7b97fcacd84ec90f$exports,
357
+ "hu-HU": $da9b443e89eebc6b$exports,
358
+ "it-IT": $35f135b45eb4d95b$exports,
359
+ "ja-JP": $760b09448e39c6cd$exports,
360
+ "ko-KR": $fc7b7d43be9703ec$exports,
361
+ "lt-LT": $74918a1664156912$exports,
362
+ "lv-LV": $4e6cde11c2bc9840$exports,
363
+ "nb-NO": $6faa3defebc3eb72$exports,
364
+ "nl-NL": $6ac9b6b1b7e3ca12$exports,
365
+ "pl-PL": $1be8b0ee8841f1e7$exports,
366
+ "pt-BR": $f9507c2d404ed689$exports,
367
+ "pt-PT": $8f872ea59c02d67e$exports,
368
+ "ro-RO": $b03b45b62a7ccae4$exports,
369
+ "ru-RU": $f1107d94c09df9b8$exports,
370
+ "sk-SK": $b61325f242fafc7c$exports,
371
+ "sl-SI": $f44b7cf39ac8f315$exports,
372
+ "sr-SP": $aa8cd83fc8d4982b$exports,
373
+ "sv-SE": $7c4f4e5bb7c06f1e$exports,
374
+ "tr-TR": $8045cf930ef745aa$exports,
375
+ "uk-UA": $ee2044a77f24b118$exports,
376
+ "zh-CN": $4e1dbc65a687dd93$exports,
377
+ "zh-TW": $b0fef28529309aa6$exports
378
+ };
379
+
380
+
381
+
382
+ /*
383
+ * Copyright 2022 Adobe. All rights reserved.
384
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
385
+ * you may not use this file except in compliance with the License. You may obtain a copy
386
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
387
+ *
388
+ * Unless required by applicable law or agreed to in writing, software distributed under
389
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
390
+ * OF ANY KIND, either express or implied. See the License for the specific language
391
+ * governing permissions and limitations under the License.
392
+ */
393
+ const $40297c24c53588e6$var$generateRGB_R = (orientation, dir, zValue)=>{
394
+ let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
395
+ let result = {
396
+ colorAreaStyles: {
397
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
398
+ },
399
+ gradientStyles: {
400
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
401
+ "WebkitMaskImage": maskImage,
402
+ maskImage: maskImage
403
+ }
404
+ };
405
+ return result;
406
+ };
407
+ const $40297c24c53588e6$var$generateRGB_G = (orientation, dir, zValue)=>{
408
+ let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
409
+ let result = {
410
+ colorAreaStyles: {
411
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
412
+ },
413
+ gradientStyles: {
414
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
415
+ "WebkitMaskImage": maskImage,
416
+ maskImage: maskImage
417
+ }
418
+ };
419
+ return result;
420
+ };
421
+ const $40297c24c53588e6$var$generateRGB_B = (orientation, dir, zValue)=>{
422
+ let maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
423
+ let result = {
424
+ colorAreaStyles: {
425
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
426
+ },
427
+ gradientStyles: {
428
+ backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
429
+ "WebkitMaskImage": maskImage,
430
+ maskImage: maskImage
431
+ }
432
+ };
433
+ return result;
434
+ };
435
+ const $40297c24c53588e6$var$generateHSL_H = (orientation, dir, zValue)=>{
436
+ let result = {
437
+ colorAreaStyles: {},
438
+ gradientStyles: {
439
+ background: [
440
+ `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%)`,
441
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
442
+ `hsl(${zValue}, 100%, 50%)`
443
+ ].join(",")
444
+ }
445
+ };
446
+ return result;
447
+ };
448
+ const $40297c24c53588e6$var$generateHSL_S = (orientation, dir, alphaValue)=>{
449
+ let result = {
450
+ colorAreaStyles: {},
451
+ gradientStyles: {
452
+ background: [
453
+ `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%)`,
454
+ `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}))`,
455
+ "hsl(0, 0%, 50%)"
456
+ ].join(",")
457
+ }
458
+ };
459
+ return result;
460
+ };
461
+ const $40297c24c53588e6$var$generateHSL_L = (orientation, dir, zValue)=>{
462
+ let result = {
463
+ colorAreaStyles: {},
464
+ gradientStyles: {
465
+ backgroundImage: [
466
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
467
+ `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}%))`
468
+ ].join(",")
469
+ }
470
+ };
471
+ return result;
472
+ };
473
+ const $40297c24c53588e6$var$generateHSB_H = (orientation, dir, zValue)=>{
474
+ let result = {
475
+ colorAreaStyles: {},
476
+ gradientStyles: {
477
+ background: [
478
+ `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
479
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
480
+ `hsl(${zValue}, 100%, 50%)`
481
+ ].join(",")
482
+ }
483
+ };
484
+ return result;
485
+ };
486
+ const $40297c24c53588e6$var$generateHSB_S = (orientation, dir, alphaValue)=>{
487
+ let result = {
488
+ colorAreaStyles: {},
489
+ gradientStyles: {
490
+ background: [
491
+ `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
492
+ `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}))`,
493
+ `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
494
+ ].join(",")
495
+ }
496
+ };
497
+ return result;
498
+ };
499
+ const $40297c24c53588e6$var$generateHSB_B = (orientation, dir, alphaValue)=>{
500
+ let result = {
501
+ colorAreaStyles: {},
502
+ gradientStyles: {
503
+ background: [
504
+ `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
505
+ `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}))`,
506
+ "#000"
507
+ ].join(",")
508
+ }
509
+ };
510
+ return result;
511
+ };
512
+ function $40297c24c53588e6$export$dd62420467d245ca({ direction: direction, state: state, zChannel: zChannel, xChannel: xChannel, isDisabled: isDisabled }) {
513
+ let returnVal = (0, $7KHxM$useMemo)(()=>{
514
+ let orientation = [
515
+ "top",
516
+ direction === "rtl" ? "left" : "right"
517
+ ];
518
+ let dir = false;
519
+ let background = {
520
+ colorAreaStyles: {},
521
+ gradientStyles: {}
522
+ };
523
+ let zValue = state.value.getChannelValue(zChannel);
524
+ let { minValue: zMin, maxValue: zMax } = state.value.getChannelRange(zChannel);
525
+ let alphaValue = (zValue - zMin) / (zMax - zMin);
526
+ let isHSL = state.value.getColorSpace() === "hsl";
527
+ if (!isDisabled) switch(zChannel){
528
+ case "red":
529
+ dir = xChannel === "green";
530
+ background = $40297c24c53588e6$var$generateRGB_R(orientation, dir, zValue);
531
+ break;
532
+ case "green":
533
+ dir = xChannel === "red";
534
+ background = $40297c24c53588e6$var$generateRGB_G(orientation, dir, zValue);
535
+ break;
536
+ case "blue":
537
+ dir = xChannel === "red";
538
+ background = $40297c24c53588e6$var$generateRGB_B(orientation, dir, zValue);
539
+ break;
540
+ case "hue":
541
+ dir = xChannel !== "saturation";
542
+ if (isHSL) background = $40297c24c53588e6$var$generateHSL_H(orientation, dir, zValue);
543
+ else background = $40297c24c53588e6$var$generateHSB_H(orientation, dir, zValue);
544
+ break;
545
+ case "saturation":
546
+ dir = xChannel === "hue";
547
+ if (isHSL) background = $40297c24c53588e6$var$generateHSL_S(orientation, dir, alphaValue);
548
+ else background = $40297c24c53588e6$var$generateHSB_S(orientation, dir, alphaValue);
549
+ break;
550
+ case "brightness":
551
+ dir = xChannel === "hue";
552
+ background = $40297c24c53588e6$var$generateHSB_B(orientation, dir, alphaValue);
553
+ break;
554
+ case "lightness":
555
+ dir = xChannel === "hue";
556
+ background = $40297c24c53588e6$var$generateHSL_L(orientation, dir, zValue);
557
+ break;
558
+ }
559
+ let { x: x, y: y } = state.getThumbPosition();
560
+ if (direction === "rtl") x = 1 - x;
561
+ let forcedColorAdjustNoneStyle = {
562
+ forcedColorAdjust: "none"
563
+ };
564
+ return {
565
+ colorAreaStyleProps: {
566
+ style: {
567
+ position: "relative",
568
+ touchAction: "none",
569
+ ...forcedColorAdjustNoneStyle,
570
+ ...background.colorAreaStyles
571
+ }
572
+ },
573
+ gradientStyleProps: {
574
+ style: {
575
+ touchAction: "none",
576
+ ...forcedColorAdjustNoneStyle,
577
+ ...background.gradientStyles
578
+ }
579
+ },
580
+ thumbStyleProps: {
581
+ style: {
582
+ position: "absolute",
583
+ left: `${x * 100}%`,
584
+ top: `${y * 100}%`,
585
+ transform: "translate(0%, 0%)",
586
+ touchAction: "none",
587
+ ...forcedColorAdjustNoneStyle
588
+ }
589
+ }
590
+ };
591
+ }, [
592
+ direction,
593
+ state,
594
+ zChannel,
595
+ xChannel,
596
+ isDisabled
597
+ ]);
598
+ return returnVal;
386
599
  }
387
600
 
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
- commit,
402
- increment,
403
- decrement,
404
- incrementToMax,
405
- decrementToMin
406
- } = state;
407
- let inputId = useId();
408
- let {
409
- spinButtonProps
410
- } = useSpinButton({
411
- isDisabled,
412
- isReadOnly,
413
- isRequired,
414
- maxValue: 0xFFFFFF,
415
- minValue: 0,
416
- onIncrement: increment,
417
- onIncrementToMax: incrementToMax,
418
- onDecrement: decrement,
419
- onDecrementToMin: decrementToMin,
420
- value: colorValue ? colorValue.toHexInt() : undefined,
421
- textValue: colorValue ? colorValue.toString('hex') : undefined
422
- });
423
- let [focusWithin, setFocusWithin] = useState(false);
424
- let {
425
- focusWithinProps
426
- } = useFocusWithin({
427
- isDisabled,
428
- onFocusWithinChange: setFocusWithin
429
- });
430
- let onWheel = useCallback(e => {
431
- if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {
432
- return;
433
- }
434
601
 
435
- if (e.deltaY > 0) {
436
- increment();
437
- } else if (e.deltaY < 0) {
438
- decrement();
602
+
603
+
604
+
605
+ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
606
+ let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, "aria-label": ariaLabel, xName: xName, yName: yName } = props;
607
+ let stringFormatter = (0, $7KHxM$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3493a52097159720$exports))), "@react-aria/color");
608
+ let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $7KHxM$useGlobalListeners)();
609
+ let { direction: direction, locale: locale } = (0, $7KHxM$useLocale)();
610
+ let [focusedInput, setFocusedInput] = (0, $7KHxM$useState)(null);
611
+ let focusInput = (0, $7KHxM$useCallback)((inputRef = inputXRef)=>{
612
+ if (inputRef.current) (0, $7KHxM$focusWithoutScrolling)(inputRef.current);
613
+ }, [
614
+ inputXRef
615
+ ]);
616
+ (0, $7KHxM$useFormReset)(inputXRef, [
617
+ state.xValue,
618
+ state.yValue
619
+ ], ([x, y])=>{
620
+ let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
621
+ state.setValue(newColor);
622
+ });
623
+ let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = (0, $7KHxM$useState)(false);
624
+ let { xChannel: xChannel, yChannel: yChannel, zChannel: zChannel } = state.channels;
625
+ let xChannelStep = state.xChannelStep;
626
+ let yChannelStep = state.yChannelStep;
627
+ let currentPosition = (0, $7KHxM$useRef)(null);
628
+ let { keyboardProps: keyboardProps } = (0, $7KHxM$useKeyboard)({
629
+ onKeyDown (e) {
630
+ // these are the cases that useMove doesn't handle
631
+ if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
632
+ e.continuePropagation();
633
+ return;
634
+ }
635
+ // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
636
+ e.preventDefault();
637
+ // remember to set this and unset it so that onChangeEnd is fired
638
+ state.setDragging(true);
639
+ setValueChangedViaKeyboard(true);
640
+ let dir;
641
+ switch(e.key){
642
+ case "PageUp":
643
+ state.incrementY(state.yChannelPageStep);
644
+ dir = "y";
645
+ break;
646
+ case "PageDown":
647
+ state.decrementY(state.yChannelPageStep);
648
+ dir = "y";
649
+ break;
650
+ case "Home":
651
+ direction === "rtl" ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
652
+ dir = "x";
653
+ break;
654
+ case "End":
655
+ direction === "rtl" ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
656
+ dir = "x";
657
+ break;
658
+ }
659
+ state.setDragging(false);
660
+ if (dir) {
661
+ let input = dir === "x" ? inputXRef : inputYRef;
662
+ focusInput(input);
663
+ setFocusedInput(dir);
664
+ }
665
+ }
666
+ });
667
+ let moveHandler = {
668
+ onMoveStart () {
669
+ currentPosition.current = null;
670
+ state.setDragging(true);
671
+ },
672
+ onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
673
+ var _containerRef_current;
674
+ let { incrementX: incrementX, decrementX: decrementX, incrementY: incrementY, decrementY: decrementY, xChannelPageStep: xChannelPageStep, xChannelStep: xChannelStep, yChannelPageStep: yChannelPageStep, yChannelStep: yChannelStep, getThumbPosition: getThumbPosition, setColorFromPoint: setColorFromPoint } = state;
675
+ if (currentPosition.current == null) currentPosition.current = getThumbPosition();
676
+ let { width: width, height: height } = ((_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect()) || {
677
+ width: 0,
678
+ height: 0
679
+ };
680
+ let valueChanged = deltaX !== 0 || deltaY !== 0;
681
+ if (pointerType === "keyboard") {
682
+ let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
683
+ let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
684
+ if (deltaX > 0 && direction === "ltr" || deltaX < 0 && direction === "rtl") incrementX(deltaXValue);
685
+ else if (deltaX < 0 && direction === "ltr" || deltaX > 0 && direction === "rtl") decrementX(deltaXValue);
686
+ else if (deltaY > 0) decrementY(deltaYValue);
687
+ else if (deltaY < 0) incrementY(deltaYValue);
688
+ setValueChangedViaKeyboard(valueChanged);
689
+ // set the focused input based on which axis has the greater delta
690
+ focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? "y" : "x";
691
+ setFocusedInput(focusedInput);
692
+ } else {
693
+ currentPosition.current.x += (direction === "rtl" ? -1 : 1) * deltaX / width;
694
+ currentPosition.current.y += deltaY / height;
695
+ setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
696
+ }
697
+ },
698
+ onMoveEnd () {
699
+ isOnColorArea.current = false;
700
+ state.setDragging(false);
701
+ let input = focusedInput === "x" ? inputXRef : inputYRef;
702
+ focusInput(input);
703
+ }
704
+ };
705
+ let { moveProps: movePropsThumb } = (0, $7KHxM$useMove)(moveHandler);
706
+ let { focusWithinProps: focusWithinProps } = (0, $7KHxM$useFocusWithin)({
707
+ onFocusWithinChange: (focusWithin)=>{
708
+ if (!focusWithin) setValueChangedViaKeyboard(false);
709
+ }
710
+ });
711
+ let currentPointer = (0, $7KHxM$useRef)(undefined);
712
+ let isOnColorArea = (0, $7KHxM$useRef)(false);
713
+ let { moveProps: movePropsContainer } = (0, $7KHxM$useMove)({
714
+ onMoveStart () {
715
+ if (isOnColorArea.current) moveHandler.onMoveStart();
716
+ },
717
+ onMove (e) {
718
+ if (isOnColorArea.current) moveHandler.onMove(e);
719
+ },
720
+ onMoveEnd () {
721
+ if (isOnColorArea.current) moveHandler.onMoveEnd();
722
+ }
723
+ });
724
+ let onThumbDown = (id)=>{
725
+ if (!state.isDragging) {
726
+ currentPointer.current = id;
727
+ setValueChangedViaKeyboard(false);
728
+ focusInput();
729
+ state.setDragging(true);
730
+ if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
731
+ else {
732
+ addGlobalListener(window, "mouseup", onThumbUp, false);
733
+ addGlobalListener(window, "touchend", onThumbUp, false);
734
+ }
735
+ }
736
+ };
737
+ let onThumbUp = (e)=>{
738
+ var _e_changedTouches;
739
+ var _e_pointerId;
740
+ let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
741
+ if (id === currentPointer.current) {
742
+ setValueChangedViaKeyboard(false);
743
+ focusInput();
744
+ state.setDragging(false);
745
+ currentPointer.current = undefined;
746
+ isOnColorArea.current = false;
747
+ if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
748
+ else {
749
+ removeGlobalListener(window, "mouseup", onThumbUp, false);
750
+ removeGlobalListener(window, "touchend", onThumbUp, false);
751
+ }
752
+ }
753
+ };
754
+ let onColorAreaDown = (colorArea, id, clientX, clientY)=>{
755
+ let rect = colorArea.getBoundingClientRect();
756
+ let { width: width, height: height } = rect;
757
+ let x = (clientX - rect.x) / width;
758
+ let y = (clientY - rect.y) / height;
759
+ if (direction === "rtl") x = 1 - x;
760
+ if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
761
+ isOnColorArea.current = true;
762
+ setValueChangedViaKeyboard(false);
763
+ currentPointer.current = id;
764
+ state.setColorFromPoint(x, y);
765
+ focusInput();
766
+ state.setDragging(true);
767
+ if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onColorAreaUp, false);
768
+ else {
769
+ addGlobalListener(window, "mouseup", onColorAreaUp, false);
770
+ addGlobalListener(window, "touchend", onColorAreaUp, false);
771
+ }
772
+ }
773
+ };
774
+ let onColorAreaUp = (e)=>{
775
+ var _e_changedTouches;
776
+ var _e_pointerId;
777
+ let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
778
+ if (isOnColorArea.current && id === currentPointer.current) {
779
+ isOnColorArea.current = false;
780
+ setValueChangedViaKeyboard(false);
781
+ currentPointer.current = undefined;
782
+ state.setDragging(false);
783
+ focusInput();
784
+ if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onColorAreaUp, false);
785
+ else {
786
+ removeGlobalListener(window, "mouseup", onColorAreaUp, false);
787
+ removeGlobalListener(window, "touchend", onColorAreaUp, false);
788
+ }
789
+ }
790
+ };
791
+ let colorAreaInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
792
+ ...typeof PointerEvent !== "undefined" ? {
793
+ onPointerDown: (e)=>{
794
+ if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
795
+ onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
796
+ }
797
+ } : {
798
+ onMouseDown: (e)=>{
799
+ if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
800
+ onColorAreaDown(e.currentTarget, undefined, e.clientX, e.clientY);
801
+ },
802
+ onTouchStart: (e)=>{
803
+ onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
804
+ }
805
+ }
806
+ }, movePropsContainer);
807
+ let thumbInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
808
+ ...typeof PointerEvent !== "undefined" ? {
809
+ onPointerDown: (e)=>{
810
+ if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
811
+ onThumbDown(e.pointerId);
812
+ }
813
+ } : {
814
+ onMouseDown: (e)=>{
815
+ if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
816
+ onThumbDown(undefined);
817
+ },
818
+ onTouchStart: (e)=>{
819
+ onThumbDown(e.changedTouches[0].identifier);
820
+ }
821
+ }
822
+ }, focusWithinProps, keyboardProps, movePropsThumb);
823
+ let { focusProps: xInputFocusProps } = (0, $7KHxM$useFocus)({
824
+ onFocus: ()=>{
825
+ setFocusedInput("x");
826
+ }
827
+ });
828
+ let { focusProps: yInputFocusProps } = (0, $7KHxM$useFocus)({
829
+ onFocus: ()=>{
830
+ setFocusedInput("y");
831
+ }
832
+ });
833
+ let isMobile = (0, $7KHxM$isIOS)() || (0, $7KHxM$isAndroid)();
834
+ function getAriaValueTextForChannel(channel) {
835
+ return valueChangedViaKeyboard ? stringFormatter.format("colorNameAndValue", {
836
+ name: state.value.getChannelName(channel, locale),
837
+ value: state.value.formatChannelValue(channel, locale)
838
+ }) : [
839
+ stringFormatter.format("colorNameAndValue", {
840
+ name: state.value.getChannelName(channel, locale),
841
+ value: state.value.formatChannelValue(channel, locale)
842
+ }),
843
+ stringFormatter.format("colorNameAndValue", {
844
+ name: state.value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
845
+ value: state.value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
846
+ })
847
+ ].join(", ");
439
848
  }
440
- }, [isReadOnly, isDisabled, decrement, increment]); // If the input isn't supposed to receive input, disable scrolling.
441
-
442
- let scrollingDisabled = isDisabled || isReadOnly || !focusWithin;
443
- useScrollWheel({
444
- onScroll: onWheel,
445
- isDisabled: scrollingDisabled
446
- }, ref);
447
-
448
- let onChange = value => {
449
- state.setInputValue(value);
450
- };
451
-
452
- let {
453
- labelProps,
454
- inputProps
455
- } = useFormattedTextField(mergeProps(props, {
456
- id: inputId,
457
- value: inputValue,
458
- type: 'text',
459
- autoComplete: 'off',
460
- onChange
461
- }), state, ref);
462
- return {
463
- labelProps,
464
- inputProps: mergeProps(inputProps, spinButtonProps, focusWithinProps, {
465
- role: 'textbox',
466
- 'aria-valuemax': null,
467
- 'aria-valuemin': null,
468
- 'aria-valuenow': null,
469
- 'aria-valuetext': null,
470
- autoCorrect: 'off',
471
- onBlur: commit
472
- })
473
- };
849
+ let colorPickerLabel = stringFormatter.format("colorPicker");
850
+ let xInputLabellingProps = (0, $7KHxM$useLabels)({
851
+ ...props,
852
+ "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
853
+ label: ariaLabel,
854
+ channelLabel: colorPickerLabel
855
+ }) : colorPickerLabel
856
+ });
857
+ let yInputLabellingProps = (0, $7KHxM$useLabels)({
858
+ ...props,
859
+ "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
860
+ label: ariaLabel,
861
+ channelLabel: colorPickerLabel
862
+ }) : colorPickerLabel
863
+ });
864
+ let colorAreaLabellingProps = (0, $7KHxM$useLabels)({
865
+ ...props,
866
+ "aria-label": ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
867
+ }, isMobile ? colorPickerLabel : undefined);
868
+ let ariaRoleDescription = stringFormatter.format("twoDimensionalSlider");
869
+ let { visuallyHiddenProps: visuallyHiddenProps } = (0, $7KHxM$useVisuallyHidden)({
870
+ style: {
871
+ opacity: "0.0001",
872
+ width: "100%",
873
+ height: "100%",
874
+ pointerEvents: "none"
875
+ }
876
+ });
877
+ let { colorAreaStyleProps: colorAreaStyleProps, gradientStyleProps: gradientStyleProps, thumbStyleProps: thumbStyleProps } = (0, $40297c24c53588e6$export$dd62420467d245ca)({
878
+ direction: direction,
879
+ state: state,
880
+ xChannel: xChannel,
881
+ zChannel: zChannel,
882
+ isDisabled: props.isDisabled
883
+ });
884
+ return {
885
+ colorAreaProps: {
886
+ ...colorAreaLabellingProps,
887
+ ...colorAreaInteractions,
888
+ ...colorAreaStyleProps,
889
+ role: "group"
890
+ },
891
+ gradientProps: {
892
+ ...gradientStyleProps,
893
+ role: "presentation"
894
+ },
895
+ thumbProps: {
896
+ ...thumbInteractions,
897
+ ...thumbStyleProps,
898
+ role: "presentation"
899
+ },
900
+ xInputProps: {
901
+ ...xInputLabellingProps,
902
+ ...visuallyHiddenProps,
903
+ ...xInputFocusProps,
904
+ type: "range",
905
+ min: state.value.getChannelRange(xChannel).minValue,
906
+ max: state.value.getChannelRange(xChannel).maxValue,
907
+ step: xChannelStep,
908
+ "aria-roledescription": ariaRoleDescription,
909
+ "aria-valuetext": getAriaValueTextForChannel(xChannel),
910
+ disabled: isDisabled,
911
+ value: state.value.getChannelValue(xChannel),
912
+ name: xName,
913
+ tabIndex: isMobile || !focusedInput || focusedInput === "x" ? undefined : -1,
914
+ /*
915
+ So that only a single "2d slider" control shows up when listing form elements for screen readers,
916
+ add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
917
+ but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
918
+ */ "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? undefined : "true",
919
+ onChange: (e)=>{
920
+ state.setXValue(parseFloat(e.target.value));
921
+ }
922
+ },
923
+ yInputProps: {
924
+ ...yInputLabellingProps,
925
+ ...visuallyHiddenProps,
926
+ ...yInputFocusProps,
927
+ type: "range",
928
+ min: state.value.getChannelRange(yChannel).minValue,
929
+ max: state.value.getChannelRange(yChannel).maxValue,
930
+ step: yChannelStep,
931
+ "aria-roledescription": ariaRoleDescription,
932
+ "aria-valuetext": getAriaValueTextForChannel(yChannel),
933
+ "aria-orientation": "vertical",
934
+ disabled: isDisabled,
935
+ value: state.value.getChannelValue(yChannel),
936
+ name: yName,
937
+ tabIndex: isMobile || focusedInput === "y" ? undefined : -1,
938
+ /*
939
+ So that only a single "2d slider" control shows up when listing form elements for screen readers,
940
+ add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
941
+ but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
942
+ */ "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? undefined : "true",
943
+ onChange: (e)=>{
944
+ state.setYValue(parseFloat(e.target.value));
945
+ }
946
+ }
947
+ };
474
948
  }
949
+
950
+
951
+ /*
952
+ * Copyright 2020 Adobe. All rights reserved.
953
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
954
+ * you may not use this file except in compliance with the License. You may obtain a copy
955
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
956
+ *
957
+ * Unless required by applicable law or agreed to in writing, software distributed under
958
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
959
+ * OF ANY KIND, either express or implied. See the License for the specific language
960
+ * governing permissions and limitations under the License.
961
+ */
962
+
963
+
964
+ function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
965
+ let { trackRef: trackRef, inputRef: inputRef, orientation: orientation, channel: channel, "aria-label": ariaLabel, name: name } = props;
966
+ let { locale: locale, direction: direction } = (0, $7KHxM$useLocale)();
967
+ // Provide a default aria-label if there is no other label provided.
968
+ if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
969
+ // @ts-ignore - ignore unused incompatible props
970
+ let { groupProps: groupProps, trackProps: trackProps, labelProps: labelProps, outputProps: outputProps } = (0, $7KHxM$useSlider)({
971
+ ...props,
972
+ "aria-label": ariaLabel
973
+ }, state, trackRef);
974
+ let { inputProps: inputProps, thumbProps: thumbProps } = (0, $7KHxM$useSliderThumb)({
975
+ index: 0,
976
+ orientation: orientation,
977
+ isDisabled: props.isDisabled,
978
+ name: name,
979
+ trackRef: trackRef,
980
+ inputRef: inputRef
981
+ }, state);
982
+ let generateBackground = ()=>{
983
+ let value = state.getDisplayColor();
984
+ let to;
985
+ if (orientation === "vertical") to = "top";
986
+ else if (direction === "ltr") to = "right";
987
+ else to = "left";
988
+ switch(channel){
989
+ case "hue":
990
+ 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%)`;
991
+ case "lightness":
992
+ {
993
+ // We have to add an extra color stop in the middle so that the hue shows up at all.
994
+ // Otherwise it will always just be black to white.
995
+ let min = state.getThumbMinValue(0);
996
+ let max = state.getThumbMaxValue(0);
997
+ let start = value.withChannelValue(channel, min).toString("css");
998
+ let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
999
+ let end = value.withChannelValue(channel, max).toString("css");
1000
+ return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
1001
+ }
1002
+ case "saturation":
1003
+ case "brightness":
1004
+ case "red":
1005
+ case "green":
1006
+ case "blue":
1007
+ case "alpha":
1008
+ {
1009
+ let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
1010
+ let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
1011
+ return `linear-gradient(to ${to}, ${start}, ${end})`;
1012
+ }
1013
+ default:
1014
+ throw new Error("Unknown color channel: " + channel);
1015
+ }
1016
+ };
1017
+ let forcedColorAdjustNoneStyle = {
1018
+ forcedColorAdjust: "none"
1019
+ };
1020
+ return {
1021
+ trackProps: {
1022
+ ...(0, $7KHxM$mergeProps)(groupProps, trackProps),
1023
+ style: {
1024
+ ...trackProps.style,
1025
+ ...forcedColorAdjustNoneStyle,
1026
+ background: generateBackground()
1027
+ }
1028
+ },
1029
+ inputProps: inputProps,
1030
+ thumbProps: {
1031
+ ...thumbProps,
1032
+ style: {
1033
+ ...thumbProps.style,
1034
+ ...forcedColorAdjustNoneStyle
1035
+ }
1036
+ },
1037
+ labelProps: labelProps,
1038
+ outputProps: outputProps
1039
+ };
1040
+ }
1041
+
1042
+
1043
+ /*
1044
+ * Copyright 2020 Adobe. All rights reserved.
1045
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1046
+ * you may not use this file except in compliance with the License. You may obtain a copy
1047
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
1048
+ *
1049
+ * Unless required by applicable law or agreed to in writing, software distributed under
1050
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1051
+ * OF ANY KIND, either express or implied. See the License for the specific language
1052
+ * governing permissions and limitations under the License.
1053
+ */
1054
+
1055
+
1056
+
1057
+ function $b4a0a4fdc900495e$export$9064ff4e44b3729a(props, state, inputRef) {
1058
+ let { isDisabled: isDisabled, innerRadius: innerRadius, outerRadius: outerRadius, "aria-label": ariaLabel, name: name } = props;
1059
+ let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $7KHxM$useGlobalListeners)();
1060
+ let thumbRadius = (innerRadius + outerRadius) / 2;
1061
+ let focusInput = (0, $7KHxM$useCallback)(()=>{
1062
+ if (inputRef.current) (0, $7KHxM$focusWithoutScrolling)(inputRef.current);
1063
+ }, [
1064
+ inputRef
1065
+ ]);
1066
+ (0, $7KHxM$useFormReset)(inputRef, state.hue, state.setHue);
1067
+ let currentPosition = (0, $7KHxM$useRef)(null);
1068
+ let { keyboardProps: keyboardProps } = (0, $7KHxM$useKeyboard)({
1069
+ onKeyDown (e) {
1070
+ // these are the cases that useMove doesn't handle
1071
+ if (!/^(PageUp|PageDown)$/.test(e.key)) {
1072
+ e.continuePropagation();
1073
+ return;
1074
+ }
1075
+ // same handling as useMove, don't need to stop propagation, useKeyboard will do that for us
1076
+ e.preventDefault();
1077
+ // remember to set this and unset it so that onChangeEnd is fired
1078
+ state.setDragging(true);
1079
+ switch(e.key){
1080
+ case "PageUp":
1081
+ e.preventDefault();
1082
+ state.increment(state.pageStep);
1083
+ break;
1084
+ case "PageDown":
1085
+ e.preventDefault();
1086
+ state.decrement(state.pageStep);
1087
+ break;
1088
+ }
1089
+ state.setDragging(false);
1090
+ }
1091
+ });
1092
+ let moveHandler = {
1093
+ onMoveStart () {
1094
+ currentPosition.current = null;
1095
+ state.setDragging(true);
1096
+ },
1097
+ onMove ({ deltaX: deltaX, deltaY: deltaY, pointerType: pointerType, shiftKey: shiftKey }) {
1098
+ if (currentPosition.current == null) currentPosition.current = state.getThumbPosition(thumbRadius);
1099
+ currentPosition.current.x += deltaX;
1100
+ currentPosition.current.y += deltaY;
1101
+ if (pointerType === "keyboard") {
1102
+ if (deltaX > 0 || deltaY < 0) state.increment(shiftKey ? state.pageStep : state.step);
1103
+ else if (deltaX < 0 || deltaY > 0) state.decrement(shiftKey ? state.pageStep : state.step);
1104
+ } else state.setHueFromPoint(currentPosition.current.x, currentPosition.current.y, thumbRadius);
1105
+ },
1106
+ onMoveEnd () {
1107
+ isOnTrack.current = false;
1108
+ state.setDragging(false);
1109
+ focusInput();
1110
+ }
1111
+ };
1112
+ let { moveProps: movePropsThumb } = (0, $7KHxM$useMove)(moveHandler);
1113
+ let currentPointer = (0, $7KHxM$useRef)(undefined);
1114
+ let isOnTrack = (0, $7KHxM$useRef)(false);
1115
+ let { moveProps: movePropsContainer } = (0, $7KHxM$useMove)({
1116
+ onMoveStart () {
1117
+ if (isOnTrack.current) moveHandler.onMoveStart();
1118
+ },
1119
+ onMove (e) {
1120
+ if (isOnTrack.current) moveHandler.onMove(e);
1121
+ },
1122
+ onMoveEnd () {
1123
+ if (isOnTrack.current) moveHandler.onMoveEnd();
1124
+ }
1125
+ });
1126
+ let onThumbDown = (id)=>{
1127
+ if (!state.isDragging) {
1128
+ currentPointer.current = id;
1129
+ focusInput();
1130
+ state.setDragging(true);
1131
+ if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
1132
+ else {
1133
+ addGlobalListener(window, "mouseup", onThumbUp, false);
1134
+ addGlobalListener(window, "touchend", onThumbUp, false);
1135
+ }
1136
+ }
1137
+ };
1138
+ let onThumbUp = (e)=>{
1139
+ var _e_changedTouches;
1140
+ var _e_pointerId;
1141
+ let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
1142
+ if (id === currentPointer.current) {
1143
+ focusInput();
1144
+ state.setDragging(false);
1145
+ currentPointer.current = undefined;
1146
+ isOnTrack.current = false;
1147
+ if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
1148
+ else {
1149
+ removeGlobalListener(window, "mouseup", onThumbUp, false);
1150
+ removeGlobalListener(window, "touchend", onThumbUp, false);
1151
+ }
1152
+ }
1153
+ };
1154
+ let onTrackDown = (track, id, pageX, pageY)=>{
1155
+ let rect = track.getBoundingClientRect();
1156
+ let x = pageX - rect.x - rect.width / 2;
1157
+ let y = pageY - rect.y - rect.height / 2;
1158
+ let radius = Math.sqrt(x * x + y * y);
1159
+ if (innerRadius < radius && radius < outerRadius && !state.isDragging && currentPointer.current === undefined) {
1160
+ isOnTrack.current = true;
1161
+ currentPointer.current = id;
1162
+ state.setHueFromPoint(x, y, radius);
1163
+ focusInput();
1164
+ state.setDragging(true);
1165
+ if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onTrackUp, false);
1166
+ else {
1167
+ addGlobalListener(window, "mouseup", onTrackUp, false);
1168
+ addGlobalListener(window, "touchend", onTrackUp, false);
1169
+ }
1170
+ }
1171
+ };
1172
+ let onTrackUp = (e)=>{
1173
+ var _e_changedTouches;
1174
+ var _e_pointerId;
1175
+ let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
1176
+ if (isOnTrack.current && id === currentPointer.current) {
1177
+ isOnTrack.current = false;
1178
+ currentPointer.current = undefined;
1179
+ state.setDragging(false);
1180
+ focusInput();
1181
+ if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onTrackUp, false);
1182
+ else {
1183
+ removeGlobalListener(window, "mouseup", onTrackUp, false);
1184
+ removeGlobalListener(window, "touchend", onTrackUp, false);
1185
+ }
1186
+ }
1187
+ };
1188
+ let trackInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
1189
+ ...typeof PointerEvent !== "undefined" ? {
1190
+ onPointerDown: (e)=>{
1191
+ if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
1192
+ onTrackDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
1193
+ }
1194
+ } : {
1195
+ onMouseDown: (e)=>{
1196
+ if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
1197
+ onTrackDown(e.currentTarget, undefined, e.clientX, e.clientY);
1198
+ },
1199
+ onTouchStart: (e)=>{
1200
+ onTrackDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
1201
+ }
1202
+ }
1203
+ }, movePropsContainer);
1204
+ let thumbInteractions = isDisabled ? {} : (0, $7KHxM$mergeProps)({
1205
+ onMouseDown: (e)=>{
1206
+ if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
1207
+ onThumbDown(undefined);
1208
+ },
1209
+ onPointerDown: (e)=>{
1210
+ if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
1211
+ onThumbDown(e.pointerId);
1212
+ },
1213
+ onTouchStart: (e)=>{
1214
+ onThumbDown(e.changedTouches[0].identifier);
1215
+ }
1216
+ }, keyboardProps, movePropsThumb);
1217
+ let { x: x, y: y } = state.getThumbPosition(thumbRadius);
1218
+ // Provide a default aria-label if none is given
1219
+ let { locale: locale } = (0, $7KHxM$useLocale)();
1220
+ if (ariaLabel == null && props["aria-labelledby"] == null) ariaLabel = state.value.getChannelName("hue", locale);
1221
+ let inputLabellingProps = (0, $7KHxM$useLabels)({
1222
+ ...props,
1223
+ "aria-label": ariaLabel
1224
+ });
1225
+ let { minValue: minValue, maxValue: maxValue, step: step } = state.value.getChannelRange("hue");
1226
+ let forcedColorAdjustNoneStyle = {
1227
+ forcedColorAdjust: "none"
1228
+ };
1229
+ return {
1230
+ trackProps: {
1231
+ ...trackInteractions,
1232
+ style: {
1233
+ position: "relative",
1234
+ touchAction: "none",
1235
+ width: outerRadius * 2,
1236
+ height: outerRadius * 2,
1237
+ background: `
1238
+ conic-gradient(
1239
+ from 90deg,
1240
+ hsl(0, 100%, 50%),
1241
+ hsl(30, 100%, 50%),
1242
+ hsl(60, 100%, 50%),
1243
+ hsl(90, 100%, 50%),
1244
+ hsl(120, 100%, 50%),
1245
+ hsl(150, 100%, 50%),
1246
+ hsl(180, 100%, 50%),
1247
+ hsl(210, 100%, 50%),
1248
+ hsl(240, 100%, 50%),
1249
+ hsl(270, 100%, 50%),
1250
+ hsl(300, 100%, 50%),
1251
+ hsl(330, 100%, 50%),
1252
+ hsl(360, 100%, 50%)
1253
+ )
1254
+ `,
1255
+ clipPath: `path(evenodd, "${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, outerRadius)} ${$b4a0a4fdc900495e$var$circlePath(outerRadius, outerRadius, innerRadius)}")`,
1256
+ ...forcedColorAdjustNoneStyle
1257
+ }
1258
+ },
1259
+ thumbProps: {
1260
+ ...thumbInteractions,
1261
+ style: {
1262
+ position: "absolute",
1263
+ left: "50%",
1264
+ top: "50%",
1265
+ transform: `translate(calc(${x}px - 50%), calc(${y}px - 50%))`,
1266
+ touchAction: "none",
1267
+ ...forcedColorAdjustNoneStyle
1268
+ }
1269
+ },
1270
+ inputProps: (0, $7KHxM$mergeProps)(inputLabellingProps, {
1271
+ type: "range",
1272
+ min: String(minValue),
1273
+ max: String(maxValue),
1274
+ step: String(step),
1275
+ "aria-valuetext": state.value.formatChannelValue("hue", locale),
1276
+ disabled: isDisabled,
1277
+ value: `${state.value.getChannelValue("hue")}`,
1278
+ name: name,
1279
+ onChange: (e)=>{
1280
+ state.setHue(parseFloat(e.target.value));
1281
+ }
1282
+ })
1283
+ };
1284
+ }
1285
+ // Creates an SVG path string for a circle.
1286
+ function $b4a0a4fdc900495e$var$circlePath(cx, cy, r) {
1287
+ 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`;
1288
+ }
1289
+
1290
+
1291
+ /*
1292
+ * Copyright 2020 Adobe. All rights reserved.
1293
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1294
+ * you may not use this file except in compliance with the License. You may obtain a copy
1295
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
1296
+ *
1297
+ * Unless required by applicable law or agreed to in writing, software distributed under
1298
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1299
+ * OF ANY KIND, either express or implied. See the License for the specific language
1300
+ * governing permissions and limitations under the License.
1301
+ */
1302
+
1303
+
1304
+
1305
+
1306
+
1307
+ function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
1308
+ let { isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, isWheelDisabled: isWheelDisabled, validationBehavior: validationBehavior = "aria" } = props;
1309
+ let { colorValue: colorValue, inputValue: inputValue, increment: increment, decrement: decrement, incrementToMax: incrementToMax, decrementToMin: decrementToMin, commit: commit } = state;
1310
+ let inputId = (0, $7KHxM$useId)();
1311
+ let { spinButtonProps: spinButtonProps } = (0, $7KHxM$useSpinButton)({
1312
+ isDisabled: isDisabled,
1313
+ isReadOnly: isReadOnly,
1314
+ isRequired: isRequired,
1315
+ maxValue: 0xFFFFFF,
1316
+ minValue: 0,
1317
+ onIncrement: increment,
1318
+ onIncrementToMax: incrementToMax,
1319
+ onDecrement: decrement,
1320
+ onDecrementToMin: decrementToMin,
1321
+ value: colorValue ? colorValue.toHexInt() : undefined,
1322
+ textValue: colorValue ? colorValue.toString("hex") : undefined
1323
+ });
1324
+ let [focusWithin, setFocusWithin] = (0, $7KHxM$useState)(false);
1325
+ let { focusWithinProps: focusWithinProps } = (0, $7KHxM$useFocusWithin)({
1326
+ isDisabled: isDisabled,
1327
+ onFocusWithinChange: setFocusWithin
1328
+ });
1329
+ let onWheel = (0, $7KHxM$useCallback)((e)=>{
1330
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
1331
+ if (e.deltaY > 0) increment();
1332
+ else if (e.deltaY < 0) decrement();
1333
+ }, [
1334
+ decrement,
1335
+ increment
1336
+ ]);
1337
+ // If the input isn't supposed to receive input, disable scrolling.
1338
+ let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
1339
+ (0, $7KHxM$useScrollWheel)({
1340
+ onScroll: onWheel,
1341
+ isDisabled: scrollingDisabled
1342
+ }, ref);
1343
+ let onChange = (value)=>{
1344
+ if (state.validate(value)) state.setInputValue(value);
1345
+ };
1346
+ let { inputProps: inputProps, ...otherProps } = (0, $7KHxM$useFormattedTextField)((0, $7KHxM$mergeProps)(props, {
1347
+ id: inputId,
1348
+ value: inputValue,
1349
+ defaultValue: undefined,
1350
+ validate: undefined,
1351
+ [(0, $7KHxM$privateValidationStateProp)]: state,
1352
+ type: "text",
1353
+ autoComplete: "off",
1354
+ onChange: onChange
1355
+ }), state, ref);
1356
+ inputProps = (0, $7KHxM$mergeProps)(inputProps, spinButtonProps, focusWithinProps, {
1357
+ role: "textbox",
1358
+ "aria-valuemax": null,
1359
+ "aria-valuemin": null,
1360
+ "aria-valuenow": null,
1361
+ "aria-valuetext": null,
1362
+ autoCorrect: "off",
1363
+ spellCheck: "false",
1364
+ onBlur: commit
1365
+ });
1366
+ if (validationBehavior === "native") inputProps["aria-required"] = undefined;
1367
+ return {
1368
+ inputProps: inputProps,
1369
+ ...otherProps
1370
+ };
1371
+ }
1372
+
1373
+
1374
+
1375
+
1376
+ export {$60bd7d6e45dcddfa$export$2f92a7a615a014f6 as useColorArea, $40af666d6c251e36$export$106b7a4e66508f66 as useColorSlider, $b4a0a4fdc900495e$export$9064ff4e44b3729a as useColorWheel, $f6896b05b2ecad12$export$77e32ca575a28fdf as useColorField};
475
1377
  //# sourceMappingURL=module.js.map