@targetprocess/popover 12.20.1-alpha.4 → 12.21.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/BodyDomNode.tsx
CHANGED
|
@@ -1,76 +1,79 @@
|
|
|
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
|
-
this.
|
|
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
|
-
this.
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
|
|
7
|
+
export type BodyDomNodeProps = {
|
|
8
|
+
children: (node: HTMLElement) => React.ReactNode
|
|
9
|
+
onOuterAction?: (event: Event) => void
|
|
10
|
+
outerActionEvents?: string[]
|
|
11
|
+
positioningTarget: HTMLElement
|
|
12
|
+
containerElement: HTMLElement
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class BodyDomNode extends React.Component<BodyDomNodeProps, {node: HTMLElement}> {
|
|
16
|
+
static propTypes = {
|
|
17
|
+
children: PropTypes.func.isRequired,
|
|
18
|
+
onOuterAction: PropTypes.func,
|
|
19
|
+
outerActionEvents: PropTypes.arrayOf(PropTypes.string),
|
|
20
|
+
positioningTarget: PropTypes.instanceOf(HTMLElement),
|
|
21
|
+
containerElement: PropTypes.instanceOf(HTMLElement)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static defaultProps = {
|
|
25
|
+
containerElement: document.body
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
state = {node: null}
|
|
29
|
+
|
|
30
|
+
_onEvent = event => {
|
|
31
|
+
if (
|
|
32
|
+
!this.state.node.contains(event.target) &&
|
|
33
|
+
!this.props.positioningTarget.contains(event.target)
|
|
34
|
+
) {
|
|
35
|
+
this.props.onOuterAction(event)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_addDocumentEventListeners = () => {
|
|
40
|
+
if (this.props.outerActionEvents && this.props.onOuterAction) {
|
|
41
|
+
this.props.outerActionEvents.forEach(event => document.addEventListener(event, this._onEvent))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_removeDocumentEventListeners = (outerActionEvents = this.props.outerActionEvents) => {
|
|
46
|
+
if (outerActionEvents) {
|
|
47
|
+
outerActionEvents.forEach(event => document.removeEventListener(event, this._onEvent))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
const node = document.createElement('div')
|
|
53
|
+
|
|
54
|
+
this.props.containerElement.appendChild(node)
|
|
55
|
+
|
|
56
|
+
this.setState({node}, this._addDocumentEventListeners)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
componentDidUpdate(prevProps: BodyDomNodeProps) {
|
|
60
|
+
if (
|
|
61
|
+
prevProps.outerActionEvents !== this.props.outerActionEvents ||
|
|
62
|
+
prevProps.onOuterAction !== this.props.onOuterAction
|
|
63
|
+
) {
|
|
64
|
+
this._removeDocumentEventListeners(prevProps.outerActionEvents)
|
|
65
|
+
this._addDocumentEventListeners()
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
componentWillUnmount() {
|
|
70
|
+
if (this.state.node) {
|
|
71
|
+
this.props.containerElement.removeChild(this.state.node)
|
|
72
|
+
this._removeDocumentEventListeners()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render() {
|
|
77
|
+
return this.props.children(this.state.node)
|
|
78
|
+
}
|
|
79
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#### v7.5.1
|
|
2
|
-
|
|
3
|
-
- Add position re-calculation on `resize` event.
|
|
4
|
-
- Use `React.createPortal` instead of `ReactDOM.unstable_renderSubtreeIntoContainer` for correcte context propogation to popover's content.
|
|
5
|
-
- Remove deprecated `ReactDOM.findDOMNode`.
|
|
6
|
-
|
|
7
|
-
#### v7.1.0
|
|
8
|
-
|
|
9
|
-
- Fixed incorrect throttle function implementation
|
|
10
|
-
- (breaking change) Now uses automatic style injection - no style import/`@global-import` is needed
|
|
11
|
-
|
|
12
|
-
#### v3.0.0
|
|
13
|
-
|
|
14
|
-
- Removed dependency on `lodash-es`.
|
|
15
|
-
|
|
16
|
-
#### 2.0.4
|
|
17
|
-
|
|
18
|
-
- Update box shadow colors to use transparency in `@targetprocess/global-constants`.
|
|
19
|
-
|
|
20
|
-
#### v2.0.0
|
|
21
|
-
|
|
22
|
-
- Fixed missing `module` field in `package.json`, which could affect some builds that rely on using CommonJS build of Popover.
|
|
1
|
+
#### v7.5.1
|
|
2
|
+
|
|
3
|
+
- Add position re-calculation on `resize` event.
|
|
4
|
+
- Use `React.createPortal` instead of `ReactDOM.unstable_renderSubtreeIntoContainer` for correcte context propogation to popover's content.
|
|
5
|
+
- Remove deprecated `ReactDOM.findDOMNode`.
|
|
6
|
+
|
|
7
|
+
#### v7.1.0
|
|
8
|
+
|
|
9
|
+
- Fixed incorrect throttle function implementation
|
|
10
|
+
- (breaking change) Now uses automatic style injection - no style import/`@global-import` is needed
|
|
11
|
+
|
|
12
|
+
#### v3.0.0
|
|
13
|
+
|
|
14
|
+
- Removed dependency on `lodash-es`.
|
|
15
|
+
|
|
16
|
+
#### 2.0.4
|
|
17
|
+
|
|
18
|
+
- Update box shadow colors to use transparency in `@targetprocess/global-constants`.
|
|
19
|
+
|
|
20
|
+
#### v2.0.0
|
|
21
|
+
|
|
22
|
+
- Fixed missing `module` field in `package.json`, which could affect some builds that rely on using CommonJS build of Popover.
|
package/Popover.tsx
CHANGED
|
@@ -1,188 +1,191 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Popover
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* Popover
|
|
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
|
-
static
|
|
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
|
-
if (this.props.
|
|
151
|
-
this.
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
import React, {createRef} from 'react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import {PopoverPosition} from './PopoverPosition'
|
|
7
|
+
import {PopoverBody} from './PopoverBody'
|
|
8
|
+
import {StatelessPopover} from './StatlessPopover'
|
|
9
|
+
import {GetPopoverPositionType} from './types'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Popover is react component for displaying some toggleable content near
|
|
13
|
+
* other elements.
|
|
14
|
+
*
|
|
15
|
+
* By itself, `<Popover>` component is pass-through, i.e. it only renders
|
|
16
|
+
* its `children` without any other side effects. Its `body` prop accepts any
|
|
17
|
+
* react element, and when `isOpen` is set to `true`, it renders `body` in a
|
|
18
|
+
* portal and appends it to the element returned by `getContainerElement`
|
|
19
|
+
* (or to `document.body`, if it's not provided).
|
|
20
|
+
*
|
|
21
|
+
* By default, `body` doesn't add any additional styling. You can use
|
|
22
|
+
* `Popover.Body` component if you need a container with commonly styled
|
|
23
|
+
* box shadow and rounded corners.
|
|
24
|
+
*
|
|
25
|
+
* Popover accepts render props children, in which case it can use its
|
|
26
|
+
* own internal state to work in uncontrolled mode. In this mode, however,
|
|
27
|
+
* `isOpen` prop on `Popover` takes preceedence over internal state.
|
|
28
|
+
* Render prop function signature is
|
|
29
|
+
* `({isOpen: boolean, setOpened: (isOpen: boolean) => void}) => React.Element`;
|
|
30
|
+
* children can use `isOpen` to adjust their own view and call setOpened to open
|
|
31
|
+
* or close the popover:
|
|
32
|
+
* ```jsx
|
|
33
|
+
* <Popover body={<Popover.Body>hello world!</Popover.Body>}>
|
|
34
|
+
* {({isOpen, setOpened}) => (
|
|
35
|
+
* <button onClick={() => setOpened(!isOpen)}>
|
|
36
|
+
* Toggle popover
|
|
37
|
+
* </button>
|
|
38
|
+
* )}
|
|
39
|
+
* </Popover>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Popover positioning can be configured using `getPopoverPosition` function.
|
|
43
|
+
* It also accepts any of the 12 positions as strings:
|
|
44
|
+
* `'bottomLeft', 'bottom', 'bottomRight', 'topLeft', 'top', 'topRight',
|
|
45
|
+
* 'leftTop', 'left', 'leftBottom', 'rightTop', 'right', 'rightBottom'`.
|
|
46
|
+
*
|
|
47
|
+
* `getPopoverPosition` accepts 3 arguments: trigger dimensions (x, y,
|
|
48
|
+
* wdith and height), body dimensions as DOMRect (x, y, width and height)
|
|
49
|
+
* and container element scroll offsets. It is expected to return any CSS
|
|
50
|
+
* style modifiers that will be then applied to the popover itself.
|
|
51
|
+
*
|
|
52
|
+
* For example, default `'bottom'` position is implemented as follows:
|
|
53
|
+
* ```js
|
|
54
|
+
* bottom: (hostRect, popoverRect, containerScroll) => ({
|
|
55
|
+
* left: '50%',
|
|
56
|
+
* marginLeft: -popoverRect.width / 2,
|
|
57
|
+
* top: hostRect.height + parseInt(SpaceXS) - containerScroll.top
|
|
58
|
+
* }),
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* Default positioning functions are also avaliable from `Popover.Position`
|
|
62
|
+
* object, so you can reuse them in certain situations. For example, if you
|
|
63
|
+
* want to use `bottom` positioning but move it 5 pixels higher, you can do
|
|
64
|
+
* it like this:
|
|
65
|
+
* ```js
|
|
66
|
+
* const getPopoverPosition = (...args) => {
|
|
67
|
+
* const defaultBottomPosition = Popover.Position.bottom(...args);
|
|
68
|
+
* return {...defaultBottomPosition, top: defaultBottomPosition - 5}
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* You can also use `showTip` to display a triangle near popover.
|
|
73
|
+
* Triangle position is calculated automatically depending on relative popover
|
|
74
|
+
* position; it is always placed at the center of the trigger from the according side.
|
|
75
|
+
*/
|
|
76
|
+
export type PopoverProps = {
|
|
77
|
+
closeOnOuterAction?: boolean
|
|
78
|
+
isOpen?: boolean
|
|
79
|
+
getPopoverPosition: GetPopoverPositionType
|
|
80
|
+
onOuterAction?: (evt: Event) => void
|
|
81
|
+
outerActionEvents?: string[]
|
|
82
|
+
getContainerElement?: () => HTMLElement
|
|
83
|
+
inline?: boolean
|
|
84
|
+
body?: React.ReactNode
|
|
85
|
+
zIndex: number
|
|
86
|
+
showTip?: boolean
|
|
87
|
+
className?: string
|
|
88
|
+
trackScroll?: boolean
|
|
89
|
+
role?: 'tooltip' | 'dialog'
|
|
90
|
+
trapFocus?: boolean
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type PopoverState = {
|
|
94
|
+
isOpen: boolean
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class Popover extends React.Component<PopoverProps, PopoverState> {
|
|
98
|
+
static Body = PopoverBody
|
|
99
|
+
static Position = PopoverPosition
|
|
100
|
+
|
|
101
|
+
static propTypes = {
|
|
102
|
+
/** Class name of toplevel popover container */
|
|
103
|
+
className: PropTypes.string,
|
|
104
|
+
/** Wether popover is opened or closed */
|
|
105
|
+
isOpen: PropTypes.bool,
|
|
106
|
+
/** Element that will be mounted within the popover */
|
|
107
|
+
body: PropTypes.element,
|
|
108
|
+
/** Called when one of the `outerActionEvents` occurs */
|
|
109
|
+
onOuterAction: PropTypes.func,
|
|
110
|
+
/** Must return DOM element to append popover to. */
|
|
111
|
+
getContainerElement: PropTypes.func,
|
|
112
|
+
/** Wether to show the triangle. */
|
|
113
|
+
showTip: PropTypes.bool,
|
|
114
|
+
/** Position string or positioning function. */
|
|
115
|
+
getPopoverPosition: PropTypes.oneOfType([
|
|
116
|
+
PropTypes.oneOf(Object.keys(PopoverPosition)),
|
|
117
|
+
PropTypes.func
|
|
118
|
+
]),
|
|
119
|
+
/**
|
|
120
|
+
* Events that trigger `onOuterAction`.
|
|
121
|
+
*/
|
|
122
|
+
outerActionEvents: PropTypes.arrayOf(PropTypes.string),
|
|
123
|
+
/** Whether uncontrolled (render props) popover should be closed on outer action */
|
|
124
|
+
closeOnOuterAction: PropTypes.bool,
|
|
125
|
+
noPadding: PropTypes.bool,
|
|
126
|
+
zIndex: PropTypes.number,
|
|
127
|
+
trackScroll: PropTypes.bool,
|
|
128
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
129
|
+
role: PropTypes.oneOf(['tooltip', 'dialog']),
|
|
130
|
+
trapFocus: PropTypes.bool
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static defaultProps = {
|
|
134
|
+
zIndex: 19999,
|
|
135
|
+
outerActionEvents: ['mousedown', 'touchstart'],
|
|
136
|
+
getPopoverPosition: 'bottomLeft',
|
|
137
|
+
role: 'dialog',
|
|
138
|
+
trapFocus: 'true'
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
state = {
|
|
142
|
+
isOpen: false
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setOpened = (isOpen: boolean) => {
|
|
146
|
+
this.setState({isOpen})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
onOuterAction = (event: Event) => {
|
|
150
|
+
if (this.props.closeOnOuterAction) {
|
|
151
|
+
this.setOpened(false)
|
|
152
|
+
}
|
|
153
|
+
if (this.props.onOuterAction) {
|
|
154
|
+
this.props.onOuterAction(event)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
onEscapeAction = (event: Event) => {
|
|
159
|
+
this.setOpened(false)
|
|
160
|
+
if (this.props.onOuterAction) {
|
|
161
|
+
this.props.onOuterAction(event)
|
|
162
|
+
}
|
|
163
|
+
this.childrenRef.current?.focus()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
childrenRef = createRef<HTMLElement>()
|
|
167
|
+
|
|
168
|
+
render() {
|
|
169
|
+
const isOpen = typeof this.props.isOpen === 'undefined' ? this.state.isOpen : this.props.isOpen
|
|
170
|
+
const children =
|
|
171
|
+
typeof this.props.children === 'function'
|
|
172
|
+
? this.props.children({isOpen, setOpened: this.setOpened, ref: this.childrenRef})
|
|
173
|
+
: this.props.children
|
|
174
|
+
const childrenWithRef = React.Children.map(children, child =>
|
|
175
|
+
React.cloneElement(child, {ref: this.childrenRef})
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<StatelessPopover
|
|
180
|
+
{...this.props}
|
|
181
|
+
onOuterAction={this.onOuterAction}
|
|
182
|
+
onEscapeAction={this.onEscapeAction}
|
|
183
|
+
isOpen={isOpen}
|
|
184
|
+
role={this.props.role}
|
|
185
|
+
trapFocus={this.props.trapFocus}
|
|
186
|
+
>
|
|
187
|
+
{childrenWithRef}
|
|
188
|
+
</StatelessPopover>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
}
|