2021-07-13 08:05:09 +00:00
|
|
|
import * as React from "react";
|
2021-08-24 05:37:16 +00:00
|
|
|
import styled, { createGlobalStyle } from "styled-components";
|
2021-07-13 08:05:09 +00:00
|
|
|
import { Alignment, Button, Icon, Menu, MenuItem } from "@blueprintjs/core";
|
|
|
|
|
import { Classes, Popover2 } from "@blueprintjs/popover2";
|
|
|
|
|
import { IconName } from "@blueprintjs/icons";
|
2021-08-24 05:37:16 +00:00
|
|
|
import tinycolor from "tinycolor2";
|
2021-07-13 08:05:09 +00:00
|
|
|
|
2021-09-23 15:14:24 +00:00
|
|
|
import { darkenActive, darkenHover } from "constants/DefaultTheme";
|
2021-08-24 05:37:16 +00:00
|
|
|
import {
|
|
|
|
|
ButtonBoxShadow,
|
|
|
|
|
ButtonBoxShadowTypes,
|
|
|
|
|
ButtonBorderRadius,
|
|
|
|
|
ButtonBorderRadiusTypes,
|
|
|
|
|
ButtonVariant,
|
|
|
|
|
ButtonVariantTypes,
|
2021-12-08 13:11:13 +00:00
|
|
|
ButtonPlacement,
|
2021-09-09 15:10:22 +00:00
|
|
|
} from "components/constants";
|
2021-08-24 05:37:16 +00:00
|
|
|
import { ThemeProp } from "components/ads/common";
|
2021-09-23 15:14:24 +00:00
|
|
|
import {
|
|
|
|
|
getCustomBackgroundColor,
|
|
|
|
|
getCustomBorderColor,
|
|
|
|
|
getCustomHoverColor,
|
|
|
|
|
getCustomTextColor,
|
2021-12-08 13:11:13 +00:00
|
|
|
getCustomJustifyContent,
|
|
|
|
|
getAlignText,
|
2021-11-30 10:38:46 +00:00
|
|
|
WidgetContainerDiff,
|
2021-10-06 12:57:05 +00:00
|
|
|
} from "widgets/WidgetUtils";
|
2022-03-17 10:19:17 +00:00
|
|
|
import orderBy from "lodash/orderBy";
|
|
|
|
|
import uniqueId from "lodash/uniqueId";
|
2022-03-13 17:21:04 +00:00
|
|
|
import { RenderMode } from "constants/WidgetConstants";
|
|
|
|
|
import { DragContainer } from "widgets/ButtonWidget/component/DragContainer";
|
2021-07-13 08:05:09 +00:00
|
|
|
|
2021-11-30 10:38:46 +00:00
|
|
|
const PopoverStyles = createGlobalStyle<{
|
|
|
|
|
parentWidth: number;
|
|
|
|
|
menuDropDownWidth: number;
|
|
|
|
|
id: string;
|
|
|
|
|
}>`
|
2021-08-24 05:37:16 +00:00
|
|
|
.menu-button-popover > .${Classes.POPOVER2_CONTENT} {
|
|
|
|
|
background: none;
|
|
|
|
|
}
|
2022-03-13 17:21:04 +00:00
|
|
|
|
|
|
|
|
& > .${Classes.POPOVER2_TARGET} {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 10:38:46 +00:00
|
|
|
${({ id, menuDropDownWidth, parentWidth }) => `
|
|
|
|
|
.menu-button-width-${id} {
|
|
|
|
|
|
|
|
|
|
max-width: ${
|
|
|
|
|
menuDropDownWidth > parentWidth
|
|
|
|
|
? `${menuDropDownWidth}px`
|
|
|
|
|
: `${parentWidth}px`
|
|
|
|
|
} !important;
|
|
|
|
|
min-width: ${
|
|
|
|
|
parentWidth > menuDropDownWidth ? parentWidth : menuDropDownWidth
|
|
|
|
|
}px !important;
|
|
|
|
|
}
|
|
|
|
|
`}
|
2021-08-24 05:37:16 +00:00
|
|
|
`;
|
|
|
|
|
|
2021-07-13 08:05:09 +00:00
|
|
|
export interface BaseStyleProps {
|
|
|
|
|
backgroundColor?: string;
|
2021-08-24 05:37:16 +00:00
|
|
|
borderRadius?: ButtonBorderRadius;
|
|
|
|
|
boxShadow?: ButtonBoxShadow;
|
|
|
|
|
boxShadowColor?: string;
|
|
|
|
|
buttonColor?: string;
|
|
|
|
|
buttonVariant?: ButtonVariant;
|
|
|
|
|
isCompact?: boolean;
|
2021-07-13 08:05:09 +00:00
|
|
|
textColor?: string;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2021-07-13 08:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-24 05:37:16 +00:00
|
|
|
const BaseButton = styled(Button)<ThemeProp & BaseStyleProps>`
|
2021-07-13 08:05:09 +00:00
|
|
|
height: 100%;
|
2021-08-24 05:37:16 +00:00
|
|
|
background-image: none !important;
|
|
|
|
|
font-weight: ${(props) => props.theme.fontWeights[2]};
|
|
|
|
|
outline: none;
|
|
|
|
|
padding: 0px 10px;
|
2021-07-13 08:05:09 +00:00
|
|
|
overflow: hidden;
|
|
|
|
|
border: 1.2px solid #ebebeb;
|
|
|
|
|
border-radius: 0;
|
|
|
|
|
box-shadow: none !important;
|
2021-08-24 05:37:16 +00:00
|
|
|
|
2021-09-23 15:14:24 +00:00
|
|
|
${({ buttonColor, buttonVariant, theme }) => `
|
2021-08-24 05:37:16 +00:00
|
|
|
background: ${
|
2021-09-23 15:14:24 +00:00
|
|
|
getCustomBackgroundColor(buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? getCustomBackgroundColor(buttonVariant, buttonColor)
|
2021-10-12 08:04:51 +00:00
|
|
|
: buttonVariant === ButtonVariantTypes.PRIMARY
|
2021-11-06 08:00:57 +00:00
|
|
|
? theme.colors.button.primary.primary.bgColor
|
2021-08-24 05:37:16 +00:00
|
|
|
: "none"
|
|
|
|
|
} !important;
|
|
|
|
|
|
2022-03-13 17:21:04 +00:00
|
|
|
&:hover, &:active {
|
2021-08-24 05:37:16 +00:00
|
|
|
background: ${
|
2021-09-23 15:14:24 +00:00
|
|
|
getCustomHoverColor(theme, buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? getCustomHoverColor(theme, buttonVariant, buttonColor)
|
2021-10-12 08:04:51 +00:00
|
|
|
: buttonVariant === ButtonVariantTypes.SECONDARY
|
2021-11-06 08:00:57 +00:00
|
|
|
? theme.colors.button.primary.secondary.hoverColor
|
2021-10-12 08:04:51 +00:00
|
|
|
: buttonVariant === ButtonVariantTypes.TERTIARY
|
2021-11-06 08:00:57 +00:00
|
|
|
? theme.colors.button.primary.tertiary.hoverColor
|
|
|
|
|
: theme.colors.button.primary.primary.hoverColor
|
2021-08-24 05:37:16 +00:00
|
|
|
} !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
|
background-color: ${theme.colors.button.disabled.bgColor} !important;
|
2021-11-18 10:22:04 +00:00
|
|
|
color: ${theme.colors.button.disabled.textColor} !important;
|
2021-11-15 06:29:06 +00:00
|
|
|
border-color: ${theme.colors.button.disabled.bgColor} !important;
|
|
|
|
|
> span {
|
|
|
|
|
color: ${theme.colors.button.disabled.textColor} !important;
|
|
|
|
|
}
|
2021-08-24 05:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
border: ${
|
2021-09-23 15:14:24 +00:00
|
|
|
getCustomBorderColor(buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? `1px solid ${getCustomBorderColor(buttonVariant, buttonColor)}`
|
2021-10-12 08:04:51 +00:00
|
|
|
: buttonVariant === ButtonVariantTypes.SECONDARY
|
2021-11-06 08:00:57 +00:00
|
|
|
? `1px solid ${theme.colors.button.primary.secondary.borderColor}`
|
2021-08-24 05:37:16 +00:00
|
|
|
: "none"
|
|
|
|
|
} !important;
|
|
|
|
|
& > span {
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
-webkit-line-clamp: 1;
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
|
|
|
|
max-height: 100%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
color: ${
|
2021-10-12 08:04:51 +00:00
|
|
|
buttonVariant === ButtonVariantTypes.PRIMARY
|
2021-09-23 15:14:24 +00:00
|
|
|
? getCustomTextColor(theme, buttonColor)
|
2021-10-12 08:04:51 +00:00
|
|
|
: getCustomBackgroundColor(
|
|
|
|
|
ButtonVariantTypes.PRIMARY,
|
|
|
|
|
buttonColor,
|
|
|
|
|
) !== "none"
|
|
|
|
|
? getCustomBackgroundColor(ButtonVariantTypes.PRIMARY, buttonColor)
|
2021-11-06 08:00:57 +00:00
|
|
|
: `${theme.colors.button.primary.secondary.textColor}`
|
2021-08-24 05:37:16 +00:00
|
|
|
} !important;
|
|
|
|
|
}
|
2021-07-13 08:05:09 +00:00
|
|
|
`}
|
|
|
|
|
|
2021-08-24 05:37:16 +00:00
|
|
|
border-radius: ${({ borderRadius }) =>
|
|
|
|
|
borderRadius === ButtonBorderRadiusTypes.ROUNDED ? "5px" : 0};
|
2021-07-13 08:05:09 +00:00
|
|
|
|
2021-08-24 05:37:16 +00:00
|
|
|
box-shadow: ${({ boxShadow, boxShadowColor, theme }) =>
|
|
|
|
|
boxShadow === ButtonBoxShadowTypes.VARIANT1
|
|
|
|
|
? `0px 0px 4px 3px ${boxShadowColor ||
|
|
|
|
|
theme.colors.button.boxShadow.default.variant1}`
|
|
|
|
|
: boxShadow === ButtonBoxShadowTypes.VARIANT2
|
|
|
|
|
? `3px 3px 4px ${boxShadowColor ||
|
|
|
|
|
theme.colors.button.boxShadow.default.variant2}`
|
|
|
|
|
: boxShadow === ButtonBoxShadowTypes.VARIANT3
|
|
|
|
|
? `0px 1px 3px ${boxShadowColor ||
|
|
|
|
|
theme.colors.button.boxShadow.default.variant3}`
|
|
|
|
|
: boxShadow === ButtonBoxShadowTypes.VARIANT4
|
|
|
|
|
? `2px 2px 0px ${boxShadowColor ||
|
|
|
|
|
theme.colors.button.boxShadow.default.variant4}`
|
|
|
|
|
: boxShadow === ButtonBoxShadowTypes.VARIANT5
|
|
|
|
|
? `-2px -2px 0px ${boxShadowColor ||
|
|
|
|
|
theme.colors.button.boxShadow.default.variant5}`
|
|
|
|
|
: "none"} !important;
|
2021-12-08 13:11:13 +00:00
|
|
|
|
|
|
|
|
${({ placement }) =>
|
|
|
|
|
placement
|
|
|
|
|
? `
|
|
|
|
|
justify-content: ${getCustomJustifyContent(placement)};
|
|
|
|
|
& > span.bp3-button-text {
|
|
|
|
|
flex: unset !important;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
: ""}
|
2021-07-13 08:05:09 +00:00
|
|
|
`;
|
|
|
|
|
|
2021-08-24 05:37:16 +00:00
|
|
|
const BaseMenuItem = styled(MenuItem)<ThemeProp & BaseStyleProps>`
|
|
|
|
|
${({ backgroundColor, theme }) =>
|
|
|
|
|
backgroundColor
|
|
|
|
|
? `
|
2021-07-13 08:05:09 +00:00
|
|
|
background-color: ${backgroundColor} !important;
|
|
|
|
|
&:hover {
|
|
|
|
|
background-color: ${darkenHover(backgroundColor)} !important;
|
|
|
|
|
}
|
|
|
|
|
&:active {
|
|
|
|
|
background-color: ${darkenActive(backgroundColor)} !important;
|
|
|
|
|
}
|
2021-08-24 05:37:16 +00:00
|
|
|
`
|
|
|
|
|
: `
|
|
|
|
|
background: none !important
|
|
|
|
|
&:hover {
|
|
|
|
|
background-color: ${tinycolor(
|
2021-11-06 08:00:57 +00:00
|
|
|
theme.colors.button.primary.primary.textColor,
|
2021-08-24 05:37:16 +00:00
|
|
|
)
|
|
|
|
|
.darken()
|
|
|
|
|
.toString()} !important;
|
|
|
|
|
}
|
|
|
|
|
&:active {
|
|
|
|
|
background-color: ${tinycolor(
|
2021-11-06 08:00:57 +00:00
|
|
|
theme.colors.button.primary.primary.textColor,
|
2021-08-24 05:37:16 +00:00
|
|
|
)
|
|
|
|
|
.darken()
|
|
|
|
|
.toString()} !important;
|
|
|
|
|
}
|
|
|
|
|
`}
|
2021-07-13 08:05:09 +00:00
|
|
|
${({ textColor }) =>
|
|
|
|
|
textColor &&
|
|
|
|
|
`
|
|
|
|
|
color: ${textColor} !important;
|
|
|
|
|
`}
|
|
|
|
|
${({ isCompact }) =>
|
|
|
|
|
isCompact &&
|
|
|
|
|
`
|
|
|
|
|
padding-top: 3px;
|
|
|
|
|
padding-bottom: 3px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
`}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledMenu = styled(Menu)`
|
|
|
|
|
padding: 0;
|
2021-11-30 10:38:46 +00:00
|
|
|
min-width: 0px;
|
2021-07-13 08:05:09 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export interface PopoverContentProps {
|
|
|
|
|
menuItems: Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
widgetId: string;
|
|
|
|
|
id: string;
|
|
|
|
|
index: number;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
textColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconColor?: string;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
onClick?: string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
onItemClicked: (onClick: string | undefined) => void;
|
|
|
|
|
isCompact?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function PopoverContent(props: PopoverContentProps) {
|
|
|
|
|
const { isCompact, menuItems: itemsObj, onItemClicked } = props;
|
|
|
|
|
|
2021-10-06 12:57:05 +00:00
|
|
|
if (!itemsObj) return <StyledMenu />;
|
2022-03-17 10:19:17 +00:00
|
|
|
const visibleItems = Object.keys(itemsObj)
|
2021-07-13 08:05:09 +00:00
|
|
|
.map((itemKey) => itemsObj[itemKey])
|
|
|
|
|
.filter((item) => item.isVisible === true);
|
|
|
|
|
|
2022-03-17 10:19:17 +00:00
|
|
|
const items = orderBy(visibleItems, ["index"], ["asc"]);
|
|
|
|
|
|
2021-07-13 08:05:09 +00:00
|
|
|
const listItems = items.map((menuItem) => {
|
|
|
|
|
const {
|
|
|
|
|
backgroundColor,
|
|
|
|
|
iconAlign,
|
|
|
|
|
iconColor,
|
|
|
|
|
iconName,
|
|
|
|
|
id,
|
|
|
|
|
isDisabled,
|
|
|
|
|
label,
|
|
|
|
|
onClick,
|
|
|
|
|
textColor,
|
|
|
|
|
} = menuItem;
|
|
|
|
|
if (iconAlign === Alignment.RIGHT) {
|
|
|
|
|
return (
|
|
|
|
|
<BaseMenuItem
|
|
|
|
|
backgroundColor={backgroundColor}
|
|
|
|
|
disabled={isDisabled}
|
|
|
|
|
isCompact={isCompact}
|
|
|
|
|
key={id}
|
|
|
|
|
labelElement={<Icon color={iconColor} icon={iconName} />}
|
|
|
|
|
onClick={() => onItemClicked(onClick)}
|
|
|
|
|
text={label}
|
|
|
|
|
textColor={textColor}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<BaseMenuItem
|
|
|
|
|
backgroundColor={backgroundColor}
|
|
|
|
|
disabled={isDisabled}
|
|
|
|
|
icon={<Icon color={iconColor} icon={iconName} />}
|
|
|
|
|
isCompact={isCompact}
|
|
|
|
|
key={id}
|
|
|
|
|
onClick={() => onItemClicked(onClick)}
|
|
|
|
|
text={label}
|
|
|
|
|
textColor={textColor}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return <StyledMenu>{listItems}</StyledMenu>;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 05:37:16 +00:00
|
|
|
export interface PopoverTargetButtonProps {
|
|
|
|
|
borderRadius?: ButtonBorderRadius;
|
|
|
|
|
boxShadow?: ButtonBoxShadow;
|
|
|
|
|
boxShadowColor?: string;
|
|
|
|
|
buttonColor?: string;
|
|
|
|
|
buttonVariant?: ButtonVariant;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
label?: string;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode?: RenderMode;
|
2021-08-24 05:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function PopoverTargetButton(props: PopoverTargetButtonProps) {
|
2021-07-13 08:05:09 +00:00
|
|
|
const {
|
2021-08-24 05:37:16 +00:00
|
|
|
borderRadius,
|
|
|
|
|
boxShadow,
|
|
|
|
|
boxShadowColor,
|
|
|
|
|
buttonColor,
|
|
|
|
|
buttonVariant,
|
2021-07-13 08:05:09 +00:00
|
|
|
iconAlign,
|
|
|
|
|
iconName,
|
|
|
|
|
isDisabled,
|
|
|
|
|
label,
|
2021-12-08 13:11:13 +00:00
|
|
|
placement,
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode,
|
2021-07-13 08:05:09 +00:00
|
|
|
} = props;
|
2021-12-08 13:11:13 +00:00
|
|
|
const isRightAlign = iconAlign === Alignment.RIGHT;
|
2021-07-13 08:05:09 +00:00
|
|
|
|
|
|
|
|
return (
|
2022-03-13 17:21:04 +00:00
|
|
|
<DragContainer
|
2021-08-24 05:37:16 +00:00
|
|
|
buttonColor={buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
2021-07-13 08:05:09 +00:00
|
|
|
disabled={isDisabled}
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode={renderMode}
|
|
|
|
|
>
|
|
|
|
|
<BaseButton
|
|
|
|
|
alignText={getAlignText(isRightAlign, iconName)}
|
|
|
|
|
borderRadius={borderRadius}
|
|
|
|
|
boxShadow={boxShadow}
|
|
|
|
|
boxShadowColor={boxShadowColor}
|
|
|
|
|
buttonColor={buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
|
|
|
|
disabled={isDisabled}
|
|
|
|
|
fill
|
|
|
|
|
icon={isRightAlign ? undefined : iconName}
|
|
|
|
|
placement={placement}
|
|
|
|
|
rightIcon={isRightAlign ? iconName : undefined}
|
|
|
|
|
text={label}
|
|
|
|
|
/>
|
|
|
|
|
</DragContainer>
|
2021-07-13 08:05:09 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 15:10:22 +00:00
|
|
|
export interface MenuButtonComponentProps {
|
2021-07-13 08:05:09 +00:00
|
|
|
label?: string;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isCompact?: boolean;
|
|
|
|
|
menuItems: Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
widgetId: string;
|
|
|
|
|
id: string;
|
|
|
|
|
index: number;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
textColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconColor?: string;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
onClick?: string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
2021-08-24 05:37:16 +00:00
|
|
|
menuVariant?: ButtonVariant;
|
|
|
|
|
menuColor?: string;
|
|
|
|
|
borderRadius?: ButtonBorderRadius;
|
|
|
|
|
boxShadow?: ButtonBoxShadow;
|
|
|
|
|
boxShadowColor?: string;
|
2021-07-13 08:05:09 +00:00
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
onItemClicked: (onClick: string | undefined) => void;
|
2021-09-09 15:10:22 +00:00
|
|
|
backgroundColor?: string;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2021-11-30 10:38:46 +00:00
|
|
|
width: number;
|
|
|
|
|
menuDropDownWidth: number;
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode?: RenderMode;
|
2021-07-13 08:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MenuButtonComponent(props: MenuButtonComponentProps) {
|
|
|
|
|
const {
|
2021-08-24 05:37:16 +00:00
|
|
|
borderRadius,
|
|
|
|
|
boxShadow,
|
|
|
|
|
boxShadowColor,
|
2021-07-13 08:05:09 +00:00
|
|
|
iconAlign,
|
|
|
|
|
iconName,
|
|
|
|
|
isCompact,
|
|
|
|
|
isDisabled,
|
|
|
|
|
label,
|
2021-08-24 05:37:16 +00:00
|
|
|
menuColor,
|
2021-11-30 10:38:46 +00:00
|
|
|
menuDropDownWidth,
|
2021-07-13 08:05:09 +00:00
|
|
|
menuItems,
|
2021-08-24 05:37:16 +00:00
|
|
|
menuVariant,
|
2021-07-13 08:05:09 +00:00
|
|
|
onItemClicked,
|
2021-12-08 13:11:13 +00:00
|
|
|
placement,
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode,
|
2021-11-30 10:38:46 +00:00
|
|
|
width,
|
2021-07-13 08:05:09 +00:00
|
|
|
} = props;
|
2022-03-17 10:19:17 +00:00
|
|
|
const id = uniqueId();
|
2021-07-13 08:05:09 +00:00
|
|
|
|
|
|
|
|
return (
|
2022-03-13 17:21:04 +00:00
|
|
|
<>
|
2021-11-30 10:38:46 +00:00
|
|
|
<PopoverStyles
|
|
|
|
|
id={id}
|
|
|
|
|
menuDropDownWidth={menuDropDownWidth}
|
|
|
|
|
parentWidth={width - WidgetContainerDiff}
|
|
|
|
|
/>
|
2021-07-13 08:05:09 +00:00
|
|
|
<Popover2
|
|
|
|
|
content={
|
|
|
|
|
<PopoverContent
|
|
|
|
|
isCompact={isCompact}
|
|
|
|
|
menuItems={menuItems}
|
|
|
|
|
onItemClicked={onItemClicked}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
disabled={isDisabled}
|
|
|
|
|
fill
|
|
|
|
|
minimal
|
|
|
|
|
placement="bottom-end"
|
2021-11-30 10:38:46 +00:00
|
|
|
popoverClassName={`menu-button-popover menu-button-width-${id}`}
|
2021-07-13 08:05:09 +00:00
|
|
|
>
|
|
|
|
|
<PopoverTargetButton
|
2021-08-24 05:37:16 +00:00
|
|
|
borderRadius={borderRadius}
|
|
|
|
|
boxShadow={boxShadow}
|
|
|
|
|
boxShadowColor={boxShadowColor}
|
|
|
|
|
buttonColor={menuColor}
|
|
|
|
|
buttonVariant={menuVariant}
|
2021-07-13 08:05:09 +00:00
|
|
|
iconAlign={iconAlign}
|
|
|
|
|
iconName={iconName}
|
|
|
|
|
isDisabled={isDisabled}
|
|
|
|
|
label={label}
|
2021-12-08 13:11:13 +00:00
|
|
|
placement={placement}
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode={renderMode}
|
2021-07-13 08:05:09 +00:00
|
|
|
/>
|
|
|
|
|
</Popover2>
|
2022-03-13 17:21:04 +00:00
|
|
|
</>
|
2021-07-13 08:05:09 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default MenuButtonComponent;
|