import type { ReactNode } from "react"; import React from "react"; import styled from "styled-components"; import type { ItemRenderer } from "@blueprintjs/select"; import { Select } from "@blueprintjs/select"; import type { Intent as BlueprintIntent } from "@blueprintjs/core"; import { Button, MenuItem, PopoverPosition, PopoverInteractionKind, } from "@blueprintjs/core"; import { noop } from "utils/AppsmithUtils"; import type { Intent } from "constants/DefaultTheme"; import type { DropdownOption } from "components/constants"; import { Icon } from "design-system"; export type ContextDropdownOption = DropdownOption & { onSelect: (event: React.MouseEvent) => void; intent?: Intent; children?: ContextDropdownOption[]; }; const Dropdown = Select.ofType(); const StyledMenuItem = styled(MenuItem)` &&&&.bp3-menu-item:hover { background: ${(props) => props.theme.colors.primaryOld}; color: ${(props) => props.theme.colors.textOnDarkBG}; } &&&.bp3-menu-item.bp3-intent-danger:hover { background: ${(props) => props.theme.colors.error}; } `; interface ContextDropdownProps { options: ContextDropdownOption[]; className: string; toggle: { type: "icon" | "button"; icon: string; iconSize?: number; text?: string; placeholder?: string; color?: string; }; } function DropdownItem(option: ContextDropdownOption) { return ( {option.children && option.children.map(DropdownItem)} ); } export function ContextDropdown(props: ContextDropdownProps) { let trigger: ReactNode; if (props.toggle.type === "icon" && props.toggle.icon) { trigger = ; } if (props.toggle.type === "button" && props.toggle.text) trigger =