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

converts ComboBox family of components to TypeScript #2838

Merged
merged 13 commits into from
Feb 24, 2020
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Converted `EuiCodeEditor` to Typescript ([#2836](https://github.com/elastic/eui/pull/2836))
- Converted `EuiCode` and `EuiCodeBlock` and to Typescript ([#2835](https://github.com/elastic/eui/pull/2835))
- Converted `EuiComboBox`, `EuiComboBoxInput`, `EuiComboBoxPill`, `EuiComboBoxOptionsList`, `EuiComboBoxOption`, and `EuiComboBoxTitle` to TypeScript ([#2838](https://github.com/elastic/eui/pull/2838))
- Converted `EuiCodeEditor` to TypeScript ([#2836](https://github.com/elastic/eui/pull/2836))
- Converted `EuiCode` and `EuiCodeBlock` and to TypeScript ([#2835](https://github.com/elastic/eui/pull/2835))
- Converted `EuiFilePicker` to TypeScript ([#2832](https://github.com/elastic/eui/issues/2832))
- Exported `EuiSelectOptionProps` type ([#2830](https://github.com/elastic/eui/pull/2830))
- Added `paperClip` glyph to `EuiIcon` ([#2845](https://github.com/elastic/eui/pull/2845))
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@
"@types/jest": "^24.0.6",
"@types/react": "^16.9.11",
"@types/react-dom": "^16.9.4",
"@types/react-input-autosize": "^2.0.1",
"@types/react-is": "^16.7.1",
"@types/resize-observer-browser": "^0.1.1",
"@types/sinon": "^7.5.1",
dimitropoulos marked this conversation as resolved.
Show resolved Hide resolved
"@types/tabbable": "^3.1.0",
"@types/uuid": "^3.4.4",
"@typescript-eslint/eslint-plugin": "^1.13.0",
Expand Down
7 changes: 4 additions & 3 deletions src/components/badge/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, {
AriaAttributes,
FunctionComponent,
MouseEventHandler,
HTMLAttributes,
MouseEventHandler,
ReactNode,
} from 'react';
import classNames from 'classnames';
Expand All @@ -22,7 +23,7 @@ type WithButtonProps = {
/**
* Aria label applied to the onClick button
*/
onClickAriaLabel: string;
onClickAriaLabel: AriaAttributes['aria-label'];
} & Omit<HTMLAttributes<HTMLButtonElement>, 'onClick' | 'color'>;

type WithSpanProps = Omit<HTMLAttributes<HTMLSpanElement>, 'onClick' | 'color'>;
Expand All @@ -36,7 +37,7 @@ interface WithIconOnClick {
/**
* Aria label applied to the iconOnClick button
*/
iconOnClickAriaLabel: string;
iconOnClickAriaLabel: AriaAttributes['aria-label'];
}

export type EuiBadgeProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports[`EuiComboBox is rendered 1`] = `
style="font-size:14px;display:inline-block"
>
<input
aria-controls=""
data-test-subj="comboBoxSearchInput"
role="textbox"
style="box-sizing:content-box;width:1px"
Expand Down Expand Up @@ -72,7 +73,6 @@ exports[`props full width is rendered 1`] = `
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={true}
hasSelectedOptions={true}
inputRef={[Function]}
Expand Down Expand Up @@ -113,7 +113,6 @@ exports[`props isClearable=false disallows user from clearing input when no opti
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={false}
hasSelectedOptions={false}
inputRef={[Function]}
Expand Down Expand Up @@ -147,7 +146,6 @@ exports[`props isClearable=false disallows user from clearing input when options
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={false}
hasSelectedOptions={true}
inputRef={[Function]}
Expand Down Expand Up @@ -190,7 +188,6 @@ exports[`props isDisabled is rendered 1`] = `
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={false}
hasSelectedOptions={true}
inputRef={[Function]}
Expand Down Expand Up @@ -310,7 +307,6 @@ exports[`props selectedOptions are rendered 1`] = `
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={false}
hasSelectedOptions={true}
inputRef={[Function]}
Expand Down Expand Up @@ -354,7 +350,6 @@ exports[`props singleSelection is rendered 1`] = `
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={false}
hasSelectedOptions={true}
inputRef={[Function]}
Expand Down Expand Up @@ -395,7 +390,6 @@ exports[`props singleSelection selects existing option when opened 1`] = `
<EuiComboBoxInput
autoSizeInputRef={[Function]}
compressed={false}
focusedOptionId={null}
fullWidth={false}
hasSelectedOptions={true}
inputRef={[Function]}
Expand Down Expand Up @@ -428,7 +422,6 @@ exports[`props singleSelection selects existing option when opened 1`] = `
areAllOptionsSelected={false}
data-test-subj=""
fullWidth={false}
getSelectedOptionForSearchValue={[Function]}
listRef={[Function]}
matchingOptions={
Array [
Expand Down Expand Up @@ -518,6 +511,7 @@ exports[`props singleSelection selects existing option when opened 1`] = `
]
}
updatePosition={[Function]}
width={0}
/>
</EuiPortal>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';
import { shallow, render, mount } from 'enzyme';
import sinon from 'sinon';
import {
Expand All @@ -11,20 +11,24 @@ import { comboBoxKeyCodes } from '../../services';
import { EuiComboBox } from './combo_box';

jest.mock('../portal', () => ({
EuiPortal: ({ children }) => children,
EuiPortal: ({ children }: { children: ReactNode }) => children,
dimitropoulos marked this conversation as resolved.
Show resolved Hide resolved
}));

// Mock the htmlIdGenerator to generate predictable ids for snapshot tests
jest.mock('../../services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => {
return suffix => `htmlid_${suffix}`;
return (suffix: string) => `htmlid_${suffix}`;
},
}));

const options = [
interface TitanOption {
'data-test-subj'?: 'titanOption';
label: string;
}
const options: TitanOption[] = [
{
label: 'Titan',
'data-test-subj': 'titanOption',
label: 'Titan',
},
{
label: 'Enceladus',
Expand Down
Loading