import { useMemo } from 'react'; import classnames from 'classnames'; import { CrossIcon } from '../../Icons'; import { slottableComponent } from '../../HOC/slottableComponent'; import { IconButton } from '../../Button/IconButton'; function isDisabled(search?: string | null) { return !search || search.trim().length === 0; } function createOnKeyDown(onClick?: () => void) { if (typeof onClick !== 'function') { return undefined; } return (e: { key: string }) => { if (e.key === 'Enter') { onClick(); } }; } type Props = { className?: string; search?: string | null; onClick?: () => void; editable?: boolean; }; function LunaticComboboxClearButton({ className, search, onClick, editable, }: Props) { const onKeyDown = useMemo(() => createOnKeyDown(onClick), [onClick]); if (!editable) { return null; } return ( ); } export const ComboboxClearButton = slottableComponent( 'ComboboxClearButton', LunaticComboboxClearButton );