/** * External dependencies */ import { Text, SearchIcon } from '@automattic/jetpack-components'; import { Spinner } from '@wordpress/components'; import { useDebounce } from '@wordpress/compose'; import { __ } from '@wordpress/i18n'; import { Icon, closeSmall } from '@wordpress/icons'; import classnames from 'classnames'; import { useCallback, ChangeEvent, KeyboardEvent } from 'react'; /** * Internal dependencies */ import styles from './style.module.scss'; import { InputProps, SearchInputProps } from './types'; import type React from 'react'; const InputWrapper = ( { className, disabled = false, loading = false, icon = null, endAdornment = null, onChange, onEnter, size = 'small', ...inputProps }: InputProps ) => { const handleChangeEvent = useCallback( ( e: ChangeEvent< HTMLInputElement | HTMLTextAreaElement > ) => { if ( onChange != null ) { onChange( e.currentTarget.value ); } }, [ onChange ] ); const handleKeyUpEvent = useCallback( ( e: KeyboardEvent< HTMLInputElement | HTMLTextAreaElement > ) => { if ( onEnter != null && [ 'Enter', 'NumpadEnter' ].includes( e.code ) ) { onEnter( e.currentTarget.value ); } }, [ onEnter ] ); const baseProps = { className: classnames( styles.input, { [ styles[ 'with-icon' ] ]: icon != null, } ), onChange: handleChangeEvent, onKeyUp: handleKeyUpEvent, disabled: disabled, [ 'aria-disabled' ]: disabled, }; const isTextarea = inputProps?.type === 'textarea'; return (
{ isTextarea ? (