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

Add TypeScript definitions for EuiConfirmModal #1260

Merged
merged 3 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,13 +1,14 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `4.6.0`.
**Bug fixes**

- Added TypeScript definitions for `EuiFieldPassword`. ([#1255](https://github.com/elastic/eui/pull/1255))
- Added TypeScript definitions for `EuiConfirmModal`, plus several definition fixes ([#1260](https://github.com/elastic/eui/pull/1260))

## [`4.6.0`](https://github.com/elastic/eui/tree/v4.6.0)

- Increased default font size of tabs in K6 theme ([#1244](https://github.com/elastic/eui/pull/1244))

**Bug fixes**

- Fixed select warning on falsy value in EuiSelect ([#1254](https://github.com/elastic/eui/pull/1254))
Expand Down
2 changes: 1 addition & 1 deletion src/components/common.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module '@elastic/eui' {
export type AnyProps = { [key: string]: string };
export type AnyProps = { [key: string]: any };

export interface CommonProps {
className?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/components/flex/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ declare module '@elastic/eui' {
*/

export type FlexGridGutterSize = 'none' | 's' | 'm' | 'l' | 'xl';
export type FlexGridColumns = 0 | 2 | 3 | 4;
export type FlexGridColumns = 0 | 1 | 2 | 3 | 4;

export interface EuiFlexGridProps {
columns: FlexGridColumns;
columns?: FlexGridColumns;
gutterSize?: FlexGridGutterSize;
}

Expand Down Expand Up @@ -46,7 +46,7 @@ declare module '@elastic/eui' {
| 'spaceBetween'
| 'spaceAround'
| 'spaceEvenly';

export interface EuiFlexGroupProps {
alignItems?: FlexGroupAlignItems;
children?: React.ReactNode;
Expand Down
1 change: 1 addition & 0 deletions src/components/form/field_password/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare module '@elastic/eui' {
inputRef?: Ref<HTMLInputElement>;
fullWidth?: boolean;
isLoading?: boolean;
compressed?: boolean;
}

export const EuiFieldPassword: SFC<
Expand Down
3 changes: 2 additions & 1 deletion src/components/icon/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ declare module '@elastic/eui' {
| 'subdued'
| 'success'
| 'text'
| 'warning';
| 'warning'
| string;

export interface EuiIconProps {
type?: IconType;
Expand Down
35 changes: 34 additions & 1 deletion src/components/modal/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="../common.d.ts" />
/// <reference path="../button/index.d.ts" />

import { SFC, HTMLAttributes } from 'react';
import { ReactNode, SFC, HTMLAttributes } from 'react';

declare module '@elastic/eui' {

Expand Down Expand Up @@ -57,5 +58,37 @@ declare module '@elastic/eui' {
CommonProps & HTMLAttributes<HTMLDivElement>
>;

/**
* Confirm modal type defs
*
* @see './confirm_modal.js'
*/

// index.js re-exports values from confirm_modal.js with these names.
export const EUI_MODAL_CONFIRM_BUTTON: 'confirm';
export const EUI_MODAL_CANCEL_BUTTON: 'cancel';

export interface EuiConfirmModalProps {
buttonColor?: ButtonColor;
cancelButtonText?: ReactNode;
confirmButtonText?: ReactNode;
defaultFocusedButton?: 'confirm' | 'cancel';
title?: ReactNode;
onCancel?: () => void;
onConfirm?: () => void;
/**
* Sets the max-width of the modal,
* set to `true` to use the default size,
* set to `false` to not restrict the width,
* set to a number for a custom width in px,
* set to a string for a custom width in custom measurement.
*/
maxWidth?: boolean | number | string;
}

// `title` from the React defs conflicts with our definition above
export const EuiConfirmModal: SFC<
CommonProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'> & EuiConfirmModalProps
>;

}
5 changes: 2 additions & 3 deletions src/components/table/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare module '@elastic/eui' {

export interface EuiTableProps {
compressed?: boolean;
responsive?: boolean;
}

export const EuiTable: SFC<
Expand Down Expand Up @@ -121,9 +122,7 @@ declare module '@elastic/eui' {
}

export const EuiTableRow: SFC<
CommonProps &
AnyProps & // at least according to the contract of table_row.js
EuiTableRowProps
CommonProps & EuiTableRowProps
pugnascotia marked this conversation as resolved.
Show resolved Hide resolved
>;

/**
Expand Down