From 98423db48c9b4d3f859149f3207be19b8ef31d2b Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 7 May 2019 12:36:07 +0100 Subject: [PATCH] `EuiFormControlLayoutClearButton` converted to TS --- ..._control_layout_clear_button.test.tsx.snap | 23 +++++++++++++++++++ .../form_control_layout_clear_button.test.tsx | 16 +++++++++++++ ...s => form_control_layout_clear_button.tsx} | 19 +++++---------- .../form/form_control_layout/index.d.ts | 8 +++++++ src/components/form/index.d.ts | 2 ++ 5 files changed, 55 insertions(+), 13 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} (69%) create mode 100644 src/components/form/form_control_layout/index.d.ts 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..13ff7d761c8 --- /dev/null +++ b/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap @@ -0,0 +1,23 @@ +// 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 69% 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..ca0ecd3ac8b 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,15 +1,13 @@ -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 ( @@ -32,8 +30,3 @@ export const EuiFormControlLayoutClearButton = ({ ); }; - -EuiFormControlLayoutClearButton.propTypes = { - className: PropTypes.string, - onClick: PropTypes.func, -}; diff --git a/src/components/form/form_control_layout/index.d.ts b/src/components/form/form_control_layout/index.d.ts new file mode 100644 index 00000000000..5a574d35712 --- /dev/null +++ b/src/components/form/form_control_layout/index.d.ts @@ -0,0 +1,8 @@ +import { EuiFormControlLayoutClearButton as FormControlLayoutClearButton } from './form_control_layout_clear_button'; + +declare module '@elastic/eui' { + /** + * @see './form_control_layout_clear_button.js' + */ + export const EuiFormControlLayoutClearButton: typeof FormControlLayoutClearButton; +} diff --git a/src/components/form/index.d.ts b/src/components/form/index.d.ts index 22100d015a1..3463ca41dd3 100644 --- a/src/components/form/index.d.ts +++ b/src/components/form/index.d.ts @@ -5,6 +5,7 @@ import { CommonProps } from '../common'; /// /// /// +/// /// /// /// @@ -12,6 +13,7 @@ import { CommonProps } from '../common'; /// /// + import { FunctionComponent, FormHTMLAttributes, ReactNode } from 'react'; declare module '@elastic/eui' {