From c1d3c066bf68a9b0fe357800e424df5ece7e4eee Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:46:21 +0000 Subject: [PATCH 01/12] Consistent delimiters. --- react-modal/index.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index e5db7d66f0..80958ae918 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -12,20 +12,20 @@ declare module "react-modal" { 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 + }; + }; + appElement?: HTMLElement | {}; + onAfterOpen?: Function; + onRequestClose?: Function; + closeTimeoutMS?: number; + ariaHideApp?: boolean; + shouldCloseOnOverlayClick?: boolean; + overlayClassName?: string; + className?: string; + contentLabel?: string; } let ReactModal: React.ClassicComponentClass; export = ReactModal; From d998af2ff33295d7bc63644086646ba1300f2ad7 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:47:04 +0000 Subject: [PATCH 02/12] Specify function type. --- react-modal/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 80958ae918..13e4a94a0c 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -18,8 +18,8 @@ declare module "react-modal" { }; }; appElement?: HTMLElement | {}; - onAfterOpen?: Function; - onRequestClose?: Function; + onAfterOpen?: () => void; + onRequestClose?: () => void; closeTimeoutMS?: number; ariaHideApp?: boolean; shouldCloseOnOverlayClick?: boolean; From e20443bdf764432446cdae94347359dab22e1ace Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:49:32 +0000 Subject: [PATCH 03/12] Add documentation. --- react-modal/index.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 13e4a94a0c..1a3826004a 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -8,7 +8,9 @@ declare module "react-modal" { interface ReactModal { + /* 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?: { content?: { [key: string]: any; @@ -17,14 +19,23 @@ declare module "react-modal" { [key: string]: any; }; }; + /* 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 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; } let ReactModal: React.ClassicComponentClass; From ae31538dc212e9a37c3463c091b37f328d9935ab Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:51:06 +0000 Subject: [PATCH 04/12] Add static members. --- react-modal/index.d.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 1a3826004a..7dc83f7d79 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -7,10 +7,7 @@ /// declare module "react-modal" { - interface ReactModal { - /* 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. */ + interface Styles { style?: { content?: { [key: string]: any; @@ -19,6 +16,12 @@ declare module "react-modal" { [key: string]: any; }; }; + } + interface ReactModal { + /* 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. */ @@ -38,6 +41,11 @@ declare module "react-modal" { /* String indicating how the content container should be announced to screenreaders. */ contentLabel?: string; } - let ReactModal: React.ClassicComponentClass; + let ReactModal: React.ClassicComponentClass & { + /* Override styles for all modals. */ + defaultStyles: Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + setAppElement(appElement: HTMLElement): void; + }; export = ReactModal; } From c6e9076a946fb67ce462ffea6c4e9bd1bc16eadb Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:52:13 +0000 Subject: [PATCH 05/12] Add missing members. --- react-modal/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 7dc83f7d79..1d24ebc85b 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -34,12 +34,18 @@ declare module "react-modal" { 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 & { /* Override styles for all modals. */ From e4bf1668726965be0860a89ede5667ace3240e1b Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Tue, 31 Jan 2017 22:52:28 +0000 Subject: [PATCH 06/12] Bump react-modal version to 1.6.5. --- react-modal/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 1d24ebc85b..115e36730b 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-modal v1.6.1 +// Type definitions for react-modal v1.6.5 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov +// Definitions by: Drew Noakes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From ff38bd198b87ba02101af481d5eac8aba3da4bed Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:39:47 +0000 Subject: [PATCH 07/12] Fix tslint errors 'dt-header' - Expected: foo MAJOR.MINOR (patch version not allowed) - Expected: foo MAJOR.MINOR ('v' not allowed) --- react-modal/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 115e36730b..20c8d08f27 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal v1.6.5 +// Type definitions for react-modal 1.6 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov // Definitions by: Drew Noakes From fb1f121c408488d14764ad99041267c9d35e876f Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:40:18 +0000 Subject: [PATCH 08/12] Fix tslint errors 'dt-header' Expected: one of /(, )|(,?\r?\n\/\/\s\s+)/ /\r?\n\/\/ Definitions by: / --- react-modal/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 20c8d08f27..30db228f59 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for react-modal 1.6 // Project: https://github.com/reactjs/react-modal -// Definitions by: Rajab Shakirov -// Definitions by: Drew Noakes +// Definitions by: Rajab Shakirov , Drew Noakes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 From 34c28a11da363a27d5de601b666c2feca176aa9a Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:41:16 +0000 Subject: [PATCH 09/12] Fix tslint error 'no-single-declare-module ' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File has only 1 module declaration — write it as an external module. --- react-modal/index.d.ts | 93 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 30db228f59..68e6f1e2bc 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -6,52 +6,53 @@ /// -declare module "react-modal" { - interface Styles { - style?: { - content?: { - [key: string]: any; - }; - overlay?: { - [key: string]: any; - }; +interface Styles { + style?: { + content?: { + [key: string]: any; + }; + overlay?: { + [key: string]: any; }; - } - interface ReactModal { - /* 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 & { - /* Override styles for all modals. */ - defaultStyles: Styles; - /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - setAppElement(appElement: HTMLElement): void; }; - export = ReactModal; } + +interface ReactModal { + /* 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; +} + +declare const ReactModal: React.ClassicComponentClass & { + /* Override styles for all modals. */ + defaultStyles: Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + setAppElement(appElement: HTMLElement): void; +}; + +export = ReactModal; From 6c1d88d6a9f3d81c993c17333bb04926051442be Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:42:48 +0000 Subject: [PATCH 10/12] Use 'import' over ' +import * as React from "react"; interface Styles { style?: { From c834c31b814c751322150cb272167e2ac504f946 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 21:41:29 +0000 Subject: [PATCH 11/12] Add tslint file. --- react-modal/tslint.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 react-modal/tslint.json 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" } From 70520cc92389c48b24ee7d51ea3a5362712a5eec Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Wed, 1 Feb 2017 22:03:12 +0000 Subject: [PATCH 12/12] Declare as class and namespace. --- react-modal/index.d.ts | 100 +++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index c26442aa76..4e038b416c 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -6,53 +6,57 @@ import * as React from "react"; -interface Styles { - style?: { - content?: { - [key: string]: any; - }; - overlay?: { - [key: string]: any; - }; - }; -} - -interface ReactModal { - /* 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; -} - -declare const ReactModal: React.ClassicComponentClass & { - /* Override styles for all modals. */ - defaultStyles: Styles; - /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - setAppElement(appElement: HTMLElement): void; -}; +export as namespace ReactModal; export = ReactModal; + +declare namespace ReactModal { + export interface Styles { + style?: { + content?: { + [key: string]: any; + }; + overlay?: { + [key: string]: any; + }; + }; + } + + 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; + } +} + +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; +}