Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiFormControlLayoutClearButton converted to TS #1922

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiFormControlLayoutClearButton is rendered 1`] = `
<button
aria-label="Clear input"
class="euiFormControlLayoutClearButton customClass"
data-test-subj="clearButton"
type="button"
>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutClearButton__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</button>
`;
Original file line number Diff line number Diff line change
@@ -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(<EuiFormControlLayoutClearButton {...clear} />);

expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -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<HTMLButtonElement>
> = ({ className, onClick, ...rest }) => {
const classes = classNames('euiFormControlLayoutClearButton', className);

return (
<EuiI18n
token="euiFormControlLayoutClearButton.label"
default="Clear input">
{label => (
{(label: string) => (
<button
type="button"
className={classes}
Expand All @@ -32,8 +30,3 @@ export const EuiFormControlLayoutClearButton = ({
</EuiI18n>
);
};

EuiFormControlLayoutClearButton.propTypes = {
className: PropTypes.string,
onClick: PropTypes.func,
};
8 changes: 8 additions & 0 deletions src/components/form/form_control_layout/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 2 additions & 0 deletions src/components/form/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { CommonProps } from '../common';
/// <reference path="./field_search/index.d.ts" />
/// <reference path="./field_text/index.d.ts" />
/// <reference path="./form_help_text/index.d.ts" />
/// <reference path="./form_control_layout/index.d.ts" />
/// <reference path="./form_row/index.d.ts" />
/// <reference path="./radio/index.d.ts" />
/// <reference path="./range/index.d.ts" />
/// <reference path="./select/index.d.ts" />
/// <reference path="./switch/index.d.ts" />
/// <reference path="./text_area/index.d.ts" />


import { FunctionComponent, FormHTMLAttributes, ReactNode } from 'react';

declare module '@elastic/eui' {
Expand Down