From 32014f3e4fade42bebfca5894d91b32a0e48dab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Franco=20Knob?= Date: Wed, 18 Dec 2019 15:35:31 -0300 Subject: [PATCH 1/2] Converts EuiTextArea to Typescript --- CHANGELOG.md | 1 + ...a.test.js.snap => text_area.test.tsx.snap} | 0 .../form/text_area/{index.js => index.ts} | 0 .../{text_area.test.js => text_area.test.tsx} | 0 .../text_area/{text_area.js => text_area.tsx} | 47 ++++++++----------- 5 files changed, 21 insertions(+), 27 deletions(-) rename src/components/form/text_area/__snapshots__/{text_area.test.js.snap => text_area.test.tsx.snap} (100%) rename src/components/form/text_area/{index.js => index.ts} (100%) rename src/components/form/text_area/{text_area.test.js => text_area.test.tsx} (100%) rename src/components/form/text_area/{text_area.js => text_area.tsx} (65%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9371f3bae2c..6bb69cbc7cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [`master`](https://github.com/elastic/eui/tree/master) - Converted `EuiHighlight` to Typescript ([#2681](https://github.com/elastic/eui/pull/2681)) +- Converted `EuiTextArea` to Typescript ([#](https://github.com/elastic/eui/pull/)) **Bug fixes** diff --git a/src/components/form/text_area/__snapshots__/text_area.test.js.snap b/src/components/form/text_area/__snapshots__/text_area.test.tsx.snap similarity index 100% rename from src/components/form/text_area/__snapshots__/text_area.test.js.snap rename to src/components/form/text_area/__snapshots__/text_area.test.tsx.snap diff --git a/src/components/form/text_area/index.js b/src/components/form/text_area/index.ts similarity index 100% rename from src/components/form/text_area/index.js rename to src/components/form/text_area/index.ts diff --git a/src/components/form/text_area/text_area.test.js b/src/components/form/text_area/text_area.test.tsx similarity index 100% rename from src/components/form/text_area/text_area.test.js rename to src/components/form/text_area/text_area.test.tsx diff --git a/src/components/form/text_area/text_area.js b/src/components/form/text_area/text_area.tsx similarity index 65% rename from src/components/form/text_area/text_area.js rename to src/components/form/text_area/text_area.tsx index d289c32b891..66990ad071a 100644 --- a/src/components/form/text_area/text_area.js +++ b/src/components/form/text_area/text_area.tsx @@ -1,9 +1,22 @@ -import React from 'react'; -import PropTypes from 'prop-types'; +import React, { TextareaHTMLAttributes, Ref, FunctionComponent } from 'react'; +import { CommonProps } from '../../common'; import classNames from 'classnames'; - import { EuiValidatableControl } from '../validatable_control'; +export type EuiTextAreaProps = TextareaHTMLAttributes & + CommonProps & { + isInvalid?: boolean; + fullWidth?: boolean; + compressed?: boolean; + + /** + * Which direction, if at all, should the textarea resize + */ + resize?: keyof typeof resizeToClassNameMap; + + inputRef?: Ref; + }; + const resizeToClassNameMap = { vertical: 'euiTextArea--resizeVertical', horizontal: 'euiTextArea--resizeHorizontal', @@ -13,17 +26,17 @@ const resizeToClassNameMap = { export const RESIZE = Object.keys(resizeToClassNameMap); -export const EuiTextArea = ({ +export const EuiTextArea: FunctionComponent = ({ children, className, compressed, - fullWidth, + fullWidth = false, id, inputRef, isInvalid, name, placeholder, - resize, + resize = 'vertical', rows, ...rest }) => { @@ -37,7 +50,7 @@ export const EuiTextArea = ({ className ); - let definedRows; + let definedRows: number; if (rows) { definedRows = rows; @@ -62,23 +75,3 @@ export const EuiTextArea = ({ ); }; - -EuiTextArea.propTypes = { - name: PropTypes.string, - id: PropTypes.string, - placeholder: PropTypes.string, - rows: PropTypes.number, - isInvalid: PropTypes.bool, - fullWidth: PropTypes.bool, - compressed: PropTypes.bool, - - /** - * Which direction, if at all, should the textarea resize - */ - resize: PropTypes.oneOf(RESIZE), -}; - -EuiTextArea.defaultProps = { - fullWidth: false, - resize: 'vertical', -}; From b920122d1d91716272babccdf52061f14e7a8e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Franco=20Knob?= Date: Wed, 18 Dec 2019 15:38:22 -0300 Subject: [PATCH 2/2] Adds PR number to CHANGELOG line --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb69cbc7cf..4847067de41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## [`master`](https://github.com/elastic/eui/tree/master) - Converted `EuiHighlight` to Typescript ([#2681](https://github.com/elastic/eui/pull/2681)) -- Converted `EuiTextArea` to Typescript ([#](https://github.com/elastic/eui/pull/)) +- Converted `EuiTextArea` to Typescript ([#2695](https://github.com/elastic/eui/pull/2695)) **Bug fixes**