react-tooltip 3.11.2 → 3.11.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/README.md +9 -1
- package/{standalone/react-tooltip.js → dist/index.es.js} +1080 -1363
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +2042 -285
- package/dist/index.js.map +1 -0
- package/package.json +52 -20
- package/Makefile +0 -62
- package/bower.json +0 -33
- package/contributing.md +0 -28
- package/dist/constant.js +0 -13
- package/dist/decorators/bodyMode.js +0 -124
- package/dist/decorators/customEvent.js +0 -110
- package/dist/decorators/getEffect.js +0 -12
- package/dist/decorators/isCapture.js +0 -11
- package/dist/decorators/staticMethods.js +0 -78
- package/dist/decorators/trackRemoval.js +0 -52
- package/dist/decorators/windowListener.js +0 -48
- package/dist/style.js +0 -6
- package/dist/utils/aria.js +0 -24
- package/dist/utils/getPosition.js +0 -274
- package/dist/utils/getTipContent.js +0 -32
- package/dist/utils/nodeListToArray.js +0 -15
- package/standalone/react-tooltip.min.js +0 -3
|
@@ -1,55 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function ___$insertStyle(css) {
|
|
2
|
+
if (!css) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
if (typeof window === 'undefined') {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
9
|
+
var style = document.createElement('style');
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
style.setAttribute('type', 'text/css');
|
|
12
|
+
style.innerHTML = css;
|
|
13
|
+
document.head.appendChild(style);
|
|
14
|
+
return css;
|
|
15
|
+
}
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
var classes = [];
|
|
17
|
+
import React from 'react';
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
function _classCallCheck(instance, Constructor) {
|
|
20
|
+
if (!(instance instanceof Constructor)) {
|
|
21
|
+
throw new TypeError("Cannot call a class as a function");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
function _defineProperties(target, props) {
|
|
26
|
+
for (var i = 0; i < props.length; i++) {
|
|
27
|
+
var descriptor = props[i];
|
|
28
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
29
|
+
descriptor.configurable = true;
|
|
30
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
31
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
for (var key in arg) {
|
|
29
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
30
|
-
classes.push(key);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
36
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
37
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
38
|
+
return Constructor;
|
|
39
|
+
}
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
function _defineProperty(obj, key, value) {
|
|
42
|
+
if (key in obj) {
|
|
43
|
+
Object.defineProperty(obj, key, {
|
|
44
|
+
value: value,
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
obj[key] = value;
|
|
51
|
+
}
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
return obj;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _extends() {
|
|
57
|
+
_extends = Object.assign || function (target) {
|
|
58
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
59
|
+
var source = arguments[i];
|
|
60
|
+
|
|
61
|
+
for (var key in source) {
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
63
|
+
target[key] = source[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return target;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return _extends.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function ownKeys(object, enumerableOnly) {
|
|
75
|
+
var keys = Object.keys(object);
|
|
76
|
+
|
|
77
|
+
if (Object.getOwnPropertySymbols) {
|
|
78
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
79
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
80
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
81
|
+
});
|
|
82
|
+
keys.push.apply(keys, symbols);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return keys;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function _objectSpread2(target) {
|
|
89
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
90
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
91
|
+
|
|
92
|
+
if (i % 2) {
|
|
93
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
94
|
+
_defineProperty(target, key, source[key]);
|
|
95
|
+
});
|
|
96
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
97
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
98
|
+
} else {
|
|
99
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
100
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return target;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function _inherits(subClass, superClass) {
|
|
109
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
110
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
114
|
+
constructor: {
|
|
115
|
+
value: subClass,
|
|
116
|
+
writable: true,
|
|
117
|
+
configurable: true
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function _getPrototypeOf(o) {
|
|
124
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
125
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
126
|
+
};
|
|
127
|
+
return _getPrototypeOf(o);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function _setPrototypeOf(o, p) {
|
|
131
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
132
|
+
o.__proto__ = p;
|
|
133
|
+
return o;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return _setPrototypeOf(o, p);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _assertThisInitialized(self) {
|
|
140
|
+
if (self === void 0) {
|
|
141
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return self;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function _possibleConstructorReturn(self, call) {
|
|
148
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
149
|
+
return call;
|
|
150
|
+
}
|
|
50
151
|
|
|
51
|
-
|
|
52
|
-
|
|
152
|
+
return _assertThisInitialized(self);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createCommonjsModule(fn, module) {
|
|
156
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
157
|
+
}
|
|
53
158
|
|
|
54
159
|
/**
|
|
55
160
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -84,9 +189,8 @@ emptyFunction.thatReturnsArgument = function (arg) {
|
|
|
84
189
|
return arg;
|
|
85
190
|
};
|
|
86
191
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(function (process){
|
|
192
|
+
var emptyFunction_1 = emptyFunction;
|
|
193
|
+
|
|
90
194
|
/**
|
|
91
195
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
92
196
|
*
|
|
@@ -95,8 +199,6 @@ module.exports = emptyFunction;
|
|
|
95
199
|
*
|
|
96
200
|
*/
|
|
97
201
|
|
|
98
|
-
'use strict';
|
|
99
|
-
|
|
100
202
|
/**
|
|
101
203
|
* Use invariant() to assert state which your program assumes to be true.
|
|
102
204
|
*
|
|
@@ -139,21 +241,7 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
139
241
|
}
|
|
140
242
|
}
|
|
141
243
|
|
|
142
|
-
|
|
143
|
-
}).call(this,require('_process'))
|
|
144
|
-
},{"_process":6}],4:[function(require,module,exports){
|
|
145
|
-
(function (process){
|
|
146
|
-
/**
|
|
147
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the MIT license found in the
|
|
150
|
-
* LICENSE file in the root directory of this source tree.
|
|
151
|
-
*
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
'use strict';
|
|
155
|
-
|
|
156
|
-
var emptyFunction = require('./emptyFunction');
|
|
244
|
+
var invariant_1 = invariant;
|
|
157
245
|
|
|
158
246
|
/**
|
|
159
247
|
* Similar to invariant but only logs a warning if the condition is not met.
|
|
@@ -162,7 +250,7 @@ var emptyFunction = require('./emptyFunction');
|
|
|
162
250
|
* same logic and follow the same code paths.
|
|
163
251
|
*/
|
|
164
252
|
|
|
165
|
-
var warning =
|
|
253
|
+
var warning = emptyFunction_1;
|
|
166
254
|
|
|
167
255
|
if (process.env.NODE_ENV !== 'production') {
|
|
168
256
|
var printWarning = function printWarning(format) {
|
|
@@ -204,16 +292,13 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
204
292
|
};
|
|
205
293
|
}
|
|
206
294
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
},{"./emptyFunction":2,"_process":6}],5:[function(require,module,exports){
|
|
295
|
+
var warning_1 = warning;
|
|
296
|
+
|
|
210
297
|
/*
|
|
211
298
|
object-assign
|
|
212
299
|
(c) Sindre Sorhus
|
|
213
300
|
@license MIT
|
|
214
301
|
*/
|
|
215
|
-
|
|
216
|
-
'use strict';
|
|
217
302
|
/* eslint-disable no-unused-vars */
|
|
218
303
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
219
304
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -271,7 +356,7 @@ function shouldUseNative() {
|
|
|
271
356
|
}
|
|
272
357
|
}
|
|
273
358
|
|
|
274
|
-
|
|
359
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
275
360
|
var from;
|
|
276
361
|
var to = toObject(target);
|
|
277
362
|
var symbols;
|
|
@@ -298,194 +383,6 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
|
|
298
383
|
return to;
|
|
299
384
|
};
|
|
300
385
|
|
|
301
|
-
},{}],6:[function(require,module,exports){
|
|
302
|
-
// shim for using process in browser
|
|
303
|
-
var process = module.exports = {};
|
|
304
|
-
|
|
305
|
-
// cached from whatever global is present so that test runners that stub it
|
|
306
|
-
// don't break things. But we need to wrap it in a try catch in case it is
|
|
307
|
-
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
308
|
-
// function because try/catches deoptimize in certain engines.
|
|
309
|
-
|
|
310
|
-
var cachedSetTimeout;
|
|
311
|
-
var cachedClearTimeout;
|
|
312
|
-
|
|
313
|
-
function defaultSetTimout() {
|
|
314
|
-
throw new Error('setTimeout has not been defined');
|
|
315
|
-
}
|
|
316
|
-
function defaultClearTimeout () {
|
|
317
|
-
throw new Error('clearTimeout has not been defined');
|
|
318
|
-
}
|
|
319
|
-
(function () {
|
|
320
|
-
try {
|
|
321
|
-
if (typeof setTimeout === 'function') {
|
|
322
|
-
cachedSetTimeout = setTimeout;
|
|
323
|
-
} else {
|
|
324
|
-
cachedSetTimeout = defaultSetTimout;
|
|
325
|
-
}
|
|
326
|
-
} catch (e) {
|
|
327
|
-
cachedSetTimeout = defaultSetTimout;
|
|
328
|
-
}
|
|
329
|
-
try {
|
|
330
|
-
if (typeof clearTimeout === 'function') {
|
|
331
|
-
cachedClearTimeout = clearTimeout;
|
|
332
|
-
} else {
|
|
333
|
-
cachedClearTimeout = defaultClearTimeout;
|
|
334
|
-
}
|
|
335
|
-
} catch (e) {
|
|
336
|
-
cachedClearTimeout = defaultClearTimeout;
|
|
337
|
-
}
|
|
338
|
-
} ())
|
|
339
|
-
function runTimeout(fun) {
|
|
340
|
-
if (cachedSetTimeout === setTimeout) {
|
|
341
|
-
//normal enviroments in sane situations
|
|
342
|
-
return setTimeout(fun, 0);
|
|
343
|
-
}
|
|
344
|
-
// if setTimeout wasn't available but was latter defined
|
|
345
|
-
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
346
|
-
cachedSetTimeout = setTimeout;
|
|
347
|
-
return setTimeout(fun, 0);
|
|
348
|
-
}
|
|
349
|
-
try {
|
|
350
|
-
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
351
|
-
return cachedSetTimeout(fun, 0);
|
|
352
|
-
} catch(e){
|
|
353
|
-
try {
|
|
354
|
-
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
355
|
-
return cachedSetTimeout.call(null, fun, 0);
|
|
356
|
-
} catch(e){
|
|
357
|
-
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
358
|
-
return cachedSetTimeout.call(this, fun, 0);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
function runClearTimeout(marker) {
|
|
365
|
-
if (cachedClearTimeout === clearTimeout) {
|
|
366
|
-
//normal enviroments in sane situations
|
|
367
|
-
return clearTimeout(marker);
|
|
368
|
-
}
|
|
369
|
-
// if clearTimeout wasn't available but was latter defined
|
|
370
|
-
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
371
|
-
cachedClearTimeout = clearTimeout;
|
|
372
|
-
return clearTimeout(marker);
|
|
373
|
-
}
|
|
374
|
-
try {
|
|
375
|
-
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
376
|
-
return cachedClearTimeout(marker);
|
|
377
|
-
} catch (e){
|
|
378
|
-
try {
|
|
379
|
-
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
380
|
-
return cachedClearTimeout.call(null, marker);
|
|
381
|
-
} catch (e){
|
|
382
|
-
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
383
|
-
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
384
|
-
return cachedClearTimeout.call(this, marker);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
var queue = [];
|
|
392
|
-
var draining = false;
|
|
393
|
-
var currentQueue;
|
|
394
|
-
var queueIndex = -1;
|
|
395
|
-
|
|
396
|
-
function cleanUpNextTick() {
|
|
397
|
-
if (!draining || !currentQueue) {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
draining = false;
|
|
401
|
-
if (currentQueue.length) {
|
|
402
|
-
queue = currentQueue.concat(queue);
|
|
403
|
-
} else {
|
|
404
|
-
queueIndex = -1;
|
|
405
|
-
}
|
|
406
|
-
if (queue.length) {
|
|
407
|
-
drainQueue();
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function drainQueue() {
|
|
412
|
-
if (draining) {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
var timeout = runTimeout(cleanUpNextTick);
|
|
416
|
-
draining = true;
|
|
417
|
-
|
|
418
|
-
var len = queue.length;
|
|
419
|
-
while(len) {
|
|
420
|
-
currentQueue = queue;
|
|
421
|
-
queue = [];
|
|
422
|
-
while (++queueIndex < len) {
|
|
423
|
-
if (currentQueue) {
|
|
424
|
-
currentQueue[queueIndex].run();
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
queueIndex = -1;
|
|
428
|
-
len = queue.length;
|
|
429
|
-
}
|
|
430
|
-
currentQueue = null;
|
|
431
|
-
draining = false;
|
|
432
|
-
runClearTimeout(timeout);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
process.nextTick = function (fun) {
|
|
436
|
-
var args = new Array(arguments.length - 1);
|
|
437
|
-
if (arguments.length > 1) {
|
|
438
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
439
|
-
args[i - 1] = arguments[i];
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
queue.push(new Item(fun, args));
|
|
443
|
-
if (queue.length === 1 && !draining) {
|
|
444
|
-
runTimeout(drainQueue);
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
// v8 likes predictible objects
|
|
449
|
-
function Item(fun, array) {
|
|
450
|
-
this.fun = fun;
|
|
451
|
-
this.array = array;
|
|
452
|
-
}
|
|
453
|
-
Item.prototype.run = function () {
|
|
454
|
-
this.fun.apply(null, this.array);
|
|
455
|
-
};
|
|
456
|
-
process.title = 'browser';
|
|
457
|
-
process.browser = true;
|
|
458
|
-
process.env = {};
|
|
459
|
-
process.argv = [];
|
|
460
|
-
process.version = ''; // empty string to avoid regexp issues
|
|
461
|
-
process.versions = {};
|
|
462
|
-
|
|
463
|
-
function noop() {}
|
|
464
|
-
|
|
465
|
-
process.on = noop;
|
|
466
|
-
process.addListener = noop;
|
|
467
|
-
process.once = noop;
|
|
468
|
-
process.off = noop;
|
|
469
|
-
process.removeListener = noop;
|
|
470
|
-
process.removeAllListeners = noop;
|
|
471
|
-
process.emit = noop;
|
|
472
|
-
process.prependListener = noop;
|
|
473
|
-
process.prependOnceListener = noop;
|
|
474
|
-
|
|
475
|
-
process.listeners = function (name) { return [] }
|
|
476
|
-
|
|
477
|
-
process.binding = function (name) {
|
|
478
|
-
throw new Error('process.binding is not supported');
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
process.cwd = function () { return '/' };
|
|
482
|
-
process.chdir = function (dir) {
|
|
483
|
-
throw new Error('process.chdir is not supported');
|
|
484
|
-
};
|
|
485
|
-
process.umask = function() { return 0; };
|
|
486
|
-
|
|
487
|
-
},{}],7:[function(require,module,exports){
|
|
488
|
-
(function (process){
|
|
489
386
|
/**
|
|
490
387
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
491
388
|
*
|
|
@@ -493,12 +390,14 @@ process.umask = function() { return 0; };
|
|
|
493
390
|
* LICENSE file in the root directory of this source tree.
|
|
494
391
|
*/
|
|
495
392
|
|
|
496
|
-
|
|
393
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
394
|
+
|
|
395
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
497
396
|
|
|
498
397
|
if (process.env.NODE_ENV !== 'production') {
|
|
499
|
-
var invariant =
|
|
500
|
-
var warning =
|
|
501
|
-
var ReactPropTypesSecret =
|
|
398
|
+
var invariant$1 = invariant_1;
|
|
399
|
+
var warning$1 = warning_1;
|
|
400
|
+
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
502
401
|
var loggedTypeFailures = {};
|
|
503
402
|
}
|
|
504
403
|
|
|
@@ -524,12 +423,12 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
524
423
|
try {
|
|
525
424
|
// This is intentionally an invariant that gets caught. It's the same
|
|
526
425
|
// behavior as without this statement except with a better message.
|
|
527
|
-
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
|
528
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
426
|
+
invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
|
|
427
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
|
529
428
|
} catch (ex) {
|
|
530
429
|
error = ex;
|
|
531
430
|
}
|
|
532
|
-
warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
|
|
431
|
+
warning$1(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
|
|
533
432
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
534
433
|
// Only monitor this failure once because there tends to be a lot of the
|
|
535
434
|
// same error.
|
|
@@ -537,96 +436,16 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
537
436
|
|
|
538
437
|
var stack = getStack ? getStack() : '';
|
|
539
438
|
|
|
540
|
-
warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
|
439
|
+
warning$1(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
|
541
440
|
}
|
|
542
441
|
}
|
|
543
442
|
}
|
|
544
443
|
}
|
|
545
444
|
}
|
|
546
445
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}).call(this,require('_process'))
|
|
550
|
-
},{"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/invariant":3,"fbjs/lib/warning":4}],8:[function(require,module,exports){
|
|
551
|
-
/**
|
|
552
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
553
|
-
*
|
|
554
|
-
* This source code is licensed under the MIT license found in the
|
|
555
|
-
* LICENSE file in the root directory of this source tree.
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
'use strict';
|
|
559
|
-
|
|
560
|
-
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
561
|
-
var invariant = require('fbjs/lib/invariant');
|
|
562
|
-
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
|
|
563
|
-
|
|
564
|
-
module.exports = function() {
|
|
565
|
-
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
566
|
-
if (secret === ReactPropTypesSecret) {
|
|
567
|
-
// It is still safe when called from React.
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
invariant(
|
|
571
|
-
false,
|
|
572
|
-
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
573
|
-
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
574
|
-
'Read more at http://fb.me/use-check-prop-types'
|
|
575
|
-
);
|
|
576
|
-
};
|
|
577
|
-
shim.isRequired = shim;
|
|
578
|
-
function getShim() {
|
|
579
|
-
return shim;
|
|
580
|
-
};
|
|
581
|
-
// Important!
|
|
582
|
-
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
583
|
-
var ReactPropTypes = {
|
|
584
|
-
array: shim,
|
|
585
|
-
bool: shim,
|
|
586
|
-
func: shim,
|
|
587
|
-
number: shim,
|
|
588
|
-
object: shim,
|
|
589
|
-
string: shim,
|
|
590
|
-
symbol: shim,
|
|
591
|
-
|
|
592
|
-
any: shim,
|
|
593
|
-
arrayOf: getShim,
|
|
594
|
-
element: shim,
|
|
595
|
-
instanceOf: getShim,
|
|
596
|
-
node: shim,
|
|
597
|
-
objectOf: getShim,
|
|
598
|
-
oneOf: getShim,
|
|
599
|
-
oneOfType: getShim,
|
|
600
|
-
shape: getShim,
|
|
601
|
-
exact: getShim
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
ReactPropTypes.checkPropTypes = emptyFunction;
|
|
605
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
606
|
-
|
|
607
|
-
return ReactPropTypes;
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
},{"./lib/ReactPropTypesSecret":11,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3}],9:[function(require,module,exports){
|
|
611
|
-
(function (process){
|
|
612
|
-
/**
|
|
613
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
614
|
-
*
|
|
615
|
-
* This source code is licensed under the MIT license found in the
|
|
616
|
-
* LICENSE file in the root directory of this source tree.
|
|
617
|
-
*/
|
|
618
|
-
|
|
619
|
-
'use strict';
|
|
620
|
-
|
|
621
|
-
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
622
|
-
var invariant = require('fbjs/lib/invariant');
|
|
623
|
-
var warning = require('fbjs/lib/warning');
|
|
624
|
-
var assign = require('object-assign');
|
|
625
|
-
|
|
626
|
-
var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
|
|
627
|
-
var checkPropTypes = require('./checkPropTypes');
|
|
446
|
+
var checkPropTypes_1 = checkPropTypes;
|
|
628
447
|
|
|
629
|
-
|
|
448
|
+
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
630
449
|
/* global Symbol */
|
|
631
450
|
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
632
451
|
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
@@ -765,10 +584,10 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
765
584
|
componentName = componentName || ANONYMOUS;
|
|
766
585
|
propFullName = propFullName || propName;
|
|
767
586
|
|
|
768
|
-
if (secret !==
|
|
587
|
+
if (secret !== ReactPropTypesSecret_1) {
|
|
769
588
|
if (throwOnDirectAccess) {
|
|
770
589
|
// New behavior only for users of `prop-types` package
|
|
771
|
-
|
|
590
|
+
invariant_1(
|
|
772
591
|
false,
|
|
773
592
|
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
774
593
|
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
@@ -782,7 +601,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
782
601
|
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
783
602
|
manualPropTypeWarningCount < 3
|
|
784
603
|
) {
|
|
785
|
-
|
|
604
|
+
warning_1(
|
|
786
605
|
false,
|
|
787
606
|
'You are manually calling a React.PropTypes validation ' +
|
|
788
607
|
'function for the `%s` prop on `%s`. This is deprecated ' +
|
|
@@ -834,7 +653,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
834
653
|
}
|
|
835
654
|
|
|
836
655
|
function createAnyTypeChecker() {
|
|
837
|
-
return createChainableTypeChecker(
|
|
656
|
+
return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
|
|
838
657
|
}
|
|
839
658
|
|
|
840
659
|
function createArrayOfTypeChecker(typeChecker) {
|
|
@@ -848,7 +667,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
848
667
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
849
668
|
}
|
|
850
669
|
for (var i = 0; i < propValue.length; i++) {
|
|
851
|
-
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']',
|
|
670
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
|
852
671
|
if (error instanceof Error) {
|
|
853
672
|
return error;
|
|
854
673
|
}
|
|
@@ -884,8 +703,8 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
884
703
|
|
|
885
704
|
function createEnumTypeChecker(expectedValues) {
|
|
886
705
|
if (!Array.isArray(expectedValues)) {
|
|
887
|
-
process.env.NODE_ENV !== 'production' ?
|
|
888
|
-
return
|
|
706
|
+
process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
|
|
707
|
+
return emptyFunction_1.thatReturnsNull;
|
|
889
708
|
}
|
|
890
709
|
|
|
891
710
|
function validate(props, propName, componentName, location, propFullName) {
|
|
@@ -914,7 +733,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
914
733
|
}
|
|
915
734
|
for (var key in propValue) {
|
|
916
735
|
if (propValue.hasOwnProperty(key)) {
|
|
917
|
-
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key,
|
|
736
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
918
737
|
if (error instanceof Error) {
|
|
919
738
|
return error;
|
|
920
739
|
}
|
|
@@ -927,28 +746,28 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
927
746
|
|
|
928
747
|
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
929
748
|
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
930
|
-
process.env.NODE_ENV !== 'production' ?
|
|
931
|
-
return
|
|
749
|
+
process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
750
|
+
return emptyFunction_1.thatReturnsNull;
|
|
932
751
|
}
|
|
933
752
|
|
|
934
753
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
935
754
|
var checker = arrayOfTypeCheckers[i];
|
|
936
755
|
if (typeof checker !== 'function') {
|
|
937
|
-
|
|
756
|
+
warning_1(
|
|
938
757
|
false,
|
|
939
758
|
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
940
759
|
'received %s at index %s.',
|
|
941
760
|
getPostfixForTypeWarning(checker),
|
|
942
761
|
i
|
|
943
762
|
);
|
|
944
|
-
return
|
|
763
|
+
return emptyFunction_1.thatReturnsNull;
|
|
945
764
|
}
|
|
946
765
|
}
|
|
947
766
|
|
|
948
767
|
function validate(props, propName, componentName, location, propFullName) {
|
|
949
768
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
950
769
|
var checker = arrayOfTypeCheckers[i];
|
|
951
|
-
if (checker(props, propName, componentName, location, propFullName,
|
|
770
|
+
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
|
952
771
|
return null;
|
|
953
772
|
}
|
|
954
773
|
}
|
|
@@ -980,7 +799,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
980
799
|
if (!checker) {
|
|
981
800
|
continue;
|
|
982
801
|
}
|
|
983
|
-
var error = checker(propValue, key, componentName, location, propFullName + '.' + key,
|
|
802
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
984
803
|
if (error) {
|
|
985
804
|
return error;
|
|
986
805
|
}
|
|
@@ -999,7 +818,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
999
818
|
}
|
|
1000
819
|
// We need to check all keys in case some are required but missing from
|
|
1001
820
|
// props.
|
|
1002
|
-
var allKeys =
|
|
821
|
+
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
1003
822
|
for (var key in allKeys) {
|
|
1004
823
|
var checker = shapeTypes[key];
|
|
1005
824
|
if (!checker) {
|
|
@@ -1009,7 +828,7 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
1009
828
|
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
1010
829
|
);
|
|
1011
830
|
}
|
|
1012
|
-
var error = checker(propValue, key, componentName, location, propFullName + '.' + key,
|
|
831
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
1013
832
|
if (error) {
|
|
1014
833
|
return error;
|
|
1015
834
|
}
|
|
@@ -1146,15 +965,57 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
|
1146
965
|
return propValue.constructor.name;
|
|
1147
966
|
}
|
|
1148
967
|
|
|
1149
|
-
ReactPropTypes.checkPropTypes =
|
|
968
|
+
ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
|
969
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
970
|
+
|
|
971
|
+
return ReactPropTypes;
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
var factoryWithThrowingShims = function() {
|
|
975
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
976
|
+
if (secret === ReactPropTypesSecret_1) {
|
|
977
|
+
// It is still safe when called from React.
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
invariant_1(
|
|
981
|
+
false,
|
|
982
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
983
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
984
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
985
|
+
);
|
|
986
|
+
} shim.isRequired = shim;
|
|
987
|
+
function getShim() {
|
|
988
|
+
return shim;
|
|
989
|
+
} // Important!
|
|
990
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
991
|
+
var ReactPropTypes = {
|
|
992
|
+
array: shim,
|
|
993
|
+
bool: shim,
|
|
994
|
+
func: shim,
|
|
995
|
+
number: shim,
|
|
996
|
+
object: shim,
|
|
997
|
+
string: shim,
|
|
998
|
+
symbol: shim,
|
|
999
|
+
|
|
1000
|
+
any: shim,
|
|
1001
|
+
arrayOf: getShim,
|
|
1002
|
+
element: shim,
|
|
1003
|
+
instanceOf: getShim,
|
|
1004
|
+
node: shim,
|
|
1005
|
+
objectOf: getShim,
|
|
1006
|
+
oneOf: getShim,
|
|
1007
|
+
oneOfType: getShim,
|
|
1008
|
+
shape: getShim,
|
|
1009
|
+
exact: getShim
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
ReactPropTypes.checkPropTypes = emptyFunction_1;
|
|
1150
1013
|
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1151
1014
|
|
|
1152
1015
|
return ReactPropTypes;
|
|
1153
1016
|
};
|
|
1154
1017
|
|
|
1155
|
-
|
|
1156
|
-
},{"./checkPropTypes":7,"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3,"fbjs/lib/warning":4,"object-assign":5}],10:[function(require,module,exports){
|
|
1157
|
-
(function (process){
|
|
1018
|
+
var propTypes = createCommonjsModule(function (module) {
|
|
1158
1019
|
/**
|
|
1159
1020
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1160
1021
|
*
|
|
@@ -1177,223 +1038,140 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1177
1038
|
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
1178
1039
|
// http://fb.me/prop-types-in-prod
|
|
1179
1040
|
var throwOnDirectAccess = true;
|
|
1180
|
-
module.exports =
|
|
1041
|
+
module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
|
|
1181
1042
|
} else {
|
|
1182
1043
|
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1183
1044
|
// http://fb.me/prop-types-in-prod
|
|
1184
|
-
module.exports =
|
|
1045
|
+
module.exports = factoryWithThrowingShims();
|
|
1185
1046
|
}
|
|
1186
|
-
|
|
1187
|
-
}).call(this,require('_process'))
|
|
1188
|
-
},{"./factoryWithThrowingShims":8,"./factoryWithTypeCheckers":9,"_process":6}],11:[function(require,module,exports){
|
|
1189
|
-
/**
|
|
1190
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1191
|
-
*
|
|
1192
|
-
* This source code is licensed under the MIT license found in the
|
|
1193
|
-
* LICENSE file in the root directory of this source tree.
|
|
1194
|
-
*/
|
|
1195
|
-
|
|
1196
|
-
'use strict';
|
|
1197
|
-
|
|
1198
|
-
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
1199
|
-
|
|
1200
|
-
module.exports = ReactPropTypesSecret;
|
|
1201
|
-
|
|
1202
|
-
},{}],12:[function(require,module,exports){
|
|
1203
|
-
'use strict';
|
|
1204
|
-
|
|
1205
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1206
|
-
value: true
|
|
1207
1047
|
});
|
|
1208
|
-
exports.default = {
|
|
1209
1048
|
|
|
1049
|
+
var CONSTANT = {
|
|
1210
1050
|
GLOBAL: {
|
|
1211
|
-
HIDE:
|
|
1212
|
-
REBUILD:
|
|
1213
|
-
SHOW:
|
|
1051
|
+
HIDE: "__react_tooltip_hide_event",
|
|
1052
|
+
REBUILD: "__react_tooltip_rebuild_event",
|
|
1053
|
+
SHOW: "__react_tooltip_show_event"
|
|
1214
1054
|
}
|
|
1215
1055
|
};
|
|
1216
1056
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1221
|
-
value: true
|
|
1222
|
-
});
|
|
1057
|
+
/**
|
|
1058
|
+
* Static methods for react-tooltip
|
|
1059
|
+
*/
|
|
1223
1060
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1061
|
+
var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) {
|
|
1062
|
+
// Compatible with IE
|
|
1063
|
+
// @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
|
|
1064
|
+
var event;
|
|
1228
1065
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1066
|
+
if (typeof window.CustomEvent === "function") {
|
|
1067
|
+
event = new window.CustomEvent(eventName, {
|
|
1068
|
+
detail: opts
|
|
1069
|
+
});
|
|
1070
|
+
} else {
|
|
1071
|
+
event = document.createEvent("Event");
|
|
1072
|
+
event.initEvent(eventName, false, true);
|
|
1073
|
+
event.detail = opts;
|
|
1074
|
+
}
|
|
1231
1075
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
eventOff = _state.eventOff,
|
|
1235
|
-
possibleCustomEvents = _state.possibleCustomEvents,
|
|
1236
|
-
possibleCustomEventsOff = _state.possibleCustomEventsOff;
|
|
1076
|
+
window.dispatchEvent(event);
|
|
1077
|
+
};
|
|
1237
1078
|
|
|
1238
|
-
|
|
1079
|
+
function staticMethods (target) {
|
|
1080
|
+
/**
|
|
1081
|
+
* Hide all tooltip
|
|
1082
|
+
* @trigger ReactTooltip.hide()
|
|
1083
|
+
*/
|
|
1084
|
+
target.hide = function (target) {
|
|
1085
|
+
dispatchGlobalEvent(CONSTANT.GLOBAL.HIDE, {
|
|
1086
|
+
target: target
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
/**
|
|
1090
|
+
* Rebuild all tooltip
|
|
1091
|
+
* @trigger ReactTooltip.rebuild()
|
|
1092
|
+
*/
|
|
1239
1093
|
|
|
1240
|
-
var customEvents = findCustomEvents(targetArray, 'data-event');
|
|
1241
|
-
var customEventsOff = findCustomEvents(targetArray, 'data-event-off');
|
|
1242
1094
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
});
|
|
1095
|
+
target.rebuild = function () {
|
|
1096
|
+
dispatchGlobalEvent(CONSTANT.GLOBAL.REBUILD);
|
|
1097
|
+
};
|
|
1098
|
+
/**
|
|
1099
|
+
* Show specific tooltip
|
|
1100
|
+
* @trigger ReactTooltip.show()
|
|
1101
|
+
*/
|
|
1251
1102
|
|
|
1252
|
-
this.unbindBodyListener(body);
|
|
1253
1103
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1104
|
+
target.show = function (target) {
|
|
1105
|
+
dispatchGlobalEvent(CONSTANT.GLOBAL.SHOW, {
|
|
1106
|
+
target: target
|
|
1107
|
+
});
|
|
1108
|
+
};
|
|
1260
1109
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
}, { customEvent: true });
|
|
1266
|
-
}
|
|
1267
|
-
for (var _event2 in customEventsOff) {
|
|
1268
|
-
listeners[_event2] = bodyListener.bind(this, this.hideTooltip, { customEvent: true });
|
|
1269
|
-
}
|
|
1270
|
-
for (var _event3 in listeners) {
|
|
1271
|
-
body.addEventListener(_event3, listeners[_event3]);
|
|
1110
|
+
target.prototype.globalRebuild = function () {
|
|
1111
|
+
if (this.mount) {
|
|
1112
|
+
this.unbindListener();
|
|
1113
|
+
this.bindListener();
|
|
1272
1114
|
}
|
|
1273
1115
|
};
|
|
1274
1116
|
|
|
1275
|
-
target.prototype.
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1117
|
+
target.prototype.globalShow = function (event) {
|
|
1118
|
+
if (this.mount) {
|
|
1119
|
+
// Create a fake event, specific show will limit the type to `solid`
|
|
1120
|
+
// only `float` type cares e.clientX e.clientY
|
|
1121
|
+
var e = {
|
|
1122
|
+
currentTarget: event.detail.target
|
|
1123
|
+
};
|
|
1124
|
+
this.showTooltip(e, true);
|
|
1281
1125
|
}
|
|
1282
1126
|
};
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1285
|
-
var _customEvent = require('./customEvent');
|
|
1286
1127
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
proxy[key] = e[key];
|
|
1128
|
+
target.prototype.globalHide = function (event) {
|
|
1129
|
+
if (this.mount) {
|
|
1130
|
+
var hasTarget = event && event.detail && event.detail.target && true || false;
|
|
1131
|
+
this.hideTooltip({
|
|
1132
|
+
currentTarget: hasTarget && event.detail.target
|
|
1133
|
+
}, hasTarget);
|
|
1294
1134
|
}
|
|
1295
|
-
}
|
|
1296
|
-
return proxy;
|
|
1297
|
-
}; /**
|
|
1298
|
-
* Util method to get effect
|
|
1299
|
-
*/
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
var bodyListener = function bodyListener(callback, options, e) {
|
|
1303
|
-
var _options$respectEffec = options.respectEffect,
|
|
1304
|
-
respectEffect = _options$respectEffec === undefined ? false : _options$respectEffec,
|
|
1305
|
-
_options$customEvent = options.customEvent,
|
|
1306
|
-
customEvent = _options$customEvent === undefined ? false : _options$customEvent;
|
|
1307
|
-
var id = this.props.id;
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
var tip = e.target.getAttribute('data-tip') || null;
|
|
1311
|
-
var forId = e.target.getAttribute('data-for') || null;
|
|
1312
|
-
|
|
1313
|
-
var target = e.target;
|
|
1314
|
-
if (this.isCustomEvent(target) && !customEvent) {
|
|
1315
|
-
return;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
var isTargetBelongsToTooltip = id == null && forId == null || forId === id;
|
|
1319
|
-
|
|
1320
|
-
if (tip != null && (!respectEffect || this.getEffect(target) === 'float') && isTargetBelongsToTooltip) {
|
|
1321
|
-
var proxy = makeProxy(e);
|
|
1322
|
-
proxy.currentTarget = target;
|
|
1323
|
-
callback(proxy);
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
|
|
1327
|
-
var findCustomEvents = function findCustomEvents(targetArray, dataAttribute) {
|
|
1328
|
-
var events = {};
|
|
1329
|
-
targetArray.forEach(function (target) {
|
|
1330
|
-
var event = target.getAttribute(dataAttribute);
|
|
1331
|
-
if (event) event.split(' ').forEach(function (event) {
|
|
1332
|
-
return events[event] = true;
|
|
1333
|
-
});
|
|
1334
|
-
});
|
|
1335
|
-
|
|
1336
|
-
return events;
|
|
1337
|
-
};
|
|
1338
|
-
|
|
1339
|
-
var getBody = function getBody() {
|
|
1340
|
-
return document.getElementsByTagName('body')[0];
|
|
1341
|
-
};
|
|
1342
|
-
|
|
1343
|
-
},{"./customEvent":14}],14:[function(require,module,exports){
|
|
1344
|
-
'use strict';
|
|
1345
|
-
|
|
1346
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1347
|
-
value: true
|
|
1348
|
-
});
|
|
1349
|
-
|
|
1350
|
-
exports.default = function (target) {
|
|
1351
|
-
target.prototype.isCustomEvent = function (ele) {
|
|
1352
|
-
var event = this.state.event;
|
|
1353
|
-
|
|
1354
|
-
return event || !!ele.getAttribute('data-event');
|
|
1355
1135
|
};
|
|
1136
|
+
}
|
|
1356
1137
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1138
|
+
/**
|
|
1139
|
+
* Events that should be bound to the window
|
|
1140
|
+
*/
|
|
1141
|
+
function windowListener (target) {
|
|
1142
|
+
target.prototype.bindWindowEvents = function (resizeHide) {
|
|
1143
|
+
// ReactTooltip.hide
|
|
1144
|
+
window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
|
|
1145
|
+
window.addEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide, false); // ReactTooltip.rebuild
|
|
1360
1146
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
eventOff = _state.eventOff;
|
|
1147
|
+
window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
|
|
1148
|
+
window.addEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild, false); // ReactTooltip.show
|
|
1364
1149
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1150
|
+
window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
|
|
1151
|
+
window.addEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow, false); // Resize
|
|
1367
1152
|
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
customListeners.set(ele, event, customListener);
|
|
1372
|
-
ele.addEventListener(event, customListener, false);
|
|
1373
|
-
});
|
|
1374
|
-
if (dataEventOff) {
|
|
1375
|
-
dataEventOff.split(' ').forEach(function (event) {
|
|
1376
|
-
ele.removeEventListener(event, _this.hideTooltip);
|
|
1377
|
-
ele.addEventListener(event, _this.hideTooltip, false);
|
|
1378
|
-
});
|
|
1153
|
+
if (resizeHide) {
|
|
1154
|
+
window.removeEventListener("resize", this.onWindowResize);
|
|
1155
|
+
window.addEventListener("resize", this.onWindowResize, false);
|
|
1379
1156
|
}
|
|
1380
1157
|
};
|
|
1381
1158
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1159
|
+
target.prototype.unbindWindowEvents = function () {
|
|
1160
|
+
window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
|
|
1161
|
+
window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
|
|
1162
|
+
window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
|
|
1163
|
+
window.removeEventListener("resize", this.onWindowResize);
|
|
1164
|
+
};
|
|
1165
|
+
/**
|
|
1166
|
+
* invoked by resize event of window
|
|
1167
|
+
*/
|
|
1387
1168
|
|
|
1388
|
-
var dataEvent = event || ele.getAttribute('data-event');
|
|
1389
|
-
var dataEventOff = eventOff || ele.getAttribute('data-event-off');
|
|
1390
1169
|
|
|
1391
|
-
|
|
1392
|
-
if (
|
|
1170
|
+
target.prototype.onWindowResize = function () {
|
|
1171
|
+
if (!this.mount) return;
|
|
1172
|
+
this.hideTooltip();
|
|
1393
1173
|
};
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1174
|
+
}
|
|
1397
1175
|
|
|
1398
1176
|
/**
|
|
1399
1177
|
* Custom events to control showing and hiding of tooltip
|
|
@@ -1402,19 +1180,17 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
1402
1180
|
* - `event` {String}
|
|
1403
1181
|
* - `eventOff` {String}
|
|
1404
1182
|
*/
|
|
1405
|
-
|
|
1406
|
-
var checkStatus = exports.checkStatus = function checkStatus(dataEventOff, e) {
|
|
1183
|
+
var checkStatus = function checkStatus(dataEventOff, e) {
|
|
1407
1184
|
var show = this.state.show;
|
|
1408
1185
|
var id = this.props.id;
|
|
1409
|
-
|
|
1410
1186
|
var isCapture = this.isCapture(e.currentTarget);
|
|
1411
|
-
var currentItem = e.currentTarget.getAttribute(
|
|
1412
|
-
|
|
1187
|
+
var currentItem = e.currentTarget.getAttribute("currentItem");
|
|
1413
1188
|
if (!isCapture) e.stopPropagation();
|
|
1414
|
-
|
|
1189
|
+
|
|
1190
|
+
if (show && currentItem === "true") {
|
|
1415
1191
|
if (!dataEventOff) this.hideTooltip(e);
|
|
1416
1192
|
} else {
|
|
1417
|
-
e.currentTarget.setAttribute(
|
|
1193
|
+
e.currentTarget.setAttribute("currentItem", "true");
|
|
1418
1194
|
setUntargetItems(e.currentTarget, this.getTargetArray(id));
|
|
1419
1195
|
this.showTooltip(e);
|
|
1420
1196
|
}
|
|
@@ -1423,15 +1199,15 @@ var checkStatus = exports.checkStatus = function checkStatus(dataEventOff, e) {
|
|
|
1423
1199
|
var setUntargetItems = function setUntargetItems(currentTarget, targetArray) {
|
|
1424
1200
|
for (var i = 0; i < targetArray.length; i++) {
|
|
1425
1201
|
if (currentTarget !== targetArray[i]) {
|
|
1426
|
-
targetArray[i].setAttribute(
|
|
1202
|
+
targetArray[i].setAttribute("currentItem", "false");
|
|
1427
1203
|
} else {
|
|
1428
|
-
targetArray[i].setAttribute(
|
|
1204
|
+
targetArray[i].setAttribute("currentItem", "true");
|
|
1429
1205
|
}
|
|
1430
1206
|
}
|
|
1431
1207
|
};
|
|
1432
1208
|
|
|
1433
1209
|
var customListeners = {
|
|
1434
|
-
id:
|
|
1210
|
+
id: "9b69f92e-d3fe-498b-b1b4-c5e63a51b0cf",
|
|
1435
1211
|
set: function set(target, event, listener) {
|
|
1436
1212
|
if (this.id in target) {
|
|
1437
1213
|
var map = target[this.id];
|
|
@@ -1446,148 +1222,234 @@ var customListeners = {
|
|
|
1446
1222
|
},
|
|
1447
1223
|
get: function get(target, event) {
|
|
1448
1224
|
var map = target[this.id];
|
|
1225
|
+
|
|
1449
1226
|
if (map !== undefined) {
|
|
1450
1227
|
return map[event];
|
|
1451
1228
|
}
|
|
1452
1229
|
}
|
|
1453
1230
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1459
|
-
value: true
|
|
1460
|
-
});
|
|
1461
|
-
|
|
1462
|
-
exports.default = function (target) {
|
|
1463
|
-
target.prototype.getEffect = function (currentTarget) {
|
|
1464
|
-
var dataEffect = currentTarget.getAttribute('data-effect');
|
|
1465
|
-
return dataEffect || this.props.effect || 'float';
|
|
1231
|
+
function customEvent (target) {
|
|
1232
|
+
target.prototype.isCustomEvent = function (ele) {
|
|
1233
|
+
var event = this.state.event;
|
|
1234
|
+
return event || !!ele.getAttribute("data-event");
|
|
1466
1235
|
};
|
|
1467
|
-
|
|
1236
|
+
/* Bind listener for custom event */
|
|
1468
1237
|
|
|
1469
|
-
},{}],16:[function(require,module,exports){
|
|
1470
|
-
'use strict';
|
|
1471
1238
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
});
|
|
1239
|
+
target.prototype.customBindListener = function (ele) {
|
|
1240
|
+
var _this = this;
|
|
1475
1241
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1242
|
+
var _this$state = this.state,
|
|
1243
|
+
event = _this$state.event,
|
|
1244
|
+
eventOff = _this$state.eventOff;
|
|
1245
|
+
var dataEvent = ele.getAttribute("data-event") || event;
|
|
1246
|
+
var dataEventOff = ele.getAttribute("data-event-off") || eventOff;
|
|
1247
|
+
dataEvent.split(" ").forEach(function (event) {
|
|
1248
|
+
ele.removeEventListener(event, customListeners.get(ele, event));
|
|
1249
|
+
var customListener = checkStatus.bind(_this, dataEventOff);
|
|
1250
|
+
customListeners.set(ele, event, customListener);
|
|
1251
|
+
ele.addEventListener(event, customListener, false);
|
|
1252
|
+
});
|
|
1481
1253
|
|
|
1482
|
-
|
|
1483
|
-
|
|
1254
|
+
if (dataEventOff) {
|
|
1255
|
+
dataEventOff.split(" ").forEach(function (event) {
|
|
1256
|
+
ele.removeEventListener(event, _this.hideTooltip);
|
|
1257
|
+
ele.addEventListener(event, _this.hideTooltip, false);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
/* Unbind listener for custom event */
|
|
1484
1262
|
|
|
1485
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1486
|
-
value: true
|
|
1487
|
-
});
|
|
1488
1263
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1264
|
+
target.prototype.customUnbindListener = function (ele) {
|
|
1265
|
+
var _this$state2 = this.state,
|
|
1266
|
+
event = _this$state2.event,
|
|
1267
|
+
eventOff = _this$state2.eventOff;
|
|
1268
|
+
var dataEvent = event || ele.getAttribute("data-event");
|
|
1269
|
+
var dataEventOff = eventOff || ele.getAttribute("data-event-off");
|
|
1270
|
+
ele.removeEventListener(dataEvent, customListeners.get(ele, event));
|
|
1271
|
+
if (dataEventOff) ele.removeEventListener(dataEventOff, this.hideTooltip);
|
|
1496
1272
|
};
|
|
1273
|
+
}
|
|
1497
1274
|
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
target.
|
|
1503
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Util method to judge if it should follow capture model
|
|
1277
|
+
*/
|
|
1278
|
+
function isCapture (target) {
|
|
1279
|
+
target.prototype.isCapture = function (currentTarget) {
|
|
1280
|
+
return currentTarget && currentTarget.getAttribute("data-iscapture") === "true" || this.props.isCapture || false;
|
|
1504
1281
|
};
|
|
1282
|
+
}
|
|
1505
1283
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
target.
|
|
1511
|
-
|
|
1284
|
+
/**
|
|
1285
|
+
* Util method to get effect
|
|
1286
|
+
*/
|
|
1287
|
+
function getEffect (target) {
|
|
1288
|
+
target.prototype.getEffect = function (currentTarget) {
|
|
1289
|
+
var dataEffect = currentTarget.getAttribute("data-effect");
|
|
1290
|
+
return dataEffect || this.props.effect || "float";
|
|
1512
1291
|
};
|
|
1292
|
+
}
|
|
1513
1293
|
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
this.bindListener();
|
|
1518
|
-
}
|
|
1519
|
-
};
|
|
1294
|
+
/**
|
|
1295
|
+
* Util method to get effect
|
|
1296
|
+
*/
|
|
1520
1297
|
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
// Create a fake event, specific show will limit the type to `solid`
|
|
1524
|
-
// only `float` type cares e.clientX e.clientY
|
|
1525
|
-
var e = { currentTarget: event.detail.target };
|
|
1526
|
-
this.showTooltip(e, true);
|
|
1527
|
-
}
|
|
1528
|
-
};
|
|
1298
|
+
var makeProxy = function makeProxy(e) {
|
|
1299
|
+
var proxy = {};
|
|
1529
1300
|
|
|
1530
|
-
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1533
|
-
|
|
1301
|
+
for (var key in e) {
|
|
1302
|
+
if (typeof e[key] === "function") {
|
|
1303
|
+
proxy[key] = e[key].bind(e);
|
|
1304
|
+
} else {
|
|
1305
|
+
proxy[key] = e[key];
|
|
1534
1306
|
}
|
|
1535
|
-
}
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
return proxy;
|
|
1536
1310
|
};
|
|
1537
1311
|
|
|
1538
|
-
var
|
|
1312
|
+
var bodyListener = function bodyListener(callback, options, e) {
|
|
1313
|
+
var _options$respectEffec = options.respectEffect,
|
|
1314
|
+
respectEffect = _options$respectEffec === void 0 ? false : _options$respectEffec,
|
|
1315
|
+
_options$customEvent = options.customEvent,
|
|
1316
|
+
customEvent = _options$customEvent === void 0 ? false : _options$customEvent;
|
|
1317
|
+
var id = this.props.id;
|
|
1318
|
+
var tip = e.target.getAttribute("data-tip") || null;
|
|
1319
|
+
var forId = e.target.getAttribute("data-for") || null;
|
|
1320
|
+
var target = e.target;
|
|
1539
1321
|
|
|
1540
|
-
|
|
1322
|
+
if (this.isCustomEvent(target) && !customEvent) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1541
1325
|
|
|
1542
|
-
|
|
1326
|
+
var isTargetBelongsToTooltip = id == null && forId == null || forId === id;
|
|
1543
1327
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
if (typeof window.CustomEvent === 'function') {
|
|
1550
|
-
event = new window.CustomEvent(eventName, { detail: opts });
|
|
1551
|
-
} else {
|
|
1552
|
-
event = document.createEvent('Event');
|
|
1553
|
-
event.initEvent(eventName, false, true);
|
|
1554
|
-
event.detail = opts;
|
|
1328
|
+
if (tip != null && (!respectEffect || this.getEffect(target) === "float") && isTargetBelongsToTooltip) {
|
|
1329
|
+
var proxy = makeProxy(e);
|
|
1330
|
+
proxy.currentTarget = target;
|
|
1331
|
+
callback(proxy);
|
|
1555
1332
|
}
|
|
1333
|
+
};
|
|
1556
1334
|
|
|
1557
|
-
|
|
1558
|
-
};
|
|
1559
|
-
|
|
1560
|
-
|
|
1335
|
+
var findCustomEvents = function findCustomEvents(targetArray, dataAttribute) {
|
|
1336
|
+
var events = {};
|
|
1337
|
+
targetArray.forEach(function (target) {
|
|
1338
|
+
var event = target.getAttribute(dataAttribute);
|
|
1339
|
+
if (event) event.split(" ").forEach(function (event) {
|
|
1340
|
+
return events[event] = true;
|
|
1341
|
+
});
|
|
1342
|
+
});
|
|
1343
|
+
return events;
|
|
1344
|
+
};
|
|
1561
1345
|
|
|
1562
|
-
|
|
1563
|
-
|
|
1346
|
+
var getBody = function getBody() {
|
|
1347
|
+
return document.getElementsByTagName("body")[0];
|
|
1348
|
+
};
|
|
1564
1349
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1350
|
+
function bodyMode (target) {
|
|
1351
|
+
target.prototype.isBodyMode = function () {
|
|
1352
|
+
return !!this.props.bodyMode;
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
target.prototype.bindBodyListener = function (targetArray) {
|
|
1356
|
+
var _this = this;
|
|
1357
|
+
|
|
1358
|
+
var _this$state = this.state,
|
|
1359
|
+
event = _this$state.event,
|
|
1360
|
+
eventOff = _this$state.eventOff,
|
|
1361
|
+
possibleCustomEvents = _this$state.possibleCustomEvents,
|
|
1362
|
+
possibleCustomEventsOff = _this$state.possibleCustomEventsOff;
|
|
1363
|
+
var body = getBody();
|
|
1364
|
+
var customEvents = findCustomEvents(targetArray, "data-event");
|
|
1365
|
+
var customEventsOff = findCustomEvents(targetArray, "data-event-off");
|
|
1366
|
+
if (event != null) customEvents[event] = true;
|
|
1367
|
+
if (eventOff != null) customEventsOff[eventOff] = true;
|
|
1368
|
+
possibleCustomEvents.split(" ").forEach(function (event) {
|
|
1369
|
+
return customEvents[event] = true;
|
|
1370
|
+
});
|
|
1371
|
+
possibleCustomEventsOff.split(" ").forEach(function (event) {
|
|
1372
|
+
return customEventsOff[event] = true;
|
|
1373
|
+
});
|
|
1374
|
+
this.unbindBodyListener(body);
|
|
1375
|
+
var listeners = this.bodyModeListeners = {};
|
|
1376
|
+
|
|
1377
|
+
if (event == null) {
|
|
1378
|
+
listeners.mouseover = bodyListener.bind(this, this.showTooltip, {});
|
|
1379
|
+
listeners.mousemove = bodyListener.bind(this, this.updateTooltip, {
|
|
1380
|
+
respectEffect: true
|
|
1381
|
+
});
|
|
1382
|
+
listeners.mouseout = bodyListener.bind(this, this.hideTooltip, {});
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
for (var _event in customEvents) {
|
|
1386
|
+
listeners[_event] = bodyListener.bind(this, function (e) {
|
|
1387
|
+
var targetEventOff = e.currentTarget.getAttribute("data-event-off") || eventOff;
|
|
1388
|
+
checkStatus.call(_this, targetEventOff, e);
|
|
1389
|
+
}, {
|
|
1390
|
+
customEvent: true
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
for (var _event2 in customEventsOff) {
|
|
1395
|
+
listeners[_event2] = bodyListener.bind(this, this.hideTooltip, {
|
|
1396
|
+
customEvent: true
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
for (var _event3 in listeners) {
|
|
1401
|
+
body.addEventListener(_event3, listeners[_event3]);
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
|
|
1405
|
+
target.prototype.unbindBodyListener = function (body) {
|
|
1406
|
+
body = body || getBody();
|
|
1407
|
+
var listeners = this.bodyModeListeners;
|
|
1408
|
+
|
|
1409
|
+
for (var event in listeners) {
|
|
1410
|
+
body.removeEventListener(event, listeners[event]);
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Tracking target removing from DOM.
|
|
1417
|
+
* It's necessary to hide tooltip when it's target disappears.
|
|
1418
|
+
* Otherwise, the tooltip would be shown forever until another target
|
|
1419
|
+
* is triggered.
|
|
1420
|
+
*
|
|
1421
|
+
* If MutationObserver is not available, this feature just doesn't work.
|
|
1422
|
+
*/
|
|
1423
|
+
// https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/
|
|
1424
|
+
var getMutationObserverClass = function getMutationObserverClass() {
|
|
1425
|
+
return window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
|
1426
|
+
};
|
|
1568
1427
|
|
|
1569
|
-
|
|
1428
|
+
function trackRemoval (target) {
|
|
1570
1429
|
target.prototype.bindRemovalTracker = function () {
|
|
1571
1430
|
var _this = this;
|
|
1572
1431
|
|
|
1573
1432
|
var MutationObserver = getMutationObserverClass();
|
|
1574
1433
|
if (MutationObserver == null) return;
|
|
1575
|
-
|
|
1576
1434
|
var observer = new MutationObserver(function (mutations) {
|
|
1577
1435
|
for (var m1 = 0; m1 < mutations.length; m1++) {
|
|
1578
1436
|
var mutation = mutations[m1];
|
|
1437
|
+
|
|
1579
1438
|
for (var m2 = 0; m2 < mutation.removedNodes.length; m2++) {
|
|
1580
1439
|
var element = mutation.removedNodes[m2];
|
|
1440
|
+
|
|
1581
1441
|
if (element === _this.state.currentTarget) {
|
|
1582
1442
|
_this.hideTooltip();
|
|
1443
|
+
|
|
1583
1444
|
return;
|
|
1584
1445
|
}
|
|
1585
1446
|
}
|
|
1586
1447
|
}
|
|
1587
1448
|
});
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1449
|
+
observer.observe(window.document, {
|
|
1450
|
+
childList: true,
|
|
1451
|
+
subtree: true
|
|
1452
|
+
});
|
|
1591
1453
|
this.removalTracker = observer;
|
|
1592
1454
|
};
|
|
1593
1455
|
|
|
@@ -1597,191 +1459,416 @@ exports.default = function (target) {
|
|
|
1597
1459
|
this.removalTracker = null;
|
|
1598
1460
|
}
|
|
1599
1461
|
};
|
|
1600
|
-
}
|
|
1462
|
+
}
|
|
1601
1463
|
|
|
1602
1464
|
/**
|
|
1603
|
-
*
|
|
1604
|
-
* It's necessary to hide tooltip when it's target disappears.
|
|
1605
|
-
* Otherwise, the tooltip would be shown forever until another target
|
|
1606
|
-
* is triggered.
|
|
1465
|
+
* Calculate the position of tooltip
|
|
1607
1466
|
*
|
|
1608
|
-
*
|
|
1467
|
+
* @params
|
|
1468
|
+
* - `e` {Event} the event of current mouse
|
|
1469
|
+
* - `target` {Element} the currentTarget of the event
|
|
1470
|
+
* - `node` {DOM} the react-tooltip object
|
|
1471
|
+
* - `place` {String} top / right / bottom / left
|
|
1472
|
+
* - `effect` {String} float / solid
|
|
1473
|
+
* - `offset` {Object} the offset to default position
|
|
1474
|
+
*
|
|
1475
|
+
* @return {Object}
|
|
1476
|
+
* - `isNewState` {Bool} required
|
|
1477
|
+
* - `newState` {Object}
|
|
1478
|
+
* - `position` {Object} {left: {Number}, top: {Number}}
|
|
1609
1479
|
*/
|
|
1480
|
+
function getPosition (e, target, node, place, desiredPlace, effect, offset) {
|
|
1481
|
+
var _getDimensions = getDimensions(node),
|
|
1482
|
+
tipWidth = _getDimensions.width,
|
|
1483
|
+
tipHeight = _getDimensions.height;
|
|
1610
1484
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
};
|
|
1485
|
+
var _getDimensions2 = getDimensions(target),
|
|
1486
|
+
targetWidth = _getDimensions2.width,
|
|
1487
|
+
targetHeight = _getDimensions2.height;
|
|
1615
1488
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1489
|
+
var _getCurrentOffset = getCurrentOffset(e, target, effect),
|
|
1490
|
+
mouseX = _getCurrentOffset.mouseX,
|
|
1491
|
+
mouseY = _getCurrentOffset.mouseY;
|
|
1618
1492
|
|
|
1619
|
-
|
|
1620
|
-
value: true
|
|
1621
|
-
});
|
|
1493
|
+
var defaultOffset = getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight);
|
|
1622
1494
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
window.removeEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide);
|
|
1627
|
-
window.addEventListener(_constant2.default.GLOBAL.HIDE, this.globalHide, false);
|
|
1495
|
+
var _calculateOffset = calculateOffset(offset),
|
|
1496
|
+
extraOffset_X = _calculateOffset.extraOffset_X,
|
|
1497
|
+
extraOffset_Y = _calculateOffset.extraOffset_Y;
|
|
1628
1498
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
window.addEventListener(_constant2.default.GLOBAL.REBUILD, this.globalRebuild, false);
|
|
1499
|
+
var windowWidth = window.innerWidth;
|
|
1500
|
+
var windowHeight = window.innerHeight;
|
|
1632
1501
|
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1502
|
+
var _getParent = getParent(node),
|
|
1503
|
+
parentTop = _getParent.parentTop,
|
|
1504
|
+
parentLeft = _getParent.parentLeft; // Get the edge offset of the tooltip
|
|
1636
1505
|
|
|
1637
|
-
// Resize
|
|
1638
|
-
if (resizeHide) {
|
|
1639
|
-
window.removeEventListener('resize', this.onWindowResize);
|
|
1640
|
-
window.addEventListener('resize', this.onWindowResize, false);
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
1643
1506
|
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
window.removeEventListener(_constant2.default.GLOBAL.SHOW, this.globalShow);
|
|
1648
|
-
window.removeEventListener('resize', this.onWindowResize);
|
|
1507
|
+
var getTipOffsetLeft = function getTipOffsetLeft(place) {
|
|
1508
|
+
var offset_X = defaultOffset[place].l;
|
|
1509
|
+
return mouseX + offset_X + extraOffset_X;
|
|
1649
1510
|
};
|
|
1650
1511
|
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
target.prototype.onWindowResize = function () {
|
|
1655
|
-
if (!this.mount) return;
|
|
1656
|
-
this.hideTooltip();
|
|
1512
|
+
var getTipOffsetRight = function getTipOffsetRight(place) {
|
|
1513
|
+
var offset_X = defaultOffset[place].r;
|
|
1514
|
+
return mouseX + offset_X + extraOffset_X;
|
|
1657
1515
|
};
|
|
1658
|
-
};
|
|
1659
|
-
|
|
1660
|
-
var _constant = require('../constant');
|
|
1661
|
-
|
|
1662
|
-
var _constant2 = _interopRequireDefault(_constant);
|
|
1663
|
-
|
|
1664
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1665
|
-
|
|
1666
|
-
},{"../constant":12}],20:[function(require,module,exports){
|
|
1667
|
-
(function (global){
|
|
1668
|
-
'use strict';
|
|
1669
|
-
|
|
1670
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1671
|
-
|
|
1672
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
1673
|
-
|
|
1674
|
-
var _class, _class2, _temp;
|
|
1675
|
-
|
|
1676
|
-
/* Decorators */
|
|
1677
|
-
|
|
1678
1516
|
|
|
1679
|
-
|
|
1517
|
+
var getTipOffsetTop = function getTipOffsetTop(place) {
|
|
1518
|
+
var offset_Y = defaultOffset[place].t;
|
|
1519
|
+
return mouseY + offset_Y + extraOffset_Y;
|
|
1520
|
+
};
|
|
1680
1521
|
|
|
1522
|
+
var getTipOffsetBottom = function getTipOffsetBottom(place) {
|
|
1523
|
+
var offset_Y = defaultOffset[place].b;
|
|
1524
|
+
return mouseY + offset_Y + extraOffset_Y;
|
|
1525
|
+
}; //
|
|
1526
|
+
// Functions to test whether the tooltip's sides are inside
|
|
1527
|
+
// the client window for a given orientation p
|
|
1528
|
+
//
|
|
1529
|
+
// _____________
|
|
1530
|
+
// | | <-- Right side
|
|
1531
|
+
// | p = 'left' |\
|
|
1532
|
+
// | |/ |\
|
|
1533
|
+
// |_____________| |_\ <-- Mouse
|
|
1534
|
+
// / \ |
|
|
1535
|
+
// |
|
|
1536
|
+
// |
|
|
1537
|
+
// Bottom side
|
|
1538
|
+
//
|
|
1681
1539
|
|
|
1682
|
-
/* CSS */
|
|
1683
1540
|
|
|
1541
|
+
var outsideLeft = function outsideLeft(p) {
|
|
1542
|
+
return getTipOffsetLeft(p) < 0;
|
|
1543
|
+
};
|
|
1684
1544
|
|
|
1685
|
-
var
|
|
1545
|
+
var outsideRight = function outsideRight(p) {
|
|
1546
|
+
return getTipOffsetRight(p) > windowWidth;
|
|
1547
|
+
};
|
|
1686
1548
|
|
|
1687
|
-
var
|
|
1549
|
+
var outsideTop = function outsideTop(p) {
|
|
1550
|
+
return getTipOffsetTop(p) < 0;
|
|
1551
|
+
};
|
|
1688
1552
|
|
|
1689
|
-
var
|
|
1553
|
+
var outsideBottom = function outsideBottom(p) {
|
|
1554
|
+
return getTipOffsetBottom(p) > windowHeight;
|
|
1555
|
+
}; // Check whether the tooltip with orientation p is completely inside the client window
|
|
1690
1556
|
|
|
1691
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
1692
1557
|
|
|
1693
|
-
var
|
|
1558
|
+
var outside = function outside(p) {
|
|
1559
|
+
return outsideLeft(p) || outsideRight(p) || outsideTop(p) || outsideBottom(p);
|
|
1560
|
+
};
|
|
1694
1561
|
|
|
1695
|
-
var
|
|
1562
|
+
var inside = function inside(p) {
|
|
1563
|
+
return !outside(p);
|
|
1564
|
+
};
|
|
1696
1565
|
|
|
1697
|
-
var
|
|
1566
|
+
var placesList = ["top", "bottom", "left", "right"];
|
|
1567
|
+
var insideList = [];
|
|
1698
1568
|
|
|
1699
|
-
var
|
|
1569
|
+
for (var i = 0; i < 4; i++) {
|
|
1570
|
+
var p = placesList[i];
|
|
1700
1571
|
|
|
1701
|
-
|
|
1572
|
+
if (inside(p)) {
|
|
1573
|
+
insideList.push(p);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1702
1576
|
|
|
1703
|
-
var
|
|
1577
|
+
var isNewState = false;
|
|
1578
|
+
var newPlace;
|
|
1579
|
+
var shouldUpdatePlace = desiredPlace !== place;
|
|
1704
1580
|
|
|
1705
|
-
|
|
1581
|
+
if (inside(desiredPlace) && shouldUpdatePlace) {
|
|
1582
|
+
isNewState = true;
|
|
1583
|
+
newPlace = desiredPlace;
|
|
1584
|
+
} else if (insideList.length > 0 && shouldUpdatePlace && outside(desiredPlace) && outside(place)) {
|
|
1585
|
+
isNewState = true;
|
|
1586
|
+
newPlace = insideList[0];
|
|
1587
|
+
}
|
|
1706
1588
|
|
|
1707
|
-
|
|
1589
|
+
if (isNewState) {
|
|
1590
|
+
return {
|
|
1591
|
+
isNewState: true,
|
|
1592
|
+
newState: {
|
|
1593
|
+
place: newPlace
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1708
1597
|
|
|
1709
|
-
|
|
1598
|
+
return {
|
|
1599
|
+
isNewState: false,
|
|
1600
|
+
position: {
|
|
1601
|
+
left: parseInt(getTipOffsetLeft(place) - parentLeft, 10),
|
|
1602
|
+
top: parseInt(getTipOffsetTop(place) - parentTop, 10)
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1710
1606
|
|
|
1711
|
-
var
|
|
1607
|
+
var getDimensions = function getDimensions(node) {
|
|
1608
|
+
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
1609
|
+
height = _node$getBoundingClie.height,
|
|
1610
|
+
width = _node$getBoundingClie.width;
|
|
1712
1611
|
|
|
1713
|
-
|
|
1612
|
+
return {
|
|
1613
|
+
height: parseInt(height, 10),
|
|
1614
|
+
width: parseInt(width, 10)
|
|
1615
|
+
};
|
|
1616
|
+
}; // Get current mouse offset
|
|
1714
1617
|
|
|
1715
|
-
var _getEffect2 = _interopRequireDefault(_getEffect);
|
|
1716
1618
|
|
|
1717
|
-
var
|
|
1619
|
+
var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
|
|
1620
|
+
var boundingClientRect = currentTarget.getBoundingClientRect();
|
|
1621
|
+
var targetTop = boundingClientRect.top;
|
|
1622
|
+
var targetLeft = boundingClientRect.left;
|
|
1718
1623
|
|
|
1719
|
-
var
|
|
1624
|
+
var _getDimensions3 = getDimensions(currentTarget),
|
|
1625
|
+
targetWidth = _getDimensions3.width,
|
|
1626
|
+
targetHeight = _getDimensions3.height;
|
|
1720
1627
|
|
|
1721
|
-
|
|
1628
|
+
if (effect === "float") {
|
|
1629
|
+
return {
|
|
1630
|
+
mouseX: e.clientX,
|
|
1631
|
+
mouseY: e.clientY
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1722
1634
|
|
|
1723
|
-
|
|
1635
|
+
return {
|
|
1636
|
+
mouseX: targetLeft + targetWidth / 2,
|
|
1637
|
+
mouseY: targetTop + targetHeight / 2
|
|
1638
|
+
};
|
|
1639
|
+
}; // List all possibility of tooltip final offset
|
|
1640
|
+
// This is useful in judging if it is necessary for tooltip to switch position when out of window
|
|
1724
1641
|
|
|
1725
|
-
var _getPosition = require('./utils/getPosition');
|
|
1726
1642
|
|
|
1727
|
-
var
|
|
1643
|
+
var getDefaultPosition = function getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight) {
|
|
1644
|
+
var top;
|
|
1645
|
+
var right;
|
|
1646
|
+
var bottom;
|
|
1647
|
+
var left;
|
|
1648
|
+
var disToMouse = 3;
|
|
1649
|
+
var triangleHeight = 2;
|
|
1650
|
+
var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip
|
|
1728
1651
|
|
|
1729
|
-
|
|
1652
|
+
if (effect === "float") {
|
|
1653
|
+
top = {
|
|
1654
|
+
l: -(tipWidth / 2),
|
|
1655
|
+
r: tipWidth / 2,
|
|
1656
|
+
t: -(tipHeight + disToMouse + triangleHeight),
|
|
1657
|
+
b: -disToMouse
|
|
1658
|
+
};
|
|
1659
|
+
bottom = {
|
|
1660
|
+
l: -(tipWidth / 2),
|
|
1661
|
+
r: tipWidth / 2,
|
|
1662
|
+
t: disToMouse + cursorHeight,
|
|
1663
|
+
b: tipHeight + disToMouse + triangleHeight + cursorHeight
|
|
1664
|
+
};
|
|
1665
|
+
left = {
|
|
1666
|
+
l: -(tipWidth + disToMouse + triangleHeight),
|
|
1667
|
+
r: -disToMouse,
|
|
1668
|
+
t: -(tipHeight / 2),
|
|
1669
|
+
b: tipHeight / 2
|
|
1670
|
+
};
|
|
1671
|
+
right = {
|
|
1672
|
+
l: disToMouse,
|
|
1673
|
+
r: tipWidth + disToMouse + triangleHeight,
|
|
1674
|
+
t: -(tipHeight / 2),
|
|
1675
|
+
b: tipHeight / 2
|
|
1676
|
+
};
|
|
1677
|
+
} else if (effect === "solid") {
|
|
1678
|
+
top = {
|
|
1679
|
+
l: -(tipWidth / 2),
|
|
1680
|
+
r: tipWidth / 2,
|
|
1681
|
+
t: -(targetHeight / 2 + tipHeight + triangleHeight),
|
|
1682
|
+
b: -(targetHeight / 2)
|
|
1683
|
+
};
|
|
1684
|
+
bottom = {
|
|
1685
|
+
l: -(tipWidth / 2),
|
|
1686
|
+
r: tipWidth / 2,
|
|
1687
|
+
t: targetHeight / 2,
|
|
1688
|
+
b: targetHeight / 2 + tipHeight + triangleHeight
|
|
1689
|
+
};
|
|
1690
|
+
left = {
|
|
1691
|
+
l: -(tipWidth + targetWidth / 2 + triangleHeight),
|
|
1692
|
+
r: -(targetWidth / 2),
|
|
1693
|
+
t: -(tipHeight / 2),
|
|
1694
|
+
b: tipHeight / 2
|
|
1695
|
+
};
|
|
1696
|
+
right = {
|
|
1697
|
+
l: targetWidth / 2,
|
|
1698
|
+
r: tipWidth + targetWidth / 2 + triangleHeight,
|
|
1699
|
+
t: -(tipHeight / 2),
|
|
1700
|
+
b: tipHeight / 2
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
return {
|
|
1705
|
+
top: top,
|
|
1706
|
+
bottom: bottom,
|
|
1707
|
+
left: left,
|
|
1708
|
+
right: right
|
|
1709
|
+
};
|
|
1710
|
+
}; // Consider additional offset into position calculation
|
|
1711
|
+
|
|
1712
|
+
|
|
1713
|
+
var calculateOffset = function calculateOffset(offset) {
|
|
1714
|
+
var extraOffset_X = 0;
|
|
1715
|
+
var extraOffset_Y = 0;
|
|
1716
|
+
|
|
1717
|
+
if (Object.prototype.toString.apply(offset) === "[object String]") {
|
|
1718
|
+
offset = JSON.parse(offset.toString().replace(/\'/g, '"'));
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
for (var key in offset) {
|
|
1722
|
+
if (key === "top") {
|
|
1723
|
+
extraOffset_Y -= parseInt(offset[key], 10);
|
|
1724
|
+
} else if (key === "bottom") {
|
|
1725
|
+
extraOffset_Y += parseInt(offset[key], 10);
|
|
1726
|
+
} else if (key === "left") {
|
|
1727
|
+
extraOffset_X -= parseInt(offset[key], 10);
|
|
1728
|
+
} else if (key === "right") {
|
|
1729
|
+
extraOffset_X += parseInt(offset[key], 10);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
return {
|
|
1734
|
+
extraOffset_X: extraOffset_X,
|
|
1735
|
+
extraOffset_Y: extraOffset_Y
|
|
1736
|
+
};
|
|
1737
|
+
}; // Get the offset of the parent elements
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
var getParent = function getParent(currentTarget) {
|
|
1741
|
+
var currentParent = currentTarget;
|
|
1742
|
+
|
|
1743
|
+
while (currentParent) {
|
|
1744
|
+
if (window.getComputedStyle(currentParent).getPropertyValue("transform") !== "none") break;
|
|
1745
|
+
currentParent = currentParent.parentElement;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
var parentTop = currentParent && currentParent.getBoundingClientRect().top || 0;
|
|
1749
|
+
var parentLeft = currentParent && currentParent.getBoundingClientRect().left || 0;
|
|
1750
|
+
return {
|
|
1751
|
+
parentTop: parentTop,
|
|
1752
|
+
parentLeft: parentLeft
|
|
1753
|
+
};
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* To get the tooltip content
|
|
1758
|
+
* it may comes from data-tip or this.props.children
|
|
1759
|
+
* it should support multiline
|
|
1760
|
+
*
|
|
1761
|
+
* @params
|
|
1762
|
+
* - `tip` {String} value of data-tip
|
|
1763
|
+
* - `children` {ReactElement} this.props.children
|
|
1764
|
+
* - `multiline` {Any} could be Bool(true/false) or String('true'/'false')
|
|
1765
|
+
*
|
|
1766
|
+
* @return
|
|
1767
|
+
* - String or react component
|
|
1768
|
+
*/
|
|
1769
|
+
function getTipContent (tip, children, getContent, multiline) {
|
|
1770
|
+
if (children) return children;
|
|
1771
|
+
if (getContent !== undefined && getContent !== null) return getContent; // getContent can be 0, '', etc.
|
|
1730
1772
|
|
|
1731
|
-
|
|
1773
|
+
if (getContent === null) return null; // Tip not exist and children is null or undefined
|
|
1774
|
+
|
|
1775
|
+
var regexp = /<br\s*\/?>/;
|
|
1732
1776
|
|
|
1733
|
-
|
|
1777
|
+
if (!multiline || multiline === "false" || !regexp.test(tip)) {
|
|
1778
|
+
// No trim(), so that user can keep their input
|
|
1779
|
+
return tip;
|
|
1780
|
+
} // Multiline tooltip content
|
|
1734
1781
|
|
|
1735
|
-
var _nodeListToArray = require('./utils/nodeListToArray');
|
|
1736
1782
|
|
|
1737
|
-
|
|
1783
|
+
return tip.split(regexp).map(function (d, i) {
|
|
1784
|
+
return React.createElement("span", {
|
|
1785
|
+
key: i,
|
|
1786
|
+
className: "multi-line"
|
|
1787
|
+
}, d);
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1738
1790
|
|
|
1739
|
-
|
|
1791
|
+
/**
|
|
1792
|
+
* Support aria- and role in ReactTooltip
|
|
1793
|
+
*
|
|
1794
|
+
* @params props {Object}
|
|
1795
|
+
* @return {Object}
|
|
1796
|
+
*/
|
|
1797
|
+
function parseAria(props) {
|
|
1798
|
+
var ariaObj = {};
|
|
1799
|
+
Object.keys(props).filter(function (prop) {
|
|
1800
|
+
// aria-xxx and role is acceptable
|
|
1801
|
+
return /(^aria-\w+$|^role$)/.test(prop);
|
|
1802
|
+
}).forEach(function (prop) {
|
|
1803
|
+
ariaObj[prop] = props[prop];
|
|
1804
|
+
});
|
|
1805
|
+
return ariaObj;
|
|
1806
|
+
}
|
|
1740
1807
|
|
|
1741
|
-
|
|
1808
|
+
/**
|
|
1809
|
+
* Convert nodelist to array
|
|
1810
|
+
* @see https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/core/createArrayFromMixed.js#L24
|
|
1811
|
+
* NodeLists are functions in Safari
|
|
1812
|
+
*/
|
|
1813
|
+
function nodeListToArray (nodeList) {
|
|
1814
|
+
var length = nodeList.length;
|
|
1742
1815
|
|
|
1743
|
-
|
|
1816
|
+
if (nodeList.hasOwnProperty) {
|
|
1817
|
+
return Array.prototype.slice.call(nodeList);
|
|
1818
|
+
}
|
|
1744
1819
|
|
|
1745
|
-
|
|
1820
|
+
return new Array(length).fill().map(function (index) {
|
|
1821
|
+
return nodeList[index];
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1746
1824
|
|
|
1747
|
-
|
|
1825
|
+
___$insertStyle(".__react_component_tooltip {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n left: -999em;\n opacity: 0;\n padding: 8px 21px;\n position: fixed;\n pointer-events: none;\n transition: opacity 0.3s ease-out;\n top: -999em;\n visibility: hidden;\n z-index: 999;\n}\n.__react_component_tooltip.allow_hover, .__react_component_tooltip.allow_click {\n pointer-events: auto;\n}\n.__react_component_tooltip:before, .__react_component_tooltip:after {\n content: \"\";\n width: 0;\n height: 0;\n position: absolute;\n}\n.__react_component_tooltip.show {\n opacity: 0.9;\n margin-top: 0px;\n margin-left: 0px;\n visibility: visible;\n}\n.__react_component_tooltip.type-dark {\n color: #fff;\n background-color: #222;\n}\n.__react_component_tooltip.type-dark.place-top:after {\n border-top-color: #222;\n border-top-style: solid;\n border-top-width: 6px;\n}\n.__react_component_tooltip.type-dark.place-bottom:after {\n border-bottom-color: #222;\n border-bottom-style: solid;\n border-bottom-width: 6px;\n}\n.__react_component_tooltip.type-dark.place-left:after {\n border-left-color: #222;\n border-left-style: solid;\n border-left-width: 6px;\n}\n.__react_component_tooltip.type-dark.place-right:after {\n border-right-color: #222;\n border-right-style: solid;\n border-right-width: 6px;\n}\n.__react_component_tooltip.type-dark.border {\n border: 1px solid #fff;\n}\n.__react_component_tooltip.type-dark.border.place-top:before {\n border-top: 8px solid #fff;\n}\n.__react_component_tooltip.type-dark.border.place-bottom:before {\n border-bottom: 8px solid #fff;\n}\n.__react_component_tooltip.type-dark.border.place-left:before {\n border-left: 8px solid #fff;\n}\n.__react_component_tooltip.type-dark.border.place-right:before {\n border-right: 8px solid #fff;\n}\n.__react_component_tooltip.type-success {\n color: #fff;\n background-color: #8DC572;\n}\n.__react_component_tooltip.type-success.place-top:after {\n border-top-color: #8DC572;\n border-top-style: solid;\n border-top-width: 6px;\n}\n.__react_component_tooltip.type-success.place-bottom:after {\n border-bottom-color: #8DC572;\n border-bottom-style: solid;\n border-bottom-width: 6px;\n}\n.__react_component_tooltip.type-success.place-left:after {\n border-left-color: #8DC572;\n border-left-style: solid;\n border-left-width: 6px;\n}\n.__react_component_tooltip.type-success.place-right:after {\n border-right-color: #8DC572;\n border-right-style: solid;\n border-right-width: 6px;\n}\n.__react_component_tooltip.type-success.border {\n border: 1px solid #fff;\n}\n.__react_component_tooltip.type-success.border.place-top:before {\n border-top: 8px solid #fff;\n}\n.__react_component_tooltip.type-success.border.place-bottom:before {\n border-bottom: 8px solid #fff;\n}\n.__react_component_tooltip.type-success.border.place-left:before {\n border-left: 8px solid #fff;\n}\n.__react_component_tooltip.type-success.border.place-right:before {\n border-right: 8px solid #fff;\n}\n.__react_component_tooltip.type-warning {\n color: #fff;\n background-color: #F0AD4E;\n}\n.__react_component_tooltip.type-warning.place-top:after {\n border-top-color: #F0AD4E;\n border-top-style: solid;\n border-top-width: 6px;\n}\n.__react_component_tooltip.type-warning.place-bottom:after {\n border-bottom-color: #F0AD4E;\n border-bottom-style: solid;\n border-bottom-width: 6px;\n}\n.__react_component_tooltip.type-warning.place-left:after {\n border-left-color: #F0AD4E;\n border-left-style: solid;\n border-left-width: 6px;\n}\n.__react_component_tooltip.type-warning.place-right:after {\n border-right-color: #F0AD4E;\n border-right-style: solid;\n border-right-width: 6px;\n}\n.__react_component_tooltip.type-warning.border {\n border: 1px solid #fff;\n}\n.__react_component_tooltip.type-warning.border.place-top:before {\n border-top: 8px solid #fff;\n}\n.__react_component_tooltip.type-warning.border.place-bottom:before {\n border-bottom: 8px solid #fff;\n}\n.__react_component_tooltip.type-warning.border.place-left:before {\n border-left: 8px solid #fff;\n}\n.__react_component_tooltip.type-warning.border.place-right:before {\n border-right: 8px solid #fff;\n}\n.__react_component_tooltip.type-error {\n color: #fff;\n background-color: #BE6464;\n}\n.__react_component_tooltip.type-error.place-top:after {\n border-top-color: #BE6464;\n border-top-style: solid;\n border-top-width: 6px;\n}\n.__react_component_tooltip.type-error.place-bottom:after {\n border-bottom-color: #BE6464;\n border-bottom-style: solid;\n border-bottom-width: 6px;\n}\n.__react_component_tooltip.type-error.place-left:after {\n border-left-color: #BE6464;\n border-left-style: solid;\n border-left-width: 6px;\n}\n.__react_component_tooltip.type-error.place-right:after {\n border-right-color: #BE6464;\n border-right-style: solid;\n border-right-width: 6px;\n}\n.__react_component_tooltip.type-error.border {\n border: 1px solid #fff;\n}\n.__react_component_tooltip.type-error.border.place-top:before {\n border-top: 8px solid #fff;\n}\n.__react_component_tooltip.type-error.border.place-bottom:before {\n border-bottom: 8px solid #fff;\n}\n.__react_component_tooltip.type-error.border.place-left:before {\n border-left: 8px solid #fff;\n}\n.__react_component_tooltip.type-error.border.place-right:before {\n border-right: 8px solid #fff;\n}\n.__react_component_tooltip.type-info {\n color: #fff;\n background-color: #337AB7;\n}\n.__react_component_tooltip.type-info.place-top:after {\n border-top-color: #337AB7;\n border-top-style: solid;\n border-top-width: 6px;\n}\n.__react_component_tooltip.type-info.place-bottom:after {\n border-bottom-color: #337AB7;\n border-bottom-style: solid;\n border-bottom-width: 6px;\n}\n.__react_component_tooltip.type-info.place-left:after {\n border-left-color: #337AB7;\n border-left-style: solid;\n border-left-width: 6px;\n}\n.__react_component_tooltip.type-info.place-right:after {\n border-right-color: #337AB7;\n border-right-style: solid;\n border-right-width: 6px;\n}\n.__react_component_tooltip.type-info.border {\n border: 1px solid #fff;\n}\n.__react_component_tooltip.type-info.border.place-top:before {\n border-top: 8px solid #fff;\n}\n.__react_component_tooltip.type-info.border.place-bottom:before {\n border-bottom: 8px solid #fff;\n}\n.__react_component_tooltip.type-info.border.place-left:before {\n border-left: 8px solid #fff;\n}\n.__react_component_tooltip.type-info.border.place-right:before {\n border-right: 8px solid #fff;\n}\n.__react_component_tooltip.type-light {\n color: #222;\n background-color: #fff;\n}\n.__react_component_tooltip.type-light.place-top:after {\n border-top-color: #fff;\n border-top-style: solid;\n border-top-width: 6px;\n}\n.__react_component_tooltip.type-light.place-bottom:after {\n border-bottom-color: #fff;\n border-bottom-style: solid;\n border-bottom-width: 6px;\n}\n.__react_component_tooltip.type-light.place-left:after {\n border-left-color: #fff;\n border-left-style: solid;\n border-left-width: 6px;\n}\n.__react_component_tooltip.type-light.place-right:after {\n border-right-color: #fff;\n border-right-style: solid;\n border-right-width: 6px;\n}\n.__react_component_tooltip.type-light.border {\n border: 1px solid #222;\n}\n.__react_component_tooltip.type-light.border.place-top:before {\n border-top: 8px solid #222;\n}\n.__react_component_tooltip.type-light.border.place-bottom:before {\n border-bottom: 8px solid #222;\n}\n.__react_component_tooltip.type-light.border.place-left:before {\n border-left: 8px solid #222;\n}\n.__react_component_tooltip.type-light.border.place-right:before {\n border-right: 8px solid #222;\n}\n.__react_component_tooltip.place-top {\n margin-top: -10px;\n}\n.__react_component_tooltip.place-top:before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n bottom: -8px;\n left: 50%;\n margin-left: -10px;\n}\n.__react_component_tooltip.place-top:after {\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n bottom: -6px;\n left: 50%;\n margin-left: -8px;\n}\n.__react_component_tooltip.place-bottom {\n margin-top: 10px;\n}\n.__react_component_tooltip.place-bottom:before {\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n top: -8px;\n left: 50%;\n margin-left: -10px;\n}\n.__react_component_tooltip.place-bottom:after {\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n top: -6px;\n left: 50%;\n margin-left: -8px;\n}\n.__react_component_tooltip.place-left {\n margin-left: -10px;\n}\n.__react_component_tooltip.place-left:before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n right: -8px;\n top: 50%;\n margin-top: -5px;\n}\n.__react_component_tooltip.place-left:after {\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n right: -6px;\n top: 50%;\n margin-top: -4px;\n}\n.__react_component_tooltip.place-right {\n margin-left: 10px;\n}\n.__react_component_tooltip.place-right:before {\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n left: -8px;\n top: 50%;\n margin-top: -5px;\n}\n.__react_component_tooltip.place-right:after {\n border-top: 5px solid transparent;\n border-bottom: 5px solid transparent;\n left: -6px;\n top: 50%;\n margin-top: -4px;\n}\n.__react_component_tooltip .multi-line {\n display: block;\n padding: 2px 0px;\n text-align: center;\n}");
|
|
1748
1826
|
|
|
1749
|
-
|
|
1827
|
+
var _class, _class2, _temp;
|
|
1750
1828
|
|
|
1751
|
-
var ReactTooltip = (
|
|
1829
|
+
var ReactTooltip = staticMethods(_class = windowListener(_class = customEvent(_class = isCapture(_class = getEffect(_class = bodyMode(_class = trackRemoval(_class = (_temp = _class2 =
|
|
1830
|
+
/*#__PURE__*/
|
|
1831
|
+
function (_React$Component) {
|
|
1752
1832
|
_inherits(ReactTooltip, _React$Component);
|
|
1753
1833
|
|
|
1754
1834
|
function ReactTooltip(props) {
|
|
1755
|
-
|
|
1835
|
+
var _this;
|
|
1756
1836
|
|
|
1757
|
-
|
|
1837
|
+
_classCallCheck(this, ReactTooltip);
|
|
1758
1838
|
|
|
1839
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactTooltip).call(this, props));
|
|
1759
1840
|
_this.state = {
|
|
1760
|
-
place: props.place ||
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1841
|
+
place: props.place || "top",
|
|
1842
|
+
// Direction of tooltip
|
|
1843
|
+
desiredPlace: props.place || "top",
|
|
1844
|
+
type: "dark",
|
|
1845
|
+
// Color theme of tooltip
|
|
1846
|
+
effect: "float",
|
|
1847
|
+
// float or fixed
|
|
1764
1848
|
show: false,
|
|
1765
1849
|
border: false,
|
|
1766
1850
|
offset: {},
|
|
1767
|
-
extraClass:
|
|
1851
|
+
extraClass: "",
|
|
1768
1852
|
html: false,
|
|
1769
1853
|
delayHide: 0,
|
|
1770
1854
|
delayShow: 0,
|
|
1771
1855
|
event: props.event || null,
|
|
1772
1856
|
eventOff: props.eventOff || null,
|
|
1773
|
-
currentEvent: null,
|
|
1774
|
-
|
|
1775
|
-
|
|
1857
|
+
currentEvent: null,
|
|
1858
|
+
// Current mouse event
|
|
1859
|
+
currentTarget: null,
|
|
1860
|
+
// Current target of mouse event
|
|
1861
|
+
ariaProps: parseAria(props),
|
|
1862
|
+
// aria- and role attributes
|
|
1776
1863
|
isEmptyTip: false,
|
|
1777
1864
|
disable: false,
|
|
1778
|
-
possibleCustomEvents: props.possibleCustomEvents ||
|
|
1779
|
-
possibleCustomEventsOff: props.possibleCustomEventsOff ||
|
|
1865
|
+
possibleCustomEvents: props.possibleCustomEvents || "",
|
|
1866
|
+
possibleCustomEventsOff: props.possibleCustomEventsOff || "",
|
|
1780
1867
|
originTooltip: null,
|
|
1781
1868
|
isMultiline: false
|
|
1782
1869
|
};
|
|
1783
1870
|
|
|
1784
|
-
_this.bind([
|
|
1871
|
+
_this.bind(["showTooltip", "updateTooltip", "hideTooltip", "hideTooltipOnScroll", "getTooltipContent", "globalRebuild", "globalShow", "globalHide", "onWindowResize", "mouseOnToolTip"]);
|
|
1785
1872
|
|
|
1786
1873
|
_this.mount = true;
|
|
1787
1874
|
_this.delayShowLoop = null;
|
|
@@ -1790,14 +1877,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1790
1877
|
_this.intervalUpdateContent = null;
|
|
1791
1878
|
return _this;
|
|
1792
1879
|
}
|
|
1793
|
-
|
|
1794
1880
|
/**
|
|
1795
1881
|
* For unify the bind and unbind listener
|
|
1796
1882
|
*/
|
|
1797
1883
|
|
|
1798
1884
|
|
|
1799
1885
|
_createClass(ReactTooltip, [{
|
|
1800
|
-
key:
|
|
1886
|
+
key: "bind",
|
|
1801
1887
|
value: function bind(methodArray) {
|
|
1802
1888
|
var _this2 = this;
|
|
1803
1889
|
|
|
@@ -1806,42 +1892,35 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1806
1892
|
});
|
|
1807
1893
|
}
|
|
1808
1894
|
}, {
|
|
1809
|
-
key:
|
|
1895
|
+
key: "componentDidMount",
|
|
1810
1896
|
value: function componentDidMount() {
|
|
1811
|
-
var
|
|
1812
|
-
insecure =
|
|
1813
|
-
resizeHide =
|
|
1814
|
-
|
|
1815
|
-
if (insecure) {
|
|
1816
|
-
this.setStyleHeader(); // Set the style to the <link>
|
|
1817
|
-
}
|
|
1897
|
+
var _this$props = this.props,
|
|
1898
|
+
insecure = _this$props.insecure,
|
|
1899
|
+
resizeHide = _this$props.resizeHide;
|
|
1818
1900
|
|
|
1819
1901
|
this.bindListener(); // Bind listener for tooltip
|
|
1902
|
+
|
|
1820
1903
|
this.bindWindowEvents(resizeHide); // Bind global event for static method
|
|
1821
1904
|
}
|
|
1822
1905
|
}, {
|
|
1823
|
-
key:
|
|
1906
|
+
key: "componentWillUnmount",
|
|
1824
1907
|
value: function componentWillUnmount() {
|
|
1825
1908
|
this.mount = false;
|
|
1826
|
-
|
|
1827
1909
|
this.clearTimer();
|
|
1828
|
-
|
|
1829
1910
|
this.unbindListener();
|
|
1830
1911
|
this.removeScrollListener();
|
|
1831
1912
|
this.unbindWindowEvents();
|
|
1832
1913
|
}
|
|
1833
|
-
|
|
1834
1914
|
/**
|
|
1835
1915
|
* Return if the mouse is on the tooltip.
|
|
1836
1916
|
* @returns {boolean} true - mouse is on the tooltip
|
|
1837
1917
|
*/
|
|
1838
1918
|
|
|
1839
1919
|
}, {
|
|
1840
|
-
key:
|
|
1920
|
+
key: "mouseOnToolTip",
|
|
1841
1921
|
value: function mouseOnToolTip() {
|
|
1842
1922
|
var show = this.state.show;
|
|
1843
1923
|
|
|
1844
|
-
|
|
1845
1924
|
if (show && this.tooltipRef) {
|
|
1846
1925
|
/* old IE or Firefox work around */
|
|
1847
1926
|
if (!this.tooltipRef.matches) {
|
|
@@ -1853,8 +1932,10 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1853
1932
|
this.tooltipRef.matches = this.tooltipRef.mozMatchesSelector;
|
|
1854
1933
|
}
|
|
1855
1934
|
}
|
|
1856
|
-
|
|
1935
|
+
|
|
1936
|
+
return this.tooltipRef.matches(":hover");
|
|
1857
1937
|
}
|
|
1938
|
+
|
|
1858
1939
|
return false;
|
|
1859
1940
|
}
|
|
1860
1941
|
/**
|
|
@@ -1862,41 +1943,42 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1862
1943
|
*/
|
|
1863
1944
|
|
|
1864
1945
|
}, {
|
|
1865
|
-
key:
|
|
1946
|
+
key: "getTargetArray",
|
|
1866
1947
|
value: function getTargetArray(id) {
|
|
1867
|
-
var targetArray
|
|
1948
|
+
var targetArray;
|
|
1949
|
+
|
|
1868
1950
|
if (!id) {
|
|
1869
|
-
targetArray = document.querySelectorAll(
|
|
1951
|
+
targetArray = document.querySelectorAll("[data-tip]:not([data-for])");
|
|
1870
1952
|
} else {
|
|
1871
|
-
var escaped = id.replace(/\\/g,
|
|
1872
|
-
targetArray = document.querySelectorAll(
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
return (0, _nodeListToArray2.default)(targetArray);
|
|
1876
|
-
}
|
|
1953
|
+
var escaped = id.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1954
|
+
targetArray = document.querySelectorAll("[data-tip][data-for=\"".concat(escaped, "\"]"));
|
|
1955
|
+
} // targetArray is a NodeList, convert it to a real array
|
|
1956
|
+
|
|
1877
1957
|
|
|
1958
|
+
return nodeListToArray(targetArray);
|
|
1959
|
+
}
|
|
1878
1960
|
/**
|
|
1879
1961
|
* Bind listener to the target elements
|
|
1880
1962
|
* These listeners used to trigger showing or hiding the tooltip
|
|
1881
1963
|
*/
|
|
1882
1964
|
|
|
1883
1965
|
}, {
|
|
1884
|
-
key:
|
|
1966
|
+
key: "bindListener",
|
|
1885
1967
|
value: function bindListener() {
|
|
1886
1968
|
var _this3 = this;
|
|
1887
1969
|
|
|
1888
|
-
var
|
|
1889
|
-
id =
|
|
1890
|
-
globalEventOff =
|
|
1891
|
-
isCapture =
|
|
1892
|
-
|
|
1970
|
+
var _this$props2 = this.props,
|
|
1971
|
+
id = _this$props2.id,
|
|
1972
|
+
globalEventOff = _this$props2.globalEventOff,
|
|
1973
|
+
isCapture = _this$props2.isCapture;
|
|
1893
1974
|
var targetArray = this.getTargetArray(id);
|
|
1894
|
-
|
|
1895
1975
|
targetArray.forEach(function (target) {
|
|
1896
|
-
if (target.getAttribute(
|
|
1897
|
-
target.setAttribute(
|
|
1976
|
+
if (target.getAttribute("currentItem") === null) {
|
|
1977
|
+
target.setAttribute("currentItem", "false");
|
|
1898
1978
|
}
|
|
1979
|
+
|
|
1899
1980
|
_this3.unbindBasicListener(target);
|
|
1981
|
+
|
|
1900
1982
|
if (_this3.isCustomEvent(target)) {
|
|
1901
1983
|
_this3.customUnbindListener(target);
|
|
1902
1984
|
}
|
|
@@ -1907,42 +1989,46 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1907
1989
|
} else {
|
|
1908
1990
|
targetArray.forEach(function (target) {
|
|
1909
1991
|
var isCaptureMode = _this3.isCapture(target);
|
|
1992
|
+
|
|
1910
1993
|
var effect = _this3.getEffect(target);
|
|
1994
|
+
|
|
1911
1995
|
if (_this3.isCustomEvent(target)) {
|
|
1912
1996
|
_this3.customBindListener(target);
|
|
1997
|
+
|
|
1913
1998
|
return;
|
|
1914
1999
|
}
|
|
1915
2000
|
|
|
1916
|
-
target.addEventListener(
|
|
1917
|
-
|
|
1918
|
-
|
|
2001
|
+
target.addEventListener("mouseenter", _this3.showTooltip, isCaptureMode);
|
|
2002
|
+
|
|
2003
|
+
if (effect === "float") {
|
|
2004
|
+
target.addEventListener("mousemove", _this3.updateTooltip, isCaptureMode);
|
|
1919
2005
|
}
|
|
1920
|
-
|
|
2006
|
+
|
|
2007
|
+
target.addEventListener("mouseleave", _this3.hideTooltip, isCaptureMode);
|
|
1921
2008
|
});
|
|
1922
|
-
}
|
|
2009
|
+
} // Global event to hide tooltip
|
|
2010
|
+
|
|
1923
2011
|
|
|
1924
|
-
// Global event to hide tooltip
|
|
1925
2012
|
if (globalEventOff) {
|
|
1926
2013
|
window.removeEventListener(globalEventOff, this.hideTooltip);
|
|
1927
2014
|
window.addEventListener(globalEventOff, this.hideTooltip, isCapture);
|
|
1928
|
-
}
|
|
2015
|
+
} // Track removal of targetArray elements from DOM
|
|
2016
|
+
|
|
1929
2017
|
|
|
1930
|
-
// Track removal of targetArray elements from DOM
|
|
1931
2018
|
this.bindRemovalTracker();
|
|
1932
2019
|
}
|
|
1933
|
-
|
|
1934
2020
|
/**
|
|
1935
2021
|
* Unbind listeners on target elements
|
|
1936
2022
|
*/
|
|
1937
2023
|
|
|
1938
2024
|
}, {
|
|
1939
|
-
key:
|
|
2025
|
+
key: "unbindListener",
|
|
1940
2026
|
value: function unbindListener() {
|
|
1941
2027
|
var _this4 = this;
|
|
1942
2028
|
|
|
1943
|
-
var
|
|
1944
|
-
id =
|
|
1945
|
-
globalEventOff =
|
|
2029
|
+
var _this$props3 = this.props,
|
|
2030
|
+
id = _this$props3.id,
|
|
2031
|
+
globalEventOff = _this$props3.globalEventOff;
|
|
1946
2032
|
|
|
1947
2033
|
if (this.isBodyMode()) {
|
|
1948
2034
|
this.unbindBodyListener();
|
|
@@ -1950,6 +2036,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1950
2036
|
var targetArray = this.getTargetArray(id);
|
|
1951
2037
|
targetArray.forEach(function (target) {
|
|
1952
2038
|
_this4.unbindBasicListener(target);
|
|
2039
|
+
|
|
1953
2040
|
if (_this4.isCustomEvent(target)) _this4.customUnbindListener(target);
|
|
1954
2041
|
});
|
|
1955
2042
|
}
|
|
@@ -1957,7 +2044,6 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1957
2044
|
if (globalEventOff) window.removeEventListener(globalEventOff, this.hideTooltip);
|
|
1958
2045
|
this.unbindRemovalTracker();
|
|
1959
2046
|
}
|
|
1960
|
-
|
|
1961
2047
|
/**
|
|
1962
2048
|
* Invoke this before bind listener and unmount the component
|
|
1963
2049
|
* it is necessary to invoke this even when binding custom event
|
|
@@ -1965,23 +2051,22 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1965
2051
|
*/
|
|
1966
2052
|
|
|
1967
2053
|
}, {
|
|
1968
|
-
key:
|
|
2054
|
+
key: "unbindBasicListener",
|
|
1969
2055
|
value: function unbindBasicListener(target) {
|
|
1970
2056
|
var isCaptureMode = this.isCapture(target);
|
|
1971
|
-
target.removeEventListener(
|
|
1972
|
-
target.removeEventListener(
|
|
1973
|
-
target.removeEventListener(
|
|
2057
|
+
target.removeEventListener("mouseenter", this.showTooltip, isCaptureMode);
|
|
2058
|
+
target.removeEventListener("mousemove", this.updateTooltip, isCaptureMode);
|
|
2059
|
+
target.removeEventListener("mouseleave", this.hideTooltip, isCaptureMode);
|
|
1974
2060
|
}
|
|
1975
2061
|
}, {
|
|
1976
|
-
key:
|
|
2062
|
+
key: "getTooltipContent",
|
|
1977
2063
|
value: function getTooltipContent() {
|
|
1978
|
-
var
|
|
1979
|
-
getContent =
|
|
1980
|
-
children =
|
|
2064
|
+
var _this$props4 = this.props,
|
|
2065
|
+
getContent = _this$props4.getContent,
|
|
2066
|
+
children = _this$props4.children; // Generate tooltip content
|
|
1981
2067
|
|
|
1982
|
-
|
|
2068
|
+
var content;
|
|
1983
2069
|
|
|
1984
|
-
var content = void 0;
|
|
1985
2070
|
if (getContent) {
|
|
1986
2071
|
if (Array.isArray(getContent)) {
|
|
1987
2072
|
content = getContent[0] && getContent[0](this.state.originTooltip);
|
|
@@ -1990,20 +2075,19 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
1990
2075
|
}
|
|
1991
2076
|
}
|
|
1992
2077
|
|
|
1993
|
-
return (
|
|
2078
|
+
return getTipContent(this.state.originTooltip, children, content, this.state.isMultiline);
|
|
1994
2079
|
}
|
|
1995
2080
|
}, {
|
|
1996
|
-
key:
|
|
2081
|
+
key: "isEmptyTip",
|
|
1997
2082
|
value: function isEmptyTip(placeholder) {
|
|
1998
|
-
return typeof placeholder ===
|
|
2083
|
+
return typeof placeholder === "string" && placeholder === "" || placeholder === null;
|
|
1999
2084
|
}
|
|
2000
|
-
|
|
2001
2085
|
/**
|
|
2002
2086
|
* When mouse enter, show the tooltip
|
|
2003
2087
|
*/
|
|
2004
2088
|
|
|
2005
2089
|
}, {
|
|
2006
|
-
key:
|
|
2090
|
+
key: "showTooltip",
|
|
2007
2091
|
value: function showTooltip(e, isGlobalCall) {
|
|
2008
2092
|
if (isGlobalCall) {
|
|
2009
2093
|
// Don't trigger other elements belongs to other ReactTooltip
|
|
@@ -2012,45 +2096,41 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2012
2096
|
return ele === e.currentTarget;
|
|
2013
2097
|
});
|
|
2014
2098
|
if (!isMyElement) return;
|
|
2015
|
-
}
|
|
2016
|
-
// Get the tooltip content
|
|
2099
|
+
} // Get the tooltip content
|
|
2017
2100
|
// calculate in this phrase so that tip width height can be detected
|
|
2018
|
-
var _props5 = this.props,
|
|
2019
|
-
multiline = _props5.multiline,
|
|
2020
|
-
getContent = _props5.getContent;
|
|
2021
2101
|
|
|
2022
|
-
var originTooltip = e.currentTarget.getAttribute('data-tip');
|
|
2023
|
-
var isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false;
|
|
2024
2102
|
|
|
2025
|
-
|
|
2026
|
-
|
|
2103
|
+
var _this$props5 = this.props,
|
|
2104
|
+
multiline = _this$props5.multiline,
|
|
2105
|
+
getContent = _this$props5.getContent;
|
|
2106
|
+
var originTooltip = e.currentTarget.getAttribute("data-tip");
|
|
2107
|
+
var isMultiline = e.currentTarget.getAttribute("data-multiline") || multiline || false; // If it is focus event or called by ReactTooltip.show, switch to `solid` effect
|
|
2108
|
+
|
|
2109
|
+
var switchToSolid = e instanceof window.FocusEvent || isGlobalCall; // if it needs to skip adding hide listener to scroll
|
|
2027
2110
|
|
|
2028
|
-
// if it needs to skip adding hide listener to scroll
|
|
2029
2111
|
var scrollHide = true;
|
|
2030
|
-
|
|
2031
|
-
|
|
2112
|
+
|
|
2113
|
+
if (e.currentTarget.getAttribute("data-scroll-hide")) {
|
|
2114
|
+
scrollHide = e.currentTarget.getAttribute("data-scroll-hide") === "true";
|
|
2032
2115
|
} else if (this.props.scrollHide != null) {
|
|
2033
2116
|
scrollHide = this.props.scrollHide;
|
|
2034
|
-
}
|
|
2117
|
+
} // Make sure the correct place is set
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
var desiredPlace = e.currentTarget.getAttribute("data-place") || this.props.place || "top";
|
|
2121
|
+
var effect = switchToSolid && "solid" || this.getEffect(e.currentTarget);
|
|
2122
|
+
var offset = e.currentTarget.getAttribute("data-offset") || this.props.offset || {};
|
|
2123
|
+
var result = getPosition(e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
2035
2124
|
|
|
2036
|
-
// Make sure the correct place is set
|
|
2037
|
-
var desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top';
|
|
2038
|
-
var effect = switchToSolid && 'solid' || this.getEffect(e.currentTarget);
|
|
2039
|
-
var offset = e.currentTarget.getAttribute('data-offset') || this.props.offset || {};
|
|
2040
|
-
var result = (0, _getPosition2.default)(e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
2041
2125
|
if (result.position && this.props.overridePosition) {
|
|
2042
2126
|
result.position = this.props.overridePosition(result.position, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
2043
2127
|
}
|
|
2044
2128
|
|
|
2045
|
-
var place = result.isNewState ? result.newState.place : desiredPlace;
|
|
2129
|
+
var place = result.isNewState ? result.newState.place : desiredPlace; // To prevent previously created timers from triggering
|
|
2046
2130
|
|
|
2047
|
-
// To prevent previously created timers from triggering
|
|
2048
2131
|
this.clearTimer();
|
|
2049
|
-
|
|
2050
2132
|
var target = e.currentTarget;
|
|
2051
|
-
|
|
2052
|
-
var reshowDelay = this.state.show ? target.getAttribute('data-delay-update') || this.props.delayUpdate : 0;
|
|
2053
|
-
|
|
2133
|
+
var reshowDelay = this.state.show ? target.getAttribute("data-delay-update") || this.props.delayUpdate : 0;
|
|
2054
2134
|
var self = this;
|
|
2055
2135
|
|
|
2056
2136
|
var updateState = function updateState() {
|
|
@@ -2059,16 +2139,16 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2059
2139
|
isMultiline: isMultiline,
|
|
2060
2140
|
desiredPlace: desiredPlace,
|
|
2061
2141
|
place: place,
|
|
2062
|
-
type: target.getAttribute(
|
|
2142
|
+
type: target.getAttribute("data-type") || self.props.type || "dark",
|
|
2063
2143
|
effect: effect,
|
|
2064
2144
|
offset: offset,
|
|
2065
|
-
html: target.getAttribute(
|
|
2066
|
-
delayShow: target.getAttribute(
|
|
2067
|
-
delayHide: target.getAttribute(
|
|
2068
|
-
delayUpdate: target.getAttribute(
|
|
2069
|
-
border: target.getAttribute(
|
|
2070
|
-
extraClass: target.getAttribute(
|
|
2071
|
-
disable: target.getAttribute(
|
|
2145
|
+
html: target.getAttribute("data-html") ? target.getAttribute("data-html") === "true" : self.props.html || false,
|
|
2146
|
+
delayShow: target.getAttribute("data-delay-show") || self.props.delayShow || 0,
|
|
2147
|
+
delayHide: target.getAttribute("data-delay-hide") || self.props.delayHide || 0,
|
|
2148
|
+
delayUpdate: target.getAttribute("data-delay-update") || self.props.delayUpdate || 0,
|
|
2149
|
+
border: target.getAttribute("data-border") ? target.getAttribute("data-border") === "true" : self.props.border || false,
|
|
2150
|
+
extraClass: target.getAttribute("data-class") || self.props["class"] || self.props.className || "",
|
|
2151
|
+
disable: target.getAttribute("data-tip-disable") ? target.getAttribute("data-tip-disable") === "true" : self.props.disable || false,
|
|
2072
2152
|
currentTarget: target
|
|
2073
2153
|
}, function () {
|
|
2074
2154
|
if (scrollHide) self.addScrollListener(self.state.currentTarget);
|
|
@@ -2078,8 +2158,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2078
2158
|
self.intervalUpdateContent = setInterval(function () {
|
|
2079
2159
|
if (self.mount) {
|
|
2080
2160
|
var _getContent = self.props.getContent;
|
|
2081
|
-
|
|
2082
|
-
var placeholder = (0, _getTipContent2.default)(originTooltip, '', _getContent[0](), isMultiline);
|
|
2161
|
+
var placeholder = getTipContent(originTooltip, "", _getContent[0](), isMultiline);
|
|
2083
2162
|
var isEmptyTip = self.isEmptyTip(placeholder);
|
|
2084
2163
|
self.setState({
|
|
2085
2164
|
isEmptyTip: isEmptyTip
|
|
@@ -2089,106 +2168,104 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2089
2168
|
}, getContent[1]);
|
|
2090
2169
|
}
|
|
2091
2170
|
});
|
|
2092
|
-
};
|
|
2171
|
+
}; // If there is no delay call immediately, don't allow events to get in first.
|
|
2172
|
+
|
|
2093
2173
|
|
|
2094
|
-
// If there is no delay call immediately, don't allow events to get in first.
|
|
2095
2174
|
if (reshowDelay) {
|
|
2096
2175
|
this.delayReshow = setTimeout(updateState, reshowDelay);
|
|
2097
2176
|
} else {
|
|
2098
2177
|
updateState();
|
|
2099
2178
|
}
|
|
2100
2179
|
}
|
|
2101
|
-
|
|
2102
2180
|
/**
|
|
2103
2181
|
* When mouse hover, update tool tip
|
|
2104
2182
|
*/
|
|
2105
2183
|
|
|
2106
2184
|
}, {
|
|
2107
|
-
key:
|
|
2185
|
+
key: "updateTooltip",
|
|
2108
2186
|
value: function updateTooltip(e) {
|
|
2109
2187
|
var _this5 = this;
|
|
2110
2188
|
|
|
2111
|
-
var
|
|
2112
|
-
delayShow =
|
|
2113
|
-
disable =
|
|
2189
|
+
var _this$state = this.state,
|
|
2190
|
+
delayShow = _this$state.delayShow,
|
|
2191
|
+
disable = _this$state.disable;
|
|
2114
2192
|
var afterShow = this.props.afterShow;
|
|
2115
|
-
|
|
2116
2193
|
var placeholder = this.getTooltipContent();
|
|
2117
2194
|
var delayTime = parseInt(delayShow, 10);
|
|
2118
|
-
var eventTarget = e.currentTarget || e.target;
|
|
2195
|
+
var eventTarget = e.currentTarget || e.target; // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
|
|
2119
2196
|
|
|
2120
|
-
// Check if the mouse is actually over the tooltip, if so don't hide the tooltip
|
|
2121
2197
|
if (this.mouseOnToolTip()) {
|
|
2122
2198
|
return;
|
|
2123
2199
|
}
|
|
2124
2200
|
|
|
2125
2201
|
if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip
|
|
2202
|
+
|
|
2126
2203
|
var updateState = function updateState() {
|
|
2127
2204
|
if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) {
|
|
2128
2205
|
var isInvisible = !_this5.state.show;
|
|
2206
|
+
|
|
2129
2207
|
_this5.setState({
|
|
2130
2208
|
currentEvent: e,
|
|
2131
2209
|
currentTarget: eventTarget,
|
|
2132
2210
|
show: true
|
|
2133
2211
|
}, function () {
|
|
2134
2212
|
_this5.updatePosition();
|
|
2213
|
+
|
|
2135
2214
|
if (isInvisible && afterShow) afterShow(e);
|
|
2136
2215
|
});
|
|
2137
2216
|
}
|
|
2138
2217
|
};
|
|
2139
2218
|
|
|
2140
2219
|
clearTimeout(this.delayShowLoop);
|
|
2220
|
+
|
|
2141
2221
|
if (delayShow) {
|
|
2142
2222
|
this.delayShowLoop = setTimeout(updateState, delayTime);
|
|
2143
2223
|
} else {
|
|
2144
2224
|
updateState();
|
|
2145
2225
|
}
|
|
2146
2226
|
}
|
|
2147
|
-
|
|
2148
2227
|
/*
|
|
2149
|
-
|
|
2228
|
+
* If we're mousing over the tooltip remove it when we leave.
|
|
2150
2229
|
*/
|
|
2151
2230
|
|
|
2152
2231
|
}, {
|
|
2153
|
-
key:
|
|
2232
|
+
key: "listenForTooltipExit",
|
|
2154
2233
|
value: function listenForTooltipExit() {
|
|
2155
2234
|
var show = this.state.show;
|
|
2156
2235
|
|
|
2157
|
-
|
|
2158
2236
|
if (show && this.tooltipRef) {
|
|
2159
|
-
this.tooltipRef.addEventListener(
|
|
2237
|
+
this.tooltipRef.addEventListener("mouseleave", this.hideTooltip);
|
|
2160
2238
|
}
|
|
2161
2239
|
}
|
|
2162
2240
|
}, {
|
|
2163
|
-
key:
|
|
2241
|
+
key: "removeListenerForTooltipExit",
|
|
2164
2242
|
value: function removeListenerForTooltipExit() {
|
|
2165
2243
|
var show = this.state.show;
|
|
2166
2244
|
|
|
2167
|
-
|
|
2168
2245
|
if (show && this.tooltipRef) {
|
|
2169
|
-
this.tooltipRef.removeEventListener(
|
|
2246
|
+
this.tooltipRef.removeEventListener("mouseleave", this.hideTooltip);
|
|
2170
2247
|
}
|
|
2171
2248
|
}
|
|
2172
|
-
|
|
2173
2249
|
/**
|
|
2174
2250
|
* When mouse leave, hide tooltip
|
|
2175
2251
|
*/
|
|
2176
2252
|
|
|
2177
2253
|
}, {
|
|
2178
|
-
key:
|
|
2254
|
+
key: "hideTooltip",
|
|
2179
2255
|
value: function hideTooltip(e, hasTarget) {
|
|
2180
2256
|
var _this6 = this;
|
|
2181
2257
|
|
|
2182
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
2258
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
2259
|
+
isScroll: false
|
|
2260
|
+
};
|
|
2183
2261
|
var disable = this.state.disable;
|
|
2184
2262
|
var isScroll = options.isScroll;
|
|
2185
|
-
|
|
2186
2263
|
var delayHide = isScroll ? 0 : this.state.delayHide;
|
|
2187
2264
|
var afterHide = this.props.afterHide;
|
|
2188
|
-
|
|
2189
2265
|
var placeholder = this.getTooltipContent();
|
|
2190
2266
|
if (!this.mount) return;
|
|
2191
2267
|
if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip
|
|
2268
|
+
|
|
2192
2269
|
if (hasTarget) {
|
|
2193
2270
|
// Don't trigger other elements belongs to other ReactTooltip
|
|
2194
2271
|
var targetArray = this.getTargetArray(this.props.id);
|
|
@@ -2199,74 +2276,76 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2199
2276
|
}
|
|
2200
2277
|
|
|
2201
2278
|
var resetState = function resetState() {
|
|
2202
|
-
var isVisible = _this6.state.show;
|
|
2203
|
-
|
|
2279
|
+
var isVisible = _this6.state.show; // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
|
|
2280
|
+
|
|
2204
2281
|
if (_this6.mouseOnToolTip()) {
|
|
2205
2282
|
_this6.listenForTooltipExit();
|
|
2283
|
+
|
|
2206
2284
|
return;
|
|
2207
2285
|
}
|
|
2286
|
+
|
|
2208
2287
|
_this6.removeListenerForTooltipExit();
|
|
2209
2288
|
|
|
2210
2289
|
_this6.setState({
|
|
2211
2290
|
show: false
|
|
2212
2291
|
}, function () {
|
|
2213
2292
|
_this6.removeScrollListener();
|
|
2293
|
+
|
|
2214
2294
|
if (isVisible && afterHide) afterHide(e);
|
|
2215
2295
|
});
|
|
2216
2296
|
};
|
|
2217
2297
|
|
|
2218
2298
|
this.clearTimer();
|
|
2299
|
+
|
|
2219
2300
|
if (delayHide) {
|
|
2220
2301
|
this.delayHideLoop = setTimeout(resetState, parseInt(delayHide, 10));
|
|
2221
2302
|
} else {
|
|
2222
2303
|
resetState();
|
|
2223
2304
|
}
|
|
2224
2305
|
}
|
|
2225
|
-
|
|
2226
2306
|
/**
|
|
2227
2307
|
* When scroll, hide tooltip
|
|
2228
2308
|
*/
|
|
2229
2309
|
|
|
2230
2310
|
}, {
|
|
2231
|
-
key:
|
|
2311
|
+
key: "hideTooltipOnScroll",
|
|
2232
2312
|
value: function hideTooltipOnScroll(event, hasTarget) {
|
|
2233
|
-
this.hideTooltip(event, hasTarget, {
|
|
2313
|
+
this.hideTooltip(event, hasTarget, {
|
|
2314
|
+
isScroll: true
|
|
2315
|
+
});
|
|
2234
2316
|
}
|
|
2235
|
-
|
|
2236
2317
|
/**
|
|
2237
2318
|
* Add scroll event listener when tooltip show
|
|
2238
2319
|
* automatically hide the tooltip when scrolling
|
|
2239
2320
|
*/
|
|
2240
2321
|
|
|
2241
2322
|
}, {
|
|
2242
|
-
key:
|
|
2323
|
+
key: "addScrollListener",
|
|
2243
2324
|
value: function addScrollListener(currentTarget) {
|
|
2244
2325
|
var isCaptureMode = this.isCapture(currentTarget);
|
|
2245
|
-
window.addEventListener(
|
|
2326
|
+
window.addEventListener("scroll", this.hideTooltipOnScroll, isCaptureMode);
|
|
2246
2327
|
}
|
|
2247
2328
|
}, {
|
|
2248
|
-
key:
|
|
2329
|
+
key: "removeScrollListener",
|
|
2249
2330
|
value: function removeScrollListener() {
|
|
2250
|
-
window.removeEventListener(
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
// Calculation the position
|
|
2331
|
+
window.removeEventListener("scroll", this.hideTooltipOnScroll);
|
|
2332
|
+
} // Calculation the position
|
|
2254
2333
|
|
|
2255
2334
|
}, {
|
|
2256
|
-
key:
|
|
2335
|
+
key: "updatePosition",
|
|
2257
2336
|
value: function updatePosition() {
|
|
2258
2337
|
var _this7 = this;
|
|
2259
2338
|
|
|
2260
|
-
var
|
|
2261
|
-
currentEvent =
|
|
2262
|
-
currentTarget =
|
|
2263
|
-
place =
|
|
2264
|
-
desiredPlace =
|
|
2265
|
-
effect =
|
|
2266
|
-
offset =
|
|
2267
|
-
|
|
2339
|
+
var _this$state2 = this.state,
|
|
2340
|
+
currentEvent = _this$state2.currentEvent,
|
|
2341
|
+
currentTarget = _this$state2.currentTarget,
|
|
2342
|
+
place = _this$state2.place,
|
|
2343
|
+
desiredPlace = _this$state2.desiredPlace,
|
|
2344
|
+
effect = _this$state2.effect,
|
|
2345
|
+
offset = _this$state2.offset;
|
|
2268
2346
|
var node = this.tooltipRef;
|
|
2269
|
-
var result = (
|
|
2347
|
+
var result = getPosition(currentEvent, currentTarget, node, place, desiredPlace, effect, offset);
|
|
2348
|
+
|
|
2270
2349
|
if (result.position && this.props.overridePosition) {
|
|
2271
2350
|
result.position = this.props.overridePosition(result.position, currentEvent, currentTarget, node, place, desiredPlace, effect, offset);
|
|
2272
2351
|
}
|
|
@@ -2276,40 +2355,42 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2276
2355
|
return this.setState(result.newState, function () {
|
|
2277
2356
|
_this7.updatePosition();
|
|
2278
2357
|
});
|
|
2279
|
-
}
|
|
2280
|
-
// Set tooltip position
|
|
2281
|
-
node.style.left = result.position.left + 'px';
|
|
2282
|
-
node.style.top = result.position.top + 'px';
|
|
2283
|
-
}
|
|
2358
|
+
} // Set tooltip position
|
|
2284
2359
|
|
|
2360
|
+
|
|
2361
|
+
node.style.left = result.position.left + "px";
|
|
2362
|
+
node.style.top = result.position.top + "px";
|
|
2363
|
+
}
|
|
2285
2364
|
/**
|
|
2286
2365
|
* Set style tag in header
|
|
2287
2366
|
* in this way we can insert default css
|
|
2288
2367
|
*/
|
|
2289
2368
|
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
value: function setStyleHeader() {
|
|
2293
|
-
var head = document.getElementsByTagName('head')[0];
|
|
2369
|
+
/* setStyleHeader() {
|
|
2370
|
+
const head = document.getElementsByTagName("head")[0];
|
|
2294
2371
|
if (!head.querySelector('style[id="react-tooltip"]')) {
|
|
2295
|
-
|
|
2296
|
-
tag.id =
|
|
2297
|
-
tag.innerHTML =
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2372
|
+
const tag = document.createElement("style");
|
|
2373
|
+
tag.id = "react-tooltip";
|
|
2374
|
+
tag.innerHTML = cssStyle; */
|
|
2375
|
+
|
|
2376
|
+
/* eslint-disable */
|
|
2377
|
+
|
|
2378
|
+
/* if (typeof __webpack_nonce__ !== 'undefined' && __webpack_nonce__) {
|
|
2379
|
+
tag.setAttribute('nonce', __webpack_nonce__)
|
|
2380
|
+
}*/
|
|
2381
|
+
|
|
2382
|
+
/* eslint-enable */
|
|
2383
|
+
|
|
2384
|
+
/* head.insertBefore(tag, head.firstChild);
|
|
2304
2385
|
}
|
|
2305
|
-
}
|
|
2386
|
+
} */
|
|
2306
2387
|
|
|
2307
2388
|
/**
|
|
2308
2389
|
* CLear all kinds of timeout of interval
|
|
2309
2390
|
*/
|
|
2310
2391
|
|
|
2311
2392
|
}, {
|
|
2312
|
-
key:
|
|
2393
|
+
key: "clearTimer",
|
|
2313
2394
|
value: function clearTimer() {
|
|
2314
2395
|
clearTimeout(this.delayShowLoop);
|
|
2315
2396
|
clearTimeout(this.delayHideLoop);
|
|
@@ -2317,476 +2398,112 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
2317
2398
|
clearInterval(this.intervalUpdateContent);
|
|
2318
2399
|
}
|
|
2319
2400
|
}, {
|
|
2320
|
-
key:
|
|
2401
|
+
key: "render",
|
|
2321
2402
|
value: function render() {
|
|
2322
2403
|
var _this8 = this;
|
|
2323
2404
|
|
|
2324
|
-
var
|
|
2325
|
-
extraClass =
|
|
2326
|
-
html =
|
|
2327
|
-
ariaProps =
|
|
2328
|
-
disable =
|
|
2329
|
-
|
|
2405
|
+
var _this$state3 = this.state,
|
|
2406
|
+
extraClass = _this$state3.extraClass,
|
|
2407
|
+
html = _this$state3.html,
|
|
2408
|
+
ariaProps = _this$state3.ariaProps,
|
|
2409
|
+
disable = _this$state3.disable;
|
|
2330
2410
|
var placeholder = this.getTooltipContent();
|
|
2331
2411
|
var isEmptyTip = this.isEmptyTip(placeholder);
|
|
2332
|
-
var tooltipClass =
|
|
2333
|
-
|
|
2412
|
+
var tooltipClass = "__react_component_tooltip" + (this.state.show && !disable && !isEmptyTip ? " show" : "") + (this.state.border ? " border" : "") + " place-".concat(this.state.place) + // top, bottom, left, right
|
|
2413
|
+
" type-".concat(this.state.type) + ( // dark, success, warning, error, info, light
|
|
2414
|
+
this.props.delayUpdate ? " allow_hover" : "") + (this.props.clickable ? " allow_click" : "");
|
|
2334
2415
|
var Wrapper = this.props.wrapper;
|
|
2416
|
+
|
|
2335
2417
|
if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) {
|
|
2336
2418
|
Wrapper = ReactTooltip.defaultProps.wrapper;
|
|
2337
2419
|
}
|
|
2338
|
-
|
|
2420
|
+
|
|
2421
|
+
var wrapperClassName = [tooltipClass, extraClass].filter(Boolean).join(" ");
|
|
2339
2422
|
|
|
2340
2423
|
if (html) {
|
|
2341
|
-
return
|
|
2424
|
+
return React.createElement(Wrapper, _extends({
|
|
2425
|
+
className: wrapperClassName,
|
|
2342
2426
|
id: this.props.id,
|
|
2343
2427
|
ref: function ref(_ref) {
|
|
2344
2428
|
return _this8.tooltipRef = _ref;
|
|
2345
2429
|
}
|
|
2346
2430
|
}, ariaProps, {
|
|
2347
|
-
|
|
2348
|
-
dangerouslySetInnerHTML: {
|
|
2431
|
+
"data-id": "tooltip",
|
|
2432
|
+
dangerouslySetInnerHTML: {
|
|
2433
|
+
__html: placeholder
|
|
2434
|
+
}
|
|
2435
|
+
}));
|
|
2349
2436
|
} else {
|
|
2350
|
-
return
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
placeholder
|
|
2360
|
-
);
|
|
2437
|
+
return React.createElement(Wrapper, _extends({
|
|
2438
|
+
className: wrapperClassName,
|
|
2439
|
+
id: this.props.id
|
|
2440
|
+
}, ariaProps, {
|
|
2441
|
+
ref: function ref(_ref2) {
|
|
2442
|
+
return _this8.tooltipRef = _ref2;
|
|
2443
|
+
},
|
|
2444
|
+
"data-id": "tooltip"
|
|
2445
|
+
}), placeholder);
|
|
2361
2446
|
}
|
|
2362
2447
|
}
|
|
2363
2448
|
}], [{
|
|
2364
|
-
key:
|
|
2449
|
+
key: "getDerivedStateFromProps",
|
|
2365
2450
|
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
2366
2451
|
var ariaProps = prevState.ariaProps;
|
|
2367
|
-
|
|
2368
|
-
var newAriaProps = (0, _aria.parseAria)(nextProps);
|
|
2452
|
+
var newAriaProps = parseAria(nextProps);
|
|
2369
2453
|
var isChanged = Object.keys(newAriaProps).some(function (props) {
|
|
2370
2454
|
return newAriaProps[props] !== ariaProps[props];
|
|
2371
2455
|
});
|
|
2456
|
+
|
|
2372
2457
|
if (!isChanged) {
|
|
2373
2458
|
return null;
|
|
2374
2459
|
}
|
|
2375
|
-
|
|
2460
|
+
|
|
2461
|
+
return _objectSpread2({}, prevState, {
|
|
2376
2462
|
ariaProps: newAriaProps
|
|
2377
2463
|
});
|
|
2378
2464
|
}
|
|
2379
2465
|
}]);
|
|
2380
2466
|
|
|
2381
2467
|
return ReactTooltip;
|
|
2382
|
-
}(
|
|
2383
|
-
children:
|
|
2384
|
-
place:
|
|
2385
|
-
type:
|
|
2386
|
-
effect:
|
|
2387
|
-
offset:
|
|
2388
|
-
multiline:
|
|
2389
|
-
border:
|
|
2390
|
-
insecure:
|
|
2391
|
-
class:
|
|
2392
|
-
className:
|
|
2393
|
-
id:
|
|
2394
|
-
html:
|
|
2395
|
-
delayHide:
|
|
2396
|
-
delayUpdate:
|
|
2397
|
-
delayShow:
|
|
2398
|
-
event:
|
|
2399
|
-
eventOff:
|
|
2400
|
-
watchWindow:
|
|
2401
|
-
isCapture:
|
|
2402
|
-
globalEventOff:
|
|
2403
|
-
getContent:
|
|
2404
|
-
afterShow:
|
|
2405
|
-
afterHide:
|
|
2406
|
-
overridePosition:
|
|
2407
|
-
disable:
|
|
2408
|
-
scrollHide:
|
|
2409
|
-
resizeHide:
|
|
2410
|
-
wrapper:
|
|
2411
|
-
bodyMode:
|
|
2412
|
-
possibleCustomEvents:
|
|
2413
|
-
possibleCustomEventsOff:
|
|
2414
|
-
clickable:
|
|
2415
|
-
}, _class2
|
|
2468
|
+
}(React.Component), _defineProperty(_class2, "propTypes", {
|
|
2469
|
+
children: propTypes.any,
|
|
2470
|
+
place: propTypes.string,
|
|
2471
|
+
type: propTypes.string,
|
|
2472
|
+
effect: propTypes.string,
|
|
2473
|
+
offset: propTypes.object,
|
|
2474
|
+
multiline: propTypes.bool,
|
|
2475
|
+
border: propTypes.bool,
|
|
2476
|
+
insecure: propTypes.bool,
|
|
2477
|
+
"class": propTypes.string,
|
|
2478
|
+
className: propTypes.string,
|
|
2479
|
+
id: propTypes.string,
|
|
2480
|
+
html: propTypes.bool,
|
|
2481
|
+
delayHide: propTypes.number,
|
|
2482
|
+
delayUpdate: propTypes.number,
|
|
2483
|
+
delayShow: propTypes.number,
|
|
2484
|
+
event: propTypes.string,
|
|
2485
|
+
eventOff: propTypes.string,
|
|
2486
|
+
watchWindow: propTypes.bool,
|
|
2487
|
+
isCapture: propTypes.bool,
|
|
2488
|
+
globalEventOff: propTypes.string,
|
|
2489
|
+
getContent: propTypes.any,
|
|
2490
|
+
afterShow: propTypes.func,
|
|
2491
|
+
afterHide: propTypes.func,
|
|
2492
|
+
overridePosition: propTypes.func,
|
|
2493
|
+
disable: propTypes.bool,
|
|
2494
|
+
scrollHide: propTypes.bool,
|
|
2495
|
+
resizeHide: propTypes.bool,
|
|
2496
|
+
wrapper: propTypes.string,
|
|
2497
|
+
bodyMode: propTypes.bool,
|
|
2498
|
+
possibleCustomEvents: propTypes.string,
|
|
2499
|
+
possibleCustomEventsOff: propTypes.string,
|
|
2500
|
+
clickable: propTypes.bool
|
|
2501
|
+
}), _defineProperty(_class2, "defaultProps", {
|
|
2416
2502
|
insecure: true,
|
|
2417
2503
|
resizeHide: true,
|
|
2418
|
-
wrapper:
|
|
2504
|
+
wrapper: "div",
|
|
2419
2505
|
clickable: false
|
|
2420
|
-
}, _class2
|
|
2421
|
-
|
|
2422
|
-
/* export default not fit for standalone, it will exports {default:...} */
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
module.exports = ReactTooltip;
|
|
2426
|
-
|
|
2427
|
-
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
2428
|
-
},{"./decorators/bodyMode":13,"./decorators/customEvent":14,"./decorators/getEffect":15,"./decorators/isCapture":16,"./decorators/staticMethods":17,"./decorators/trackRemoval":18,"./decorators/windowListener":19,"./style":21,"./utils/aria":22,"./utils/getPosition":23,"./utils/getTipContent":24,"./utils/nodeListToArray":25,"classnames":1,"prop-types":10}],21:[function(require,module,exports){
|
|
2429
|
-
'use strict';
|
|
2430
|
-
|
|
2431
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2432
|
-
value: true
|
|
2433
|
-
});
|
|
2434
|
-
exports.default = '.__react_component_tooltip{border-radius:3px;display:inline-block;font-size:13px;left:-999em;opacity:0;padding:8px 21px;position:fixed;pointer-events:none;transition:opacity 0.3s ease-out;top:-999em;visibility:hidden;z-index:999}.__react_component_tooltip.allow_hover,.__react_component_tooltip.allow_click{pointer-events:auto}.__react_component_tooltip:before,.__react_component_tooltip:after{content:"";width:0;height:0;position:absolute}.__react_component_tooltip.show{opacity:0.9;margin-top:0px;margin-left:0px;visibility:visible}.__react_component_tooltip.type-dark{color:#fff;background-color:#222}.__react_component_tooltip.type-dark.place-top:after{border-top-color:#222;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-dark.place-bottom:after{border-bottom-color:#222;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-dark.place-left:after{border-left-color:#222;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-dark.place-right:after{border-right-color:#222;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-dark.border{border:1px solid #fff}.__react_component_tooltip.type-dark.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-dark.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-dark.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-dark.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-success{color:#fff;background-color:#8DC572}.__react_component_tooltip.type-success.place-top:after{border-top-color:#8DC572;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-success.place-bottom:after{border-bottom-color:#8DC572;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-success.place-left:after{border-left-color:#8DC572;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-success.place-right:after{border-right-color:#8DC572;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-success.border{border:1px solid #fff}.__react_component_tooltip.type-success.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-success.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-success.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-success.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-warning{color:#fff;background-color:#F0AD4E}.__react_component_tooltip.type-warning.place-top:after{border-top-color:#F0AD4E;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-warning.place-bottom:after{border-bottom-color:#F0AD4E;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-warning.place-left:after{border-left-color:#F0AD4E;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-warning.place-right:after{border-right-color:#F0AD4E;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-warning.border{border:1px solid #fff}.__react_component_tooltip.type-warning.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-warning.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-warning.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-warning.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-error{color:#fff;background-color:#BE6464}.__react_component_tooltip.type-error.place-top:after{border-top-color:#BE6464;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-error.place-bottom:after{border-bottom-color:#BE6464;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-error.place-left:after{border-left-color:#BE6464;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-error.place-right:after{border-right-color:#BE6464;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-error.border{border:1px solid #fff}.__react_component_tooltip.type-error.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-error.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-error.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-error.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-info{color:#fff;background-color:#337AB7}.__react_component_tooltip.type-info.place-top:after{border-top-color:#337AB7;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-info.place-bottom:after{border-bottom-color:#337AB7;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-info.place-left:after{border-left-color:#337AB7;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-info.place-right:after{border-right-color:#337AB7;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-info.border{border:1px solid #fff}.__react_component_tooltip.type-info.border.place-top:before{border-top:8px solid #fff}.__react_component_tooltip.type-info.border.place-bottom:before{border-bottom:8px solid #fff}.__react_component_tooltip.type-info.border.place-left:before{border-left:8px solid #fff}.__react_component_tooltip.type-info.border.place-right:before{border-right:8px solid #fff}.__react_component_tooltip.type-light{color:#222;background-color:#fff}.__react_component_tooltip.type-light.place-top:after{border-top-color:#fff;border-top-style:solid;border-top-width:6px}.__react_component_tooltip.type-light.place-bottom:after{border-bottom-color:#fff;border-bottom-style:solid;border-bottom-width:6px}.__react_component_tooltip.type-light.place-left:after{border-left-color:#fff;border-left-style:solid;border-left-width:6px}.__react_component_tooltip.type-light.place-right:after{border-right-color:#fff;border-right-style:solid;border-right-width:6px}.__react_component_tooltip.type-light.border{border:1px solid #222}.__react_component_tooltip.type-light.border.place-top:before{border-top:8px solid #222}.__react_component_tooltip.type-light.border.place-bottom:before{border-bottom:8px solid #222}.__react_component_tooltip.type-light.border.place-left:before{border-left:8px solid #222}.__react_component_tooltip.type-light.border.place-right:before{border-right:8px solid #222}.__react_component_tooltip.place-top{margin-top:-10px}.__react_component_tooltip.place-top:before{border-left:10px solid transparent;border-right:10px solid transparent;bottom:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-top:after{border-left:8px solid transparent;border-right:8px solid transparent;bottom:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-bottom{margin-top:10px}.__react_component_tooltip.place-bottom:before{border-left:10px solid transparent;border-right:10px solid transparent;top:-8px;left:50%;margin-left:-10px}.__react_component_tooltip.place-bottom:after{border-left:8px solid transparent;border-right:8px solid transparent;top:-6px;left:50%;margin-left:-8px}.__react_component_tooltip.place-left{margin-left:-10px}.__react_component_tooltip.place-left:before{border-top:6px solid transparent;border-bottom:6px solid transparent;right:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-left:after{border-top:5px solid transparent;border-bottom:5px solid transparent;right:-6px;top:50%;margin-top:-4px}.__react_component_tooltip.place-right{margin-left:10px}.__react_component_tooltip.place-right:before{border-top:6px solid transparent;border-bottom:6px solid transparent;left:-8px;top:50%;margin-top:-5px}.__react_component_tooltip.place-right:after{border-top:5px solid transparent;border-bottom:5px solid transparent;left:-6px;top:50%;margin-top:-4px}.__react_component_tooltip .multi-line{display:block;padding:2px 0px;text-align:center}';
|
|
2435
|
-
|
|
2436
|
-
},{}],22:[function(require,module,exports){
|
|
2437
|
-
"use strict";
|
|
2438
|
-
|
|
2439
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2440
|
-
value: true
|
|
2441
|
-
});
|
|
2442
|
-
exports.parseAria = parseAria;
|
|
2443
|
-
/**
|
|
2444
|
-
* Support aria- and role in ReactTooltip
|
|
2445
|
-
*
|
|
2446
|
-
* @params props {Object}
|
|
2447
|
-
* @return {Object}
|
|
2448
|
-
*/
|
|
2449
|
-
function parseAria(props) {
|
|
2450
|
-
var ariaObj = {};
|
|
2451
|
-
Object.keys(props).filter(function (prop) {
|
|
2452
|
-
// aria-xxx and role is acceptable
|
|
2453
|
-
return (/(^aria-\w+$|^role$)/.test(prop)
|
|
2454
|
-
);
|
|
2455
|
-
}).forEach(function (prop) {
|
|
2456
|
-
ariaObj[prop] = props[prop];
|
|
2457
|
-
});
|
|
2458
|
-
|
|
2459
|
-
return ariaObj;
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
},{}],23:[function(require,module,exports){
|
|
2463
|
-
'use strict';
|
|
2464
|
-
|
|
2465
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2466
|
-
value: true
|
|
2467
|
-
});
|
|
2468
|
-
|
|
2469
|
-
exports.default = function (e, target, node, place, desiredPlace, effect, offset) {
|
|
2470
|
-
var _getDimensions = getDimensions(node),
|
|
2471
|
-
tipWidth = _getDimensions.width,
|
|
2472
|
-
tipHeight = _getDimensions.height;
|
|
2473
|
-
|
|
2474
|
-
var _getDimensions2 = getDimensions(target),
|
|
2475
|
-
targetWidth = _getDimensions2.width,
|
|
2476
|
-
targetHeight = _getDimensions2.height;
|
|
2506
|
+
}), _defineProperty(_class2, "supportedWrappers", ["div", "span"]), _defineProperty(_class2, "displayName", "ReactTooltip"), _temp)) || _class) || _class) || _class) || _class) || _class) || _class) || _class;
|
|
2477
2507
|
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
mouseY = _getCurrentOffset.mouseY;
|
|
2481
|
-
|
|
2482
|
-
var defaultOffset = getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight);
|
|
2483
|
-
|
|
2484
|
-
var _calculateOffset = calculateOffset(offset),
|
|
2485
|
-
extraOffset_X = _calculateOffset.extraOffset_X,
|
|
2486
|
-
extraOffset_Y = _calculateOffset.extraOffset_Y;
|
|
2487
|
-
|
|
2488
|
-
var windowWidth = window.innerWidth;
|
|
2489
|
-
var windowHeight = window.innerHeight;
|
|
2490
|
-
|
|
2491
|
-
var _getParent = getParent(node),
|
|
2492
|
-
parentTop = _getParent.parentTop,
|
|
2493
|
-
parentLeft = _getParent.parentLeft;
|
|
2494
|
-
|
|
2495
|
-
// Get the edge offset of the tooltip
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
var getTipOffsetLeft = function getTipOffsetLeft(place) {
|
|
2499
|
-
var offset_X = defaultOffset[place].l;
|
|
2500
|
-
return mouseX + offset_X + extraOffset_X;
|
|
2501
|
-
};
|
|
2502
|
-
var getTipOffsetRight = function getTipOffsetRight(place) {
|
|
2503
|
-
var offset_X = defaultOffset[place].r;
|
|
2504
|
-
return mouseX + offset_X + extraOffset_X;
|
|
2505
|
-
};
|
|
2506
|
-
var getTipOffsetTop = function getTipOffsetTop(place) {
|
|
2507
|
-
var offset_Y = defaultOffset[place].t;
|
|
2508
|
-
return mouseY + offset_Y + extraOffset_Y;
|
|
2509
|
-
};
|
|
2510
|
-
var getTipOffsetBottom = function getTipOffsetBottom(place) {
|
|
2511
|
-
var offset_Y = defaultOffset[place].b;
|
|
2512
|
-
return mouseY + offset_Y + extraOffset_Y;
|
|
2513
|
-
};
|
|
2514
|
-
|
|
2515
|
-
//
|
|
2516
|
-
// Functions to test whether the tooltip's sides are inside
|
|
2517
|
-
// the client window for a given orientation p
|
|
2518
|
-
//
|
|
2519
|
-
// _____________
|
|
2520
|
-
// | | <-- Right side
|
|
2521
|
-
// | p = 'left' |\
|
|
2522
|
-
// | |/ |\
|
|
2523
|
-
// |_____________| |_\ <-- Mouse
|
|
2524
|
-
// / \ |
|
|
2525
|
-
// |
|
|
2526
|
-
// |
|
|
2527
|
-
// Bottom side
|
|
2528
|
-
//
|
|
2529
|
-
var outsideLeft = function outsideLeft(p) {
|
|
2530
|
-
return getTipOffsetLeft(p) < 0;
|
|
2531
|
-
};
|
|
2532
|
-
var outsideRight = function outsideRight(p) {
|
|
2533
|
-
return getTipOffsetRight(p) > windowWidth;
|
|
2534
|
-
};
|
|
2535
|
-
var outsideTop = function outsideTop(p) {
|
|
2536
|
-
return getTipOffsetTop(p) < 0;
|
|
2537
|
-
};
|
|
2538
|
-
var outsideBottom = function outsideBottom(p) {
|
|
2539
|
-
return getTipOffsetBottom(p) > windowHeight;
|
|
2540
|
-
};
|
|
2541
|
-
|
|
2542
|
-
// Check whether the tooltip with orientation p is completely inside the client window
|
|
2543
|
-
var outside = function outside(p) {
|
|
2544
|
-
return outsideLeft(p) || outsideRight(p) || outsideTop(p) || outsideBottom(p);
|
|
2545
|
-
};
|
|
2546
|
-
var inside = function inside(p) {
|
|
2547
|
-
return !outside(p);
|
|
2548
|
-
};
|
|
2549
|
-
|
|
2550
|
-
var placesList = ['top', 'bottom', 'left', 'right'];
|
|
2551
|
-
var insideList = [];
|
|
2552
|
-
for (var i = 0; i < 4; i++) {
|
|
2553
|
-
var p = placesList[i];
|
|
2554
|
-
if (inside(p)) {
|
|
2555
|
-
insideList.push(p);
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
var isNewState = false;
|
|
2560
|
-
var newPlace = void 0;
|
|
2561
|
-
var shouldUpdatePlace = desiredPlace !== place;
|
|
2562
|
-
if (inside(desiredPlace) && shouldUpdatePlace) {
|
|
2563
|
-
isNewState = true;
|
|
2564
|
-
newPlace = desiredPlace;
|
|
2565
|
-
} else if (insideList.length > 0 && shouldUpdatePlace && outside(desiredPlace) && outside(place)) {
|
|
2566
|
-
isNewState = true;
|
|
2567
|
-
newPlace = insideList[0];
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
-
if (isNewState) {
|
|
2571
|
-
return {
|
|
2572
|
-
isNewState: true,
|
|
2573
|
-
newState: { place: newPlace }
|
|
2574
|
-
};
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
return {
|
|
2578
|
-
isNewState: false,
|
|
2579
|
-
position: {
|
|
2580
|
-
left: parseInt(getTipOffsetLeft(place) - parentLeft, 10),
|
|
2581
|
-
top: parseInt(getTipOffsetTop(place) - parentTop, 10)
|
|
2582
|
-
}
|
|
2583
|
-
};
|
|
2584
|
-
};
|
|
2585
|
-
|
|
2586
|
-
var getDimensions = function getDimensions(node) {
|
|
2587
|
-
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
2588
|
-
height = _node$getBoundingClie.height,
|
|
2589
|
-
width = _node$getBoundingClie.width;
|
|
2590
|
-
|
|
2591
|
-
return {
|
|
2592
|
-
height: parseInt(height, 10),
|
|
2593
|
-
width: parseInt(width, 10)
|
|
2594
|
-
};
|
|
2595
|
-
};
|
|
2596
|
-
|
|
2597
|
-
// Get current mouse offset
|
|
2598
|
-
/**
|
|
2599
|
-
* Calculate the position of tooltip
|
|
2600
|
-
*
|
|
2601
|
-
* @params
|
|
2602
|
-
* - `e` {Event} the event of current mouse
|
|
2603
|
-
* - `target` {Element} the currentTarget of the event
|
|
2604
|
-
* - `node` {DOM} the react-tooltip object
|
|
2605
|
-
* - `place` {String} top / right / bottom / left
|
|
2606
|
-
* - `effect` {String} float / solid
|
|
2607
|
-
* - `offset` {Object} the offset to default position
|
|
2608
|
-
*
|
|
2609
|
-
* @return {Object}
|
|
2610
|
-
* - `isNewState` {Bool} required
|
|
2611
|
-
* - `newState` {Object}
|
|
2612
|
-
* - `position` {Object} {left: {Number}, top: {Number}}
|
|
2613
|
-
*/
|
|
2614
|
-
var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
|
|
2615
|
-
var boundingClientRect = currentTarget.getBoundingClientRect();
|
|
2616
|
-
var targetTop = boundingClientRect.top;
|
|
2617
|
-
var targetLeft = boundingClientRect.left;
|
|
2618
|
-
|
|
2619
|
-
var _getDimensions3 = getDimensions(currentTarget),
|
|
2620
|
-
targetWidth = _getDimensions3.width,
|
|
2621
|
-
targetHeight = _getDimensions3.height;
|
|
2622
|
-
|
|
2623
|
-
if (effect === 'float') {
|
|
2624
|
-
return {
|
|
2625
|
-
mouseX: e.clientX,
|
|
2626
|
-
mouseY: e.clientY
|
|
2627
|
-
};
|
|
2628
|
-
}
|
|
2629
|
-
return {
|
|
2630
|
-
mouseX: targetLeft + targetWidth / 2,
|
|
2631
|
-
mouseY: targetTop + targetHeight / 2
|
|
2632
|
-
};
|
|
2633
|
-
};
|
|
2634
|
-
|
|
2635
|
-
// List all possibility of tooltip final offset
|
|
2636
|
-
// This is useful in judging if it is necessary for tooltip to switch position when out of window
|
|
2637
|
-
var getDefaultPosition = function getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight) {
|
|
2638
|
-
var top = void 0;
|
|
2639
|
-
var right = void 0;
|
|
2640
|
-
var bottom = void 0;
|
|
2641
|
-
var left = void 0;
|
|
2642
|
-
var disToMouse = 3;
|
|
2643
|
-
var triangleHeight = 2;
|
|
2644
|
-
var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip
|
|
2645
|
-
|
|
2646
|
-
if (effect === 'float') {
|
|
2647
|
-
top = {
|
|
2648
|
-
l: -(tipWidth / 2),
|
|
2649
|
-
r: tipWidth / 2,
|
|
2650
|
-
t: -(tipHeight + disToMouse + triangleHeight),
|
|
2651
|
-
b: -disToMouse
|
|
2652
|
-
};
|
|
2653
|
-
bottom = {
|
|
2654
|
-
l: -(tipWidth / 2),
|
|
2655
|
-
r: tipWidth / 2,
|
|
2656
|
-
t: disToMouse + cursorHeight,
|
|
2657
|
-
b: tipHeight + disToMouse + triangleHeight + cursorHeight
|
|
2658
|
-
};
|
|
2659
|
-
left = {
|
|
2660
|
-
l: -(tipWidth + disToMouse + triangleHeight),
|
|
2661
|
-
r: -disToMouse,
|
|
2662
|
-
t: -(tipHeight / 2),
|
|
2663
|
-
b: tipHeight / 2
|
|
2664
|
-
};
|
|
2665
|
-
right = {
|
|
2666
|
-
l: disToMouse,
|
|
2667
|
-
r: tipWidth + disToMouse + triangleHeight,
|
|
2668
|
-
t: -(tipHeight / 2),
|
|
2669
|
-
b: tipHeight / 2
|
|
2670
|
-
};
|
|
2671
|
-
} else if (effect === 'solid') {
|
|
2672
|
-
top = {
|
|
2673
|
-
l: -(tipWidth / 2),
|
|
2674
|
-
r: tipWidth / 2,
|
|
2675
|
-
t: -(targetHeight / 2 + tipHeight + triangleHeight),
|
|
2676
|
-
b: -(targetHeight / 2)
|
|
2677
|
-
};
|
|
2678
|
-
bottom = {
|
|
2679
|
-
l: -(tipWidth / 2),
|
|
2680
|
-
r: tipWidth / 2,
|
|
2681
|
-
t: targetHeight / 2,
|
|
2682
|
-
b: targetHeight / 2 + tipHeight + triangleHeight
|
|
2683
|
-
};
|
|
2684
|
-
left = {
|
|
2685
|
-
l: -(tipWidth + targetWidth / 2 + triangleHeight),
|
|
2686
|
-
r: -(targetWidth / 2),
|
|
2687
|
-
t: -(tipHeight / 2),
|
|
2688
|
-
b: tipHeight / 2
|
|
2689
|
-
};
|
|
2690
|
-
right = {
|
|
2691
|
-
l: targetWidth / 2,
|
|
2692
|
-
r: tipWidth + targetWidth / 2 + triangleHeight,
|
|
2693
|
-
t: -(tipHeight / 2),
|
|
2694
|
-
b: tipHeight / 2
|
|
2695
|
-
};
|
|
2696
|
-
}
|
|
2697
|
-
|
|
2698
|
-
return { top: top, bottom: bottom, left: left, right: right };
|
|
2699
|
-
};
|
|
2700
|
-
|
|
2701
|
-
// Consider additional offset into position calculation
|
|
2702
|
-
var calculateOffset = function calculateOffset(offset) {
|
|
2703
|
-
var extraOffset_X = 0;
|
|
2704
|
-
var extraOffset_Y = 0;
|
|
2705
|
-
|
|
2706
|
-
if (Object.prototype.toString.apply(offset) === '[object String]') {
|
|
2707
|
-
offset = JSON.parse(offset.toString().replace(/\'/g, '\"'));
|
|
2708
|
-
}
|
|
2709
|
-
for (var key in offset) {
|
|
2710
|
-
if (key === 'top') {
|
|
2711
|
-
extraOffset_Y -= parseInt(offset[key], 10);
|
|
2712
|
-
} else if (key === 'bottom') {
|
|
2713
|
-
extraOffset_Y += parseInt(offset[key], 10);
|
|
2714
|
-
} else if (key === 'left') {
|
|
2715
|
-
extraOffset_X -= parseInt(offset[key], 10);
|
|
2716
|
-
} else if (key === 'right') {
|
|
2717
|
-
extraOffset_X += parseInt(offset[key], 10);
|
|
2718
|
-
}
|
|
2719
|
-
}
|
|
2720
|
-
|
|
2721
|
-
return { extraOffset_X: extraOffset_X, extraOffset_Y: extraOffset_Y };
|
|
2722
|
-
};
|
|
2723
|
-
|
|
2724
|
-
// Get the offset of the parent elements
|
|
2725
|
-
var getParent = function getParent(currentTarget) {
|
|
2726
|
-
var currentParent = currentTarget;
|
|
2727
|
-
while (currentParent) {
|
|
2728
|
-
if (window.getComputedStyle(currentParent).getPropertyValue('transform') !== 'none') break;
|
|
2729
|
-
currentParent = currentParent.parentElement;
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
var parentTop = currentParent && currentParent.getBoundingClientRect().top || 0;
|
|
2733
|
-
var parentLeft = currentParent && currentParent.getBoundingClientRect().left || 0;
|
|
2734
|
-
|
|
2735
|
-
return { parentTop: parentTop, parentLeft: parentLeft };
|
|
2736
|
-
};
|
|
2737
|
-
|
|
2738
|
-
},{}],24:[function(require,module,exports){
|
|
2739
|
-
(function (global){
|
|
2740
|
-
'use strict';
|
|
2741
|
-
|
|
2742
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2743
|
-
value: true
|
|
2744
|
-
});
|
|
2745
|
-
|
|
2746
|
-
exports.default = function (tip, children, getContent, multiline) {
|
|
2747
|
-
if (children) return children;
|
|
2748
|
-
if (getContent !== undefined && getContent !== null) return getContent; // getContent can be 0, '', etc.
|
|
2749
|
-
if (getContent === null) return null; // Tip not exist and children is null or undefined
|
|
2750
|
-
|
|
2751
|
-
var regexp = /<br\s*\/?>/;
|
|
2752
|
-
if (!multiline || multiline === 'false' || !regexp.test(tip)) {
|
|
2753
|
-
// No trim(), so that user can keep their input
|
|
2754
|
-
return tip;
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
// Multiline tooltip content
|
|
2758
|
-
return tip.split(regexp).map(function (d, i) {
|
|
2759
|
-
return _react2.default.createElement(
|
|
2760
|
-
'span',
|
|
2761
|
-
{ key: i, className: 'multi-line' },
|
|
2762
|
-
d
|
|
2763
|
-
);
|
|
2764
|
-
});
|
|
2765
|
-
};
|
|
2766
|
-
|
|
2767
|
-
var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null);
|
|
2768
|
-
|
|
2769
|
-
var _react2 = _interopRequireDefault(_react);
|
|
2770
|
-
|
|
2771
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2772
|
-
|
|
2773
|
-
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
2774
|
-
},{}],25:[function(require,module,exports){
|
|
2775
|
-
"use strict";
|
|
2776
|
-
|
|
2777
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2778
|
-
value: true
|
|
2779
|
-
});
|
|
2780
|
-
|
|
2781
|
-
exports.default = function (nodeList) {
|
|
2782
|
-
var length = nodeList.length;
|
|
2783
|
-
if (nodeList.hasOwnProperty) {
|
|
2784
|
-
return Array.prototype.slice.call(nodeList);
|
|
2785
|
-
}
|
|
2786
|
-
return new Array(length).fill().map(function (index) {
|
|
2787
|
-
return nodeList[index];
|
|
2788
|
-
});
|
|
2789
|
-
};
|
|
2790
|
-
|
|
2791
|
-
},{}]},{},[20])(20)
|
|
2792
|
-
});
|
|
2508
|
+
export default ReactTooltip;
|
|
2509
|
+
//# sourceMappingURL=index.es.js.map
|