1- import React from 'react' ;
2- import PropTypes from 'prop-types ' ;
1+ import React , { TextareaHTMLAttributes , Ref , FunctionComponent } from 'react' ;
2+ import { CommonProps } from '../../common ' ;
33import classNames from 'classnames' ;
4-
54import { EuiValidatableControl } from '../validatable_control' ;
65
6+ export type EuiTextAreaProps = TextareaHTMLAttributes < HTMLTextAreaElement > &
7+ CommonProps & {
8+ isInvalid ?: boolean ;
9+ fullWidth ?: boolean ;
10+ compressed ?: boolean ;
11+
12+ /**
13+ * Which direction, if at all, should the textarea resize
14+ */
15+ resize ?: keyof typeof resizeToClassNameMap ;
16+
17+ inputRef ?: Ref < HTMLTextAreaElement > ;
18+ } ;
19+
720const resizeToClassNameMap = {
821 vertical : 'euiTextArea--resizeVertical' ,
922 horizontal : 'euiTextArea--resizeHorizontal' ,
@@ -13,17 +26,17 @@ const resizeToClassNameMap = {
1326
1427export const RESIZE = Object . keys ( resizeToClassNameMap ) ;
1528
16- export const EuiTextArea = ( {
29+ export const EuiTextArea : FunctionComponent < EuiTextAreaProps > = ( {
1730 children,
1831 className,
1932 compressed,
20- fullWidth,
33+ fullWidth = false ,
2134 id,
2235 inputRef,
2336 isInvalid,
2437 name,
2538 placeholder,
26- resize,
39+ resize = 'vertical' ,
2740 rows,
2841 ...rest
2942} ) => {
@@ -37,7 +50,7 @@ export const EuiTextArea = ({
3750 className
3851 ) ;
3952
40- let definedRows ;
53+ let definedRows : number ;
4154
4255 if ( rows ) {
4356 definedRows = rows ;
@@ -62,23 +75,3 @@ export const EuiTextArea = ({
6275 </ EuiValidatableControl >
6376 ) ;
6477} ;
65-
66- EuiTextArea . propTypes = {
67- name : PropTypes . string ,
68- id : PropTypes . string ,
69- placeholder : PropTypes . string ,
70- rows : PropTypes . number ,
71- isInvalid : PropTypes . bool ,
72- fullWidth : PropTypes . bool ,
73- compressed : PropTypes . bool ,
74-
75- /**
76- * Which direction, if at all, should the textarea resize
77- */
78- resize : PropTypes . oneOf ( RESIZE ) ,
79- } ;
80-
81- EuiTextArea . defaultProps = {
82- fullWidth : false ,
83- resize : 'vertical' ,
84- } ;
0 commit comments