@react-aria/color 3.0.0-nightly.4623 → 3.0.0-nightly.4629
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/useColorArea.main.js +70 -70
- package/dist/useColorArea.mjs +70 -70
- package/dist/useColorArea.module.js +70 -70
- package/dist/useColorAreaGradient.main.js +26 -26
- package/dist/useColorAreaGradient.mjs +26 -26
- package/dist/useColorAreaGradient.module.js +26 -26
- package/dist/useColorChannelField.main.js +1 -1
- package/dist/useColorChannelField.mjs +1 -1
- package/dist/useColorChannelField.module.js +1 -1
- package/dist/useColorField.main.js +12 -12
- package/dist/useColorField.mjs +12 -12
- package/dist/useColorField.module.js +12 -12
- package/dist/useColorSlider.main.js +28 -28
- package/dist/useColorSlider.mjs +28 -28
- package/dist/useColorSlider.module.js +28 -28
- package/dist/useColorSwatch.main.js +12 -12
- package/dist/useColorSwatch.mjs +12 -12
- package/dist/useColorSwatch.module.js +12 -12
- package/dist/useColorWheel.main.js +38 -38
- package/dist/useColorWheel.mjs +38 -38
- package/dist/useColorWheel.module.js +38 -38
- package/package.json +14 -14
package/dist/useColorArea.mjs
CHANGED
|
@@ -28,8 +28,8 @@ function $parcel$interopDefault(a) {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
31
|
-
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef,
|
|
32
|
-
let stringFormatter = (0, $8t1z9$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8t1z9$intlStringsmodulejs))),
|
|
31
|
+
let { isDisabled: isDisabled, inputXRef: inputXRef, inputYRef: inputYRef, containerRef: containerRef, 'aria-label': ariaLabel, xName: xName, yName: yName } = props;
|
|
32
|
+
let stringFormatter = (0, $8t1z9$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8t1z9$intlStringsmodulejs))), '@react-aria/color');
|
|
33
33
|
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $8t1z9$useGlobalListeners)();
|
|
34
34
|
let { direction: direction, locale: locale } = (0, $8t1z9$useLocale)();
|
|
35
35
|
let [focusedInput, setFocusedInput] = (0, $8t1z9$useState)(null);
|
|
@@ -65,26 +65,26 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
65
65
|
setValueChangedViaKeyboard(true);
|
|
66
66
|
let dir;
|
|
67
67
|
switch(e.key){
|
|
68
|
-
case
|
|
68
|
+
case 'PageUp':
|
|
69
69
|
state.incrementY(state.yChannelPageStep);
|
|
70
|
-
dir =
|
|
70
|
+
dir = 'y';
|
|
71
71
|
break;
|
|
72
|
-
case
|
|
72
|
+
case 'PageDown':
|
|
73
73
|
state.decrementY(state.yChannelPageStep);
|
|
74
|
-
dir =
|
|
74
|
+
dir = 'y';
|
|
75
75
|
break;
|
|
76
|
-
case
|
|
77
|
-
direction ===
|
|
78
|
-
dir =
|
|
76
|
+
case 'Home':
|
|
77
|
+
direction === 'rtl' ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
|
|
78
|
+
dir = 'x';
|
|
79
79
|
break;
|
|
80
|
-
case
|
|
81
|
-
direction ===
|
|
82
|
-
dir =
|
|
80
|
+
case 'End':
|
|
81
|
+
direction === 'rtl' ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
|
|
82
|
+
dir = 'x';
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
state.setDragging(false);
|
|
86
86
|
if (dir) {
|
|
87
|
-
let input = dir ===
|
|
87
|
+
let input = dir === 'x' ? inputXRef : inputYRef;
|
|
88
88
|
focusInput(input);
|
|
89
89
|
setFocusedInput(dir);
|
|
90
90
|
}
|
|
@@ -104,19 +104,19 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
104
104
|
height: 0
|
|
105
105
|
};
|
|
106
106
|
let valueChanged = deltaX !== 0 || deltaY !== 0;
|
|
107
|
-
if (pointerType ===
|
|
107
|
+
if (pointerType === 'keyboard') {
|
|
108
108
|
let deltaXValue = shiftKey && xChannelPageStep > xChannelStep ? xChannelPageStep : xChannelStep;
|
|
109
109
|
let deltaYValue = shiftKey && yChannelPageStep > yChannelStep ? yChannelPageStep : yChannelStep;
|
|
110
|
-
if (deltaX > 0 && direction ===
|
|
111
|
-
else if (deltaX < 0 && direction ===
|
|
110
|
+
if (deltaX > 0 && direction === 'ltr' || deltaX < 0 && direction === 'rtl') incrementX(deltaXValue);
|
|
111
|
+
else if (deltaX < 0 && direction === 'ltr' || deltaX > 0 && direction === 'rtl') decrementX(deltaXValue);
|
|
112
112
|
else if (deltaY > 0) decrementY(deltaYValue);
|
|
113
113
|
else if (deltaY < 0) incrementY(deltaYValue);
|
|
114
114
|
setValueChangedViaKeyboard(valueChanged);
|
|
115
115
|
// set the focused input based on which axis has the greater delta
|
|
116
|
-
focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ?
|
|
116
|
+
focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? 'y' : 'x';
|
|
117
117
|
setFocusedInput(focusedInput);
|
|
118
118
|
} else {
|
|
119
|
-
currentPosition.current.x += (direction ===
|
|
119
|
+
currentPosition.current.x += (direction === 'rtl' ? -1 : 1) * deltaX / width;
|
|
120
120
|
currentPosition.current.y += deltaY / height;
|
|
121
121
|
setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
|
|
122
122
|
}
|
|
@@ -124,7 +124,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
124
124
|
onMoveEnd () {
|
|
125
125
|
isOnColorArea.current = false;
|
|
126
126
|
state.setDragging(false);
|
|
127
|
-
let input = focusedInput ===
|
|
127
|
+
let input = focusedInput === 'x' ? inputXRef : inputYRef;
|
|
128
128
|
focusInput(input);
|
|
129
129
|
}
|
|
130
130
|
};
|
|
@@ -156,10 +156,10 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
156
156
|
setValueChangedViaKeyboard(false);
|
|
157
157
|
focusInput();
|
|
158
158
|
state.setDragging(true);
|
|
159
|
-
if (typeof PointerEvent !==
|
|
159
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
160
160
|
else {
|
|
161
|
-
addGlobalListener(window,
|
|
162
|
-
addGlobalListener(window,
|
|
161
|
+
addGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
162
|
+
addGlobalListener(window, 'touchend', onThumbUp, false);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
};
|
|
@@ -173,10 +173,10 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
173
173
|
state.setDragging(false);
|
|
174
174
|
currentPointer.current = undefined;
|
|
175
175
|
isOnColorArea.current = false;
|
|
176
|
-
if (typeof PointerEvent !==
|
|
176
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onThumbUp, false);
|
|
177
177
|
else {
|
|
178
|
-
removeGlobalListener(window,
|
|
179
|
-
removeGlobalListener(window,
|
|
178
|
+
removeGlobalListener(window, 'mouseup', onThumbUp, false);
|
|
179
|
+
removeGlobalListener(window, 'touchend', onThumbUp, false);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
};
|
|
@@ -185,7 +185,7 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
185
185
|
let { width: width, height: height } = rect;
|
|
186
186
|
let x = (clientX - rect.x) / width;
|
|
187
187
|
let y = (clientY - rect.y) / height;
|
|
188
|
-
if (direction ===
|
|
188
|
+
if (direction === 'rtl') x = 1 - x;
|
|
189
189
|
if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === undefined) {
|
|
190
190
|
isOnColorArea.current = true;
|
|
191
191
|
setValueChangedViaKeyboard(false);
|
|
@@ -193,10 +193,10 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
193
193
|
state.setColorFromPoint(x, y);
|
|
194
194
|
focusInput();
|
|
195
195
|
state.setDragging(true);
|
|
196
|
-
if (typeof PointerEvent !==
|
|
196
|
+
if (typeof PointerEvent !== 'undefined') addGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
197
197
|
else {
|
|
198
|
-
addGlobalListener(window,
|
|
199
|
-
addGlobalListener(window,
|
|
198
|
+
addGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
199
|
+
addGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
};
|
|
@@ -210,17 +210,17 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
210
210
|
currentPointer.current = undefined;
|
|
211
211
|
state.setDragging(false);
|
|
212
212
|
focusInput();
|
|
213
|
-
if (typeof PointerEvent !==
|
|
213
|
+
if (typeof PointerEvent !== 'undefined') removeGlobalListener(window, 'pointerup', onColorAreaUp, false);
|
|
214
214
|
else {
|
|
215
|
-
removeGlobalListener(window,
|
|
216
|
-
removeGlobalListener(window,
|
|
215
|
+
removeGlobalListener(window, 'mouseup', onColorAreaUp, false);
|
|
216
|
+
removeGlobalListener(window, 'touchend', onColorAreaUp, false);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
let colorAreaInteractions = isDisabled ? {} : (0, $8t1z9$mergeProps)({
|
|
221
|
-
...typeof PointerEvent !==
|
|
221
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
222
222
|
onPointerDown: (e)=>{
|
|
223
|
-
if (e.pointerType ===
|
|
223
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
224
224
|
onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
|
|
225
225
|
}
|
|
226
226
|
} : {
|
|
@@ -234,9 +234,9 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
234
234
|
}
|
|
235
235
|
}, movePropsContainer);
|
|
236
236
|
let thumbInteractions = isDisabled ? {} : (0, $8t1z9$mergeProps)({
|
|
237
|
-
...typeof PointerEvent !==
|
|
237
|
+
...typeof PointerEvent !== 'undefined' ? {
|
|
238
238
|
onPointerDown: (e)=>{
|
|
239
|
-
if (e.pointerType ===
|
|
239
|
+
if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
240
240
|
onThumbDown(e.pointerId);
|
|
241
241
|
}
|
|
242
242
|
} : {
|
|
@@ -251,12 +251,12 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
251
251
|
}, focusWithinProps, keyboardProps, movePropsThumb);
|
|
252
252
|
let { focusProps: xInputFocusProps } = (0, $8t1z9$useFocus)({
|
|
253
253
|
onFocus: ()=>{
|
|
254
|
-
setFocusedInput(
|
|
254
|
+
setFocusedInput('x');
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
257
|
let { focusProps: yInputFocusProps } = (0, $8t1z9$useFocus)({
|
|
258
258
|
onFocus: ()=>{
|
|
259
|
-
setFocusedInput(
|
|
259
|
+
setFocusedInput('y');
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
const onChange = (e)=>{
|
|
@@ -269,23 +269,23 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
269
269
|
let value = state.getDisplayColor();
|
|
270
270
|
const getAriaValueTextForChannel = (0, $8t1z9$useCallback)((channel)=>{
|
|
271
271
|
const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
|
|
272
|
-
return `${isAfterInput ? stringFormatter.format(
|
|
272
|
+
return `${isAfterInput ? stringFormatter.format('colorNameAndValue', {
|
|
273
273
|
name: value.getChannelName(channel, locale),
|
|
274
274
|
value: value.formatChannelValue(channel, locale)
|
|
275
275
|
}) : [
|
|
276
|
-
stringFormatter.format(
|
|
276
|
+
stringFormatter.format('colorNameAndValue', {
|
|
277
277
|
name: value.getChannelName(channel, locale),
|
|
278
278
|
value: value.formatChannelValue(channel, locale)
|
|
279
279
|
}),
|
|
280
|
-
stringFormatter.format(
|
|
280
|
+
stringFormatter.format('colorNameAndValue', {
|
|
281
281
|
name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
|
|
282
282
|
value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
|
|
283
283
|
}),
|
|
284
|
-
stringFormatter.format(
|
|
284
|
+
stringFormatter.format('colorNameAndValue', {
|
|
285
285
|
name: value.getChannelName(zChannel, locale),
|
|
286
286
|
value: value.formatChannelValue(zChannel, locale)
|
|
287
287
|
})
|
|
288
|
-
].join(
|
|
288
|
+
].join(', ')}, ${value.getColorName(locale)}`;
|
|
289
289
|
}, [
|
|
290
290
|
locale,
|
|
291
291
|
value,
|
|
@@ -296,32 +296,32 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
296
296
|
yChannel,
|
|
297
297
|
zChannel
|
|
298
298
|
]);
|
|
299
|
-
let colorPickerLabel = stringFormatter.format(
|
|
299
|
+
let colorPickerLabel = stringFormatter.format('colorPicker');
|
|
300
300
|
let xInputLabellingProps = (0, $8t1z9$useLabels)({
|
|
301
301
|
...props,
|
|
302
|
-
|
|
302
|
+
'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
|
|
303
303
|
label: ariaLabel,
|
|
304
304
|
channelLabel: colorPickerLabel
|
|
305
305
|
}) : colorPickerLabel
|
|
306
306
|
});
|
|
307
307
|
let yInputLabellingProps = (0, $8t1z9$useLabels)({
|
|
308
308
|
...props,
|
|
309
|
-
|
|
309
|
+
'aria-label': ariaLabel ? stringFormatter.format('colorInputLabel', {
|
|
310
310
|
label: ariaLabel,
|
|
311
311
|
channelLabel: colorPickerLabel
|
|
312
312
|
}) : colorPickerLabel
|
|
313
313
|
});
|
|
314
314
|
let colorAreaLabellingProps = (0, $8t1z9$useLabels)({
|
|
315
315
|
...props,
|
|
316
|
-
|
|
316
|
+
'aria-label': ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : undefined
|
|
317
317
|
}, isMobile ? colorPickerLabel : undefined);
|
|
318
|
-
let ariaRoleDescription = stringFormatter.format(
|
|
318
|
+
let ariaRoleDescription = stringFormatter.format('twoDimensionalSlider');
|
|
319
319
|
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $8t1z9$useVisuallyHidden)({
|
|
320
320
|
style: {
|
|
321
|
-
opacity:
|
|
322
|
-
width:
|
|
323
|
-
height:
|
|
324
|
-
pointerEvents:
|
|
321
|
+
opacity: '0.0001',
|
|
322
|
+
width: '100%',
|
|
323
|
+
height: '100%',
|
|
324
|
+
pointerEvents: 'none'
|
|
325
325
|
}
|
|
326
326
|
});
|
|
327
327
|
let { colorAreaStyleProps: colorAreaStyleProps, thumbStyleProps: thumbStyleProps } = (0, $40297c24c53588e6$export$dd62420467d245ca)({
|
|
@@ -336,59 +336,59 @@ function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
|
|
|
336
336
|
...colorAreaLabellingProps,
|
|
337
337
|
...colorAreaInteractions,
|
|
338
338
|
...colorAreaStyleProps,
|
|
339
|
-
role:
|
|
339
|
+
role: 'group'
|
|
340
340
|
},
|
|
341
341
|
thumbProps: {
|
|
342
342
|
...thumbInteractions,
|
|
343
343
|
...thumbStyleProps,
|
|
344
|
-
role:
|
|
344
|
+
role: 'presentation'
|
|
345
345
|
},
|
|
346
346
|
xInputProps: {
|
|
347
347
|
...xInputLabellingProps,
|
|
348
348
|
...visuallyHiddenProps,
|
|
349
349
|
...xInputFocusProps,
|
|
350
|
-
type:
|
|
350
|
+
type: 'range',
|
|
351
351
|
min: state.value.getChannelRange(xChannel).minValue,
|
|
352
352
|
max: state.value.getChannelRange(xChannel).maxValue,
|
|
353
353
|
step: xChannelStep,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
354
|
+
'aria-roledescription': ariaRoleDescription,
|
|
355
|
+
'aria-valuetext': getAriaValueTextForChannel(xChannel),
|
|
356
|
+
'aria-orientation': 'horizontal',
|
|
357
|
+
'aria-describedby': props['aria-describedby'],
|
|
358
|
+
'aria-details': props['aria-details'],
|
|
359
359
|
disabled: isDisabled,
|
|
360
360
|
value: state.value.getChannelValue(xChannel),
|
|
361
361
|
name: xName,
|
|
362
|
-
tabIndex: isMobile || !focusedInput || focusedInput ===
|
|
362
|
+
tabIndex: isMobile || !focusedInput || focusedInput === 'x' ? undefined : -1,
|
|
363
363
|
/*
|
|
364
364
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
365
365
|
add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
|
|
366
366
|
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
367
|
-
*/
|
|
367
|
+
*/ 'aria-hidden': isMobile || !focusedInput || focusedInput === 'x' || valueChangedViaKeyboard ? undefined : 'true',
|
|
368
368
|
onChange: onChange
|
|
369
369
|
},
|
|
370
370
|
yInputProps: {
|
|
371
371
|
...yInputLabellingProps,
|
|
372
372
|
...visuallyHiddenProps,
|
|
373
373
|
...yInputFocusProps,
|
|
374
|
-
type:
|
|
374
|
+
type: 'range',
|
|
375
375
|
min: state.value.getChannelRange(yChannel).minValue,
|
|
376
376
|
max: state.value.getChannelRange(yChannel).maxValue,
|
|
377
377
|
step: yChannelStep,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
'aria-roledescription': ariaRoleDescription,
|
|
379
|
+
'aria-valuetext': getAriaValueTextForChannel(yChannel),
|
|
380
|
+
'aria-orientation': 'vertical',
|
|
381
|
+
'aria-describedby': props['aria-describedby'],
|
|
382
|
+
'aria-details': props['aria-details'],
|
|
383
383
|
disabled: isDisabled,
|
|
384
384
|
value: state.value.getChannelValue(yChannel),
|
|
385
385
|
name: yName,
|
|
386
|
-
tabIndex: isMobile || focusedInput ===
|
|
386
|
+
tabIndex: isMobile || focusedInput === 'y' ? undefined : -1,
|
|
387
387
|
/*
|
|
388
388
|
So that only a single "2d slider" control shows up when listing form elements for screen readers,
|
|
389
389
|
add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
|
|
390
390
|
but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
|
|
391
|
-
*/
|
|
391
|
+
*/ 'aria-hidden': isMobile || focusedInput === 'y' || valueChangedViaKeyboard ? undefined : 'true',
|
|
392
392
|
onChange: onChange
|
|
393
393
|
}
|
|
394
394
|
};
|