@targetprocess/popover 12.20.1-alpha.2 → 12.20.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BodyDomNode.tsx +79 -76
- package/CHANGELOG.md +22 -22
- package/Popover.tsx +191 -188
- package/PopoverBody.tsx +40 -37
- package/PopoverContainer.tsx +325 -322
- package/PopoverPosition.ts +62 -59
- package/PositioningTarget.tsx +29 -26
- package/StatlessPopover.tsx +98 -101
- package/__tests__/BodyDomNode.tests.tsx +287 -284
- package/__tests__/Popover.tests.tsx +66 -63
- package/__tests__/PositioningTarget.tests.tsx +46 -43
- package/dist/BodyDomNode.d.ts +3 -0
- package/dist/Popover.d.ts +3 -0
- package/dist/PopoverBody.d.ts +3 -0
- package/dist/PopoverContainer.d.ts +3 -0
- package/dist/PositioningTarget.d.ts +3 -0
- package/dist/StatlessPopover.d.ts +4 -1
- package/dist/index.d.ts +3 -0
- package/dist/popover.es.js +22 -11
- package/dist/popover.js +22 -11
- package/dist/types.d.ts +3 -0
- package/index.ts +17 -14
- package/package.json +3 -3
- package/style/index.css +107 -104
- package/types.ts +40 -37
package/PopoverContainer.tsx
CHANGED
|
@@ -1,322 +1,325 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (popoverPosition.
|
|
205
|
-
return '
|
|
206
|
-
}
|
|
207
|
-
if (popoverPosition.
|
|
208
|
-
return '
|
|
209
|
-
}
|
|
210
|
-
if (popoverPosition.
|
|
211
|
-
return '
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
{this.props.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
{this.props.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
/* eslint-disable id-length,wrap-regex */
|
|
5
|
+
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import PropTypes from 'prop-types'
|
|
8
|
+
import classNames from 'classnames'
|
|
9
|
+
import {PopoverPosition} from './PopoverPosition'
|
|
10
|
+
import styles from './style/index.css'
|
|
11
|
+
import {DimensionParams, GetPopoverPositionType, PositionParams} from './types'
|
|
12
|
+
import {throttle} from '../../base/utils/throttle'
|
|
13
|
+
import FocusTrap from 'focus-trap-react'
|
|
14
|
+
import {generateId, focusFirstDescendant} from '../../base/utils/ariaUtils'
|
|
15
|
+
|
|
16
|
+
const popoverContainerPrefix = 'popover-container-'
|
|
17
|
+
|
|
18
|
+
type PopoverContainerProps = {
|
|
19
|
+
containerElement?: HTMLElement
|
|
20
|
+
positioningTarget: HTMLElement
|
|
21
|
+
className?: string
|
|
22
|
+
relativeToParent?: boolean
|
|
23
|
+
trackScroll?: boolean
|
|
24
|
+
scrollThrottleIntervalMs?: number
|
|
25
|
+
getPopoverPosition: GetPopoverPositionType
|
|
26
|
+
showTip?: boolean
|
|
27
|
+
zIndex: number
|
|
28
|
+
role?: 'tooltip' | 'dialog'
|
|
29
|
+
trapFocus?: boolean
|
|
30
|
+
onEscapeAction: (event: Event) => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type PopoverContainerState = {
|
|
34
|
+
adjusted: boolean
|
|
35
|
+
positionX: number
|
|
36
|
+
positionY: number
|
|
37
|
+
hostRect?: PositionParams & DimensionParams
|
|
38
|
+
popoverRect?: DimensionParams
|
|
39
|
+
scroll?: PositionParams
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const isScrollParent = (element: HTMLElement): boolean => {
|
|
43
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
44
|
+
const {overflow, overflowX, overflowY} = getComputedStyle(element)
|
|
45
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getNodeName(element): string | null | undefined {
|
|
49
|
+
return element ? (element.nodeName || '').toLowerCase() : null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getNodeScroll(node) {
|
|
53
|
+
if (node === window) {
|
|
54
|
+
return {
|
|
55
|
+
scrollLeft: window.pageXOffset,
|
|
56
|
+
scrollTop: window.pageYOffset
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
scrollLeft: node.scrollLeft,
|
|
61
|
+
scrollTop: node.scrollTop
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const getCompositeRect = (elementOrVirtualElement, offsetParent) => {
|
|
66
|
+
const rect = elementOrVirtualElement.getBoundingClientRect()
|
|
67
|
+
let scroll = {scrollLeft: 0, scrollTop: 0}
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
// https://github.com/popperjs/popper-core/issues/1078
|
|
71
|
+
getNodeName(offsetParent) !== 'body' ||
|
|
72
|
+
isScrollParent(document.documentElement)
|
|
73
|
+
) {
|
|
74
|
+
scroll = getNodeScroll(offsetParent)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const offsets = offsetParent.getBoundingClientRect()
|
|
78
|
+
offsets.x += offsetParent.clientLeft
|
|
79
|
+
offsets.y += offsetParent.clientTop
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
left: rect.left + scroll.scrollLeft - offsets.x,
|
|
83
|
+
top: rect.top + scroll.scrollTop - offsets.y,
|
|
84
|
+
right: rect.right + scroll.scrollLeft - offsets.x,
|
|
85
|
+
bottom: rect.bottom + scroll.scrollTop - offsets.y,
|
|
86
|
+
width: rect.width,
|
|
87
|
+
height: rect.height
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class PopoverContainer extends React.Component<
|
|
92
|
+
PopoverContainerProps,
|
|
93
|
+
PopoverContainerState
|
|
94
|
+
> {
|
|
95
|
+
static propTypes = {
|
|
96
|
+
positioningTarget: PropTypes.object,
|
|
97
|
+
containerElement: PropTypes.object,
|
|
98
|
+
className: PropTypes.string,
|
|
99
|
+
trackScroll: PropTypes.bool,
|
|
100
|
+
role: PropTypes.oneOf(['tooltip', 'dialog']),
|
|
101
|
+
trapFocus: PropTypes.bool,
|
|
102
|
+
onEscapeAction: PropTypes.func
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static defaultProps = {
|
|
106
|
+
trackScroll: true
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
mounted = false
|
|
110
|
+
popoverContentRef = React.createRef<HTMLDivElement>()
|
|
111
|
+
|
|
112
|
+
state: PopoverContainerState = {
|
|
113
|
+
adjusted: false,
|
|
114
|
+
positionX: 0,
|
|
115
|
+
positionY: 0
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
popoverContainerId = generateId(popoverContainerPrefix)
|
|
119
|
+
|
|
120
|
+
adjustPosition() {
|
|
121
|
+
if (!this.mounted) {
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const containerElement = this.props.containerElement || document.body
|
|
126
|
+
const positioningBoundingRect = getCompositeRect(
|
|
127
|
+
this.props.positioningTarget,
|
|
128
|
+
this.props.containerElement
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
this.setState({
|
|
132
|
+
hostRect: {
|
|
133
|
+
top: this.props.relativeToParent ? 0 : positioningBoundingRect.top,
|
|
134
|
+
left: this.props.relativeToParent ? 0 : positioningBoundingRect.left,
|
|
135
|
+
right: this.props.relativeToParent ? 0 : positioningBoundingRect.right,
|
|
136
|
+
bottom: this.props.relativeToParent ? 0 : positioningBoundingRect.bottom,
|
|
137
|
+
width: positioningBoundingRect.width,
|
|
138
|
+
height: positioningBoundingRect.height
|
|
139
|
+
},
|
|
140
|
+
popoverRect: this.popoverContentRef.current.getBoundingClientRect(),
|
|
141
|
+
scroll:
|
|
142
|
+
containerElement === document.body || !this.props.trackScroll
|
|
143
|
+
? {left: 0, top: 0}
|
|
144
|
+
: {
|
|
145
|
+
left: containerElement.scrollLeft,
|
|
146
|
+
top: containerElement.scrollTop
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
window.requestAnimationFrame(() => {
|
|
151
|
+
if (this.mounted) {
|
|
152
|
+
this.setState({adjusted: true})
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
onResize = () => this.adjustPosition()
|
|
158
|
+
|
|
159
|
+
onScroll = throttle(() => {
|
|
160
|
+
this.adjustPosition()
|
|
161
|
+
}, this.props.scrollThrottleIntervalMs || 200)
|
|
162
|
+
|
|
163
|
+
componentDidMount() {
|
|
164
|
+
this.mounted = true
|
|
165
|
+
this.adjustPosition()
|
|
166
|
+
|
|
167
|
+
if (this.props.trackScroll) {
|
|
168
|
+
document.addEventListener('scroll', this.onScroll)
|
|
169
|
+
window.addEventListener('resize', this.onResize)
|
|
170
|
+
if (this.props.containerElement && this.props.containerElement !== document.body) {
|
|
171
|
+
this.props.containerElement.addEventListener('scroll', this.onScroll)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this.popoverContentRef.current && !this.props.trapFocus) {
|
|
176
|
+
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
177
|
+
this.popoverContentRef.current.tabIndex = -1
|
|
178
|
+
this.popoverContentRef.current.focus()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
componentDidUpdate(previousProps) {
|
|
184
|
+
if (
|
|
185
|
+
this.props.containerElement !== previousProps.containerElement ||
|
|
186
|
+
this.props.getPopoverPosition !== previousProps.getPopoverPosition
|
|
187
|
+
) {
|
|
188
|
+
this.adjustPosition()
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
componentWillUnmount() {
|
|
193
|
+
this.mounted = false
|
|
194
|
+
if (this.onScroll && this.props.trackScroll) {
|
|
195
|
+
document.body.removeEventListener('scroll', this.onScroll)
|
|
196
|
+
window.removeEventListener('resize', this.onResize)
|
|
197
|
+
if (this.props.containerElement && this.props.containerElement !== document.body) {
|
|
198
|
+
this.props.containerElement.removeEventListener('scroll', this.onScroll)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
getPopoverTipPosition = (popoverPosition, containerPosition) => {
|
|
204
|
+
if (popoverPosition.bottom && popoverPosition.bottom >= containerPosition.height) {
|
|
205
|
+
return 'top'
|
|
206
|
+
}
|
|
207
|
+
if (popoverPosition.top && popoverPosition.top >= containerPosition.height) {
|
|
208
|
+
return 'bottom'
|
|
209
|
+
}
|
|
210
|
+
if (popoverPosition.left && popoverPosition.left >= containerPosition.width) {
|
|
211
|
+
return 'right'
|
|
212
|
+
}
|
|
213
|
+
if (popoverPosition.right && popoverPosition.right >= containerPosition.width) {
|
|
214
|
+
return 'left'
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return null
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
handleKeyDown = event => {
|
|
221
|
+
if (event.key === 'Escape') {
|
|
222
|
+
event.stopPropagation()
|
|
223
|
+
this.props.onEscapeAction(event)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
render() {
|
|
228
|
+
const getPopoverPosition =
|
|
229
|
+
typeof this.props.getPopoverPosition === 'function'
|
|
230
|
+
? this.props.getPopoverPosition
|
|
231
|
+
: PopoverPosition[this.props.getPopoverPosition] || PopoverPosition.bottomLeft
|
|
232
|
+
const position = this.state.hostRect
|
|
233
|
+
? getPopoverPosition(
|
|
234
|
+
this.state.hostRect,
|
|
235
|
+
this.state.popoverRect,
|
|
236
|
+
this.state.scroll,
|
|
237
|
+
this.props.containerElement
|
|
238
|
+
)
|
|
239
|
+
: {}
|
|
240
|
+
|
|
241
|
+
const containerPosition = {
|
|
242
|
+
left: this.state.hostRect ? this.state.hostRect.left : 0,
|
|
243
|
+
top: this.state.hostRect ? this.state.hostRect.top : 0,
|
|
244
|
+
width: this.state.hostRect && this.state.hostRect.width,
|
|
245
|
+
height: this.state.hostRect && this.state.hostRect.height
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const tipPosition = this.getPopoverTipPosition(position, containerPosition)
|
|
249
|
+
|
|
250
|
+
// FIXME: position.top cast to number, because value may be not a number
|
|
251
|
+
return (
|
|
252
|
+
<div
|
|
253
|
+
style={{
|
|
254
|
+
position: 'absolute',
|
|
255
|
+
...containerPosition,
|
|
256
|
+
pointerEvents: 'none',
|
|
257
|
+
zIndex: this.props.zIndex,
|
|
258
|
+
transition: '0.1s',
|
|
259
|
+
transitionProperty: 'opacity',
|
|
260
|
+
opacity: this.state.adjusted ? 1 : 0
|
|
261
|
+
}}
|
|
262
|
+
>
|
|
263
|
+
{this.props.showTip && tipPosition && (
|
|
264
|
+
<div
|
|
265
|
+
className={classNames(
|
|
266
|
+
styles['popover-tip'],
|
|
267
|
+
styles[`popover-tip--${tipPosition}`],
|
|
268
|
+
'popover-tip'
|
|
269
|
+
)}
|
|
270
|
+
style={{
|
|
271
|
+
top: tipPosition === 'bottom' && (position.top as number) - 8,
|
|
272
|
+
bottom: tipPosition === 'top' && (position.bottom as number) - 8,
|
|
273
|
+
left: tipPosition === 'right' && (position.left as number) - 8,
|
|
274
|
+
right: tipPosition === 'left' && (position.right as number) - 8
|
|
275
|
+
}}
|
|
276
|
+
/>
|
|
277
|
+
)}
|
|
278
|
+
{this.props.trapFocus && (
|
|
279
|
+
<FocusTrap
|
|
280
|
+
focusTrapOptions={{
|
|
281
|
+
fallbackFocus: `#${this.popoverContainerId}`,
|
|
282
|
+
clickOutsideDeactivates: true
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
<div
|
|
286
|
+
id={this.popoverContainerId}
|
|
287
|
+
ref={this.popoverContentRef}
|
|
288
|
+
style={{
|
|
289
|
+
position: 'absolute',
|
|
290
|
+
pointerEvents: 'all',
|
|
291
|
+
...position
|
|
292
|
+
}}
|
|
293
|
+
tabIndex={-1}
|
|
294
|
+
className={this.props.className}
|
|
295
|
+
role={this.props.role}
|
|
296
|
+
aria-modal={this.props.trapFocus ? 'true' : 'false'}
|
|
297
|
+
onKeyDown={this.handleKeyDown}
|
|
298
|
+
>
|
|
299
|
+
{this.props.children}
|
|
300
|
+
</div>
|
|
301
|
+
</FocusTrap>
|
|
302
|
+
)}
|
|
303
|
+
|
|
304
|
+
{!this.props.trapFocus && (
|
|
305
|
+
<div
|
|
306
|
+
id={this.popoverContainerId}
|
|
307
|
+
ref={this.popoverContentRef}
|
|
308
|
+
style={{
|
|
309
|
+
position: 'absolute',
|
|
310
|
+
pointerEvents: 'all',
|
|
311
|
+
...position
|
|
312
|
+
}}
|
|
313
|
+
tabIndex={-1}
|
|
314
|
+
className={this.props.className}
|
|
315
|
+
role={this.props.role}
|
|
316
|
+
aria-modal={this.props.trapFocus ? 'true' : 'false'}
|
|
317
|
+
onKeyDown={this.handleKeyDown}
|
|
318
|
+
>
|
|
319
|
+
{this.props.children}
|
|
320
|
+
</div>
|
|
321
|
+
)}
|
|
322
|
+
</div>
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
}
|