Skip to content

Commit

Permalink
Feature/1102 combo box typedefs (#1115)
Browse files Browse the repository at this point in the history
* small progress

* more progress

* Almost completed types for EuiComboBox and related components

* filled out combobox types

* update @types/react versions to be the same

* add combobox index.d.ts to components

* changelog, updated yarn.lock
  • Loading branch information
chandlerprall authored Aug 28, 2018
1 parent b6eed6f commit f67b408
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ No public interface changes since `3.7.0`.
## [`3.6.1`](https://github.com/elastic/eui/tree/v3.6.1)

- Added TypeScript definition for `findTestSubject` test util ([#1106](https://github.com/elastic/eui/pull/1106))
- Added TypeScript definition for `EuiComboBox` ([#1115](https://github.com/elastic/eui/pull/1115))

**Bug fixes**

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"devDependencies": {
"@elastic/eslint-config-kibana": "^0.15.0",
"@types/enzyme": "^3.1.13",
"@types/react": "^16.4.9",
"@types/react": "^16.0.31",
"@types/react-virtualized": "^9.18.6",
"autoprefixer": "^7.1.5",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.1",
Expand Down
73 changes: 73 additions & 0 deletions src/components/combo_box/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { ButtonHTMLAttributes, ReactNode, SFC } from 'react';
import { ListProps } from 'react-virtualized';
import {
EuiComboBoxOption,
EuiComboBoxOptionProps,
EuiComboBoxOptionsListPosition,
EuiComboBoxOptionsListProps,
} from '@elastic/eui';

declare module '@elastic/eui' {
export type EuiComboBoxOptionProps = ButtonHTMLAttributes<HTMLButtonElement> & {
label: string,
isGroupLabelOption: boolean,
}

export type EuiComboBoxOptionsListPosition = 'top' | 'bottom'

export interface EuiComboBoxOption {
option: EuiComboBoxOptionProps,
children?: ReactNode,
className?: string,
optionRef?: RefCallback<HTMLButtonElement>,
onClick: (option: EuiComboBoxOptionProps) => any,
onEnterKey: (option: EuiComboBoxOptionProps) => any,
disabled?: boolean,
}

export interface EuiComboBoxOptionsListProps {
options?: Array<EuiComboBoxOptionProps>,
isLoading?: boolean,
selectedOptions?: Array<any>,
onCreateOption?: any,
searchValue?: string,
matchingOptions?: Array<EuiComboBoxOptionProps>,
optionRef?: EuiComboBoxOption['optionRef'],
onOptionClick?: EuiComboBoxOption['onClick'],
onOptionEnterKey?: EuiComboBoxOption['onEnterKey'],
areAllOptionsSelected?: boolean,
getSelectedOptionForSearchValue?: (searchValue: string, selectedOptions: Array<any>) => EuiComboBoxOptionProps,
updatePosition: (parameter?: UIEvent | EuiPanelProps['panelRef']) => any,
position?: EuiComboBoxOptionsListPosition,
listRef: EuiPanelProps['panelRef'],
renderOption?: (option: EuiComboBoxOptionProps, searchValue: string, OPTION_CONTENT_CLASSNAME: string) => ReactNode,
width?: number,
scrollToIndex?: number,
onScroll?: ListProps['onScroll'],
rowHeight?: number,
fullWidth?: boolean,
}
export const EuiComboBoxOptionsList: SFC<EuiComboBoxOptionsListProps>;

export interface EuiComboBoxProps {
id?: string,
isDisabled?: boolean,
className?: string,
placeholder?: string,
isLoading?: boolean,
async?: boolean,
singleSelection?: boolean,
noSuggestions?: boolean,
options?: EuiComboBoxOptionsListProps['options'],
selectedOptions?: EuiComboBoxOptionsListProps['selectedOptions'],
onChange?: (options: Array<EuiComboBoxOptionProps>) => any,
onSearchChange?: (searchValue: string) => any,
onCreateOption?: EuiComboBoxOptionsListProps['onCreateOption'],
renderOption?: EuiComboBoxOptionsListProps['renderOption'],
isInvalid?: boolean,
rowHeight?: number,
isClearable?: boolean,
fullWidth?: boolean,
}
export const EuiComboBox: SFC<EuiComboBoxProps>;
}
2 changes: 2 additions & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="./common.d.ts" />
/// <reference path="./avatar/index.d.ts" />
/// <reference path="./button/index.d.ts" />
/// <reference path="./combo_box/index.d.ts" />
/// <reference path="./context_menu/index.d.ts" />
/// <reference path="./flex/index.d.ts" />
/// <reference path="./health/index.d.ts" />
Expand Down Expand Up @@ -28,3 +29,4 @@
/// <reference path="./badge/index.d.ts" />
/// <reference path="./toast/index.d.ts" />
/// <reference path="./tool_tip/index.d.ts" />
/// <reference path="./combo_box/index.d.ts" />
20 changes: 17 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,23 @@
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@^16.4.9":
version "16.4.9"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.9.tgz#98b4dba5a0419dbd594f5dbbb2479e1e153431bb"
"@types/react-virtualized@^9.18.6":
version "9.18.6"
resolved "https://registry.yarnpkg.com/@types/react-virtualized/-/react-virtualized-9.18.6.tgz#d5c559bd003a6c58ba9e20d6cda0dde0342f59af"
dependencies:
"@types/prop-types" "*"
"@types/react" "*"

"@types/react@*":
version "16.4.10"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.10.tgz#fb577091034b25a81f829923e7d38258f43e3165"
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"

"@types/react@^16.0.31":
version "16.4.10"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.10.tgz#fb577091034b25a81f829923e7d38258f43e3165"
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"
Expand Down

0 comments on commit f67b408

Please sign in to comment.