File size: 1,307 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import clsx from 'clsx';
import { forwardRef } from 'react';
import withUserMentions from 'calypso/blocks/user-mentions/index';
import AutoDirection from 'calypso/components/auto-direction';
import FormTextarea from 'calypso/components/forms/form-textarea';
import withPasteToLink from 'calypso/lib/paste-to-link';
import './autoresizing-form-textarea.scss';
const AutoresizingFormTextarea = (
{
hasFocus,
value,
placeholder,
onKeyUp,
onKeyDown,
onFocus,
onBlur,
onChange,
enableAutoFocus,
...otherProps
},
forwardedRef
) => {
const classes = clsx( 'expanding-area', { focused: hasFocus } );
return (
<div className={ classes }>
<pre>
<span>{ value }</span>
<br />
</pre>
<AutoDirection>
<FormTextarea
{ ...otherProps }
value={ value }
placeholder={ placeholder }
onKeyUp={ onKeyUp }
onKeyDown={ onKeyDown }
onFocus={ onFocus }
onBlur={ onBlur }
onChange={ onChange }
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={ enableAutoFocus }
forwardedRef={ forwardedRef }
/>
</AutoDirection>
</div>
);
};
export const ForwardedAutoresizingFormTextarea = forwardRef( AutoresizingFormTextarea );
export default withPasteToLink( withUserMentions( ForwardedAutoresizingFormTextarea ) );
|