From 9011566734427556565b1a8ce1b55fdb23c91d3c Mon Sep 17 00:00:00 2001 From: Bogdan Hanea Date: Mon, 13 Nov 2023 12:31:29 +0200 Subject: [PATCH] WIP --- .../CreatableSingleSelect.tsx | 21 ++++++++++++++++--- .../DefaultComponents/ClearIndicator.tsx | 15 +++++++++++++ .../ReactSelect/DefaultComponents/index.ts | 1 + .../web/src/plugins/test-sources/plugin.tsx | 2 ++ packages/web/src/utils/sources.ts | 8 +++---- 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 packages/web/src/components/atoms/ReactSelect/DefaultComponents/ClearIndicator.tsx diff --git a/packages/web/src/components/atoms/ReactSelect/CreatableSingleSelect/CreatableSingleSelect.tsx b/packages/web/src/components/atoms/ReactSelect/CreatableSingleSelect/CreatableSingleSelect.tsx index 02d6e7286..6a239bf75 100644 --- a/packages/web/src/components/atoms/ReactSelect/CreatableSingleSelect/CreatableSingleSelect.tsx +++ b/packages/web/src/components/atoms/ReactSelect/CreatableSingleSelect/CreatableSingleSelect.tsx @@ -7,7 +7,9 @@ import usePressEnter from '@hooks/usePressEnter'; import {Option} from '@models/form'; import CustomSingleValue from '../CustomComponents/SingleValue'; -import {DefaultDropdownIndicator, DefaultOptionComponent} from '../DefaultComponents'; +import {DefaultClearIndicator, DefaultOptionComponent} from '../DefaultComponents'; +import ClearIndicator from '../DefaultComponents/ClearIndicator'; +import MultiValueRemove from '../DefaultComponents/MultiValueRemove'; import {customSingleValueStyles, customTheme} from '../ReactSelect.styled'; type SingleSelectProps = { @@ -59,13 +61,23 @@ const CreatableSingleSelect: React.FC = props => { } }; + const selectionStyles = { + clearIndicator: (base: any, state: any) => ({ + ...base, + cursor: 'pointer', + color: state.isFocused ? 'red' : 'green', + fontWeight: 500, + }), + // Add more custom styles here if needed + }; + return ( = props => { styles={customSingleValueStyles(validation, stylePlaceholderAsValue)} components={{ Option: CustomOptionComponent, - DropdownIndicator: DefaultDropdownIndicator, + // removing default dropdown indicator + DropdownIndicator: () => null, + ClearIndicator: DefaultClearIndicator, SingleValue: CustomSingleValue, }} data-test={dataTest} isDisabled={disabled} + noOptionsMessage={() => null} /> ); }; diff --git a/packages/web/src/components/atoms/ReactSelect/DefaultComponents/ClearIndicator.tsx b/packages/web/src/components/atoms/ReactSelect/DefaultComponents/ClearIndicator.tsx new file mode 100644 index 000000000..9a64dcaf3 --- /dev/null +++ b/packages/web/src/components/atoms/ReactSelect/DefaultComponents/ClearIndicator.tsx @@ -0,0 +1,15 @@ +import {ClearIndicatorProps, components} from 'react-select'; + +import {ReactComponent as RemoveIcon} from '@assets/closeCircle.svg'; + +import {Option} from '@models/form'; + +const ClearIndicator = (props: ClearIndicatorProps