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