Skip to content

Commit

Permalink
refactor(ds): make onPressClearButton required when showClearButton (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wachunei authored Dec 18, 2023
1 parent c4b18ed commit db8b71d
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit db8b71d

Please sign in to comment.