MCPcopy Index your code
hub / github.com/adobe/react-spectrum / ColorChannelField

Function ColorChannelField

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

Source from the content-addressed store, hash-verified

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