From bceae2fb4e6106cb2b01e9ab8617ae29e6b6d8ff Mon Sep 17 00:00:00 2001 From: Preet Date: Thu, 17 Mar 2022 10:57:39 +0530 Subject: [PATCH] refactor select button --- .../SelectWidget/component/SelectButton.tsx | 57 +++++++++++++++++ .../SelectWidget/component/index.styled.tsx | 2 +- .../widgets/SelectWidget/component/index.tsx | 64 ++----------------- 3 files changed, 63 insertions(+), 60 deletions(-) create mode 100644 app/client/src/widgets/SelectWidget/component/SelectButton.tsx diff --git a/app/client/src/widgets/SelectWidget/component/SelectButton.tsx b/app/client/src/widgets/SelectWidget/component/SelectButton.tsx new file mode 100644 index 0000000000..12d96c7c83 --- /dev/null +++ b/app/client/src/widgets/SelectWidget/component/SelectButton.tsx @@ -0,0 +1,57 @@ +import React, { memo } from "react"; +import Icon, { IconSize } from "components/ads/Icon"; +import { Button } from "@blueprintjs/core"; +import { Colors } from "constants/Colors"; +import { isNil } from "lodash"; + +import { isString } from "../../../utils/helpers"; +import { StyledDiv } from "./index.styled"; + +export const isEmptyOrNill = (value: any) => { + return isNil(value) || (isString(value) && value === ""); +}; + +interface SelectButtonProps { + disabled?: boolean; + displayText?: string; + handleCancelClick?: (event: React.MouseEvent) => void; + togglePopoverVisibility: () => void; + value?: string; +} + +function SelectButton(props: SelectButtonProps) { + const { + disabled, + displayText, + handleCancelClick, + togglePopoverVisibility, + value, + } = props; + return ( +