feat(actions): simplify action corner api through the toolbarService (#5033)
This commit is contained in:
1 parent
f71b88e639
commit
7c15bb8901
246 files changed
+7930
-4270
No files matched your search
@@ -50,7 +50,9 @@ export interface MenuProps {
|
||||
showHeaderDivider?: boolean;
|
||||
activePanelIndex?: number;
|
||||
onVisibilityChange?: (isVisible: boolean) => void;
|
||||
horizontalDirection?: HorizontalDirection;
|
||||
// New props that can be used as alternatives to horizontalDirection and verticalDirection
|
||||
align?: 'start' | 'end' | 'center';
|
||||
side?: 'top' | 'bottom' | 'left' | 'right';
|
||||
children: ReactNode;
|
||||
}
|
||||
type MenuContextProps = {
|
||||
@@ -58,6 +60,7 @@ type MenuContextProps = {
|
||||
hideMenu: () => void;
|
||||
addItemPanel: (index: number, label: string) => void;
|
||||
horizontalDirection: HorizontalDirection;
|
||||
verticalDirection?: VerticalDirection;
|
||||
activePanelIndex: number;
|
||||
};
|
||||
|
||||
@@ -76,9 +79,24 @@ const Menu = (props: MenuProps) => {
|
||||
preventHideMenu,
|
||||
menuClassName,
|
||||
menuStyle,
|
||||
horizontalDirection = HorizontalDirection.LeftToRight,
|
||||
align,
|
||||
side,
|
||||
} = props;
|
||||
|
||||
// Derive horizontalDirection and verticalDirection from align and side if provided
|
||||
let horizontalDirection = HorizontalDirection.LeftToRight;
|
||||
let verticalDirection = VerticalDirection.BottomToTop;
|
||||
|
||||
if (align !== undefined) {
|
||||
horizontalDirection =
|
||||
align === 'start' ? HorizontalDirection.LeftToRight : HorizontalDirection.RightToLeft;
|
||||
}
|
||||
|
||||
if (side !== undefined) {
|
||||
verticalDirection =
|
||||
side === 'bottom' ? VerticalDirection.TopToBottom : VerticalDirection.BottomToTop;
|
||||
}
|
||||
|
||||
const [isMenuVisible, setIsMenuVisible] = useState(isVisible);
|
||||
|
||||
// The menuPath is an array consisting of this top Menu and every SubMenu
|
||||
@@ -151,6 +169,7 @@ const Menu = (props: MenuProps) => {
|
||||
addItemPanel,
|
||||
activePanelIndex: currentMenuActivePanelIndex,
|
||||
horizontalDirection,
|
||||
verticalDirection,
|
||||
}}
|
||||
>
|
||||
{isMenuVisible && (
|
||||
|
||||
Reference in new issue
Block a user