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

Function SelectInner

packages/react-aria-components/src/Select.tsx:177–293  ·  view source on GitHub ↗
({props, selectRef: ref, collection}: SelectInnerProps<T>)

Source from the content-addressed store, hash-verified

175}
176
177function SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {
178 let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};
179 let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';
180 let state = useSelectState({
181 ...props,
182 collection,
183 children: undefined,
184 validationBehavior
185 });
186
187 let {isFocusVisible, focusProps} = useFocusRing({within: true});
188
189 // Get props for child elements from useSelect
190 let buttonRef = useRef<HTMLButtonElement>(null);
191 let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);
192 let {
193 labelProps,
194 triggerProps,
195 valueProps,
196 menuProps,
197 descriptionProps,
198 errorMessageProps,
199 hiddenSelectProps,
200 ...validation
201 } = useSelect(
202 {
203 ...removeDataAttributes(props),
204 label,
205 validationBehavior
206 },
207 state,
208 buttonRef
209 );
210
211 // Only expose a subset of state to renderProps function to avoid infinite render loop
212 let renderPropsState = useMemo(
213 () => ({
214 isOpen: state.isOpen,
215 isFocused: state.isFocused,
216 isFocusVisible,
217 isDisabled: props.isDisabled || false,
218 isInvalid: validation.isInvalid || false,
219 isRequired: props.isRequired || false
220 }),
221 [
222 state.isOpen,
223 state.isFocused,
224 isFocusVisible,
225 props.isDisabled,
226 validation.isInvalid,
227 props.isRequired
228 ]
229 );
230
231 let renderProps = useRenderProps({
232 ...props,
233 values: renderPropsState,
234 defaultClassName: 'react-aria-Select'

Callers

nothing calls this directly

Calls 9

useSlottedContextFunction · 0.90
useSelectStateFunction · 0.90
useFocusRingFunction · 0.90
useSlotFunction · 0.90
useSelectFunction · 0.90
removeDataAttributesFunction · 0.90
useRenderPropsFunction · 0.90
filterDOMPropsFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected