@react-aria/color 3.0.0-nightly.4228 → 3.0.0-nightly.4242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +69 -62
- package/dist/main.js +70 -62
- package/dist/main.js.map +1 -1
- package/dist/module.js +69 -62
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -13
- package/src/useColorField.ts +27 -16
package/src/useColorField.ts
CHANGED
|
@@ -20,11 +20,13 @@ import {
|
|
|
20
20
|
useState
|
|
21
21
|
} from 'react';
|
|
22
22
|
import {mergeProps, useId} from '@react-aria/utils';
|
|
23
|
+
import {privateValidationStateProp} from '@react-stately/form';
|
|
23
24
|
import {useFocusWithin, useScrollWheel} from '@react-aria/interactions';
|
|
24
25
|
import {useFormattedTextField} from '@react-aria/textfield';
|
|
25
26
|
import {useSpinButton} from '@react-aria/spinbutton';
|
|
27
|
+
import {ValidationResult} from '@react-types/shared';
|
|
26
28
|
|
|
27
|
-
export interface ColorFieldAria {
|
|
29
|
+
export interface ColorFieldAria extends ValidationResult {
|
|
28
30
|
/** Props for the label element. */
|
|
29
31
|
labelProps: LabelHTMLAttributes<HTMLLabelElement>,
|
|
30
32
|
/** Props for the input element. */
|
|
@@ -43,17 +45,18 @@ export function useColorField(
|
|
|
43
45
|
let {
|
|
44
46
|
isDisabled,
|
|
45
47
|
isReadOnly,
|
|
46
|
-
isRequired
|
|
48
|
+
isRequired,
|
|
49
|
+
validationBehavior = 'aria'
|
|
47
50
|
} = props;
|
|
48
51
|
|
|
49
52
|
let {
|
|
50
53
|
colorValue,
|
|
51
54
|
inputValue,
|
|
52
|
-
commit,
|
|
53
55
|
increment,
|
|
54
56
|
decrement,
|
|
55
57
|
incrementToMax,
|
|
56
|
-
decrementToMin
|
|
58
|
+
decrementToMin,
|
|
59
|
+
commit
|
|
57
60
|
} = state;
|
|
58
61
|
|
|
59
62
|
let inputId = useId();
|
|
@@ -96,27 +99,35 @@ export function useColorField(
|
|
|
96
99
|
}
|
|
97
100
|
};
|
|
98
101
|
|
|
99
|
-
let {
|
|
102
|
+
let {inputProps, ...otherProps} = useFormattedTextField(
|
|
100
103
|
mergeProps(props, {
|
|
101
104
|
id: inputId,
|
|
102
105
|
value: inputValue,
|
|
103
106
|
defaultValue: undefined,
|
|
107
|
+
validate: undefined,
|
|
108
|
+
[privateValidationStateProp]: state,
|
|
104
109
|
type: 'text',
|
|
105
110
|
autoComplete: 'off',
|
|
106
111
|
onChange
|
|
107
112
|
}), state, ref);
|
|
108
113
|
|
|
114
|
+
inputProps = mergeProps(inputProps, spinButtonProps, focusWithinProps, {
|
|
115
|
+
role: 'textbox',
|
|
116
|
+
'aria-valuemax': null,
|
|
117
|
+
'aria-valuemin': null,
|
|
118
|
+
'aria-valuenow': null,
|
|
119
|
+
'aria-valuetext': null,
|
|
120
|
+
autoCorrect: 'off',
|
|
121
|
+
spellCheck: 'false',
|
|
122
|
+
onBlur: commit
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
if (validationBehavior === 'native') {
|
|
126
|
+
inputProps['aria-required'] = undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
109
129
|
return {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
role: 'textbox',
|
|
113
|
-
'aria-valuemax': null,
|
|
114
|
-
'aria-valuemin': null,
|
|
115
|
-
'aria-valuenow': null,
|
|
116
|
-
'aria-valuetext': null,
|
|
117
|
-
autoCorrect: 'off',
|
|
118
|
-
spellCheck: 'false',
|
|
119
|
-
onBlur: commit
|
|
120
|
-
})
|
|
130
|
+
inputProps,
|
|
131
|
+
...otherProps
|
|
121
132
|
};
|
|
122
133
|
}
|