From a0c7aa0bf8007e29261cf39fa22880dbae8c80d6 Mon Sep 17 00:00:00 2001 From: Theofanis Despoudis Date: Tue, 21 May 2019 15:03:07 +0100 Subject: [PATCH] `EuiFormControlLayoutClearButton` converted to TS (#1922) * `EuiFormControlLayoutClearButton` converted to TS * `EuiFormControlLayoutClearButton` code review --- CHANGELOG.md | 2 +- ..._control_layout_clear_button.test.tsx.snap | 19 +++++++++++++++++ .../form_control_layout_clear_button.test.tsx | 16 ++++++++++++++ ...s => form_control_layout_clear_button.tsx} | 21 +++++++------------ .../form/form_control_layout/index.d.ts | 8 +++++++ src/components/form/index.d.ts | 2 ++ 6 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap create mode 100644 src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx rename src/components/form/form_control_layout/{form_control_layout_clear_button.js => form_control_layout_clear_button.tsx} (66%) create mode 100644 src/components/form/form_control_layout/index.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index eadf8a1adb0..2ce223abbdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `11.1.0`. +- Converted `EuiFormControlLayoutClearButton` to TS ([#1922](https://github.com/elastic/eui/pull/1922)) ## [`11.1.0`](https://github.com/elastic/eui/tree/v11.1.0) diff --git a/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap b/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap new file mode 100644 index 00000000000..62e712f7b36 --- /dev/null +++ b/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiFormControlLayoutClearButton is rendered 1`] = ` + +`; diff --git a/src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx b/src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx new file mode 100644 index 00000000000..b5964bb44ea --- /dev/null +++ b/src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { render } from 'enzyme'; +import { EuiFormControlLayoutClearButton } from './form_control_layout_clear_button'; + +describe('EuiFormControlLayoutClearButton', () => { + test('is rendered', () => { + const clear = { + onClick: () => null, + className: 'customClass', + 'data-test-subj': 'clearButton', + }; + const component = render(); + + expect(component).toMatchSnapshot(); + }); +}); diff --git a/src/components/form/form_control_layout/form_control_layout_clear_button.js b/src/components/form/form_control_layout/form_control_layout_clear_button.tsx similarity index 66% rename from src/components/form/form_control_layout/form_control_layout_clear_button.js rename to src/components/form/form_control_layout/form_control_layout_clear_button.tsx index 9c840ac9904..f9a712a90ce 100644 --- a/src/components/form/form_control_layout/form_control_layout_clear_button.js +++ b/src/components/form/form_control_layout/form_control_layout_clear_button.tsx @@ -1,22 +1,20 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import classNames from 'classnames'; +import React, { FunctionComponent, ButtonHTMLAttributes } from 'react'; +import classNames from 'classnames'; +import { CommonProps } from '../../common'; import { EuiIcon } from '../../icon'; import { EuiI18n } from '../../i18n'; -export const EuiFormControlLayoutClearButton = ({ - className, - onClick, - ...rest -}) => { +export const EuiFormControlLayoutClearButton: FunctionComponent< + CommonProps & ButtonHTMLAttributes +> = ({ className, onClick, ...rest }) => { const classes = classNames('euiFormControlLayoutClearButton', className); return ( - {label => ( + {(label: string) => (