( props: MenuSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-MenuSection' )
| 444 | } |
| 445 | |
| 446 | function MenuSectionInner<T>( |
| 447 | props: MenuSectionProps<T>, |
| 448 | ref: ForwardedRef<HTMLElement>, |
| 449 | section: Node<T>, |
| 450 | className = 'react-aria-MenuSection' |
| 451 | ) { |
| 452 | let state = useContext(MenuStateContext)!; |
| 453 | let {CollectionBranch} = useContext(CollectionRendererContext); |
| 454 | let [headingRef, heading] = useSlot(); |
| 455 | let {headingProps, groupProps} = useMenuSection({ |
| 456 | heading, |
| 457 | 'aria-label': section.props['aria-label'] ?? undefined |
| 458 | }); |
| 459 | let renderProps = useRenderProps({ |
| 460 | ...props, |
| 461 | id: undefined, |
| 462 | children: undefined, |
| 463 | defaultClassName: className, |
| 464 | className: section.props?.className, |
| 465 | style: section.props?.style, |
| 466 | values: undefined |
| 467 | }); |
| 468 | |
| 469 | let parent = useContext(SelectionManagerContext)!; |
| 470 | let selectionState = useMultipleSelectionState(props); |
| 471 | let manager = |
| 472 | props.selectionMode != null ? new GroupSelectionManager(parent, selectionState) : parent; |
| 473 | |
| 474 | let closeOnSelect = useSlottedContext(MenuItemContext)?.shouldCloseOnSelect; |
| 475 | |
| 476 | let DOMProps = filterDOMProps(props as any, {global: true}); |
| 477 | delete DOMProps.id; |
| 478 | |
| 479 | return ( |
| 480 | <dom.section {...mergeProps(DOMProps, renderProps, groupProps)} ref={ref}> |
| 481 | <Provider |
| 482 | values={[ |
| 483 | [HeaderContext, {...headingProps, ref: headingRef}], |
| 484 | [SelectionManagerContext, manager], |
| 485 | [MenuItemContext, {shouldCloseOnSelect: props.shouldCloseOnSelect ?? closeOnSelect}] |
| 486 | ]}> |
| 487 | <CollectionBranch collection={state.collection} parent={section} /> |
| 488 | </Provider> |
| 489 | </dom.section> |
| 490 | ); |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * A MenuSection represents a section within a Menu. |
nothing calls this directly
no test coverage detected