PromucFlow_constructor/app/client/src/components/propertyControls/DropDownControl.tsx

74 lines
2.0 KiB
TypeScript
Raw Normal View History

2019-11-05 05:09:50 +00:00
import React from "react";
import BaseControl, { ControlProps } from "./BaseControl";
import { StyledDropDown, StyledDropDownContainer } from "./StyledControls";
import { DropdownOption } from "components/ads/Dropdown";
2022-02-15 07:34:17 +00:00
import { isNil } from "lodash";
class DropDownControl extends BaseControl<DropDownControlProps> {
render() {
let defaultSelected: DropdownOption = {
2021-05-20 08:24:26 +00:00
label: "No selection.",
value: undefined,
};
if (this.props.defaultValue) {
defaultSelected = this.props.options.find(
(option) => option.value === this.props.defaultValue,
);
}
const selected: DropdownOption = this.props.options.find(
2020-12-24 04:32:25 +00:00
(option) => option.value === this.props.propertyValue,
);
if (selected) {
defaultSelected = selected;
}
return (
<StyledDropDownContainer>
<StyledDropDown
dropdownHeight={this.props.dropdownHeight}
enableSearch={this.props.enableSearch}
feat: Property pane dropdown overflow issues (#8236) * * hide subtext for date picker fix * EE clicking on entity, unfolding/folding added * * bug fixes in action dropdown * bug fix for cursor * fix: 8190 background api request and welcome helper button (#8281) * chore: Move action/js debugger tabs related logic to a common component (#8199) * removed background of api request textbox and added hover text on "no thanks" button Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> * fix: added scrolling in invited users more popup (#8226) * added scrolling in invited users more popup * always scrollbar displaying on invited users pan * fixed issue related with 8190 * updated cursor of invited users more * replace edit data source icon with remix icon (#8192) * * active text color * fix: dropdownlist props issue (#8322) * Commented failing JS tests (#8276) Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> * docs: Update ServerSetup.md (#8255) * Make port customizable from env variable (#8288) * fix: issue with string templates (#7848) * Remove bracket highlight on error * fix string template issue * using string template to join strings * fix breaking tests * fixed props pass issue Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> * * bug fixes * * bug fix * * test cases fix * - test case fix * * test fixes * * bug fix in test case Co-authored-by: haojin111 <63215848+haojin111@users.noreply.github.com> Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2021-10-11 06:01:05 +00:00
hideSubText={this.props.hideSubText}
onSelect={this.onItemSelect}
optionWidth={
this.props.optionWidth ? this.props.optionWidth : "231px"
}
options={this.props.options}
searchPlaceholder={this.props.placeholderText}
selected={defaultSelected}
showLabelOnly
width="100%"
/>
</StyledDropDownContainer>
);
}
onItemSelect = (value?: string): void => {
2022-02-15 07:34:17 +00:00
if (!isNil(value)) {
this.updateProperty(this.props.propertyName, value);
}
2019-10-31 05:28:11 +00:00
};
isOptionSelected = (selectedOption: any) => {
2019-11-05 05:09:50 +00:00
return selectedOption.value === this.props.propertyValue;
};
static getControlType() {
return "DROP_DOWN";
}
}
export interface DropDownControlProps extends ControlProps {
options: any[];
defaultValue?: string;
2019-11-05 05:09:50 +00:00
placeholderText: string;
dropdownHeight?: string;
enableSearch?: boolean;
2019-11-05 05:09:50 +00:00
propertyValue: string;
optionWidth?: string;
feat: Property pane dropdown overflow issues (#8236) * * hide subtext for date picker fix * EE clicking on entity, unfolding/folding added * * bug fixes in action dropdown * bug fix for cursor * fix: 8190 background api request and welcome helper button (#8281) * chore: Move action/js debugger tabs related logic to a common component (#8199) * removed background of api request textbox and added hover text on "no thanks" button Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> * fix: added scrolling in invited users more popup (#8226) * added scrolling in invited users more popup * always scrollbar displaying on invited users pan * fixed issue related with 8190 * updated cursor of invited users more * replace edit data source icon with remix icon (#8192) * * active text color * fix: dropdownlist props issue (#8322) * Commented failing JS tests (#8276) Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> * docs: Update ServerSetup.md (#8255) * Make port customizable from env variable (#8288) * fix: issue with string templates (#7848) * Remove bracket highlight on error * fix string template issue * using string template to join strings * fix breaking tests * fixed props pass issue Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> * * bug fixes * * bug fix * * test cases fix * - test case fix * * test fixes * * bug fix in test case Co-authored-by: haojin111 <63215848+haojin111@users.noreply.github.com> Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2021-10-11 06:01:05 +00:00
hideSubText?: boolean;
}
export default DropDownControl;