2021-09-09 15:10:22 +00:00
|
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
|
|
|
import { Alignment } from "@blueprintjs/core";
|
2022-12-01 04:55:57 +00:00
|
|
|
import { IconName, IconNames } from "@blueprintjs/icons";
|
2021-09-09 15:10:22 +00:00
|
|
|
import {
|
|
|
|
|
ButtonBorderRadius,
|
|
|
|
|
ButtonVariant,
|
2022-12-01 04:55:57 +00:00
|
|
|
ButtonPlacement,
|
2021-09-09 15:10:22 +00:00
|
|
|
} from "components/constants";
|
2022-12-01 04:55:57 +00:00
|
|
|
import { RenderMode } from "constants/WidgetConstants";
|
|
|
|
|
|
|
|
|
|
export enum MenuItemsSource {
|
|
|
|
|
STATIC = "STATIC",
|
|
|
|
|
DYNAMIC = "DYNAMIC",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface MenuItem {
|
|
|
|
|
widgetId?: string;
|
|
|
|
|
index?: number;
|
|
|
|
|
id: string;
|
|
|
|
|
label?: string;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
onClick?: string;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
textColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconColor?: string;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ConfigureMenuItems {
|
|
|
|
|
label: string;
|
|
|
|
|
id: string;
|
|
|
|
|
config: MenuItem;
|
|
|
|
|
}
|
2021-09-09 15:10:22 +00:00
|
|
|
|
|
|
|
|
export interface MenuButtonWidgetProps extends WidgetProps {
|
|
|
|
|
label?: string;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isCompact?: boolean;
|
2022-12-01 04:55:57 +00:00
|
|
|
menuItems: Record<string, MenuItem>;
|
|
|
|
|
getVisibleItems: () => Array<MenuItem>;
|
2021-09-09 15:10:22 +00:00
|
|
|
menuVariant?: ButtonVariant;
|
|
|
|
|
menuColor?: string;
|
2022-12-01 04:55:57 +00:00
|
|
|
borderRadius: ButtonBorderRadius;
|
2022-05-04 09:45:57 +00:00
|
|
|
boxShadow?: string;
|
2022-12-01 04:55:57 +00:00
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
placement?: ButtonPlacement;
|
|
|
|
|
menuItemsSource: MenuItemsSource;
|
|
|
|
|
configureMenuItems: ConfigureMenuItems;
|
|
|
|
|
sourceData?: Array<Record<string, unknown>>;
|
|
|
|
|
sourceDataKeys?: Array<string>;
|
|
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2022-12-01 04:55:57 +00:00
|
|
|
export interface MenuButtonComponentProps {
|
|
|
|
|
label?: string;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isCompact?: boolean;
|
|
|
|
|
menuItems: Record<string, MenuItem>;
|
|
|
|
|
getVisibleItems: () => Array<MenuItem>;
|
|
|
|
|
menuVariant?: ButtonVariant;
|
|
|
|
|
menuColor?: string;
|
|
|
|
|
borderRadius: string;
|
|
|
|
|
boxShadow?: string;
|
2021-09-09 15:10:22 +00:00
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
2022-12-01 04:55:57 +00:00
|
|
|
onItemClicked: (onClick: string | undefined, index: number) => void;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
placement?: ButtonPlacement;
|
|
|
|
|
width: number;
|
|
|
|
|
widgetId: string;
|
|
|
|
|
menuDropDownWidth: number;
|
|
|
|
|
renderMode?: RenderMode;
|
|
|
|
|
menuItemsSource: MenuItemsSource;
|
|
|
|
|
configureMenuItems: ConfigureMenuItems;
|
|
|
|
|
sourceData?: Array<Record<string, unknown>>;
|
|
|
|
|
sourceDataKeys?: Array<string>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PopoverContentProps {
|
|
|
|
|
menuItems: Record<string, MenuItem>;
|
|
|
|
|
getVisibleItems: () => Array<MenuItem>;
|
|
|
|
|
onItemClicked: (onClick: string | undefined, index: number) => void;
|
|
|
|
|
isCompact?: boolean;
|
|
|
|
|
borderRadius?: string;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
menuItemsSource: MenuItemsSource;
|
|
|
|
|
configureMenuItems: ConfigureMenuItems;
|
|
|
|
|
sourceData?: Array<Record<string, unknown>>;
|
|
|
|
|
sourceDataKeys?: Array<string>;
|
2021-09-09 15:10:22 +00:00
|
|
|
}
|
2022-12-01 04:55:57 +00:00
|
|
|
|
|
|
|
|
export const ICON_NAMES = Object.keys(IconNames).map(
|
|
|
|
|
(name: string) => IconNames[name as keyof typeof IconNames],
|
|
|
|
|
);
|