@khanacademy/wonder-blocks-tooltip 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 +19 -0
- package/dist/components/tooltip-anchor.js.flow +1 -2
- package/dist/components/tooltip-bubble.js.flow +1 -2
- package/dist/components/tooltip-content.js.flow +1 -2
- package/dist/components/tooltip-popper.js.flow +1 -2
- package/dist/components/tooltip-tail.js.flow +1 -2
- package/dist/components/tooltip.js.flow +1 -2
- package/dist/es/index.js +157 -203
- package/dist/index.js +170 -216
- package/dist/index.js.flow +1 -2
- package/dist/util/active-tracker.js.flow +1 -2
- package/dist/util/constants.js.flow +1 -2
- package/dist/util/ref-tracker.js.flow +1 -2
- package/dist/util/types.js.flow +1 -2
- package/package.json +6 -6
package/dist/es/index.js
CHANGED
|
@@ -2,37 +2,22 @@ import * as React from 'react';
|
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
3
|
import { Text as Text$1, View, UniqueIDProvider } from '@khanacademy/wonder-blocks-core';
|
|
4
4
|
import { maybeGetPortalMountedModalHostElement } from '@khanacademy/wonder-blocks-modal';
|
|
5
|
-
import {
|
|
5
|
+
import { StyleSheet, css } from 'aphrodite';
|
|
6
6
|
import Colors from '@khanacademy/wonder-blocks-color';
|
|
7
7
|
import Spacing from '@khanacademy/wonder-blocks-spacing';
|
|
8
8
|
import { Strut } from '@khanacademy/wonder-blocks-layout';
|
|
9
9
|
import { HeadingSmall, LabelMedium } from '@khanacademy/wonder-blocks-typography';
|
|
10
10
|
import { Popper } from 'react-popper';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
o.__proto__ = p;
|
|
15
|
-
return o;
|
|
16
|
-
};
|
|
17
|
-
return _setPrototypeOf(o, p);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _inheritsLoose(subClass, superClass) {
|
|
21
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
22
|
-
subClass.prototype.constructor = subClass;
|
|
23
|
-
_setPrototypeOf(subClass, superClass);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let ActiveTracker = function () {
|
|
27
|
-
function ActiveTracker() {
|
|
12
|
+
class ActiveTracker {
|
|
13
|
+
constructor() {
|
|
28
14
|
this._subscribers = [];
|
|
29
15
|
this._active = void 0;
|
|
30
16
|
}
|
|
31
|
-
|
|
32
|
-
_proto._getIndex = function _getIndex(who) {
|
|
17
|
+
_getIndex(who) {
|
|
33
18
|
return this._subscribers.findIndex(v => v === who);
|
|
34
|
-
}
|
|
35
|
-
|
|
19
|
+
}
|
|
20
|
+
steal(who) {
|
|
36
21
|
const wasActive = !!this._active;
|
|
37
22
|
this._active = true;
|
|
38
23
|
for (const anchor of this._subscribers) {
|
|
@@ -42,11 +27,11 @@ let ActiveTracker = function () {
|
|
|
42
27
|
anchor.activeStateStolen();
|
|
43
28
|
}
|
|
44
29
|
return wasActive;
|
|
45
|
-
}
|
|
46
|
-
|
|
30
|
+
}
|
|
31
|
+
giveup() {
|
|
47
32
|
this._active = false;
|
|
48
|
-
}
|
|
49
|
-
|
|
33
|
+
}
|
|
34
|
+
subscribe(who) {
|
|
50
35
|
if (this._getIndex(who) >= 0) {
|
|
51
36
|
throw new Error("Already subscribed.");
|
|
52
37
|
}
|
|
@@ -56,59 +41,54 @@ let ActiveTracker = function () {
|
|
|
56
41
|
this._subscribers.splice(index, 1);
|
|
57
42
|
};
|
|
58
43
|
return unsubscribe;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
62
46
|
|
|
63
47
|
const TooltipAppearanceDelay = 100;
|
|
64
48
|
const TooltipDisappearanceDelay = 75;
|
|
65
49
|
|
|
66
50
|
const TRACKER = new ActiveTracker();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
_this._focused = false;
|
|
82
|
-
_this._setActiveState(false, true);
|
|
51
|
+
class TooltipAnchor extends React.Component {
|
|
52
|
+
constructor(props) {
|
|
53
|
+
super(props);
|
|
54
|
+
this._weSetFocusivity = void 0;
|
|
55
|
+
this._anchorNode = void 0;
|
|
56
|
+
this._focused = void 0;
|
|
57
|
+
this._hovered = void 0;
|
|
58
|
+
this._stolenFromUs = void 0;
|
|
59
|
+
this._unsubscribeFromTracker = void 0;
|
|
60
|
+
this._timeoutID = void 0;
|
|
61
|
+
this.activeStateStolen = () => {
|
|
62
|
+
this._stolenFromUs = this.state.active || !!this._timeoutID;
|
|
63
|
+
this._focused = false;
|
|
64
|
+
this._setActiveState(false, true);
|
|
83
65
|
};
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
this._handleFocusIn = () => {
|
|
67
|
+
this._updateActiveState(this._hovered, true);
|
|
86
68
|
};
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
this._handleFocusOut = () => {
|
|
70
|
+
this._updateActiveState(this._hovered, false);
|
|
89
71
|
};
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
this._handleMouseEnter = () => {
|
|
73
|
+
this._updateActiveState(true, this._focused);
|
|
92
74
|
};
|
|
93
|
-
|
|
94
|
-
|
|
75
|
+
this._handleMouseLeave = () => {
|
|
76
|
+
this._updateActiveState(false, this._focused);
|
|
95
77
|
};
|
|
96
|
-
|
|
97
|
-
if (e.key === "Escape" &&
|
|
78
|
+
this._handleKeyUp = e => {
|
|
79
|
+
if (e.key === "Escape" && this.state.active) {
|
|
98
80
|
e.preventDefault();
|
|
99
81
|
e.stopPropagation();
|
|
100
|
-
|
|
82
|
+
this._updateActiveState(false, false);
|
|
101
83
|
}
|
|
102
84
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
this._focused = false;
|
|
86
|
+
this._hovered = false;
|
|
87
|
+
this.state = {
|
|
106
88
|
active: false
|
|
107
89
|
};
|
|
108
|
-
return _this;
|
|
109
90
|
}
|
|
110
|
-
|
|
111
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
91
|
+
componentDidMount() {
|
|
112
92
|
const anchorNode = ReactDOM.findDOMNode(this);
|
|
113
93
|
if (anchorNode instanceof Text) {
|
|
114
94
|
throw new Error("TooltipAnchor must be applied to an Element. Text content is not supported.");
|
|
@@ -123,13 +103,13 @@ let TooltipAnchor = function (_ref) {
|
|
|
123
103
|
anchorNode.addEventListener("mouseleave", this._handleMouseLeave);
|
|
124
104
|
this.props.anchorRef(this._anchorNode);
|
|
125
105
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
106
|
+
}
|
|
107
|
+
componentDidUpdate(prevProps) {
|
|
128
108
|
if (prevProps.forceAnchorFocusivity !== this.props.forceAnchorFocusivity || prevProps.children !== this.props.children) {
|
|
129
109
|
this._updateFocusivity();
|
|
130
110
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
111
|
+
}
|
|
112
|
+
componentWillUnmount() {
|
|
133
113
|
if (this._unsubscribeFromTracker) {
|
|
134
114
|
this._unsubscribeFromTracker();
|
|
135
115
|
}
|
|
@@ -144,8 +124,8 @@ let TooltipAnchor = function (_ref) {
|
|
|
144
124
|
if (this.state.active) {
|
|
145
125
|
document.removeEventListener("keyup", this._handleKeyUp);
|
|
146
126
|
}
|
|
147
|
-
}
|
|
148
|
-
|
|
127
|
+
}
|
|
128
|
+
_updateFocusivity() {
|
|
149
129
|
const anchorNode = this._anchorNode;
|
|
150
130
|
if (!anchorNode) {
|
|
151
131
|
return;
|
|
@@ -163,19 +143,19 @@ let TooltipAnchor = function (_ref) {
|
|
|
163
143
|
this._weSetFocusivity = false;
|
|
164
144
|
}
|
|
165
145
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
146
|
+
}
|
|
147
|
+
_updateActiveState(hovered, focused) {
|
|
168
148
|
this._hovered = hovered;
|
|
169
149
|
this._focused = focused;
|
|
170
150
|
this._setActiveState(hovered || focused);
|
|
171
|
-
}
|
|
172
|
-
|
|
151
|
+
}
|
|
152
|
+
_clearPendingAction() {
|
|
173
153
|
if (this._timeoutID) {
|
|
174
154
|
clearTimeout(this._timeoutID);
|
|
175
155
|
this._timeoutID = null;
|
|
176
156
|
}
|
|
177
|
-
}
|
|
178
|
-
|
|
157
|
+
}
|
|
158
|
+
_setActiveState(active, instant) {
|
|
179
159
|
if (this._stolenFromUs || active !== this.state.active || !this.state.active && this._timeoutID) {
|
|
180
160
|
this._clearPendingAction();
|
|
181
161
|
} else if (active === this.state.active && !this._timeoutID) {
|
|
@@ -203,27 +183,26 @@ let TooltipAnchor = function (_ref) {
|
|
|
203
183
|
this._setActiveState(active, true);
|
|
204
184
|
}, delay);
|
|
205
185
|
}
|
|
206
|
-
}
|
|
207
|
-
|
|
186
|
+
}
|
|
187
|
+
_renderAnchorableChildren() {
|
|
208
188
|
const {
|
|
209
189
|
children
|
|
210
190
|
} = this.props;
|
|
211
191
|
return typeof children === "string" ? React.createElement(Text$1, null, children) : children;
|
|
212
|
-
}
|
|
213
|
-
|
|
192
|
+
}
|
|
193
|
+
_renderAccessibleChildren(ids) {
|
|
214
194
|
const anchorableChildren = this._renderAnchorableChildren();
|
|
215
195
|
return React.cloneElement(anchorableChildren, {
|
|
216
196
|
"aria-describedby": ids.get(TooltipAnchor.ariaContentId)
|
|
217
197
|
});
|
|
218
|
-
}
|
|
219
|
-
|
|
198
|
+
}
|
|
199
|
+
render() {
|
|
220
200
|
if (this.props.ids) {
|
|
221
201
|
return this._renderAccessibleChildren(this.props.ids);
|
|
222
202
|
}
|
|
223
203
|
return this._renderAnchorableChildren();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
}(React.Component);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
227
206
|
TooltipAnchor.defaultProps = {
|
|
228
207
|
forceAnchorFocusivity: true
|
|
229
208
|
};
|
|
@@ -245,13 +224,8 @@ function _extends() {
|
|
|
245
224
|
}
|
|
246
225
|
|
|
247
226
|
let tempIdCounter = 0;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
function TooltipTail() {
|
|
251
|
-
return _React$Component.apply(this, arguments) || this;
|
|
252
|
-
}
|
|
253
|
-
var _proto = TooltipTail.prototype;
|
|
254
|
-
_proto._calculateDimensionsFromPlacement = function _calculateDimensionsFromPlacement() {
|
|
227
|
+
class TooltipTail extends React.Component {
|
|
228
|
+
_calculateDimensionsFromPlacement() {
|
|
255
229
|
const {
|
|
256
230
|
placement
|
|
257
231
|
} = this.props;
|
|
@@ -288,8 +262,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
288
262
|
default:
|
|
289
263
|
throw new Error(`Unknown placement: ${placement}`);
|
|
290
264
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
265
|
+
}
|
|
266
|
+
_getFilterPositioning() {
|
|
293
267
|
const {
|
|
294
268
|
placement
|
|
295
269
|
} = this.props;
|
|
@@ -317,8 +291,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
317
291
|
default:
|
|
318
292
|
throw new Error(`Unknown placement: ${placement}`);
|
|
319
293
|
}
|
|
320
|
-
}
|
|
321
|
-
|
|
294
|
+
}
|
|
295
|
+
_maybeRenderDropshadow(points) {
|
|
322
296
|
const position = this._getFilterPositioning();
|
|
323
297
|
if (!position) {
|
|
324
298
|
return null;
|
|
@@ -354,14 +328,14 @@ let TooltipTail = function (_React$Component) {
|
|
|
354
328
|
stroke: Colors.offBlack32,
|
|
355
329
|
filter: `url(#${dropShadowFilterId})`
|
|
356
330
|
}))];
|
|
357
|
-
}
|
|
358
|
-
|
|
331
|
+
}
|
|
332
|
+
_getFullTailWidth() {
|
|
359
333
|
return ARROW_WIDTH + 2 * MIN_DISTANCE_FROM_CORNERS;
|
|
360
|
-
}
|
|
361
|
-
|
|
334
|
+
}
|
|
335
|
+
_getFullTailHeight() {
|
|
362
336
|
return ARROW_HEIGHT + DISTANCE_FROM_ANCHOR;
|
|
363
|
-
}
|
|
364
|
-
|
|
337
|
+
}
|
|
338
|
+
_getContainerStyle() {
|
|
365
339
|
const {
|
|
366
340
|
placement
|
|
367
341
|
} = this.props;
|
|
@@ -395,8 +369,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
395
369
|
default:
|
|
396
370
|
throw new Error(`Unknown placement: ${placement}`);
|
|
397
371
|
}
|
|
398
|
-
}
|
|
399
|
-
|
|
372
|
+
}
|
|
373
|
+
_getArrowStyle() {
|
|
400
374
|
const {
|
|
401
375
|
placement
|
|
402
376
|
} = this.props;
|
|
@@ -428,8 +402,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
428
402
|
default:
|
|
429
403
|
throw new Error(`Unknown placement: ${placement}`);
|
|
430
404
|
}
|
|
431
|
-
}
|
|
432
|
-
|
|
405
|
+
}
|
|
406
|
+
_renderArrow() {
|
|
433
407
|
const {
|
|
434
408
|
trimlinePoints,
|
|
435
409
|
points,
|
|
@@ -457,8 +431,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
457
431
|
stroke: Colors[color],
|
|
458
432
|
points: trimlinePoints.join(" ")
|
|
459
433
|
}));
|
|
460
|
-
}
|
|
461
|
-
|
|
434
|
+
}
|
|
435
|
+
render() {
|
|
462
436
|
const {
|
|
463
437
|
offset,
|
|
464
438
|
placement,
|
|
@@ -469,9 +443,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
469
443
|
"data-placement": placement,
|
|
470
444
|
ref: updateRef
|
|
471
445
|
}, this._renderArrow());
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
}(React.Component);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
475
448
|
TooltipTail.defaultProps = {
|
|
476
449
|
color: "white"
|
|
477
450
|
};
|
|
@@ -489,30 +462,26 @@ const styles$2 = StyleSheet.create({
|
|
|
489
462
|
}
|
|
490
463
|
});
|
|
491
464
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
497
|
-
_this.state = {
|
|
465
|
+
class TooltipBubble extends React.Component {
|
|
466
|
+
constructor(...args) {
|
|
467
|
+
super(...args);
|
|
468
|
+
this.state = {
|
|
498
469
|
active: false
|
|
499
470
|
};
|
|
500
|
-
|
|
501
|
-
|
|
471
|
+
this.handleMouseEnter = () => {
|
|
472
|
+
this._setActiveState(true);
|
|
502
473
|
};
|
|
503
|
-
|
|
504
|
-
|
|
474
|
+
this.handleMouseLeave = () => {
|
|
475
|
+
this.props.onActiveChanged(false);
|
|
505
476
|
};
|
|
506
|
-
return _this;
|
|
507
477
|
}
|
|
508
|
-
|
|
509
|
-
_proto._setActiveState = function _setActiveState(active) {
|
|
478
|
+
_setActiveState(active) {
|
|
510
479
|
this.setState({
|
|
511
480
|
active
|
|
512
481
|
});
|
|
513
482
|
this.props.onActiveChanged(active);
|
|
514
|
-
}
|
|
515
|
-
|
|
483
|
+
}
|
|
484
|
+
render() {
|
|
516
485
|
const {
|
|
517
486
|
id,
|
|
518
487
|
children,
|
|
@@ -538,9 +507,8 @@ let TooltipBubble = function (_React$Component) {
|
|
|
538
507
|
placement: placement,
|
|
539
508
|
offset: tailOffset
|
|
540
509
|
}));
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
}(React.Component);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
544
512
|
const styles$1 = StyleSheet.create({
|
|
545
513
|
bubble: {
|
|
546
514
|
position: "absolute"
|
|
@@ -573,13 +541,8 @@ const styles$1 = StyleSheet.create({
|
|
|
573
541
|
}
|
|
574
542
|
});
|
|
575
543
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
function TooltipContent() {
|
|
579
|
-
return _React$Component.apply(this, arguments) || this;
|
|
580
|
-
}
|
|
581
|
-
var _proto = TooltipContent.prototype;
|
|
582
|
-
_proto._renderTitle = function _renderTitle() {
|
|
544
|
+
class TooltipContent extends React.Component {
|
|
545
|
+
_renderTitle() {
|
|
583
546
|
const {
|
|
584
547
|
title
|
|
585
548
|
} = this.props;
|
|
@@ -591,8 +554,8 @@ let TooltipContent = function (_React$Component) {
|
|
|
591
554
|
}
|
|
592
555
|
}
|
|
593
556
|
return null;
|
|
594
|
-
}
|
|
595
|
-
|
|
557
|
+
}
|
|
558
|
+
_renderChildren() {
|
|
596
559
|
const {
|
|
597
560
|
children
|
|
598
561
|
} = this.props;
|
|
@@ -601,8 +564,8 @@ let TooltipContent = function (_React$Component) {
|
|
|
601
564
|
} else {
|
|
602
565
|
return children;
|
|
603
566
|
}
|
|
604
|
-
}
|
|
605
|
-
|
|
567
|
+
}
|
|
568
|
+
render() {
|
|
606
569
|
const title = this._renderTitle();
|
|
607
570
|
const children = this._renderChildren();
|
|
608
571
|
const containerStyle = title ? styles.withTitle : styles.withoutTitle;
|
|
@@ -611,9 +574,8 @@ let TooltipContent = function (_React$Component) {
|
|
|
611
574
|
}, title, title && children && React.createElement(Strut, {
|
|
612
575
|
size: Spacing.xxxSmall_4
|
|
613
576
|
}), children);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
}(React.Component);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
617
579
|
const styles = StyleSheet.create({
|
|
618
580
|
withoutTitle: {
|
|
619
581
|
padding: `10px ${Spacing.medium_16}px`
|
|
@@ -623,43 +585,41 @@ const styles = StyleSheet.create({
|
|
|
623
585
|
}
|
|
624
586
|
});
|
|
625
587
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
};
|
|
639
|
-
this.setCallback = targetFn => {
|
|
640
|
-
if (this._targetFn !== targetFn) {
|
|
641
|
-
if (targetFn && typeof targetFn !== "function") {
|
|
642
|
-
throw new Error("targetFn must be a function");
|
|
588
|
+
class RefTracker {
|
|
589
|
+
constructor() {
|
|
590
|
+
this._lastRef = void 0;
|
|
591
|
+
this._targetFn = void 0;
|
|
592
|
+
this.updateRef = ref => {
|
|
593
|
+
if (ref) {
|
|
594
|
+
const domNode = ReactDOM.findDOMNode(ref);
|
|
595
|
+
if (domNode instanceof HTMLElement && domNode !== this._lastRef) {
|
|
596
|
+
var _this$_targetFn;
|
|
597
|
+
this._lastRef = domNode;
|
|
598
|
+
(_this$_targetFn = this._targetFn) == null ? void 0 : _this$_targetFn.call(this, domNode);
|
|
599
|
+
}
|
|
643
600
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
601
|
+
};
|
|
602
|
+
this.setCallback = targetFn => {
|
|
603
|
+
if (this._targetFn !== targetFn) {
|
|
604
|
+
if (targetFn && typeof targetFn !== "function") {
|
|
605
|
+
throw new Error("targetFn must be a function");
|
|
606
|
+
}
|
|
607
|
+
this._targetFn = targetFn || null;
|
|
608
|
+
if (this._lastRef && this._targetFn) {
|
|
609
|
+
this._targetFn(this._lastRef);
|
|
610
|
+
}
|
|
647
611
|
}
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
}
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
}
|
|
651
615
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
return _this;
|
|
660
|
-
}
|
|
661
|
-
var _proto = TooltipPopper.prototype;
|
|
662
|
-
_proto._renderPositionedContent = function _renderPositionedContent(popperProps) {
|
|
616
|
+
class TooltipPopper extends React.Component {
|
|
617
|
+
constructor(...args) {
|
|
618
|
+
super(...args);
|
|
619
|
+
this._bubbleRefTracker = new RefTracker();
|
|
620
|
+
this._tailRefTracker = new RefTracker();
|
|
621
|
+
}
|
|
622
|
+
_renderPositionedContent(popperProps) {
|
|
663
623
|
const {
|
|
664
624
|
children
|
|
665
625
|
} = this.props;
|
|
@@ -688,8 +648,8 @@ let TooltipPopper = function (_React$Component) {
|
|
|
688
648
|
isReferenceHidden: popperProps.isReferenceHidden
|
|
689
649
|
};
|
|
690
650
|
return children(bubbleProps);
|
|
691
|
-
}
|
|
692
|
-
|
|
651
|
+
}
|
|
652
|
+
render() {
|
|
693
653
|
const {
|
|
694
654
|
anchorElement,
|
|
695
655
|
placement
|
|
@@ -705,36 +665,31 @@ let TooltipPopper = function (_React$Component) {
|
|
|
705
665
|
}
|
|
706
666
|
}]
|
|
707
667
|
}, props => this._renderPositionedContent(props));
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
}(React.Component);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
711
670
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
717
|
-
_this.state = {
|
|
671
|
+
class Tooltip extends React.Component {
|
|
672
|
+
constructor(...args) {
|
|
673
|
+
super(...args);
|
|
674
|
+
this.state = {
|
|
718
675
|
active: false,
|
|
719
676
|
activeBubble: false,
|
|
720
677
|
anchorElement: null
|
|
721
678
|
};
|
|
722
|
-
return _this;
|
|
723
679
|
}
|
|
724
|
-
|
|
680
|
+
static getDerivedStateFromProps(props, state) {
|
|
725
681
|
return {
|
|
726
682
|
active: typeof props.opened === "boolean" ? props.opened : state.active
|
|
727
683
|
};
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
_proto._updateAnchorElement = function _updateAnchorElement(ref) {
|
|
684
|
+
}
|
|
685
|
+
_updateAnchorElement(ref) {
|
|
731
686
|
if (ref && ref !== this.state.anchorElement) {
|
|
732
687
|
this.setState({
|
|
733
688
|
anchorElement: ref
|
|
734
689
|
});
|
|
735
690
|
}
|
|
736
|
-
}
|
|
737
|
-
|
|
691
|
+
}
|
|
692
|
+
_renderBubbleContent() {
|
|
738
693
|
const {
|
|
739
694
|
title,
|
|
740
695
|
content
|
|
@@ -750,8 +705,8 @@ let Tooltip = function (_React$Component) {
|
|
|
750
705
|
} else {
|
|
751
706
|
return content;
|
|
752
707
|
}
|
|
753
|
-
}
|
|
754
|
-
|
|
708
|
+
}
|
|
709
|
+
_renderPopper(ids) {
|
|
755
710
|
const {
|
|
756
711
|
id
|
|
757
712
|
} = this.props;
|
|
@@ -777,14 +732,14 @@ let Tooltip = function (_React$Component) {
|
|
|
777
732
|
activeBubble: active
|
|
778
733
|
})
|
|
779
734
|
}, this._renderBubbleContent()));
|
|
780
|
-
}
|
|
781
|
-
|
|
735
|
+
}
|
|
736
|
+
_getHost() {
|
|
782
737
|
const {
|
|
783
738
|
anchorElement
|
|
784
739
|
} = this.state;
|
|
785
740
|
return maybeGetPortalMountedModalHostElement(anchorElement) || document.body;
|
|
786
|
-
}
|
|
787
|
-
|
|
741
|
+
}
|
|
742
|
+
_renderTooltipAnchor(ids) {
|
|
788
743
|
const {
|
|
789
744
|
children,
|
|
790
745
|
forceAnchorFocusivity
|
|
@@ -802,8 +757,8 @@ let Tooltip = function (_React$Component) {
|
|
|
802
757
|
}),
|
|
803
758
|
ids: ids
|
|
804
759
|
}, children), popperHost && (active || activeBubble) && ReactDOM.createPortal(this._renderPopper(ids), popperHost));
|
|
805
|
-
}
|
|
806
|
-
|
|
760
|
+
}
|
|
761
|
+
render() {
|
|
807
762
|
const {
|
|
808
763
|
id
|
|
809
764
|
} = this.props;
|
|
@@ -815,9 +770,8 @@ let Tooltip = function (_React$Component) {
|
|
|
815
770
|
mockOnFirstRender: true
|
|
816
771
|
}, ids => this._renderTooltipAnchor(ids));
|
|
817
772
|
}
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
}(React.Component);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
821
775
|
Tooltip.defaultProps = {
|
|
822
776
|
forceAnchorFocusivity: true,
|
|
823
777
|
placement: "top"
|