mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
* refactor: simplify table toolbar * refactor: table links and padding * fix: header icons colors * fix: minor table style changes
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
import { IconButton, InputBase, Tooltip } from '@mui/material';
|
|
import { Search, Close } from '@mui/icons-material';
|
|
import classnames from 'classnames';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import { useStyles } from './TableSearchField.styles';
|
|
|
|
interface ITableSearchFieldProps {
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
className?: string;
|
|
placeholder: string;
|
|
onBlur?: (clear?: boolean) => void;
|
|
}
|
|
|
|
export const TableSearchField = ({
|
|
value = '',
|
|
onChange,
|
|
className,
|
|
placeholder,
|
|
onBlur,
|
|
}: ITableSearchFieldProps) => {
|
|
const { classes: styles } = useStyles();
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
<div
|
|
className={classnames(
|
|
styles.search,
|
|
className,
|
|
'search-container'
|
|
)}
|
|
>
|
|
<Search
|
|
className={classnames(styles.searchIcon, 'search-icon')}
|
|
/>
|
|
<InputBase
|
|
autoFocus
|
|
placeholder={placeholder}
|
|
classes={{
|
|
root: classnames(styles.inputRoot, 'input-container'),
|
|
}}
|
|
inputProps={{ 'aria-label': placeholder }}
|
|
value={value}
|
|
onChange={e => onChange(e.target.value)}
|
|
onBlur={() => onBlur?.()}
|
|
/>
|
|
<div
|
|
className={classnames(
|
|
styles.clearContainer,
|
|
'clear-container'
|
|
)}
|
|
>
|
|
<ConditionallyRender
|
|
condition={Boolean(value)}
|
|
show={
|
|
<Tooltip title="Clear search query" arrow>
|
|
<IconButton
|
|
size="small"
|
|
onClick={() => {
|
|
onChange('');
|
|
onBlur?.(true);
|
|
}}
|
|
>
|
|
<Close className={styles.clearIcon} />
|
|
</IconButton>
|
|
</Tooltip>
|
|
}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|