diff --git a/app/client/.eslintrc.json b/app/client/.eslintrc.json index 0e6d1239e1..fe0ab77466 100644 --- a/app/client/.eslintrc.json +++ b/app/client/.eslintrc.json @@ -28,7 +28,13 @@ "react/prop-types": 0, "@typescript-eslint/explicit-module-boundary-types": 0, "cypress/no-unnecessary-waiting": 0, - "cypress/no-assigning-return-values": 0 + "cypress/no-assigning-return-values": 0, + "react/function-component-definition": "warn", + "react/jsx-boolean-value": "error", + "react/self-closing-comp": "error", + "react/jsx-sort-props": "error", + "react/jsx-fragments": "error", + "react/jsx-no-useless-fragment": "error" }, "settings": { "react": { diff --git a/app/client/cypress/fixtures/formResetDsl.json b/app/client/cypress/fixtures/formResetDsl.json index e45820cd8b..99048332fc 100644 --- a/app/client/cypress/fixtures/formResetDsl.json +++ b/app/client/cypress/fixtures/formResetDsl.json @@ -137,6 +137,27 @@ "parentId": "qrqizehc5b", "widgetId": "672gf8vm2q", "dynamicBindingPathList": [] + }, + { + "defaultOptionValue": "", + "dynamicBindingPathList": [], + "dynamicTriggerPathList": [], + "isLoading": false, + "isVisible": true, + "label": "", + "options": "[\n {\n \"label\": \"Option 1\",\n \"value\": \"1\"\n },\n {\n \"label\": \"Option 2\",\n \"value\": \"2\"\n },\n {\n \"label\": \"Option 3\",\n \"value\": \"3\"\n },\n {\n \"label\": \"Option 4\",\n \"value\": \"4\"\n },\n {\n \"label\": \"Option 5\",\n \"value\": \"5\"\n }\n]", + "parentId": "qrqizehc5b", + "parentColumnSpace": 71.5, + "parentRowSpace": 40, + "selectionType": "MULTI_SELECT", + "leftColumn": 6, + "rightColumn": 16, + "topRow": 9, + "bottomRow": 10, + "type": "DROP_DOWN_WIDGET", + "version": 1, + "widgetId": "dwh49bulj9", + "widgetName": "Dropdown1" } ], "blueprint": { diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_Table_Widget_API_Derived_Column_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_Table_Widget_API_Derived_Column_spec.js index e6d76b3bc6..f39a3eb08b 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_Table_Widget_API_Derived_Column_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_Table_Widget_API_Derived_Column_spec.js @@ -4,6 +4,7 @@ const pages = require("../../../../locators/Pages.json"); const apiPage = require("../../../../locators/ApiEditor.json"); const publishPage = require("../../../../locators/publishWidgetspage.json"); const testdata = require("../../../../fixtures/testdata.json"); +const widgetsPage = require("../../../../locators/Widgets.json"); describe("Test Create Api and Bind to Table widget", function() { before(() => { @@ -41,6 +42,37 @@ describe("Test Create Api and Bind to Table widget", function() { cy.closePropertyPane(); }); + it("Check Image alignment is working as expected", function() { + cy.SearchEntityandOpen("Table1"); + cy.editColumn("avatar"); + cy.changeColumnType("Image"); + cy.closePropertyPane(); + cy.SearchEntityandOpen("Table1"); + cy.get(widgetsPage.centerAlign) + .first() + .click({ force: true }); + cy.closePropertyPane(); + cy.get(`.t--widget-tablewidget .tbody .image-cell`) + .first() + .should("have.css", "background-position", "50% 50%"); + cy.SearchEntityandOpen("Table1"); + cy.get(widgetsPage.rightAlign) + .first() + .click({ force: true }); + cy.closePropertyPane(); + cy.get(`.t--widget-tablewidget .tbody .image-cell`) + .first() + .should("have.css", "background-position", "100% 50%"); + cy.SearchEntityandOpen("Table1"); + cy.get(widgetsPage.leftAlign) + .first() + .click({ force: true }); + cy.closePropertyPane(); + cy.get(`.t--widget-tablewidget .tbody .image-cell`) + .first() + .should("have.css", "background-position", "0% 50%"); + }); + it("Update table json data and check the derived column values after update", function() { cy.SearchEntityandOpen("Table1"); cy.tableColumnDataValidation("id"); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Dropdown_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Dropdown_spec.js index 5c6d853449..140fe89090 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Dropdown_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Dropdown_spec.js @@ -15,7 +15,6 @@ describe("Dropdown Widget Functionality", function() { cy.testJsontext("options", JSON.stringify(data.input)); cy.testJsontext("defaultoption", "{{ undefined }}"); - cy.get(formWidgetsPage.dropdownWidget) .find(widgetLocators.dropdownSingleSelect) .click({ force: true }); @@ -27,6 +26,13 @@ describe("Dropdown Widget Functionality", function() { .find(widgetLocators.defaultSingleSelectValue) .should("have.text", "Option 3"); }); + it("Selects value with enter in default value", () => { + // cy.openPropertyPane("dropdownwidget"); + cy.testJsontext("defaultoption", "3\n"); + cy.get(formWidgetsPage.dropdownWidget) + .find(widgetLocators.defaultSingleSelectValue) + .should("have.text", "Option 3"); + }); it("Dropdown Widget Functionality", function() { cy.widgetText( "lock", diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js index 541586379a..837c8813e8 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js @@ -12,6 +12,12 @@ describe("Form reset functionality", function() { .click() .should("have.class", "selected-row"); + cy.get(".t--draggable-dropdownwidget").click({ force: true }); + cy.get(".t--draggable-dropdownwidget").type("Option"); + cy.dropdownDynamic("Option 1"); + cy.dropdownDynamic("Option 2"); + cy.dropdownDynamic("Option 3"); + cy.get(widgetsPage.inputWidget + " " + "input") .invoke("attr", "value") .should("contain", "lindsay.ferguson@reqres.in"); @@ -26,6 +32,12 @@ describe("Form reset functionality", function() { .eq(2) .should("not.have.class", "selected-row"); + cy.get(".t-draggable-dropdownwidget .bp3-tag-input-values .bp3-tag").should( + ($span) => { + expect($span).to.have.length(0); + }, + ); + cy.get(widgetsPage.inputWidget + " " + "input") .invoke("attr", "value") .should("not.contain", "lindsay.ferguson@reqres.in"); diff --git a/app/client/src/AppErrorBoundry.tsx b/app/client/src/AppErrorBoundry.tsx index 776993508a..172c4aab80 100644 --- a/app/client/src/AppErrorBoundry.tsx +++ b/app/client/src/AppErrorBoundry.tsx @@ -51,7 +51,7 @@ class AppErrorBoundary extends Component { if (this.state.hasError) { return ( - App crashed + App crashed

Oops! Something went wrong

diff --git a/app/client/src/AppRouter.tsx b/app/client/src/AppRouter.tsx index 9d91296f6e..1ba02d5b77 100644 --- a/app/client/src/AppRouter.tsx +++ b/app/client/src/AppRouter.tsx @@ -90,24 +90,24 @@ class AppRouter extends React.Component { <> - + - - - + + + - + - - + + diff --git a/app/client/src/LandingScreen.tsx b/app/client/src/LandingScreen.tsx index 3a3457aee1..8b456959a9 100755 --- a/app/client/src/LandingScreen.tsx +++ b/app/client/src/LandingScreen.tsx @@ -13,7 +13,7 @@ type Props = { authError: string; }; -const LandingScreen = (props: Props) => { +function LandingScreen(props: Props) { if (props.user && window.location.pathname === BASE_URL) { if (props.user.email === ANONYMOUS_USERNAME) { return ; @@ -25,7 +25,7 @@ const LandingScreen = (props: Props) => { return ; } return ; -}; +} const mapStateToProps = (state: AppState) => ({ user: getCurrentUser(state), diff --git a/app/client/src/components/ads/AppIcon.tsx b/app/client/src/components/ads/AppIcon.tsx index adb38cc047..bfc56042cd 100644 --- a/app/client/src/components/ads/AppIcon.tsx +++ b/app/client/src/components/ads/AppIcon.tsx @@ -223,7 +223,7 @@ export type AppIconProps = CommonComponentProps & { name: AppIconName; }; -const AppIcon = (props: AppIconProps) => { +function AppIcon(props: AppIconProps) { const styledProps = useMemo(() => appSizeHandler(props.size || Size.medium), [ props, ]); @@ -484,6 +484,6 @@ const AppIcon = (props: AppIconProps) => { {returnIcon} ) : null; -}; +} export default AppIcon; diff --git a/app/client/src/components/ads/Button.tsx b/app/client/src/components/ads/Button.tsx index 584a257d82..ea97229575 100644 --- a/app/client/src/components/ads/Button.tsx +++ b/app/client/src/components/ads/Button.tsx @@ -376,13 +376,13 @@ const IconSizeProp = (size?: Size) => { return size ? sizeMapping[size] : IconSize.SMALL; }; -const TextLoadingState = ({ text }: { text?: string }) => ( - {text} -); +function TextLoadingState({ text }: { text?: string }) { + return {text}; +} -const IconLoadingState = ({ size, icon }: { size?: Size; icon?: IconName }) => ( - -); +function IconLoadingState({ size, icon }: { size?: Size; icon?: IconName }) { + return ; +} const getIconContent = (props: ButtonProps) => props.icon ? ( @@ -410,39 +410,44 @@ const getButtonContent = (props: ButtonProps) => ( ); -const ButtonComponent = (props: ButtonProps) => ( - ) => - props.onClick && props.onClick(e) - } - > - {getButtonContent(props)} - -); +function ButtonComponent(props: ButtonProps) { + return ( + ) => + props.onClick && props.onClick(e) + } + > + {getButtonContent(props)} + + ); +} -const LinkButtonComponent = (props: ButtonProps) => ( - ) => - props.onClick && props.onClick(e) - } - > - {getButtonContent(props)} - -); +function LinkButtonComponent(props: ButtonProps) { + return ( + ) => + props.onClick && props.onClick(e) + } + > + {getButtonContent(props)} + + ); +} -const Button = (props: ButtonProps) => - props.tag === "button" ? ( +function Button(props: ButtonProps) { + return props.tag === "button" ? ( ) : ( ); +} export default Button; diff --git a/app/client/src/components/ads/ButtonTabComponent.tsx b/app/client/src/components/ads/ButtonTabComponent.tsx index 4fd11e6b73..4fe5bbe03f 100644 --- a/app/client/src/components/ads/ButtonTabComponent.tsx +++ b/app/client/src/components/ads/ButtonTabComponent.tsx @@ -41,7 +41,7 @@ interface ButtonTabComponentProps { selectButton: (value: string) => void; } -const ButtonTabComponent = (props: ButtonTabComponentProps) => { +function ButtonTabComponent(props: ButtonTabComponentProps) { return ( {props.options.map((option: ButtonTabOption, index: number) => { @@ -50,17 +50,17 @@ const ButtonTabComponent = (props: ButtonTabComponentProps) => { const isSelected = props.values.includes(option.value); return ( props.selectButton(option.value)} className={`t--button-tab-${option.value}`} + key={index} + onClick={() => props.selectButton(option.value)} + selected={isSelected} > - + ); })} ); -}; +} export default ButtonTabComponent; diff --git a/app/client/src/components/ads/Callout.tsx b/app/client/src/components/ads/Callout.tsx index a1eeabb6e8..2df99e39a2 100644 --- a/app/client/src/components/ads/Callout.tsx +++ b/app/client/src/components/ads/Callout.tsx @@ -73,14 +73,14 @@ Callout.defaultProps = { function Callout(props: CalloutProps) { return ( - + {props.text && props.variant !== Variant.info ? ( ) : null} {props.text} {props.label ? props.label : null} {props.closeButton ? ( -

-
+
{fileInfo.name} {fileInfo.size}KB
-
+
); -}; +} -const FilePicker = (props: FilePickerProps) => { +function FilePicker(props: FilePickerProps) { return ( ); -}; +} export default FilePicker; diff --git a/app/client/src/components/ads/GifPlayerComponent.tsx b/app/client/src/components/ads/GifPlayerComponent.tsx index abd58e55af..3074ee7e0d 100644 --- a/app/client/src/components/ads/GifPlayerComponent.tsx +++ b/app/client/src/components/ads/GifPlayerComponent.tsx @@ -52,24 +52,20 @@ const Overlay = styled.div` transition: 0.5s ease; `; -const GifPlayerComponent = (props: GifPlayerProps) => { +function GifPlayerComponent(props: GifPlayerProps) { const [startGif, setStartGif] = useState(false); - return ( - - {!startGif ? ( - setStartGif(!startGif)}> - - - - - Click to play - - - ) : ( - - )} - + return !startGif ? ( + setStartGif(!startGif)}> + + + + + Click to play + + + ) : ( + ); -}; +} export default GifPlayerComponent; diff --git a/app/client/src/components/ads/Icon.tsx b/app/client/src/components/ads/Icon.tsx index ac3a081541..d1e7283cab 100644 --- a/app/client/src/components/ads/Icon.tsx +++ b/app/client/src/components/ads/Icon.tsx @@ -364,7 +364,7 @@ const Icon = forwardRef( case "PARAGRAPH": case "PARAGRAPH_TWO": const ControlIcon = ControlIcons[props.name]; - returnIcon = ; + returnIcon = ; break; default: diff --git a/app/client/src/components/ads/IconSelector.tsx b/app/client/src/components/ads/IconSelector.tsx index e71b7f6317..61b0632d26 100644 --- a/app/client/src/components/ads/IconSelector.tsx +++ b/app/client/src/components/ads/IconSelector.tsx @@ -58,7 +58,7 @@ const IconBox = styled.div<{ selectedColor?: string }>` : null}; `; -const IconSelector = (props: IconSelectorProps) => { +function IconSelector(props: IconSelectorProps) { const iconRef = useRef(null); const [selected, setSelected] = useState(firstSelectedIcon()); const iconPaletteRef = React.createRef(); @@ -87,8 +87,8 @@ const IconSelector = (props: IconSelectorProps) => { return ( {props.iconPalette && @@ -96,19 +96,19 @@ const IconSelector = (props: IconSelectorProps) => { return ( { if (iconName !== selected) { setSelected(iconName); props.onSelect && props.onSelect(iconName); } }} + selectedColor={selected === iconName ? props.selectedColor : ""} > @@ -117,7 +117,7 @@ const IconSelector = (props: IconSelectorProps) => { ); -}; +} IconSelector.defaultProps = { fill: false, diff --git a/app/client/src/components/ads/IconTabsComponent.tsx b/app/client/src/components/ads/IconTabsComponent.tsx index 36dea7abc2..0ea7d8e293 100644 --- a/app/client/src/components/ads/IconTabsComponent.tsx +++ b/app/client/src/components/ads/IconTabsComponent.tsx @@ -38,7 +38,7 @@ interface IconTabsComponentProps { selectOption: (value: string) => void; } -const IconTabsComponent = (props: IconTabsComponentProps) => { +function IconTabsComponent(props: IconTabsComponentProps) { return ( {props.options.map((option: IconTabOption, index: number) => { @@ -47,17 +47,17 @@ const IconTabsComponent = (props: IconTabsComponentProps) => { const isSelected = props.value === option.value; return ( props.selectOption(option.value)} className={`t--icon-tab-${option.value}`} + key={index} + onClick={() => props.selectOption(option.value)} + selected={isSelected} > - + ); })} ); -}; +} export default IconTabsComponent; diff --git a/app/client/src/components/ads/Menu.tsx b/app/client/src/components/ads/Menu.tsx index 116dcfed15..dc3437cba9 100644 --- a/app/client/src/components/ads/Menu.tsx +++ b/app/client/src/components/ads/Menu.tsx @@ -24,18 +24,18 @@ const MenuOption = styled.div` font-family: ${(props) => props.theme.fonts[3]}; `; -const Menu = (props: MenuProps) => { +function Menu(props: MenuProps) { return ( {props.target} @@ -46,6 +46,6 @@ const Menu = (props: MenuProps) => { ); -}; +} export default Menu; diff --git a/app/client/src/components/ads/MenuItem.tsx b/app/client/src/components/ads/MenuItem.tsx index cf0b12e76c..6bf988dfa9 100644 --- a/app/client/src/components/ads/MenuItem.tsx +++ b/app/client/src/components/ads/MenuItem.tsx @@ -90,7 +90,7 @@ const IconContainer = styled.span` const MenuItem = forwardRef( (props: MenuItemProps, ref: Ref) => { return props.ellipsize && props.text.length > props.ellipsize ? ( - + ) : ( @@ -102,13 +102,13 @@ const MenuItemContent = forwardRef( (props: MenuItemProps, ref: Ref) => { return ( {props.icon ? : null} diff --git a/app/client/src/components/ads/MultiSwitch.tsx b/app/client/src/components/ads/MultiSwitch.tsx index e1382bafff..1e08617841 100644 --- a/app/client/src/components/ads/MultiSwitch.tsx +++ b/app/client/src/components/ads/MultiSwitch.tsx @@ -55,10 +55,10 @@ export default function MultiSwitch(props: MultiSwitchProps) { {props.tabs.map((tab) => ( props.onSelect(tab.title)} + selected={props.selected.value === tab.key} > - + {tab.title} diff --git a/app/client/src/components/ads/MultiselectDropdown.tsx b/app/client/src/components/ads/MultiselectDropdown.tsx index d4c258a1fd..57b3a9d6e2 100644 --- a/app/client/src/components/ads/MultiselectDropdown.tsx +++ b/app/client/src/components/ads/MultiselectDropdown.tsx @@ -166,7 +166,7 @@ type DropdownProps = CommonComponentProps & { selectAllQuantifier?: string; }; -const MultiSelectDropdown = (props: DropdownProps) => { +function MultiSelectDropdown(props: DropdownProps) { const [isOpen, setIsOpen] = useState(false); const [containerWidth, setContainerWidth] = useState("0px"); @@ -229,23 +229,23 @@ const MultiSelectDropdown = (props: DropdownProps) => { return ( setIsOpen(state)} boundary="scrollParent" + isOpen={isOpen && !props.disabled} + minimal + onInteraction={(state) => setIsOpen(state)} + position={Position.TOP_LEFT} > setIsOpen(!isOpen)} className={props.className} + disabled={props.disabled} + isOpen={isOpen} + onClick={() => setIsOpen(!isOpen)} > {props.selected.length @@ -260,12 +260,12 @@ const MultiSelectDropdown = (props: DropdownProps) => { {props.options.map((option: DropdownOption, index: number) => { return ( { optionClickHandler(option.value as string); }} - className="t--multi-dropdown-option" + selected={isItemSelected(option.value)} > {option.icon ? ( @@ -288,6 +288,6 @@ const MultiSelectDropdown = (props: DropdownProps) => { ); -}; +} export default MultiSelectDropdown; diff --git a/app/client/src/components/ads/Radio.tsx b/app/client/src/components/ads/Radio.tsx index 8d21f828db..2d89c7e2d3 100644 --- a/app/client/src/components/ads/Radio.tsx +++ b/app/client/src/components/ads/Radio.tsx @@ -129,29 +129,29 @@ export default function RadioComponent(props: RadioProps) { return ( onChangeHandler(e.target.value)} className={props.className} + columns={props.columns} + data-cy={props.cypressSelector} + onChange={(e: any) => onChangeHandler(e.target.value)} + rows={props.rows} > {props.options.map((option: OptionProps, index: number) => ( {option.label} option.onSelect && option.onSelect(e.target.value)} type="radio" value={option.value} - disabled={props.disabled || option.disabled} - onChange={(e) => option.onSelect && option.onSelect(e.target.value)} - checked={selected === option.value} - name="radio" /> - + ))} diff --git a/app/client/src/components/ads/RectangularSwitcher.tsx b/app/client/src/components/ads/RectangularSwitcher.tsx index 179c662ea9..08228fb044 100644 --- a/app/client/src/components/ads/RectangularSwitcher.tsx +++ b/app/client/src/components/ads/RectangularSwitcher.tsx @@ -100,14 +100,13 @@ export default function Switch(props: SwitchProps) { return ( ) => { if (!firstRender) { @@ -115,8 +114,9 @@ export default function Switch(props: SwitchProps) { } onChangeHandler(e.target.checked); }} + type="checkbox" /> - + Light diff --git a/app/client/src/components/ads/ScrollIndicator.tsx b/app/client/src/components/ads/ScrollIndicator.tsx index cc1c88a758..159164bc2d 100644 --- a/app/client/src/components/ads/ScrollIndicator.tsx +++ b/app/client/src/components/ads/ScrollIndicator.tsx @@ -47,7 +47,7 @@ interface Props { right?: string; mode?: "DARK" | "LIGHT"; } -const ScrollIndicator = ({ containerRef, top, bottom, right }: Props) => { +function ScrollIndicator({ containerRef, top, bottom, right }: Props) { const [{ thumbPosition }, setThumbPosition] = useSpring<{ thumbPosition: number; config: { @@ -105,10 +105,10 @@ const ScrollIndicator = ({ containerRef, top, bottom, right }: Props) => { return ( { /> ); -}; +} export default ScrollIndicator; diff --git a/app/client/src/components/ads/SearchInput.tsx b/app/client/src/components/ads/SearchInput.tsx index f0feeb39b2..6a3e6f27c2 100644 --- a/app/client/src/components/ads/SearchInput.tsx +++ b/app/client/src/components/ads/SearchInput.tsx @@ -118,30 +118,30 @@ const SearchInput = forwardRef( return ( - + setIsFocused(true)} onBlur={() => setIsFocused(false)} onChange={memoizedChangeHandler} + onFocus={() => setIsFocused(true)} + placeholder={props.placeholder ? props.placeholder : ""} /> {searchValue && props.variant === SearchVariant.BACKGROUND ? ( setSearchValue("")} + size={IconSize.MEDIUM} /> ) : null} diff --git a/app/client/src/components/ads/Spinner.tsx b/app/client/src/components/ads/Spinner.tsx index 4f1b24bcbd..a1e7cb7247 100644 --- a/app/client/src/components/ads/Spinner.tsx +++ b/app/client/src/components/ads/Spinner.tsx @@ -48,11 +48,11 @@ Spinner.defaultProp = { export default function Spinner(props: SpinnerProp) { return ( - + ); } diff --git a/app/client/src/components/ads/StepComponent.tsx b/app/client/src/components/ads/StepComponent.tsx index 8826f22b56..403fb24c77 100644 --- a/app/client/src/components/ads/StepComponent.tsx +++ b/app/client/src/components/ads/StepComponent.tsx @@ -63,7 +63,7 @@ interface StepComponentProps { onChange: (value: number) => void; } -export const StepComponent = (props: StepComponentProps) => { +export function StepComponent(props: StepComponentProps) { function decrease() { if (props.value < props.min) { return; @@ -80,11 +80,11 @@ export const StepComponent = (props: StepComponentProps) => { } return ( - + {props.displayFormat(props.value)} - + ); -}; +} export default StepComponent; diff --git a/app/client/src/components/ads/Table.tsx b/app/client/src/components/ads/Table.tsx index 4af94a42f1..fdfd1501be 100644 --- a/app/client/src/components/ads/Table.tsx +++ b/app/client/src/components/ads/Table.tsx @@ -138,8 +138,8 @@ function Table(props: TableProps) { return ( {cell.render("Cell")} diff --git a/app/client/src/components/ads/TableDropdown.tsx b/app/client/src/components/ads/TableDropdown.tsx index a27b050d87..9afcbdbf92 100644 --- a/app/client/src/components/ads/TableDropdown.tsx +++ b/app/client/src/components/ads/TableDropdown.tsx @@ -1,14 +1,14 @@ -import React, { Fragment, useState } from "react"; -import { CommonComponentProps, Classes } from "./common"; -import Text, { TextType } from "./Text"; -import styled from "styled-components"; +import { Position } from "@blueprintjs/core/lib/esm/common/position"; import { Popover, PopoverInteractionKind, } from "@blueprintjs/core/lib/esm/components/popover/popover"; -import { Position } from "@blueprintjs/core/lib/esm/common/position"; +import React, { useState } from "react"; +import styled from "styled-components"; +import { Classes, CommonComponentProps } from "./common"; import Icon, { IconSize } from "./Icon"; import Spinner from "./Spinner"; +import Text, { TextType } from "./Text"; type DropdownOption = { name: string; @@ -79,7 +79,7 @@ const Content = styled.div<{ isLoading?: boolean }>` } `; -const TableDropdown = (props: DropdownProps) => { +function TableDropdown(props: DropdownProps) { const [selectedIndex, setSelectedIndex] = useState(props.selectedIndex); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const [selectedOption, setSelectedOption] = useState( @@ -93,41 +93,37 @@ const TableDropdown = (props: DropdownProps) => { setIsDropdownOpen(false); }; - return ( - - {props.isLoading ? ( - - ) : ( - setIsDropdownOpen(state)} - interactionKind={PopoverInteractionKind.CLICK} - > - - - {selectedOption.name} - - - - - {props.options.map((el: DropdownOption, index: number) => ( - optionSelector(index)} - > - {el.name} - {el.desc} - - ))} - - - )} - + return props.isLoading ? ( + + ) : ( + setIsDropdownOpen(state)} + position={props.position || Position.BOTTOM_LEFT} + usePortal={false} + > + + + {selectedOption.name} + + + + + {props.options.map((el: DropdownOption, index: number) => ( + optionSelector(index)} + > + {el.name} + {el.desc} + + ))} + + ); -}; +} export default TableDropdown; diff --git a/app/client/src/components/ads/Tabs.tsx b/app/client/src/components/ads/Tabs.tsx index 37b698a753..a70206d531 100644 --- a/app/client/src/components/ads/Tabs.tsx +++ b/app/client/src/components/ads/Tabs.tsx @@ -130,17 +130,17 @@ type TabbedViewComponentType = CommonComponentProps & { overflow?: boolean; }; -export const TabComponent = (props: TabbedViewComponentType) => { +export function TabComponent(props: TabbedViewComponentType) { return ( { props.onSelect && props.onSelect(index); }} + selectedIndex={props.selectedIndex} > {props.tabs.map((tab) => ( @@ -163,4 +163,4 @@ export const TabComponent = (props: TabbedViewComponentType) => { ); -}; +} diff --git a/app/client/src/components/ads/TagInputComponent.tsx b/app/client/src/components/ads/TagInputComponent.tsx index 79ad502e8c..38de855dc8 100644 --- a/app/client/src/components/ads/TagInputComponent.tsx +++ b/app/client/src/components/ads/TagInputComponent.tsx @@ -62,7 +62,7 @@ type TagInputProps = { * On addition or removal of tags, passes the comman separated string to input.onChange prop * @param props : TagInputProps */ -const TagInputComponent = (props: TagInputProps) => { +function TagInputComponent(props: TagInputProps) { const _values = props.input.value && props.input.value.length > 0 ? props.input.value.split(",") @@ -145,25 +145,25 @@ const TagInputComponent = (props: TagInputProps) => { return ( ); -}; +} export default TagInputComponent; diff --git a/app/client/src/components/ads/TextInput.tsx b/app/client/src/components/ads/TextInput.tsx index 5bf0b9f4e7..a7aee853bf 100644 --- a/app/client/src/components/ads/TextInput.tsx +++ b/app/client/src/components/ads/TextInput.tsx @@ -88,8 +88,8 @@ const StyledInput = styled((props) => { return props.asyncControl ? ( ) : ( @@ -200,17 +200,17 @@ const TextInput = forwardRef( return ( {ErrorMessage} diff --git a/app/client/src/components/ads/Toast.tsx b/app/client/src/components/ads/Toast.tsx index e31fafe90a..8685e03e1c 100644 --- a/app/client/src/components/ads/Toast.tsx +++ b/app/client/src/components/ads/Toast.tsx @@ -39,13 +39,13 @@ const WrappedToastContainer = styled.div` top: 4em; } `; -export const StyledToastContainer = (props: ToastOptions) => { +export function StyledToastContainer(props: ToastOptions) { return ( ); -}; +} const ToastBody = styled.div<{ variant?: Variant; @@ -110,19 +110,19 @@ const StyledDebugButton = styled(DebugButton)` margin-left: auto; `; -const ToastComponent = (props: ToastProps & { undoAction?: () => void }) => { +function ToastComponent(props: ToastProps & { undoAction?: () => void }) { const dispatch = useDispatch(); return ( {props.variant === Variant.success ? ( - + ) : props.variant === Variant.warning ? ( ) : null} @@ -139,7 +139,6 @@ const ToastComponent = (props: ToastProps & { undoAction?: () => void }) => {
{props.onUndo || props.dispatchableAction ? ( { if (props.dispatchableAction) { dispatch(props.dispatchableAction); @@ -148,6 +147,7 @@ const ToastComponent = (props: ToastProps & { undoAction?: () => void }) => { props.undoAction && props.undoAction(); } }} + type={TextType.H6} > UNDO @@ -155,7 +155,7 @@ const ToastComponent = (props: ToastProps & { undoAction?: () => void }) => {
); -}; +} export const Toaster = { show: (config: ToastProps) => { diff --git a/app/client/src/components/ads/Toggle.tsx b/app/client/src/components/ads/Toggle.tsx index 60ae853016..5ae09a22ff 100644 --- a/app/client/src/components/ads/Toggle.tsx +++ b/app/client/src/components/ads/Toggle.tsx @@ -126,21 +126,21 @@ export default function Toggle(props: ToggleProps) { return ( ) => onChangeHandler(e.target.checked) } + type="checkbox" /> - + {props.isLoading ? (
diff --git a/app/client/src/components/ads/Tooltip.tsx b/app/client/src/components/ads/Tooltip.tsx index 6c858528bd..da2b2d7b23 100644 --- a/app/client/src/components/ads/Tooltip.tsx +++ b/app/client/src/components/ads/Tooltip.tsx @@ -19,26 +19,26 @@ type TooltipProps = CommonComponentProps & { minimal?: boolean; }; -const TooltipComponent = (props: TooltipProps) => { +function TooltipComponent(props: TooltipProps) { return ( {props.children} ); -}; +} TooltipComponent.defaultProps = { position: Position.TOP, diff --git a/app/client/src/components/ads/TreeDropdown.tsx b/app/client/src/components/ads/TreeDropdown.tsx index a25274362f..bede261783 100644 --- a/app/client/src/components/ads/TreeDropdown.tsx +++ b/app/client/src/components/ads/TreeDropdown.tsx @@ -169,10 +169,11 @@ export default function TreeDropdown(props: TreeDropdownProps) { selectedOption.type === option.value; return ( e.stopPropagation() }, }} + text={option.label} > {option.children && option.children.map(renderTreeOption)} @@ -202,30 +202,30 @@ export default function TreeDropdown(props: TreeDropdownProps) { const defaultToggle = (