1 | // Type definitions for react-modal 3.13
|
2 | // Project: https://github.com/reactjs/react-modal
|
3 | // Definitions by: Rajab Shakirov <https://github.com/radziksh>,
|
4 | // Drew Noakes <https://github.com/drewnoakes>,
|
5 | // Thomas B Homburg <https://github.com/homburg>,
|
6 | // Tatu Tamminen <https://github.com/ttamminen>,
|
7 | // Uwe Wiemer <https://github.com/hallowatcher>,
|
8 | // Peter Blazejewicz <https://github.com/peterblazejewicz>,
|
9 | // Justin Powell <https://github.com/jpowell>
|
10 | // Juwan Wheatley <https://github.com/fiberjw>
|
11 | // Nitzan Mousan <https://github.com/nitzanmo>
|
12 | // dkrk <https://github.com/grgr-dkrk>
|
13 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
14 | // TypeScript Version: 2.8
|
15 |
|
16 | import * as React from "react";
|
17 |
|
18 | export = ReactModal;
|
19 | export as namespace ReactModal;
|
20 |
|
21 | declare namespace ReactModal {
|
22 | interface Styles {
|
23 | content?: React.CSSProperties | undefined;
|
24 | overlay?: React.CSSProperties | undefined;
|
25 | }
|
26 |
|
27 | interface Classes {
|
28 | base: string;
|
29 | afterOpen: string;
|
30 | beforeClose: string;
|
31 | }
|
32 |
|
33 | interface Aria {
|
34 | /** Defines a string value that labels the current element. */
|
35 | labelledby?: string | undefined;
|
36 | /** Identifies the element (or elements) that describes the object. */
|
37 | describedby?: string | undefined;
|
38 | /** Indicates whether an element is modal when displayed. */
|
39 | modal?: boolean | 'false' | 'true' | undefined;
|
40 | }
|
41 |
|
42 | /** Describes overlay and content element references passed to onAfterOpen function */
|
43 | interface OnAfterOpenCallbackOptions {
|
44 | /** overlay element reference */
|
45 | overlayEl: Element;
|
46 | /** content element reference */
|
47 | contentEl: HTMLDivElement;
|
48 | }
|
49 |
|
50 | /** Describes unction that will be run after the modal has opened */
|
51 | interface OnAfterOpenCallback {
|
52 | (obj?: OnAfterOpenCallbackOptions): void;
|
53 | }
|
54 |
|
55 | interface Props {
|
56 | children?: React.ReactNode;
|
57 |
|
58 | /* Boolean describing if the modal should be shown or not. Defaults to false. */
|
59 | isOpen: boolean;
|
60 |
|
61 | /* Object indicating styles to be used for the modal, divided into overlay and content styles. */
|
62 | style?: Styles | undefined;
|
63 |
|
64 | /* String className to be applied to the portal. Defaults to "ReactModalPortal". */
|
65 | portalClassName?: string | undefined;
|
66 |
|
67 | /* String className to be applied to the document.body (must be a constant string). When set to null it doesn't add any class to document.body. */
|
68 | bodyOpenClassName?: string | null | undefined;
|
69 |
|
70 | /* String className to be applied to the document.html (must be a constant string). Defaults to null. */
|
71 | htmlOpenClassName?: string | null | undefined;
|
72 |
|
73 | /* String or object className to be applied to the modal content. */
|
74 | className?: string | Classes | undefined;
|
75 |
|
76 | /* String or object className to be applied to the overlay. */
|
77 | overlayClassName?: string | Classes | undefined;
|
78 |
|
79 | /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */
|
80 | appElement?: HTMLElement | HTMLElement[] | HTMLCollection | NodeList | undefined;
|
81 |
|
82 | /* Function that will be run after the modal has opened. */
|
83 | onAfterOpen?: OnAfterOpenCallback | undefined;
|
84 |
|
85 | /* Function that will be run after the modal has closed. */
|
86 | onAfterClose?(): void;
|
87 |
|
88 | /* Function that will be run when the modal is requested to be closed, prior to actually closing. */
|
89 | onRequestClose?(event: React.MouseEvent | React.KeyboardEvent): void;
|
90 |
|
91 | /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */
|
92 | closeTimeoutMS?: number | undefined;
|
93 |
|
94 | /* Boolean indicating if the appElement should be hidden. Defaults to true. */
|
95 | ariaHideApp?: boolean | undefined;
|
96 |
|
97 | /* Boolean indicating if the modal should be focused after render */
|
98 | shouldFocusAfterRender?: boolean | undefined;
|
99 |
|
100 | /* Boolean indicating if the overlay should close the modal. Defaults to true. */
|
101 | shouldCloseOnOverlayClick?: boolean | undefined;
|
102 |
|
103 | /* Boolean indicating if pressing the esc key should close the modal */
|
104 | shouldCloseOnEsc?: boolean | undefined;
|
105 |
|
106 | /* Boolean indicating if the modal should restore focus to the element that had focus prior to its display. */
|
107 | shouldReturnFocusAfterClose?: boolean | undefined;
|
108 |
|
109 | /* Boolean indicating if the modal should use the preventScroll flag when restoring focus to the element that had focus prior to its display. */
|
110 | preventScroll?: boolean | undefined;
|
111 |
|
112 | /* Function that will be called to get the parent element that the modal will be attached to. */
|
113 | parentSelector?(): HTMLElement;
|
114 |
|
115 | /* Additional aria attributes. */
|
116 | aria?: Aria | undefined;
|
117 |
|
118 | /* Additional data attributes to be applied to to the modal content in the form of "data-*" */
|
119 | data?: any;
|
120 |
|
121 | /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. Defaults to "dialog". */
|
122 | role?: string | null | undefined;
|
123 |
|
124 | /* String indicating how the content container should be announced to screenreaders. */
|
125 | contentLabel?: string | undefined;
|
126 |
|
127 | /* Function accepting the ref for the content */
|
128 | contentRef?: ((instance: HTMLDivElement) => void) | undefined;
|
129 |
|
130 | /* Function accepting the ref for the overlay */
|
131 | overlayRef?: ((instance: HTMLDivElement) => void) | undefined;
|
132 |
|
133 | /* Custom Overlay element. */
|
134 | overlayElement?: ((props: React.ComponentPropsWithRef<"div">, contentEl: React.ReactElement) => React.ReactElement) | undefined;
|
135 | /* Custom Content element. */
|
136 | contentElement?: ((props: React.ComponentPropsWithRef<"div">, children: React.ReactNode) => React.ReactElement) | undefined;
|
137 |
|
138 | /* String value of data-test-id attibute to be applied to to the modal content. */
|
139 | testId?: string | undefined;
|
140 |
|
141 | /* String value of an id attribute to be applied to the modal content */
|
142 | id?: string | undefined;
|
143 | }
|
144 | }
|
145 |
|
146 | declare class ReactModal extends React.Component<ReactModal.Props> {
|
147 | /* Override base styles for all instances of this component. */
|
148 | static defaultStyles: ReactModal.Styles;
|
149 | /**
|
150 | * Call this to properly hide your application from assistive screenreaders
|
151 | * and other assistive technologies while the modal is open.
|
152 | */
|
153 | static setAppElement(appElement: string | HTMLElement): void;
|
154 |
|
155 | portal: null | {
|
156 | overlay: null | HTMLDivElement;
|
157 | content: null | HTMLDivElement;
|
158 | };
|
159 | }
|
160 |
|
\ | No newline at end of file |