diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index e5db7d66f0..4e038b416c 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,32 +1,62 @@ -// Type definitions for react-modal v1.6.1 +// Type definitions for react-modal 1.6 // Project: https://github.com/reactjs/react-modal -// Definitions by: Rajab Shakirov +// Definitions by: Rajab Shakirov , Drew Noakes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -/// +import * as React from "react"; -declare module "react-modal" { - interface ReactModal { - isOpen: boolean; +export as namespace ReactModal; + +export = ReactModal; + +declare namespace ReactModal { + export interface Styles { style?: { content?: { [key: string]: any; - }, + }; overlay?: { [key: string]: any; - } - }, - appElement?: HTMLElement | {}, - onAfterOpen?: Function, - onRequestClose?: Function, - closeTimeoutMS?: number, - ariaHideApp?: boolean, - shouldCloseOnOverlayClick?: boolean, - overlayClassName?: string, - className?: string - contentLabel?: string + }; + }; + } + + export interface Props { + /* Boolean describing if the modal should be shown or not. Defaults to false. */ + isOpen: boolean; + /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ + style?: Styles; + /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + appElement?: HTMLElement | {}; + /* Function that will be run after the modal has opened. */ + onAfterOpen?: () => void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ + onRequestClose?: () => void; + /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ + closeTimeoutMS?: number; + /* Boolean indicating if the appElement should be hidden. Defaults to true. */ + ariaHideApp?: boolean; + /* Boolean indicating if the overlay should close the modal. Defaults to true. */ + shouldCloseOnOverlayClick?: boolean; + /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ + portalClassName?: string; + /* String className to be applied to the overlay. */ + overlayClassName?: string; + /* String className to be applied to the modal content. */ + className?: string; + /* String indicating how the content container should be announced to screenreaders. */ + contentLabel?: string; + /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ + role?: string; + /* Function that will be called to get the parent element that the modal will be attached to. */ + parentSelector?: () => HTMLElement; } - let ReactModal: React.ClassicComponentClass; - export = ReactModal; +} + +declare class ReactModal extends React.Component { + /* Override base styles for all instances of this component. */ + static defaultStyles: ReactModal.Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + static setAppElement(appElement: HTMLElement): void; } diff --git a/react-modal/tslint.json b/react-modal/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-modal/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }