diff --git a/app/component-library/components/Form/TextFieldSearch/TextFieldSearch.types.ts b/app/component-library/components/Form/TextFieldSearch/TextFieldSearch.types.ts index 00a121c6b90..68b7aa2da18 100644 --- a/app/component-library/components/Form/TextFieldSearch/TextFieldSearch.types.ts +++ b/app/component-library/components/Form/TextFieldSearch/TextFieldSearch.types.ts @@ -2,21 +2,39 @@ import { TextFieldProps } from '../TextField/TextField.types'; import { ButtonIconProps } from '../../Buttons/ButtonIcon/ButtonIcon.types'; -/** - * TextFieldSearch component props. - */ -export interface TextFieldSearchProps extends TextFieldProps { +interface BaseTextFieldSearchProps extends TextFieldProps { + /** + * Optional prop to pass any additional props to the clear button. + */ + clearButtonProps?: ButtonIconProps; +} + +interface HideClearButtonTextFieldSearchProps extends BaseTextFieldSearchProps { /** * Optional boolean to show the Clear button. * @default false */ - showClearButton?: boolean; + showClearButton?: false; /** * Function to trigger when pressing the clear button. */ onPressClearButton?: () => void; +} + +interface ShowClearButtonTextFieldSearchProps extends BaseTextFieldSearchProps { /** - * Optional prop to pass any additional props to the clear button. + * Show the Clear button. */ - clearButtonProps?: ButtonIconProps; + showClearButton: true; + /** + * Function to trigger when pressing the clear button. + */ + onPressClearButton: () => void; } + +/** + * TextFieldSearch component props. + */ +export type TextFieldSearchProps = + | HideClearButtonTextFieldSearchProps + | ShowClearButtonTextFieldSearchProps;