@@ -21,33 +21,59 @@ export type PopupPlacement = PopperPlacement;
21
21
export type PopupAnchorRef = PopperAnchorRef ;
22
22
23
23
export interface PopupProps extends DOMProps , LayerExtendableProps , PopperProps , QAProps {
24
- open ?: boolean ;
25
24
children ?: React . ReactNode ;
25
+ /** Manages `Popup` visibility */
26
+ open ?: boolean ;
27
+ /** `Popup` will not be removed from the DOM upon hiding */
26
28
keepMounted ?: boolean ;
29
+ /** Render an arrow pointing to the anchor */
27
30
hasArrow ?: boolean ;
31
+ /** Do not use `LayerManager` on stacking popups */
28
32
disableLayer ?: boolean ;
29
33
/** @deprecated Add onClick handler to children */
30
34
onClick ?: React . MouseEventHandler < HTMLDivElement > ;
35
+ /** `mouseenter` event handler */
31
36
onMouseEnter ?: React . MouseEventHandler < HTMLDivElement > ;
37
+ /** `mouseleave` event handler */
32
38
onMouseLeave ?: React . MouseEventHandler < HTMLDivElement > ;
39
+ /** `focus` event handler */
33
40
onFocus ?: React . FocusEventHandler < HTMLDivElement > ;
41
+ /** `blur` event handler */
34
42
onBlur ?: React . FocusEventHandler < HTMLDivElement > ;
43
+ /** On start open popup animation void callback */
44
+ onTransitionEnter ?: VoidFunction ;
45
+ /** On finish open popup animation void callback */
46
+ onTransitionEntered ?: VoidFunction ;
47
+ /** On start close popup animation void callback */
48
+ onTransitionExit ?: VoidFunction ;
49
+ /** On finish close popup animation void callback */
50
+ onTransitionExited ?: VoidFunction ;
51
+ /** Do not use `Portal` for children */
35
52
disablePortal ?: boolean ;
53
+ /** DOM element children to be mounted to */
36
54
container ?: HTMLElement ;
55
+ /** HTML `class` attribute for content node */
37
56
contentClassName ?: string ;
57
+ /** If true, the focus will return to the anchor element */
38
58
restoreFocus ?: boolean ;
59
+ /** Element the focus will be restored to, depends on `restoreFocus` */
39
60
restoreFocusRef ?: React . RefObject < HTMLElement > ;
61
+ /** `aria-label` attribute, use this attribute only if you didn't have visible caption */
40
62
'aria-label' ?: React . AriaAttributes [ 'aria-label' ] ;
63
+ /** `aria-labelledby` attribute, prefer this attribute if you have visible caption */
41
64
'aria-labelledby' ?: React . AriaAttributes [ 'aria-labelledby' ] ;
65
+ /** `aria-role` attribute */
42
66
role ?: React . AriaRole ;
67
+ /** HTML `id` attribute */
43
68
id ?: string ;
69
+ /** Enable focus trapping behavior */
44
70
focusTrap ?: boolean ;
71
+ /** While open, the focus will be set to the first interactive element in the content */
45
72
autoFocus ?: boolean ;
46
73
}
47
74
48
75
const b = block ( 'popup' ) ;
49
76
const ARROW_SIZE = 8 ;
50
-
51
77
export function Popup ( {
52
78
keepMounted = false ,
53
79
hasArrow = false ,
@@ -71,6 +97,10 @@ export function Popup({
71
97
onMouseLeave,
72
98
onFocus,
73
99
onBlur,
100
+ onTransitionEnter,
101
+ onTransitionEntered,
102
+ onTransitionExit,
103
+ onTransitionExited,
74
104
disablePortal,
75
105
container,
76
106
strategy,
@@ -132,6 +162,18 @@ export function Popup({
132
162
mountOnEnter = { ! keepMounted }
133
163
unmountOnExit = { ! keepMounted }
134
164
appear = { true }
165
+ onEnter = { ( ) => {
166
+ onTransitionEnter ?.( ) ;
167
+ } }
168
+ onEntered = { ( ) => {
169
+ onTransitionEntered ?.( ) ;
170
+ } }
171
+ onExit = { ( ) => {
172
+ onTransitionExit ?.( ) ;
173
+ } }
174
+ onExited = { ( ) => {
175
+ onTransitionExited ?.( ) ;
176
+ } }
135
177
>
136
178
< div
137
179
ref = { handleRef }
0 commit comments