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 TS definitions for step components, and tweak checkbox definition #1265

Merged
merged 3 commits into from
Nov 5, 2018
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**Bug fixes**

- Added TypeScript definitions for `EuiToolTip`'s `delay` prop. ([#1284](https://github.com/elastic/eui/pull/1284))
- Added TypeScript definitions for step components, and some checkbox definition fixes ([#1263](https://github.com/elastic/eui/pull/1263))

**Framer X**

Expand Down
2 changes: 1 addition & 1 deletion src/components/form/checkbox/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class EuiCheckbox extends Component {
EuiCheckbox.propTypes = {
className: PropTypes.string,
id: PropTypes.string.isRequired,
checked: PropTypes.bool.isRequired,
checked: PropTypes.bool,
label: PropTypes.node,
onChange: PropTypes.func.isRequired,
type: PropTypes.oneOf(TYPES),
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/checkbox/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare module '@elastic/eui' {

export interface EuiCheckboxProps {
id: string;
checked: boolean;
checked?: boolean;
onChange: ChangeEventHandler<HTMLInputElement>; // overriding to make it required
label?: ReactNode;
type?: EuiCheckboxType;
Expand Down
39 changes: 20 additions & 19 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
/// <reference path="./common.d.ts" />
/// <reference path="./accordion/index.d.ts" />
/// <reference path="./avatar/index.d.ts" />
/// <reference path="./badge/index.d.ts" />
/// <reference path="./button/index.d.ts" />
/// <reference path="./call_out/index.d.ts" />
/// <reference path="./code/index.d.ts" />
/// <reference path="./combo_box/index.d.ts" />
/// <reference path="./combo_box/index.d.ts" />
/// <reference path="./common.d.ts" />
/// <reference path="./context_menu/index.d.ts" />
/// <reference path="./description_list/index.d.ts" />
/// <reference path="./empty_prompt/index.d.ts" />
/// <reference path="./flex/index.d.ts" />
/// <reference path="./flyout/index.d.ts" />
/// <reference path="./form/index.d.ts" />
/// <reference path="./health/index.d.ts" />
/// <reference path="./horizontal_rule/index.d.ts" />
/// <reference path="./icon/index.d.ts" />
/// <reference path="./panel/index.d.ts" />
/// <reference path="./popover/index.d.ts" />
/// <reference path="./form/index.d.ts" />
/// <reference path="./table/index.d.ts" />
/// <reference path="./spacer/index.d.ts" />
/// <reference path="./pagination/index.d.ts" />
/// <reference path="./key_pad_menu/index.d.ts" />
/// <reference path="./link/index.d.ts" />
/// <reference path="./loading/index.d.ts" />
/// <reference path="./progress/index.d.ts" />
/// <reference path="./portal/index.d.ts" />
/// <reference path="./title/index.d.ts" />
/// <reference path="./text/index.d.ts" />
/// <reference path="./modal/index.d.ts" />
/// <reference path="./overlay_mask/index.d.ts" />
/// <reference path="./horizontal_rule/index.d.ts" />
/// <reference path="./page/index.d.ts" />
/// <reference path="./flyout/index.d.ts" />
/// <reference path="./empty_prompt/index.d.ts" />
/// <reference path="./code/index.d.ts" />
/// <reference path="./call_out/index.d.ts" />
/// <reference path="./badge/index.d.ts" />
/// <reference path="./pagination/index.d.ts" />
/// <reference path="./panel/index.d.ts" />
/// <reference path="./popover/index.d.ts" />
/// <reference path="./portal/index.d.ts" />
/// <reference path="./progress/index.d.ts" />
/// <reference path="./spacer/index.d.ts" />
/// <reference path="./steps/index.d.ts" />
/// <reference path="./table/index.d.ts" />
/// <reference path="./text/index.d.ts" />
/// <reference path="./title/index.d.ts" />
/// <reference path="./toast/index.d.ts" />
/// <reference path="./tool_tip/index.d.ts" />
/// <reference path="./combo_box/index.d.ts" />
/// <reference path="./key_pad_menu/index.d.ts" />
77 changes: 77 additions & 0 deletions src/components/steps/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/// <reference path="../common.d.ts" />

declare module '@elastic/eui' {
import { SFC, ReactNode, HTMLAttributes, MouseEventHandler } from 'react';

export type EuiStepStatus = 'complete' | 'incomplete' | 'warning' | 'danger' | 'disabled'

/**
* @see './step.js'
*/

export interface EuiStepProps {
children: ReactNode, // required
status?: EuiStepStatus,
step: number,
title: string,
headingElement?: string,
}

type StandaloneEuiStepProps =
CommonProps & HTMLAttributes<HTMLDivElement> & EuiStepProps

export const EuiStep: SFC<StandaloneEuiStepProps>;

/**
* @see './steps.js'
*/

export type EuiContainedStepProps = Omit<StandaloneEuiStepProps, 'step'>;

export interface EuiStepsProps {
firstStepNumber?: number,
headingElement?: string,
steps: Array<EuiContainedStepProps>,
}

export const EuiSteps: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiStepsProps
>;

/**
* @see './sub_steps.js'
*/

export interface EuiSubStepsProps {
}

export const EuiSubSteps: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiSubStepsProps
>;

/**
* @see './steps_horizontal.js'
*/

// EuiStepHorizontal is not exported by EUI
type EuiStepHorizontalProp = CommonProps & HTMLAttributes<HTMLDivElement> & {
isSelected?: boolean,
isComplete?: boolean,
onClick: MouseEventHandler<HTMLDivElement>, // required
step: number,
title: ReactNode,
disabled?: boolean,
status?: EuiStepStatus,
};

type ContainedEuiStepHorizontalProps = Omit<EuiStepHorizontalProp, 'step'>;

export interface EuiStepsHorizontalProps {
steps: Array<ContainedEuiStepHorizontalProps>,
}

export const EuiStepsHorizontal: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiStepsHorizontalProps
>;
}