({props, selectRef: ref, collection}: SelectInnerProps<T>)
| 175 | } |
| 176 | |
| 177 | function 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' |
nothing calls this directly
no test coverage detected