@khanacademy/wonder-blocks-popover 2.0.4 → 2.0.6
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/CHANGELOG.md +23 -0
- package/dist/components/close-button.js.flow +1 -2
- package/dist/components/focus-manager.js.flow +1 -2
- package/dist/components/initial-focus.js.flow +1 -2
- package/dist/components/popover-anchor.js.flow +1 -2
- package/dist/components/popover-content-core.js.flow +1 -2
- package/dist/components/popover-content.js.flow +1 -2
- package/dist/components/popover-context.js.flow +1 -2
- package/dist/components/popover-dialog.js.flow +1 -2
- package/dist/components/popover-event-listener.js.flow +1 -2
- package/dist/components/popover.js.flow +1 -2
- package/dist/es/index.js +135 -197
- package/dist/index.js +135 -197
- package/dist/index.js.flow +1 -2
- package/dist/util/util.js.flow +1 -2
- package/package.json +8 -8
package/dist/es/index.js
CHANGED
|
@@ -25,39 +25,20 @@ function _extends() {
|
|
|
25
25
|
return _extends.apply(this, arguments);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function _setPrototypeOf(o, p) {
|
|
29
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
30
|
-
o.__proto__ = p;
|
|
31
|
-
return o;
|
|
32
|
-
};
|
|
33
|
-
return _setPrototypeOf(o, p);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _inheritsLoose(subClass, superClass) {
|
|
37
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
38
|
-
subClass.prototype.constructor = subClass;
|
|
39
|
-
_setPrototypeOf(subClass, superClass);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
28
|
const defaultContext = {
|
|
43
29
|
close: undefined,
|
|
44
30
|
placement: "top"
|
|
45
31
|
};
|
|
46
32
|
var PopoverContext = React.createContext(defaultContext);
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function PopoverAnchor() {
|
|
51
|
-
return _React$Component.apply(this, arguments) || this;
|
|
52
|
-
}
|
|
53
|
-
var _proto = PopoverAnchor.prototype;
|
|
54
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
34
|
+
class PopoverAnchor extends React.Component {
|
|
35
|
+
componentDidMount() {
|
|
55
36
|
const anchorNode = ReactDOM.findDOMNode(this);
|
|
56
37
|
if (anchorNode) {
|
|
57
38
|
this.props.anchorRef(anchorNode);
|
|
58
39
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
61
42
|
const {
|
|
62
43
|
children,
|
|
63
44
|
id,
|
|
@@ -84,22 +65,16 @@ let PopoverAnchor = function (_React$Component) {
|
|
|
84
65
|
} : onClick
|
|
85
66
|
}));
|
|
86
67
|
}
|
|
87
|
-
};
|
|
88
|
-
return PopoverAnchor;
|
|
89
|
-
}(React.Component);
|
|
90
|
-
|
|
91
|
-
let PopoverDialog = function (_React$Component) {
|
|
92
|
-
_inheritsLoose(PopoverDialog, _React$Component);
|
|
93
|
-
function PopoverDialog() {
|
|
94
|
-
return _React$Component.apply(this, arguments) || this;
|
|
95
68
|
}
|
|
96
|
-
|
|
97
|
-
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class PopoverDialog extends React.Component {
|
|
72
|
+
componentDidUpdate(prevProps) {
|
|
98
73
|
if (prevProps.placement !== this.props.placement) {
|
|
99
74
|
this.props.onUpdate(this.props.placement);
|
|
100
75
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
103
78
|
const {
|
|
104
79
|
placement,
|
|
105
80
|
children,
|
|
@@ -126,9 +101,8 @@ let PopoverDialog = function (_React$Component) {
|
|
|
126
101
|
placement: placement,
|
|
127
102
|
offset: tailOffset
|
|
128
103
|
})));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
}(React.Component);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
132
106
|
const styles$2 = StyleSheet.create({
|
|
133
107
|
hide: {
|
|
134
108
|
pointerEvents: "none",
|
|
@@ -155,13 +129,11 @@ function findFocusableNodes(root) {
|
|
|
155
129
|
return Array.from(root.querySelectorAll(FOCUSABLE_ELEMENTS));
|
|
156
130
|
}
|
|
157
131
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
_this.setInitialFocusableElement = node => {
|
|
164
|
-
const firstFocusableElement = _this.maybeGetInitialFocusElement(node) || _this.maybeGetFirstFocusableElement(node) || node;
|
|
132
|
+
class InitialFocus extends React.Component {
|
|
133
|
+
constructor(...args) {
|
|
134
|
+
super(...args);
|
|
135
|
+
this.setInitialFocusableElement = node => {
|
|
136
|
+
const firstFocusableElement = this.maybeGetInitialFocusElement(node) || this.maybeGetFirstFocusableElement(node) || node;
|
|
165
137
|
if (firstFocusableElement === node) {
|
|
166
138
|
node.tabIndex = -1;
|
|
167
139
|
}
|
|
@@ -169,17 +141,15 @@ let InitialFocus = function (_React$Component) {
|
|
|
169
141
|
firstFocusableElement.focus();
|
|
170
142
|
}, 0);
|
|
171
143
|
};
|
|
172
|
-
return _this;
|
|
173
144
|
}
|
|
174
|
-
|
|
175
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
145
|
+
componentDidMount() {
|
|
176
146
|
const node = ReactDOM.findDOMNode(this);
|
|
177
147
|
if (!node) {
|
|
178
148
|
return;
|
|
179
149
|
}
|
|
180
150
|
this.setInitialFocusableElement(node);
|
|
181
|
-
}
|
|
182
|
-
|
|
151
|
+
}
|
|
152
|
+
maybeGetInitialFocusElement(node) {
|
|
183
153
|
const {
|
|
184
154
|
initialFocusId
|
|
185
155
|
} = this.props;
|
|
@@ -187,45 +157,42 @@ let InitialFocus = function (_React$Component) {
|
|
|
187
157
|
return null;
|
|
188
158
|
}
|
|
189
159
|
return node.querySelector(`#${initialFocusId}`);
|
|
190
|
-
}
|
|
191
|
-
|
|
160
|
+
}
|
|
161
|
+
maybeGetFirstFocusableElement(node) {
|
|
192
162
|
const focusableElements = findFocusableNodes(node);
|
|
193
163
|
if (!focusableElements.length) {
|
|
194
164
|
return null;
|
|
195
165
|
}
|
|
196
166
|
return focusableElements[0];
|
|
197
|
-
}
|
|
198
|
-
|
|
167
|
+
}
|
|
168
|
+
render() {
|
|
199
169
|
return this.props.children;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
}(React.Component);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
203
172
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
_this.focusableElementsInPopover = [];
|
|
212
|
-
_this.addEventListeners = () => {
|
|
173
|
+
class FocusManager extends React.Component {
|
|
174
|
+
constructor(...args) {
|
|
175
|
+
super(...args);
|
|
176
|
+
this.nextElementAfterPopover = void 0;
|
|
177
|
+
this.rootNode = void 0;
|
|
178
|
+
this.focusableElementsInPopover = [];
|
|
179
|
+
this.addEventListeners = () => {
|
|
213
180
|
const {
|
|
214
181
|
anchorElement
|
|
215
|
-
} =
|
|
182
|
+
} = this.props;
|
|
216
183
|
if (anchorElement) {
|
|
217
|
-
anchorElement.addEventListener("keydown",
|
|
184
|
+
anchorElement.addEventListener("keydown", this.handleKeydownPreviousFocusableElement, true);
|
|
218
185
|
}
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
|
|
186
|
+
this.nextElementAfterPopover = this.getNextFocusableElement();
|
|
187
|
+
if (this.nextElementAfterPopover) {
|
|
188
|
+
this.nextElementAfterPopover.addEventListener("keydown", this.handleKeydownNextFocusableElement, true);
|
|
222
189
|
}
|
|
223
190
|
};
|
|
224
|
-
|
|
191
|
+
this.getNextFocusableElement = () => {
|
|
225
192
|
const {
|
|
226
193
|
anchorElement
|
|
227
|
-
} =
|
|
228
|
-
if (!anchorElement ||
|
|
194
|
+
} = this.props;
|
|
195
|
+
if (!anchorElement || this.nextElementAfterPopover) {
|
|
229
196
|
return;
|
|
230
197
|
}
|
|
231
198
|
const focusableElements = findFocusableNodes(document);
|
|
@@ -236,7 +203,7 @@ let FocusManager = function (_React$Component) {
|
|
|
236
203
|
}
|
|
237
204
|
return;
|
|
238
205
|
};
|
|
239
|
-
|
|
206
|
+
this.getComponentRootNode = node => {
|
|
240
207
|
if (!node) {
|
|
241
208
|
return;
|
|
242
209
|
}
|
|
@@ -244,42 +211,40 @@ let FocusManager = function (_React$Component) {
|
|
|
244
211
|
if (!rootNode) {
|
|
245
212
|
throw new Error("Assertion error: root node should exist after mount");
|
|
246
213
|
}
|
|
247
|
-
|
|
248
|
-
|
|
214
|
+
this.rootNode = rootNode;
|
|
215
|
+
this.focusableElementsInPopover = findFocusableNodes(this.rootNode);
|
|
249
216
|
};
|
|
250
|
-
|
|
251
|
-
if (
|
|
252
|
-
|
|
217
|
+
this.handleFocusPreviousFocusableElement = () => {
|
|
218
|
+
if (this.props.anchorElement) {
|
|
219
|
+
this.props.anchorElement.focus();
|
|
253
220
|
}
|
|
254
221
|
};
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
222
|
+
this.handleFocusNextFocusableElement = () => {
|
|
223
|
+
if (this.nextElementAfterPopover) {
|
|
224
|
+
this.nextElementAfterPopover.focus();
|
|
258
225
|
}
|
|
259
226
|
};
|
|
260
|
-
|
|
227
|
+
this.handleKeydownPreviousFocusableElement = e => {
|
|
261
228
|
if (e.key === "Tab" && !e.shiftKey) {
|
|
262
229
|
e.preventDefault();
|
|
263
|
-
|
|
230
|
+
this.focusableElementsInPopover[0].focus();
|
|
264
231
|
}
|
|
265
232
|
};
|
|
266
|
-
|
|
233
|
+
this.handleKeydownNextFocusableElement = e => {
|
|
267
234
|
if (e.key === "Tab" && e.shiftKey) {
|
|
268
235
|
e.preventDefault();
|
|
269
|
-
const lastElementIndex =
|
|
270
|
-
|
|
236
|
+
const lastElementIndex = this.focusableElementsInPopover.length - 1;
|
|
237
|
+
this.focusableElementsInPopover[lastElementIndex].focus();
|
|
271
238
|
}
|
|
272
239
|
};
|
|
273
|
-
return _this;
|
|
274
240
|
}
|
|
275
|
-
|
|
276
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
241
|
+
componentDidMount() {
|
|
277
242
|
this.addEventListeners();
|
|
278
|
-
}
|
|
279
|
-
|
|
243
|
+
}
|
|
244
|
+
componentDidUpdate() {
|
|
280
245
|
this.addEventListeners();
|
|
281
|
-
}
|
|
282
|
-
|
|
246
|
+
}
|
|
247
|
+
componentWillUnmount() {
|
|
283
248
|
const {
|
|
284
249
|
anchorElement
|
|
285
250
|
} = this.props;
|
|
@@ -290,8 +255,8 @@ let FocusManager = function (_React$Component) {
|
|
|
290
255
|
if (this.nextElementAfterPopover) {
|
|
291
256
|
this.nextElementAfterPopover.removeEventListener("keydown", this.handleKeydownNextFocusableElement, true);
|
|
292
257
|
}
|
|
293
|
-
}
|
|
294
|
-
|
|
258
|
+
}
|
|
259
|
+
render() {
|
|
295
260
|
const {
|
|
296
261
|
children
|
|
297
262
|
} = this.props;
|
|
@@ -312,103 +277,94 @@ let FocusManager = function (_React$Component) {
|
|
|
312
277
|
position: "fixed"
|
|
313
278
|
}
|
|
314
279
|
}));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
}(React.Component);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
318
282
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
324
|
-
_this.state = {
|
|
283
|
+
class PopoverEventListener extends React.Component {
|
|
284
|
+
constructor(...args) {
|
|
285
|
+
super(...args);
|
|
286
|
+
this.state = {
|
|
325
287
|
isFirstClick: true
|
|
326
288
|
};
|
|
327
|
-
|
|
289
|
+
this._handleKeyup = e => {
|
|
328
290
|
if (e.key === "Escape") {
|
|
329
291
|
e.preventDefault();
|
|
330
292
|
e.stopPropagation();
|
|
331
|
-
|
|
293
|
+
this.props.onClose();
|
|
332
294
|
}
|
|
333
295
|
};
|
|
334
|
-
|
|
296
|
+
this._handleClick = e => {
|
|
335
297
|
var _this$props$contentRe;
|
|
336
|
-
if (
|
|
337
|
-
|
|
298
|
+
if (this.state.isFirstClick) {
|
|
299
|
+
this.setState({
|
|
338
300
|
isFirstClick: false
|
|
339
301
|
});
|
|
340
302
|
return;
|
|
341
303
|
}
|
|
342
|
-
const node = ReactDOM.findDOMNode((_this$props$contentRe =
|
|
304
|
+
const node = ReactDOM.findDOMNode((_this$props$contentRe = this.props.contentRef) == null ? void 0 : _this$props$contentRe.current);
|
|
343
305
|
if (node && !node.contains(e.target)) {
|
|
344
306
|
e.preventDefault();
|
|
345
307
|
e.stopPropagation();
|
|
346
|
-
|
|
308
|
+
this.props.onClose();
|
|
347
309
|
}
|
|
348
310
|
};
|
|
349
|
-
return _this;
|
|
350
311
|
}
|
|
351
|
-
|
|
352
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
312
|
+
componentDidMount() {
|
|
353
313
|
window.addEventListener("keyup", this._handleKeyup);
|
|
354
314
|
window.addEventListener("click", this._handleClick);
|
|
355
|
-
}
|
|
356
|
-
|
|
315
|
+
}
|
|
316
|
+
componentWillUnmount() {
|
|
357
317
|
window.removeEventListener("keyup", this._handleKeyup);
|
|
358
318
|
window.removeEventListener("click", this._handleClick);
|
|
359
|
-
}
|
|
360
|
-
|
|
319
|
+
}
|
|
320
|
+
render() {
|
|
361
321
|
return null;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
}(React.Component);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
365
324
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
_this.state = {
|
|
372
|
-
opened: !!_this.props.opened,
|
|
325
|
+
class Popover extends React.Component {
|
|
326
|
+
constructor(...args) {
|
|
327
|
+
super(...args);
|
|
328
|
+
this.state = {
|
|
329
|
+
opened: !!this.props.opened,
|
|
373
330
|
anchorElement: null,
|
|
374
|
-
placement:
|
|
331
|
+
placement: this.props.placement
|
|
375
332
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
333
|
+
this.contentRef = React.createRef();
|
|
334
|
+
this.handleClose = () => {
|
|
335
|
+
this.setState({
|
|
379
336
|
opened: false
|
|
380
337
|
}, () => {
|
|
381
|
-
_this
|
|
338
|
+
var _this$props$onClose, _this$props;
|
|
339
|
+
(_this$props$onClose = (_this$props = this.props).onClose) == null ? void 0 : _this$props$onClose.call(_this$props);
|
|
382
340
|
});
|
|
383
341
|
};
|
|
384
|
-
|
|
385
|
-
if (
|
|
386
|
-
|
|
342
|
+
this.handleOpen = () => {
|
|
343
|
+
if (this.props.dismissEnabled && this.state.opened) {
|
|
344
|
+
this.setState({
|
|
387
345
|
opened: false
|
|
388
346
|
});
|
|
389
347
|
} else {
|
|
390
|
-
|
|
348
|
+
this.setState({
|
|
391
349
|
opened: true
|
|
392
350
|
});
|
|
393
351
|
}
|
|
394
352
|
};
|
|
395
|
-
|
|
353
|
+
this.updateRef = ref => {
|
|
396
354
|
const actualRef = ref && ReactDOM.findDOMNode(ref);
|
|
397
|
-
if (actualRef &&
|
|
398
|
-
|
|
355
|
+
if (actualRef && this.state.anchorElement !== actualRef) {
|
|
356
|
+
this.setState({
|
|
399
357
|
anchorElement: actualRef
|
|
400
358
|
});
|
|
401
359
|
}
|
|
402
360
|
};
|
|
403
|
-
return _this;
|
|
404
361
|
}
|
|
405
|
-
|
|
362
|
+
static getDerivedStateFromProps(props, state) {
|
|
406
363
|
return {
|
|
407
364
|
opened: typeof props.opened === "boolean" ? props.opened : state.opened
|
|
408
365
|
};
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
_proto.renderContent = function renderContent() {
|
|
366
|
+
}
|
|
367
|
+
renderContent() {
|
|
412
368
|
const {
|
|
413
369
|
content
|
|
414
370
|
} = this.props;
|
|
@@ -418,8 +374,8 @@ let Popover = function (_React$Component) {
|
|
|
418
374
|
return React.cloneElement(popoverContents, {
|
|
419
375
|
ref: this.contentRef
|
|
420
376
|
});
|
|
421
|
-
}
|
|
422
|
-
|
|
377
|
+
}
|
|
378
|
+
renderPopper(uniqueId) {
|
|
423
379
|
const {
|
|
424
380
|
initialFocusId,
|
|
425
381
|
placement
|
|
@@ -440,11 +396,11 @@ let Popover = function (_React$Component) {
|
|
|
440
396
|
placement
|
|
441
397
|
})
|
|
442
398
|
}), this.renderContent())));
|
|
443
|
-
}
|
|
444
|
-
|
|
399
|
+
}
|
|
400
|
+
getHost() {
|
|
445
401
|
return maybeGetPortalMountedModalHostElement(this.state.anchorElement) || document.body;
|
|
446
|
-
}
|
|
447
|
-
|
|
402
|
+
}
|
|
403
|
+
render() {
|
|
448
404
|
const {
|
|
449
405
|
children,
|
|
450
406
|
dismissEnabled,
|
|
@@ -473,20 +429,14 @@ let Popover = function (_React$Component) {
|
|
|
473
429
|
onClose: this.handleClose,
|
|
474
430
|
contentRef: this.contentRef
|
|
475
431
|
}));
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
}(React.Component);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
479
434
|
Popover.defaultProps = {
|
|
480
435
|
placement: "top"
|
|
481
436
|
};
|
|
482
437
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
function CloseButton() {
|
|
486
|
-
return _React$Component.apply(this, arguments) || this;
|
|
487
|
-
}
|
|
488
|
-
var _proto = CloseButton.prototype;
|
|
489
|
-
_proto.render = function render() {
|
|
438
|
+
class CloseButton extends React.Component {
|
|
439
|
+
render() {
|
|
490
440
|
const {
|
|
491
441
|
light,
|
|
492
442
|
"aria-label": ariaLabel,
|
|
@@ -506,21 +456,15 @@ let CloseButton = function (_React$Component) {
|
|
|
506
456
|
testId: testId
|
|
507
457
|
});
|
|
508
458
|
});
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
}(React.Component);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
512
461
|
CloseButton.defaultProps = {
|
|
513
462
|
light: true,
|
|
514
463
|
"aria-label": "Close Popover"
|
|
515
464
|
};
|
|
516
465
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
function PopoverContentCore() {
|
|
520
|
-
return _React$Component.apply(this, arguments) || this;
|
|
521
|
-
}
|
|
522
|
-
var _proto = PopoverContentCore.prototype;
|
|
523
|
-
_proto.render = function render() {
|
|
466
|
+
class PopoverContentCore extends React.Component {
|
|
467
|
+
render() {
|
|
524
468
|
const {
|
|
525
469
|
children,
|
|
526
470
|
closeButtonLight,
|
|
@@ -539,9 +483,8 @@ let PopoverContentCore = function (_React$Component) {
|
|
|
539
483
|
style: styles$1.closeButton,
|
|
540
484
|
testId: `${testId || "popover"}-close-btn`
|
|
541
485
|
}), children);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
}(React.Component);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
545
488
|
PopoverContentCore.defaultProps = {
|
|
546
489
|
color: "white",
|
|
547
490
|
closeButtonLight: false,
|
|
@@ -576,17 +519,15 @@ const styles$1 = StyleSheet.create({
|
|
|
576
519
|
});
|
|
577
520
|
|
|
578
521
|
const StyledImage = addStyle("img");
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
584
|
-
_this.maybeRenderImage = ({
|
|
522
|
+
class PopoverContent extends React.Component {
|
|
523
|
+
constructor(...args) {
|
|
524
|
+
super(...args);
|
|
525
|
+
this.maybeRenderImage = ({
|
|
585
526
|
placement
|
|
586
527
|
}) => {
|
|
587
528
|
const {
|
|
588
529
|
image
|
|
589
|
-
} =
|
|
530
|
+
} = this.props;
|
|
590
531
|
if (!image) {
|
|
591
532
|
return null;
|
|
592
533
|
}
|
|
@@ -594,10 +535,10 @@ let PopoverContent = function (_React$Component) {
|
|
|
594
535
|
style: [styles.image, placement === "bottom" && styles.imageToBottom]
|
|
595
536
|
}, image);
|
|
596
537
|
};
|
|
597
|
-
|
|
538
|
+
this.maybeRenderIcon = () => {
|
|
598
539
|
const {
|
|
599
540
|
icon
|
|
600
|
-
} =
|
|
541
|
+
} = this.props;
|
|
601
542
|
if (!icon) {
|
|
602
543
|
return null;
|
|
603
544
|
}
|
|
@@ -608,10 +549,10 @@ let PopoverContent = function (_React$Component) {
|
|
|
608
549
|
style: styles.icon
|
|
609
550
|
}));
|
|
610
551
|
};
|
|
611
|
-
|
|
552
|
+
this.maybeRenderActions = close => {
|
|
612
553
|
const {
|
|
613
554
|
actions
|
|
614
|
-
} =
|
|
555
|
+
} = this.props;
|
|
615
556
|
if (!actions) {
|
|
616
557
|
return null;
|
|
617
558
|
}
|
|
@@ -621,10 +562,8 @@ let PopoverContent = function (_React$Component) {
|
|
|
621
562
|
close: close
|
|
622
563
|
}) : actions);
|
|
623
564
|
};
|
|
624
|
-
return _this;
|
|
625
565
|
}
|
|
626
|
-
|
|
627
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
566
|
+
componentDidMount() {
|
|
628
567
|
const {
|
|
629
568
|
icon,
|
|
630
569
|
image
|
|
@@ -632,15 +571,15 @@ let PopoverContent = function (_React$Component) {
|
|
|
632
571
|
if (image && icon) {
|
|
633
572
|
throw new Error("'image' and 'icon' cannot be used at the same time. You can fix this by either removing 'image' or 'icon' from your instance.");
|
|
634
573
|
}
|
|
635
|
-
}
|
|
636
|
-
|
|
574
|
+
}
|
|
575
|
+
validateProps({
|
|
637
576
|
placement
|
|
638
577
|
}) {
|
|
639
578
|
if (this.props.image && (placement === "left" || placement === "right")) {
|
|
640
579
|
throw new Error("'image' can only be vertically placed. You can fix this by either changing `placement` to `top` or `bottom` or removing the `image` prop inside `content`.");
|
|
641
580
|
}
|
|
642
|
-
}
|
|
643
|
-
|
|
581
|
+
}
|
|
582
|
+
render() {
|
|
644
583
|
const {
|
|
645
584
|
closeButtonLabel,
|
|
646
585
|
closeButtonVisible,
|
|
@@ -677,9 +616,8 @@ let PopoverContent = function (_React$Component) {
|
|
|
677
616
|
style: styles.title
|
|
678
617
|
}, title), React.createElement(Body, null, content))), this.maybeRenderActions(close));
|
|
679
618
|
});
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
}(React.Component);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
683
621
|
PopoverContent.defaultProps = {
|
|
684
622
|
closeButtonVisible: false
|
|
685
623
|
};
|