Skip to content

Commit 0b9e6bd

Browse files
ffknobchandlerprall
authored andcommitted
EuiTextArea: converted to Typescript (#2695)
* Converts EuiTextArea to Typescript * Adds PR number to CHANGELOG line
1 parent 3c08e54 commit 0b9e6bd

File tree

5 files changed

+21
-27
lines changed

5 files changed

+21
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## [`master`](https://github.com/elastic/eui/tree/master)
22

33
- Converted `EuiHighlight` to Typescript ([#2681](https://github.com/elastic/eui/pull/2681))
4+
- Converted `EuiTextArea` to Typescript ([#2695](https://github.com/elastic/eui/pull/2695))
45
- Converted `EuiPage` and related child components to TypeScript ([#2669](https://github.com/elastic/eui/pull/2669))
56

67
**Bug fixes**
File renamed without changes.
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
1+
import React, { TextareaHTMLAttributes, Ref, FunctionComponent } from 'react';
2+
import { CommonProps } from '../../common';
33
import classNames from 'classnames';
4-
54
import { 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+
720
const resizeToClassNameMap = {
821
vertical: 'euiTextArea--resizeVertical',
922
horizontal: 'euiTextArea--resizeHorizontal',
@@ -13,17 +26,17 @@ const resizeToClassNameMap = {
1326

1427
export 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

Comments
 (0)