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