MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ColorChannelField

Function ColorChannelField

packages/react-aria-components/src/ColorField.tsx:153–197  ·  view source on GitHub ↗
(props: ColorChannelFieldProps)

Source from the content-addressed store, hash-verified

151}
152
153function ColorChannelField(props: ColorChannelFieldProps) {
154 let {locale} = useLocale();
155 let state = useColorChannelFieldState({
156 ...props,
157 locale
158 });
159
160 let inputRef = useRef<HTMLInputElement>(null);
161 let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);
162 let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} =
163 useColorChannelField(
164 {
165 ...removeDataAttributes(props),
166 label,
167 validationBehavior: props.validationBehavior ?? 'native'
168 },
169 state,
170 inputRef
171 );
172
173 return (
174 <>
175 {useChildren(
176 props,
177 state,
178 props.forwardedRef,
179 inputProps,
180 inputRef,
181 labelProps,
182 labelRef,
183 descriptionProps,
184 errorMessageProps,
185 validation
186 )}
187 {props.name && (
188 <input
189 type="hidden"
190 name={props.name}
191 form={props.form}
192 value={isNaN(state.numberValue) ? '' : state.numberValue}
193 />
194 )}
195 </>
196 );
197}
198
199interface HexColorFieldProps extends ColorFieldProps {
200 forwardedRef: ForwardedRef<HTMLDivElement>;

Callers

nothing calls this directly

Calls 6

useLocaleFunction · 0.90
useSlotFunction · 0.90
removeDataAttributesFunction · 0.90
useColorChannelFieldFunction · 0.85
useChildrenFunction · 0.85

Tested by

no test coverage detected