11'use client' ;
22import * as React from 'react' ;
3+ import { useStore } from '@base-ui-components/utils/store' ;
34import type { BaseUIComponentProps } from '../../utils/types' ;
45import { useRenderElement } from '../../utils/useRenderElement' ;
6+ import { useSelectRootContext } from '../root/SelectRootContext' ;
7+ import { triggerOpenStateMapping } from '../../utils/popupStateMapping' ;
8+ import { selectors } from '../store' ;
59
610/**
711 * An icon that indicates that the trigger button opens a select menu.
@@ -11,19 +15,25 @@ import { useRenderElement } from '../../utils/useRenderElement';
1115 */
1216export const SelectIcon = React . forwardRef ( function SelectIcon (
1317 componentProps : SelectIcon . Props ,
14- forwardedRef : React . ForwardedRef < HTMLDivElement > ,
18+ forwardedRef : React . ForwardedRef < HTMLSpanElement > ,
1519) {
1620 const { className, render, ...elementProps } = componentProps ;
1721
22+ const { store } = useSelectRootContext ( ) ;
23+ const open = useStore ( store , selectors . open ) ;
24+
25+ const state : SelectIcon . State = React . useMemo (
26+ ( ) => ( {
27+ open,
28+ } ) ,
29+ [ open ] ,
30+ ) ;
31+
1832 const element = useRenderElement ( 'span' , componentProps , {
33+ state,
1934 ref : forwardedRef ,
20- props : [
21- {
22- 'aria-hidden' : true ,
23- children : '▼' ,
24- } ,
25- elementProps ,
26- ] ,
35+ props : [ { 'aria-hidden' : true , children : '▼' } , elementProps ] ,
36+ stateAttributesMapping : triggerOpenStateMapping ,
2737 } ) ;
2838
2939 return element ;
0 commit comments