Private
Public Access
1
0
Files

34 lines
1.2 KiB
JavaScript

'use client';
import * as React from 'react';
import { ChevronDownRegular } from '@fluentui/react-icons';
import { slot } from '@fluentui/react-utilities';
import { useButton_unstable } from '../Button/index';
/**
* Given user props, returns the final state for a MenuButton.
*/ export const useMenuButton_unstable = (props, ref)=>{
const { menuIcon, ...buttonProps } = props;
const buttonState = useButton_unstable(buttonProps, ref);
return {
...buttonState,
iconOnly: Boolean(!props.children),
// Slots definition
components: {
// eslint-disable-next-line @typescript-eslint/no-deprecated
...buttonState.components,
menuIcon: 'span'
},
root: {
...buttonState.root,
// force aria-expanded to be a boolean, not a string
'aria-expanded': props['aria-expanded'] ? props['aria-expanded'] === 'true' || props['aria-expanded'] === true : false
},
menuIcon: slot.optional(menuIcon, {
defaultProps: {
children: /*#__PURE__*/ React.createElement(ChevronDownRegular, null)
},
renderByDefault: true,
elementType: 'span'
})
};
};