@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/index.js
CHANGED
|
@@ -16,21 +16,21 @@ var reactPopper = require('react-popper');
|
|
|
16
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
17
|
|
|
18
18
|
function _interopNamespace(e) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
if (e && e.__esModule) return e;
|
|
20
|
+
var n = Object.create(null);
|
|
21
|
+
if (e) {
|
|
22
|
+
Object.keys(e).forEach(function (k) {
|
|
23
|
+
if (k !== 'default') {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return e[k]; }
|
|
28
|
+
});
|
|
29
|
+
}
|
|
28
30
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
n["default"] = e;
|
|
33
|
-
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
n["default"] = e;
|
|
33
|
+
return Object.freeze(n);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
@@ -38,30 +38,15 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
|
38
38
|
var Colors__default = /*#__PURE__*/_interopDefaultLegacy(Colors);
|
|
39
39
|
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
o.__proto__ = p;
|
|
44
|
-
return o;
|
|
45
|
-
};
|
|
46
|
-
return _setPrototypeOf(o, p);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function _inheritsLoose(subClass, superClass) {
|
|
50
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
51
|
-
subClass.prototype.constructor = subClass;
|
|
52
|
-
_setPrototypeOf(subClass, superClass);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let ActiveTracker = function () {
|
|
56
|
-
function ActiveTracker() {
|
|
41
|
+
class ActiveTracker {
|
|
42
|
+
constructor() {
|
|
57
43
|
this._subscribers = [];
|
|
58
44
|
this._active = void 0;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
|
-
_proto._getIndex = function _getIndex(who) {
|
|
46
|
+
_getIndex(who) {
|
|
62
47
|
return this._subscribers.findIndex(v => v === who);
|
|
63
|
-
}
|
|
64
|
-
|
|
48
|
+
}
|
|
49
|
+
steal(who) {
|
|
65
50
|
const wasActive = !!this._active;
|
|
66
51
|
this._active = true;
|
|
67
52
|
for (const anchor of this._subscribers) {
|
|
@@ -71,11 +56,11 @@ let ActiveTracker = function () {
|
|
|
71
56
|
anchor.activeStateStolen();
|
|
72
57
|
}
|
|
73
58
|
return wasActive;
|
|
74
|
-
}
|
|
75
|
-
|
|
59
|
+
}
|
|
60
|
+
giveup() {
|
|
76
61
|
this._active = false;
|
|
77
|
-
}
|
|
78
|
-
|
|
62
|
+
}
|
|
63
|
+
subscribe(who) {
|
|
79
64
|
if (this._getIndex(who) >= 0) {
|
|
80
65
|
throw new Error("Already subscribed.");
|
|
81
66
|
}
|
|
@@ -85,59 +70,54 @@ let ActiveTracker = function () {
|
|
|
85
70
|
this._subscribers.splice(index, 1);
|
|
86
71
|
};
|
|
87
72
|
return unsubscribe;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
91
75
|
|
|
92
76
|
const TooltipAppearanceDelay = 100;
|
|
93
77
|
const TooltipDisappearanceDelay = 75;
|
|
94
78
|
|
|
95
79
|
const TRACKER = new ActiveTracker();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_this._focused = false;
|
|
111
|
-
_this._setActiveState(false, true);
|
|
80
|
+
class TooltipAnchor extends React__namespace.Component {
|
|
81
|
+
constructor(props) {
|
|
82
|
+
super(props);
|
|
83
|
+
this._weSetFocusivity = void 0;
|
|
84
|
+
this._anchorNode = void 0;
|
|
85
|
+
this._focused = void 0;
|
|
86
|
+
this._hovered = void 0;
|
|
87
|
+
this._stolenFromUs = void 0;
|
|
88
|
+
this._unsubscribeFromTracker = void 0;
|
|
89
|
+
this._timeoutID = void 0;
|
|
90
|
+
this.activeStateStolen = () => {
|
|
91
|
+
this._stolenFromUs = this.state.active || !!this._timeoutID;
|
|
92
|
+
this._focused = false;
|
|
93
|
+
this._setActiveState(false, true);
|
|
112
94
|
};
|
|
113
|
-
|
|
114
|
-
|
|
95
|
+
this._handleFocusIn = () => {
|
|
96
|
+
this._updateActiveState(this._hovered, true);
|
|
115
97
|
};
|
|
116
|
-
|
|
117
|
-
|
|
98
|
+
this._handleFocusOut = () => {
|
|
99
|
+
this._updateActiveState(this._hovered, false);
|
|
118
100
|
};
|
|
119
|
-
|
|
120
|
-
|
|
101
|
+
this._handleMouseEnter = () => {
|
|
102
|
+
this._updateActiveState(true, this._focused);
|
|
121
103
|
};
|
|
122
|
-
|
|
123
|
-
|
|
104
|
+
this._handleMouseLeave = () => {
|
|
105
|
+
this._updateActiveState(false, this._focused);
|
|
124
106
|
};
|
|
125
|
-
|
|
126
|
-
if (e.key === "Escape" &&
|
|
107
|
+
this._handleKeyUp = e => {
|
|
108
|
+
if (e.key === "Escape" && this.state.active) {
|
|
127
109
|
e.preventDefault();
|
|
128
110
|
e.stopPropagation();
|
|
129
|
-
|
|
111
|
+
this._updateActiveState(false, false);
|
|
130
112
|
}
|
|
131
113
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
114
|
+
this._focused = false;
|
|
115
|
+
this._hovered = false;
|
|
116
|
+
this.state = {
|
|
135
117
|
active: false
|
|
136
118
|
};
|
|
137
|
-
return _this;
|
|
138
119
|
}
|
|
139
|
-
|
|
140
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
120
|
+
componentDidMount() {
|
|
141
121
|
const anchorNode = ReactDOM__namespace.findDOMNode(this);
|
|
142
122
|
if (anchorNode instanceof Text) {
|
|
143
123
|
throw new Error("TooltipAnchor must be applied to an Element. Text content is not supported.");
|
|
@@ -152,13 +132,13 @@ let TooltipAnchor = function (_ref) {
|
|
|
152
132
|
anchorNode.addEventListener("mouseleave", this._handleMouseLeave);
|
|
153
133
|
this.props.anchorRef(this._anchorNode);
|
|
154
134
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
135
|
+
}
|
|
136
|
+
componentDidUpdate(prevProps) {
|
|
157
137
|
if (prevProps.forceAnchorFocusivity !== this.props.forceAnchorFocusivity || prevProps.children !== this.props.children) {
|
|
158
138
|
this._updateFocusivity();
|
|
159
139
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
140
|
+
}
|
|
141
|
+
componentWillUnmount() {
|
|
162
142
|
if (this._unsubscribeFromTracker) {
|
|
163
143
|
this._unsubscribeFromTracker();
|
|
164
144
|
}
|
|
@@ -173,8 +153,8 @@ let TooltipAnchor = function (_ref) {
|
|
|
173
153
|
if (this.state.active) {
|
|
174
154
|
document.removeEventListener("keyup", this._handleKeyUp);
|
|
175
155
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
156
|
+
}
|
|
157
|
+
_updateFocusivity() {
|
|
178
158
|
const anchorNode = this._anchorNode;
|
|
179
159
|
if (!anchorNode) {
|
|
180
160
|
return;
|
|
@@ -192,19 +172,19 @@ let TooltipAnchor = function (_ref) {
|
|
|
192
172
|
this._weSetFocusivity = false;
|
|
193
173
|
}
|
|
194
174
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
175
|
+
}
|
|
176
|
+
_updateActiveState(hovered, focused) {
|
|
197
177
|
this._hovered = hovered;
|
|
198
178
|
this._focused = focused;
|
|
199
179
|
this._setActiveState(hovered || focused);
|
|
200
|
-
}
|
|
201
|
-
|
|
180
|
+
}
|
|
181
|
+
_clearPendingAction() {
|
|
202
182
|
if (this._timeoutID) {
|
|
203
183
|
clearTimeout(this._timeoutID);
|
|
204
184
|
this._timeoutID = null;
|
|
205
185
|
}
|
|
206
|
-
}
|
|
207
|
-
|
|
186
|
+
}
|
|
187
|
+
_setActiveState(active, instant) {
|
|
208
188
|
if (this._stolenFromUs || active !== this.state.active || !this.state.active && this._timeoutID) {
|
|
209
189
|
this._clearPendingAction();
|
|
210
190
|
} else if (active === this.state.active && !this._timeoutID) {
|
|
@@ -232,27 +212,26 @@ let TooltipAnchor = function (_ref) {
|
|
|
232
212
|
this._setActiveState(active, true);
|
|
233
213
|
}, delay);
|
|
234
214
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
215
|
+
}
|
|
216
|
+
_renderAnchorableChildren() {
|
|
237
217
|
const {
|
|
238
218
|
children
|
|
239
219
|
} = this.props;
|
|
240
220
|
return typeof children === "string" ? React__namespace.createElement(wonderBlocksCore.Text, null, children) : children;
|
|
241
|
-
}
|
|
242
|
-
|
|
221
|
+
}
|
|
222
|
+
_renderAccessibleChildren(ids) {
|
|
243
223
|
const anchorableChildren = this._renderAnchorableChildren();
|
|
244
224
|
return React__namespace.cloneElement(anchorableChildren, {
|
|
245
225
|
"aria-describedby": ids.get(TooltipAnchor.ariaContentId)
|
|
246
226
|
});
|
|
247
|
-
}
|
|
248
|
-
|
|
227
|
+
}
|
|
228
|
+
render() {
|
|
249
229
|
if (this.props.ids) {
|
|
250
230
|
return this._renderAccessibleChildren(this.props.ids);
|
|
251
231
|
}
|
|
252
232
|
return this._renderAnchorableChildren();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
}(React__namespace.Component);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
256
235
|
TooltipAnchor.defaultProps = {
|
|
257
236
|
forceAnchorFocusivity: true
|
|
258
237
|
};
|
|
@@ -274,13 +253,8 @@ function _extends() {
|
|
|
274
253
|
}
|
|
275
254
|
|
|
276
255
|
let tempIdCounter = 0;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
function TooltipTail() {
|
|
280
|
-
return _React$Component.apply(this, arguments) || this;
|
|
281
|
-
}
|
|
282
|
-
var _proto = TooltipTail.prototype;
|
|
283
|
-
_proto._calculateDimensionsFromPlacement = function _calculateDimensionsFromPlacement() {
|
|
256
|
+
class TooltipTail extends React__namespace.Component {
|
|
257
|
+
_calculateDimensionsFromPlacement() {
|
|
284
258
|
const {
|
|
285
259
|
placement
|
|
286
260
|
} = 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
|
+
_getFilterPositioning() {
|
|
322
296
|
const {
|
|
323
297
|
placement
|
|
324
298
|
} = this.props;
|
|
@@ -346,8 +320,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
346
320
|
default:
|
|
347
321
|
throw new Error(`Unknown placement: ${placement}`);
|
|
348
322
|
}
|
|
349
|
-
}
|
|
350
|
-
|
|
323
|
+
}
|
|
324
|
+
_maybeRenderDropshadow(points) {
|
|
351
325
|
const position = this._getFilterPositioning();
|
|
352
326
|
if (!position) {
|
|
353
327
|
return null;
|
|
@@ -383,14 +357,14 @@ let TooltipTail = function (_React$Component) {
|
|
|
383
357
|
stroke: Colors__default["default"].offBlack32,
|
|
384
358
|
filter: `url(#${dropShadowFilterId})`
|
|
385
359
|
}))];
|
|
386
|
-
}
|
|
387
|
-
|
|
360
|
+
}
|
|
361
|
+
_getFullTailWidth() {
|
|
388
362
|
return ARROW_WIDTH + 2 * MIN_DISTANCE_FROM_CORNERS;
|
|
389
|
-
}
|
|
390
|
-
|
|
363
|
+
}
|
|
364
|
+
_getFullTailHeight() {
|
|
391
365
|
return ARROW_HEIGHT + DISTANCE_FROM_ANCHOR;
|
|
392
|
-
}
|
|
393
|
-
|
|
366
|
+
}
|
|
367
|
+
_getContainerStyle() {
|
|
394
368
|
const {
|
|
395
369
|
placement
|
|
396
370
|
} = this.props;
|
|
@@ -424,8 +398,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
424
398
|
default:
|
|
425
399
|
throw new Error(`Unknown placement: ${placement}`);
|
|
426
400
|
}
|
|
427
|
-
}
|
|
428
|
-
|
|
401
|
+
}
|
|
402
|
+
_getArrowStyle() {
|
|
429
403
|
const {
|
|
430
404
|
placement
|
|
431
405
|
} = this.props;
|
|
@@ -457,8 +431,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
457
431
|
default:
|
|
458
432
|
throw new Error(`Unknown placement: ${placement}`);
|
|
459
433
|
}
|
|
460
|
-
}
|
|
461
|
-
|
|
434
|
+
}
|
|
435
|
+
_renderArrow() {
|
|
462
436
|
const {
|
|
463
437
|
trimlinePoints,
|
|
464
438
|
points,
|
|
@@ -486,8 +460,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
486
460
|
stroke: Colors__default["default"][color],
|
|
487
461
|
points: trimlinePoints.join(" ")
|
|
488
462
|
}));
|
|
489
|
-
}
|
|
490
|
-
|
|
463
|
+
}
|
|
464
|
+
render() {
|
|
491
465
|
const {
|
|
492
466
|
offset,
|
|
493
467
|
placement,
|
|
@@ -498,9 +472,8 @@ let TooltipTail = function (_React$Component) {
|
|
|
498
472
|
"data-placement": placement,
|
|
499
473
|
ref: updateRef
|
|
500
474
|
}, this._renderArrow());
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
}(React__namespace.Component);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
504
477
|
TooltipTail.defaultProps = {
|
|
505
478
|
color: "white"
|
|
506
479
|
};
|
|
@@ -518,30 +491,26 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
518
491
|
}
|
|
519
492
|
});
|
|
520
493
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
526
|
-
_this.state = {
|
|
494
|
+
class TooltipBubble extends React__namespace.Component {
|
|
495
|
+
constructor(...args) {
|
|
496
|
+
super(...args);
|
|
497
|
+
this.state = {
|
|
527
498
|
active: false
|
|
528
499
|
};
|
|
529
|
-
|
|
530
|
-
|
|
500
|
+
this.handleMouseEnter = () => {
|
|
501
|
+
this._setActiveState(true);
|
|
531
502
|
};
|
|
532
|
-
|
|
533
|
-
|
|
503
|
+
this.handleMouseLeave = () => {
|
|
504
|
+
this.props.onActiveChanged(false);
|
|
534
505
|
};
|
|
535
|
-
return _this;
|
|
536
506
|
}
|
|
537
|
-
|
|
538
|
-
_proto._setActiveState = function _setActiveState(active) {
|
|
507
|
+
_setActiveState(active) {
|
|
539
508
|
this.setState({
|
|
540
509
|
active
|
|
541
510
|
});
|
|
542
511
|
this.props.onActiveChanged(active);
|
|
543
|
-
}
|
|
544
|
-
|
|
512
|
+
}
|
|
513
|
+
render() {
|
|
545
514
|
const {
|
|
546
515
|
id,
|
|
547
516
|
children,
|
|
@@ -567,9 +536,8 @@ let TooltipBubble = function (_React$Component) {
|
|
|
567
536
|
placement: placement,
|
|
568
537
|
offset: tailOffset
|
|
569
538
|
}));
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
}(React__namespace.Component);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
573
541
|
const styles$1 = aphrodite.StyleSheet.create({
|
|
574
542
|
bubble: {
|
|
575
543
|
position: "absolute"
|
|
@@ -602,13 +570,8 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
602
570
|
}
|
|
603
571
|
});
|
|
604
572
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
function TooltipContent() {
|
|
608
|
-
return _React$Component.apply(this, arguments) || this;
|
|
609
|
-
}
|
|
610
|
-
var _proto = TooltipContent.prototype;
|
|
611
|
-
_proto._renderTitle = function _renderTitle() {
|
|
573
|
+
class TooltipContent extends React__namespace.Component {
|
|
574
|
+
_renderTitle() {
|
|
612
575
|
const {
|
|
613
576
|
title
|
|
614
577
|
} = this.props;
|
|
@@ -620,8 +583,8 @@ let TooltipContent = function (_React$Component) {
|
|
|
620
583
|
}
|
|
621
584
|
}
|
|
622
585
|
return null;
|
|
623
|
-
}
|
|
624
|
-
|
|
586
|
+
}
|
|
587
|
+
_renderChildren() {
|
|
625
588
|
const {
|
|
626
589
|
children
|
|
627
590
|
} = this.props;
|
|
@@ -630,8 +593,8 @@ let TooltipContent = function (_React$Component) {
|
|
|
630
593
|
} else {
|
|
631
594
|
return children;
|
|
632
595
|
}
|
|
633
|
-
}
|
|
634
|
-
|
|
596
|
+
}
|
|
597
|
+
render() {
|
|
635
598
|
const title = this._renderTitle();
|
|
636
599
|
const children = this._renderChildren();
|
|
637
600
|
const containerStyle = title ? styles.withTitle : styles.withoutTitle;
|
|
@@ -640,9 +603,8 @@ let TooltipContent = function (_React$Component) {
|
|
|
640
603
|
}, title, title && children && React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
641
604
|
size: Spacing__default["default"].xxxSmall_4
|
|
642
605
|
}), children);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
}(React__namespace.Component);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
646
608
|
const styles = aphrodite.StyleSheet.create({
|
|
647
609
|
withoutTitle: {
|
|
648
610
|
padding: `10px ${Spacing__default["default"].medium_16}px`
|
|
@@ -652,43 +614,41 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
652
614
|
}
|
|
653
615
|
});
|
|
654
616
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
};
|
|
668
|
-
this.setCallback = targetFn => {
|
|
669
|
-
if (this._targetFn !== targetFn) {
|
|
670
|
-
if (targetFn && typeof targetFn !== "function") {
|
|
671
|
-
throw new Error("targetFn must be a function");
|
|
617
|
+
class RefTracker {
|
|
618
|
+
constructor() {
|
|
619
|
+
this._lastRef = void 0;
|
|
620
|
+
this._targetFn = void 0;
|
|
621
|
+
this.updateRef = ref => {
|
|
622
|
+
if (ref) {
|
|
623
|
+
const domNode = ReactDOM__namespace.findDOMNode(ref);
|
|
624
|
+
if (domNode instanceof HTMLElement && domNode !== this._lastRef) {
|
|
625
|
+
var _this$_targetFn;
|
|
626
|
+
this._lastRef = domNode;
|
|
627
|
+
(_this$_targetFn = this._targetFn) == null ? void 0 : _this$_targetFn.call(this, domNode);
|
|
628
|
+
}
|
|
672
629
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
630
|
+
};
|
|
631
|
+
this.setCallback = targetFn => {
|
|
632
|
+
if (this._targetFn !== targetFn) {
|
|
633
|
+
if (targetFn && typeof targetFn !== "function") {
|
|
634
|
+
throw new Error("targetFn must be a function");
|
|
635
|
+
}
|
|
636
|
+
this._targetFn = targetFn || null;
|
|
637
|
+
if (this._lastRef && this._targetFn) {
|
|
638
|
+
this._targetFn(this._lastRef);
|
|
639
|
+
}
|
|
676
640
|
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
}
|
|
680
644
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return _this;
|
|
689
|
-
}
|
|
690
|
-
var _proto = TooltipPopper.prototype;
|
|
691
|
-
_proto._renderPositionedContent = function _renderPositionedContent(popperProps) {
|
|
645
|
+
class TooltipPopper extends React__namespace.Component {
|
|
646
|
+
constructor(...args) {
|
|
647
|
+
super(...args);
|
|
648
|
+
this._bubbleRefTracker = new RefTracker();
|
|
649
|
+
this._tailRefTracker = new RefTracker();
|
|
650
|
+
}
|
|
651
|
+
_renderPositionedContent(popperProps) {
|
|
692
652
|
const {
|
|
693
653
|
children
|
|
694
654
|
} = this.props;
|
|
@@ -717,8 +677,8 @@ let TooltipPopper = function (_React$Component) {
|
|
|
717
677
|
isReferenceHidden: popperProps.isReferenceHidden
|
|
718
678
|
};
|
|
719
679
|
return children(bubbleProps);
|
|
720
|
-
}
|
|
721
|
-
|
|
680
|
+
}
|
|
681
|
+
render() {
|
|
722
682
|
const {
|
|
723
683
|
anchorElement,
|
|
724
684
|
placement
|
|
@@ -734,36 +694,31 @@ let TooltipPopper = function (_React$Component) {
|
|
|
734
694
|
}
|
|
735
695
|
}]
|
|
736
696
|
}, props => this._renderPositionedContent(props));
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
}(React__namespace.Component);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
740
699
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
746
|
-
_this.state = {
|
|
700
|
+
class Tooltip extends React__namespace.Component {
|
|
701
|
+
constructor(...args) {
|
|
702
|
+
super(...args);
|
|
703
|
+
this.state = {
|
|
747
704
|
active: false,
|
|
748
705
|
activeBubble: false,
|
|
749
706
|
anchorElement: null
|
|
750
707
|
};
|
|
751
|
-
return _this;
|
|
752
708
|
}
|
|
753
|
-
|
|
709
|
+
static getDerivedStateFromProps(props, state) {
|
|
754
710
|
return {
|
|
755
711
|
active: typeof props.opened === "boolean" ? props.opened : state.active
|
|
756
712
|
};
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
_proto._updateAnchorElement = function _updateAnchorElement(ref) {
|
|
713
|
+
}
|
|
714
|
+
_updateAnchorElement(ref) {
|
|
760
715
|
if (ref && ref !== this.state.anchorElement) {
|
|
761
716
|
this.setState({
|
|
762
717
|
anchorElement: ref
|
|
763
718
|
});
|
|
764
719
|
}
|
|
765
|
-
}
|
|
766
|
-
|
|
720
|
+
}
|
|
721
|
+
_renderBubbleContent() {
|
|
767
722
|
const {
|
|
768
723
|
title,
|
|
769
724
|
content
|
|
@@ -779,8 +734,8 @@ let Tooltip = function (_React$Component) {
|
|
|
779
734
|
} else {
|
|
780
735
|
return content;
|
|
781
736
|
}
|
|
782
|
-
}
|
|
783
|
-
|
|
737
|
+
}
|
|
738
|
+
_renderPopper(ids) {
|
|
784
739
|
const {
|
|
785
740
|
id
|
|
786
741
|
} = this.props;
|
|
@@ -806,14 +761,14 @@ let Tooltip = function (_React$Component) {
|
|
|
806
761
|
activeBubble: active
|
|
807
762
|
})
|
|
808
763
|
}, this._renderBubbleContent()));
|
|
809
|
-
}
|
|
810
|
-
|
|
764
|
+
}
|
|
765
|
+
_getHost() {
|
|
811
766
|
const {
|
|
812
767
|
anchorElement
|
|
813
768
|
} = this.state;
|
|
814
769
|
return wonderBlocksModal.maybeGetPortalMountedModalHostElement(anchorElement) || document.body;
|
|
815
|
-
}
|
|
816
|
-
|
|
770
|
+
}
|
|
771
|
+
_renderTooltipAnchor(ids) {
|
|
817
772
|
const {
|
|
818
773
|
children,
|
|
819
774
|
forceAnchorFocusivity
|
|
@@ -831,8 +786,8 @@ let Tooltip = function (_React$Component) {
|
|
|
831
786
|
}),
|
|
832
787
|
ids: ids
|
|
833
788
|
}, children), popperHost && (active || activeBubble) && ReactDOM__namespace.createPortal(this._renderPopper(ids), popperHost));
|
|
834
|
-
}
|
|
835
|
-
|
|
789
|
+
}
|
|
790
|
+
render() {
|
|
836
791
|
const {
|
|
837
792
|
id
|
|
838
793
|
} = this.props;
|
|
@@ -844,9 +799,8 @@ let Tooltip = function (_React$Component) {
|
|
|
844
799
|
mockOnFirstRender: true
|
|
845
800
|
}, ids => this._renderTooltipAnchor(ids));
|
|
846
801
|
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
}(React__namespace.Component);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
850
804
|
Tooltip.defaultProps = {
|
|
851
805
|
forceAnchorFocusivity: true,
|
|
852
806
|
placement: "top"
|
package/dist/index.js.flow
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Flowtype definitions for
|
|
2
|
+
* Flowtype definitions for data
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import type { Placement } from "./util/types";
|
|
9
8
|
import type { PopperElementProps } from "./components/tooltip-bubble";
|
|
10
9
|
import Tooltip from "./components/tooltip";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Flowtype definitions for
|
|
2
|
+
* Flowtype definitions for data
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* This interface should be implemented by types that are interested in the
|
|
10
9
|
* notifications of active state being stolen. Generally, this would also be
|