import React, { useMemo } from "react"; import { ComponentProps } from "widgets/BaseComponent"; import { MenuItem, Button, Classes } from "@blueprintjs/core"; import { DropdownOption } from "../constants"; import { IItemRendererProps } from "@blueprintjs/select"; import { debounce, findIndex, isEmpty, isNil } from "lodash"; import "../../../../node_modules/@blueprintjs/select/lib/css/blueprint-select.css"; import { Colors } from "constants/Colors"; import { TextSize } from "constants/WidgetConstants"; import { StyledLabel, TextLabelWrapper, StyledControlGroup, StyledSingleDropDown, DropdownStyles, DropdownContainer, StyledDiv, } from "./index.styled"; import Fuse from "fuse.js"; import { WidgetContainerDiff } from "widgets/WidgetUtils"; import Icon, { IconSize } from "components/ads/Icon"; import { isString } from "../../../utils/helpers"; import { IPopoverProps } from "@blueprintjs/select/node_modules/@blueprintjs/core"; const FUSE_OPTIONS = { shouldSort: true, threshold: 0.5, location: 0, minMatchCharLength: 3, findAllMatches: true, keys: ["label", "value"], }; export const isEmptyOrNill = (value: any) => { return isNil(value) || (isString(value) && value === ""); }; const DEBOUNCE_TIMEOUT = 800; interface SelectComponentState { activeItemIndex: number | undefined; query?: string; } interface SelectButtonProps { disabled?: boolean; displayText?: string; handleCancelClick?: (event: React.MouseEvent) => void; value?: string; } function SelectButton(props: SelectButtonProps) { const { disabled, displayText, handleCancelClick, value } = props; return useMemo( () => (