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
package/dist/index.js
CHANGED
|
@@ -1,120 +1,1880 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
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; };
|
|
4
3
|
|
|
5
|
-
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; }; }();
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
function ___$insertStyle(css) {
|
|
6
|
+
if (!css) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (typeof window === 'undefined') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var style = document.createElement('style');
|
|
14
|
+
|
|
15
|
+
style.setAttribute('type', 'text/css');
|
|
16
|
+
style.innerHTML = css;
|
|
17
|
+
document.head.appendChild(style);
|
|
18
|
+
return css;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
22
|
+
|
|
23
|
+
var React = _interopDefault(require('react'));
|
|
24
|
+
|
|
25
|
+
function _classCallCheck(instance, Constructor) {
|
|
26
|
+
if (!(instance instanceof Constructor)) {
|
|
27
|
+
throw new TypeError("Cannot call a class as a function");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _defineProperties(target, props) {
|
|
32
|
+
for (var i = 0; i < props.length; i++) {
|
|
33
|
+
var descriptor = props[i];
|
|
34
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
35
|
+
descriptor.configurable = true;
|
|
36
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
37
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
42
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
43
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
44
|
+
return Constructor;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _defineProperty(obj, key, value) {
|
|
48
|
+
if (key in obj) {
|
|
49
|
+
Object.defineProperty(obj, key, {
|
|
50
|
+
value: value,
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
obj[key] = value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _extends() {
|
|
63
|
+
_extends = Object.assign || function (target) {
|
|
64
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
65
|
+
var source = arguments[i];
|
|
66
|
+
|
|
67
|
+
for (var key in source) {
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
69
|
+
target[key] = source[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return target;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return _extends.apply(this, arguments);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ownKeys(object, enumerableOnly) {
|
|
81
|
+
var keys = Object.keys(object);
|
|
82
|
+
|
|
83
|
+
if (Object.getOwnPropertySymbols) {
|
|
84
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
85
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
86
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
87
|
+
});
|
|
88
|
+
keys.push.apply(keys, symbols);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return keys;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _objectSpread2(target) {
|
|
95
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
96
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
97
|
+
|
|
98
|
+
if (i % 2) {
|
|
99
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
100
|
+
_defineProperty(target, key, source[key]);
|
|
101
|
+
});
|
|
102
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
103
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
104
|
+
} else {
|
|
105
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
106
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return target;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _inherits(subClass, superClass) {
|
|
115
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
116
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
120
|
+
constructor: {
|
|
121
|
+
value: subClass,
|
|
122
|
+
writable: true,
|
|
123
|
+
configurable: true
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function _getPrototypeOf(o) {
|
|
130
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
131
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
132
|
+
};
|
|
133
|
+
return _getPrototypeOf(o);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _setPrototypeOf(o, p) {
|
|
137
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
138
|
+
o.__proto__ = p;
|
|
139
|
+
return o;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return _setPrototypeOf(o, p);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function _assertThisInitialized(self) {
|
|
146
|
+
if (self === void 0) {
|
|
147
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return self;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function _possibleConstructorReturn(self, call) {
|
|
154
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
155
|
+
return call;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return _assertThisInitialized(self);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function createCommonjsModule(fn, module) {
|
|
162
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
167
|
+
*
|
|
168
|
+
* This source code is licensed under the MIT license found in the
|
|
169
|
+
* LICENSE file in the root directory of this source tree.
|
|
170
|
+
*
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
function makeEmptyFunction(arg) {
|
|
175
|
+
return function () {
|
|
176
|
+
return arg;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* This function accepts and discards inputs; it has no side effects. This is
|
|
182
|
+
* primarily useful idiomatically for overridable function endpoints which
|
|
183
|
+
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
184
|
+
*/
|
|
185
|
+
var emptyFunction = function emptyFunction() {};
|
|
186
|
+
|
|
187
|
+
emptyFunction.thatReturns = makeEmptyFunction;
|
|
188
|
+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
189
|
+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
190
|
+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
191
|
+
emptyFunction.thatReturnsThis = function () {
|
|
192
|
+
return this;
|
|
193
|
+
};
|
|
194
|
+
emptyFunction.thatReturnsArgument = function (arg) {
|
|
195
|
+
return arg;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
var emptyFunction_1 = emptyFunction;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
202
|
+
*
|
|
203
|
+
* This source code is licensed under the MIT license found in the
|
|
204
|
+
* LICENSE file in the root directory of this source tree.
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
210
|
+
*
|
|
211
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
212
|
+
* to provide information about what broke and what you were
|
|
213
|
+
* expecting.
|
|
214
|
+
*
|
|
215
|
+
* The invariant message will be stripped in production, but the invariant
|
|
216
|
+
* will remain to ensure logic does not differ in production.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
var validateFormat = function validateFormat(format) {};
|
|
220
|
+
|
|
221
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
222
|
+
validateFormat = function validateFormat(format) {
|
|
223
|
+
if (format === undefined) {
|
|
224
|
+
throw new Error('invariant requires an error message argument');
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function invariant(condition, format, a, b, c, d, e, f) {
|
|
230
|
+
validateFormat(format);
|
|
231
|
+
|
|
232
|
+
if (!condition) {
|
|
233
|
+
var error;
|
|
234
|
+
if (format === undefined) {
|
|
235
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
236
|
+
} else {
|
|
237
|
+
var args = [a, b, c, d, e, f];
|
|
238
|
+
var argIndex = 0;
|
|
239
|
+
error = new Error(format.replace(/%s/g, function () {
|
|
240
|
+
return args[argIndex++];
|
|
241
|
+
}));
|
|
242
|
+
error.name = 'Invariant Violation';
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var invariant_1 = invariant;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
254
|
+
* This can be used to log issues in development environments in critical
|
|
255
|
+
* paths. Removing the logging code for production environments will keep the
|
|
256
|
+
* same logic and follow the same code paths.
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
var warning = emptyFunction_1;
|
|
260
|
+
|
|
261
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
262
|
+
var printWarning = function printWarning(format) {
|
|
263
|
+
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
264
|
+
args[_key - 1] = arguments[_key];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
var argIndex = 0;
|
|
268
|
+
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
269
|
+
return args[argIndex++];
|
|
270
|
+
});
|
|
271
|
+
if (typeof console !== 'undefined') {
|
|
272
|
+
console.error(message);
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
// --- Welcome to debugging React ---
|
|
276
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
277
|
+
// to find the callsite that caused this warning to fire.
|
|
278
|
+
throw new Error(message);
|
|
279
|
+
} catch (x) {}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
warning = function warning(condition, format) {
|
|
283
|
+
if (format === undefined) {
|
|
284
|
+
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
288
|
+
return; // Ignore CompositeComponent proptype check.
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (!condition) {
|
|
292
|
+
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
293
|
+
args[_key2 - 2] = arguments[_key2];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
printWarning.apply(undefined, [format].concat(args));
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
var warning_1 = warning;
|
|
302
|
+
|
|
303
|
+
/*
|
|
304
|
+
object-assign
|
|
305
|
+
(c) Sindre Sorhus
|
|
306
|
+
@license MIT
|
|
307
|
+
*/
|
|
308
|
+
/* eslint-disable no-unused-vars */
|
|
309
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
310
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
311
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
312
|
+
|
|
313
|
+
function toObject(val) {
|
|
314
|
+
if (val === null || val === undefined) {
|
|
315
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return Object(val);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function shouldUseNative() {
|
|
322
|
+
try {
|
|
323
|
+
if (!Object.assign) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
328
|
+
|
|
329
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
330
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
331
|
+
test1[5] = 'de';
|
|
332
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
337
|
+
var test2 = {};
|
|
338
|
+
for (var i = 0; i < 10; i++) {
|
|
339
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
340
|
+
}
|
|
341
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
342
|
+
return test2[n];
|
|
343
|
+
});
|
|
344
|
+
if (order2.join('') !== '0123456789') {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
349
|
+
var test3 = {};
|
|
350
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
351
|
+
test3[letter] = letter;
|
|
352
|
+
});
|
|
353
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
354
|
+
'abcdefghijklmnopqrst') {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return true;
|
|
359
|
+
} catch (err) {
|
|
360
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
366
|
+
var from;
|
|
367
|
+
var to = toObject(target);
|
|
368
|
+
var symbols;
|
|
369
|
+
|
|
370
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
371
|
+
from = Object(arguments[s]);
|
|
372
|
+
|
|
373
|
+
for (var key in from) {
|
|
374
|
+
if (hasOwnProperty.call(from, key)) {
|
|
375
|
+
to[key] = from[key];
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (getOwnPropertySymbols) {
|
|
380
|
+
symbols = getOwnPropertySymbols(from);
|
|
381
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
382
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
383
|
+
to[symbols[i]] = from[symbols[i]];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return to;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
394
|
+
*
|
|
395
|
+
* This source code is licensed under the MIT license found in the
|
|
396
|
+
* LICENSE file in the root directory of this source tree.
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
400
|
+
|
|
401
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
402
|
+
|
|
403
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
404
|
+
var invariant$1 = invariant_1;
|
|
405
|
+
var warning$1 = warning_1;
|
|
406
|
+
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
407
|
+
var loggedTypeFailures = {};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Assert that the values match with the type specs.
|
|
412
|
+
* Error messages are memorized and will only be shown once.
|
|
413
|
+
*
|
|
414
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
415
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
416
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
417
|
+
* @param {string} componentName Name of the component for error messages.
|
|
418
|
+
* @param {?Function} getStack Returns the component stack.
|
|
419
|
+
* @private
|
|
420
|
+
*/
|
|
421
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
422
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
423
|
+
for (var typeSpecName in typeSpecs) {
|
|
424
|
+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
425
|
+
var error;
|
|
426
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
427
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
428
|
+
// After these have been cleaned up, we'll let them throw.
|
|
429
|
+
try {
|
|
430
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
431
|
+
// behavior as without this statement except with a better message.
|
|
432
|
+
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]);
|
|
433
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
|
|
434
|
+
} catch (ex) {
|
|
435
|
+
error = ex;
|
|
436
|
+
}
|
|
437
|
+
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);
|
|
438
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
439
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
440
|
+
// same error.
|
|
441
|
+
loggedTypeFailures[error.message] = true;
|
|
442
|
+
|
|
443
|
+
var stack = getStack ? getStack() : '';
|
|
444
|
+
|
|
445
|
+
warning$1(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
var checkPropTypes_1 = checkPropTypes;
|
|
453
|
+
|
|
454
|
+
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
455
|
+
/* global Symbol */
|
|
456
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
457
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Returns the iterator method function contained on the iterable object.
|
|
461
|
+
*
|
|
462
|
+
* Be sure to invoke the function with the iterable as context:
|
|
463
|
+
*
|
|
464
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
465
|
+
* if (iteratorFn) {
|
|
466
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
467
|
+
* ...
|
|
468
|
+
* }
|
|
469
|
+
*
|
|
470
|
+
* @param {?object} maybeIterable
|
|
471
|
+
* @return {?function}
|
|
472
|
+
*/
|
|
473
|
+
function getIteratorFn(maybeIterable) {
|
|
474
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
475
|
+
if (typeof iteratorFn === 'function') {
|
|
476
|
+
return iteratorFn;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
482
|
+
* supplied to React components. Example usage:
|
|
483
|
+
*
|
|
484
|
+
* var Props = require('ReactPropTypes');
|
|
485
|
+
* var MyArticle = React.createClass({
|
|
486
|
+
* propTypes: {
|
|
487
|
+
* // An optional string prop named "description".
|
|
488
|
+
* description: Props.string,
|
|
489
|
+
*
|
|
490
|
+
* // A required enum prop named "category".
|
|
491
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
492
|
+
*
|
|
493
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
494
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
495
|
+
* },
|
|
496
|
+
* render: function() { ... }
|
|
497
|
+
* });
|
|
498
|
+
*
|
|
499
|
+
* A more formal specification of how these methods are used:
|
|
500
|
+
*
|
|
501
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
502
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
503
|
+
*
|
|
504
|
+
* Each and every declaration produces a function with the same signature. This
|
|
505
|
+
* allows the creation of custom validation functions. For example:
|
|
506
|
+
*
|
|
507
|
+
* var MyLink = React.createClass({
|
|
508
|
+
* propTypes: {
|
|
509
|
+
* // An optional string or URI prop named "href".
|
|
510
|
+
* href: function(props, propName, componentName) {
|
|
511
|
+
* var propValue = props[propName];
|
|
512
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
513
|
+
* !(propValue instanceof URI)) {
|
|
514
|
+
* return new Error(
|
|
515
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
516
|
+
* componentName
|
|
517
|
+
* );
|
|
518
|
+
* }
|
|
519
|
+
* }
|
|
520
|
+
* },
|
|
521
|
+
* render: function() {...}
|
|
522
|
+
* });
|
|
523
|
+
*
|
|
524
|
+
* @internal
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
528
|
+
|
|
529
|
+
// Important!
|
|
530
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
531
|
+
var ReactPropTypes = {
|
|
532
|
+
array: createPrimitiveTypeChecker('array'),
|
|
533
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
534
|
+
func: createPrimitiveTypeChecker('function'),
|
|
535
|
+
number: createPrimitiveTypeChecker('number'),
|
|
536
|
+
object: createPrimitiveTypeChecker('object'),
|
|
537
|
+
string: createPrimitiveTypeChecker('string'),
|
|
538
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
539
|
+
|
|
540
|
+
any: createAnyTypeChecker(),
|
|
541
|
+
arrayOf: createArrayOfTypeChecker,
|
|
542
|
+
element: createElementTypeChecker(),
|
|
543
|
+
instanceOf: createInstanceTypeChecker,
|
|
544
|
+
node: createNodeChecker(),
|
|
545
|
+
objectOf: createObjectOfTypeChecker,
|
|
546
|
+
oneOf: createEnumTypeChecker,
|
|
547
|
+
oneOfType: createUnionTypeChecker,
|
|
548
|
+
shape: createShapeTypeChecker,
|
|
549
|
+
exact: createStrictShapeTypeChecker,
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
554
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
555
|
+
*/
|
|
556
|
+
/*eslint-disable no-self-compare*/
|
|
557
|
+
function is(x, y) {
|
|
558
|
+
// SameValue algorithm
|
|
559
|
+
if (x === y) {
|
|
560
|
+
// Steps 1-5, 7-10
|
|
561
|
+
// Steps 6.b-6.e: +0 != -0
|
|
562
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
563
|
+
} else {
|
|
564
|
+
// Step 6.a: NaN == NaN
|
|
565
|
+
return x !== x && y !== y;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
/*eslint-enable no-self-compare*/
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
572
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
573
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
574
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
575
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
576
|
+
*/
|
|
577
|
+
function PropTypeError(message) {
|
|
578
|
+
this.message = message;
|
|
579
|
+
this.stack = '';
|
|
580
|
+
}
|
|
581
|
+
// Make `instanceof Error` still work for returned errors.
|
|
582
|
+
PropTypeError.prototype = Error.prototype;
|
|
583
|
+
|
|
584
|
+
function createChainableTypeChecker(validate) {
|
|
585
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
586
|
+
var manualPropTypeCallCache = {};
|
|
587
|
+
var manualPropTypeWarningCount = 0;
|
|
588
|
+
}
|
|
589
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
590
|
+
componentName = componentName || ANONYMOUS;
|
|
591
|
+
propFullName = propFullName || propName;
|
|
592
|
+
|
|
593
|
+
if (secret !== ReactPropTypesSecret_1) {
|
|
594
|
+
if (throwOnDirectAccess) {
|
|
595
|
+
// New behavior only for users of `prop-types` package
|
|
596
|
+
invariant_1(
|
|
597
|
+
false,
|
|
598
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
599
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
600
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
601
|
+
);
|
|
602
|
+
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
603
|
+
// Old behavior for people using React.PropTypes
|
|
604
|
+
var cacheKey = componentName + ':' + propName;
|
|
605
|
+
if (
|
|
606
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
607
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
608
|
+
manualPropTypeWarningCount < 3
|
|
609
|
+
) {
|
|
610
|
+
warning_1(
|
|
611
|
+
false,
|
|
612
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
613
|
+
'function for the `%s` prop on `%s`. This is deprecated ' +
|
|
614
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
615
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
616
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
|
|
617
|
+
propFullName,
|
|
618
|
+
componentName
|
|
619
|
+
);
|
|
620
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
621
|
+
manualPropTypeWarningCount++;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (props[propName] == null) {
|
|
626
|
+
if (isRequired) {
|
|
627
|
+
if (props[propName] === null) {
|
|
628
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
629
|
+
}
|
|
630
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
631
|
+
}
|
|
632
|
+
return null;
|
|
633
|
+
} else {
|
|
634
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
639
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
640
|
+
|
|
641
|
+
return chainedCheckType;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
645
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
646
|
+
var propValue = props[propName];
|
|
647
|
+
var propType = getPropType(propValue);
|
|
648
|
+
if (propType !== expectedType) {
|
|
649
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
650
|
+
// check, but we can offer a more precise error message here rather than
|
|
651
|
+
// 'of type `object`'.
|
|
652
|
+
var preciseType = getPreciseType(propValue);
|
|
653
|
+
|
|
654
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
655
|
+
}
|
|
656
|
+
return null;
|
|
657
|
+
}
|
|
658
|
+
return createChainableTypeChecker(validate);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function createAnyTypeChecker() {
|
|
662
|
+
return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
666
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
667
|
+
if (typeof typeChecker !== 'function') {
|
|
668
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
669
|
+
}
|
|
670
|
+
var propValue = props[propName];
|
|
671
|
+
if (!Array.isArray(propValue)) {
|
|
672
|
+
var propType = getPropType(propValue);
|
|
673
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
674
|
+
}
|
|
675
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
676
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
|
677
|
+
if (error instanceof Error) {
|
|
678
|
+
return error;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
return createChainableTypeChecker(validate);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function createElementTypeChecker() {
|
|
687
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
688
|
+
var propValue = props[propName];
|
|
689
|
+
if (!isValidElement(propValue)) {
|
|
690
|
+
var propType = getPropType(propValue);
|
|
691
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
692
|
+
}
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
return createChainableTypeChecker(validate);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
699
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
700
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
701
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
702
|
+
var actualClassName = getClassName(props[propName]);
|
|
703
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
704
|
+
}
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
return createChainableTypeChecker(validate);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function createEnumTypeChecker(expectedValues) {
|
|
711
|
+
if (!Array.isArray(expectedValues)) {
|
|
712
|
+
process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
|
|
713
|
+
return emptyFunction_1.thatReturnsNull;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
717
|
+
var propValue = props[propName];
|
|
718
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
719
|
+
if (is(propValue, expectedValues[i])) {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
var valuesString = JSON.stringify(expectedValues);
|
|
725
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
726
|
+
}
|
|
727
|
+
return createChainableTypeChecker(validate);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
731
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
732
|
+
if (typeof typeChecker !== 'function') {
|
|
733
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
734
|
+
}
|
|
735
|
+
var propValue = props[propName];
|
|
736
|
+
var propType = getPropType(propValue);
|
|
737
|
+
if (propType !== 'object') {
|
|
738
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
739
|
+
}
|
|
740
|
+
for (var key in propValue) {
|
|
741
|
+
if (propValue.hasOwnProperty(key)) {
|
|
742
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
743
|
+
if (error instanceof Error) {
|
|
744
|
+
return error;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
return createChainableTypeChecker(validate);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
754
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
755
|
+
process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
756
|
+
return emptyFunction_1.thatReturnsNull;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
760
|
+
var checker = arrayOfTypeCheckers[i];
|
|
761
|
+
if (typeof checker !== 'function') {
|
|
762
|
+
warning_1(
|
|
763
|
+
false,
|
|
764
|
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
765
|
+
'received %s at index %s.',
|
|
766
|
+
getPostfixForTypeWarning(checker),
|
|
767
|
+
i
|
|
768
|
+
);
|
|
769
|
+
return emptyFunction_1.thatReturnsNull;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
774
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
775
|
+
var checker = arrayOfTypeCheckers[i];
|
|
776
|
+
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
|
777
|
+
return null;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
782
|
+
}
|
|
783
|
+
return createChainableTypeChecker(validate);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
function createNodeChecker() {
|
|
787
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
788
|
+
if (!isNode(props[propName])) {
|
|
789
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
790
|
+
}
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
793
|
+
return createChainableTypeChecker(validate);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
797
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
798
|
+
var propValue = props[propName];
|
|
799
|
+
var propType = getPropType(propValue);
|
|
800
|
+
if (propType !== 'object') {
|
|
801
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
802
|
+
}
|
|
803
|
+
for (var key in shapeTypes) {
|
|
804
|
+
var checker = shapeTypes[key];
|
|
805
|
+
if (!checker) {
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
809
|
+
if (error) {
|
|
810
|
+
return error;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return null;
|
|
814
|
+
}
|
|
815
|
+
return createChainableTypeChecker(validate);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
819
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
820
|
+
var propValue = props[propName];
|
|
821
|
+
var propType = getPropType(propValue);
|
|
822
|
+
if (propType !== 'object') {
|
|
823
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
824
|
+
}
|
|
825
|
+
// We need to check all keys in case some are required but missing from
|
|
826
|
+
// props.
|
|
827
|
+
var allKeys = objectAssign({}, props[propName], shapeTypes);
|
|
828
|
+
for (var key in allKeys) {
|
|
829
|
+
var checker = shapeTypes[key];
|
|
830
|
+
if (!checker) {
|
|
831
|
+
return new PropTypeError(
|
|
832
|
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
833
|
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
834
|
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
838
|
+
if (error) {
|
|
839
|
+
return error;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return null;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
return createChainableTypeChecker(validate);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function isNode(propValue) {
|
|
849
|
+
switch (typeof propValue) {
|
|
850
|
+
case 'number':
|
|
851
|
+
case 'string':
|
|
852
|
+
case 'undefined':
|
|
853
|
+
return true;
|
|
854
|
+
case 'boolean':
|
|
855
|
+
return !propValue;
|
|
856
|
+
case 'object':
|
|
857
|
+
if (Array.isArray(propValue)) {
|
|
858
|
+
return propValue.every(isNode);
|
|
859
|
+
}
|
|
860
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
865
|
+
if (iteratorFn) {
|
|
866
|
+
var iterator = iteratorFn.call(propValue);
|
|
867
|
+
var step;
|
|
868
|
+
if (iteratorFn !== propValue.entries) {
|
|
869
|
+
while (!(step = iterator.next()).done) {
|
|
870
|
+
if (!isNode(step.value)) {
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
} else {
|
|
875
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
876
|
+
while (!(step = iterator.next()).done) {
|
|
877
|
+
var entry = step.value;
|
|
878
|
+
if (entry) {
|
|
879
|
+
if (!isNode(entry[1])) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
} else {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
return true;
|
|
890
|
+
default:
|
|
891
|
+
return false;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function isSymbol(propType, propValue) {
|
|
896
|
+
// Native Symbol.
|
|
897
|
+
if (propType === 'symbol') {
|
|
898
|
+
return true;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
902
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
903
|
+
return true;
|
|
904
|
+
}
|
|
8
905
|
|
|
9
|
-
|
|
906
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
907
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
908
|
+
return true;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
915
|
+
function getPropType(propValue) {
|
|
916
|
+
var propType = typeof propValue;
|
|
917
|
+
if (Array.isArray(propValue)) {
|
|
918
|
+
return 'array';
|
|
919
|
+
}
|
|
920
|
+
if (propValue instanceof RegExp) {
|
|
921
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
922
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
923
|
+
// passes PropTypes.object.
|
|
924
|
+
return 'object';
|
|
925
|
+
}
|
|
926
|
+
if (isSymbol(propType, propValue)) {
|
|
927
|
+
return 'symbol';
|
|
928
|
+
}
|
|
929
|
+
return propType;
|
|
930
|
+
}
|
|
10
931
|
|
|
932
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
933
|
+
// See `createPrimitiveTypeChecker`.
|
|
934
|
+
function getPreciseType(propValue) {
|
|
935
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
936
|
+
return '' + propValue;
|
|
937
|
+
}
|
|
938
|
+
var propType = getPropType(propValue);
|
|
939
|
+
if (propType === 'object') {
|
|
940
|
+
if (propValue instanceof Date) {
|
|
941
|
+
return 'date';
|
|
942
|
+
} else if (propValue instanceof RegExp) {
|
|
943
|
+
return 'regexp';
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
return propType;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
950
|
+
// For example, "undefined" or "of type array"
|
|
951
|
+
function getPostfixForTypeWarning(value) {
|
|
952
|
+
var type = getPreciseType(value);
|
|
953
|
+
switch (type) {
|
|
954
|
+
case 'array':
|
|
955
|
+
case 'object':
|
|
956
|
+
return 'an ' + type;
|
|
957
|
+
case 'boolean':
|
|
958
|
+
case 'date':
|
|
959
|
+
case 'regexp':
|
|
960
|
+
return 'a ' + type;
|
|
961
|
+
default:
|
|
962
|
+
return type;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// Returns class name of the object, if any.
|
|
967
|
+
function getClassName(propValue) {
|
|
968
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
969
|
+
return ANONYMOUS;
|
|
970
|
+
}
|
|
971
|
+
return propValue.constructor.name;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
ReactPropTypes.checkPropTypes = checkPropTypes_1;
|
|
975
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
976
|
+
|
|
977
|
+
return ReactPropTypes;
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
var factoryWithThrowingShims = function() {
|
|
981
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
982
|
+
if (secret === ReactPropTypesSecret_1) {
|
|
983
|
+
// It is still safe when called from React.
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
invariant_1(
|
|
987
|
+
false,
|
|
988
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
989
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
990
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
991
|
+
);
|
|
992
|
+
} shim.isRequired = shim;
|
|
993
|
+
function getShim() {
|
|
994
|
+
return shim;
|
|
995
|
+
} // Important!
|
|
996
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
997
|
+
var ReactPropTypes = {
|
|
998
|
+
array: shim,
|
|
999
|
+
bool: shim,
|
|
1000
|
+
func: shim,
|
|
1001
|
+
number: shim,
|
|
1002
|
+
object: shim,
|
|
1003
|
+
string: shim,
|
|
1004
|
+
symbol: shim,
|
|
1005
|
+
|
|
1006
|
+
any: shim,
|
|
1007
|
+
arrayOf: getShim,
|
|
1008
|
+
element: shim,
|
|
1009
|
+
instanceOf: getShim,
|
|
1010
|
+
node: shim,
|
|
1011
|
+
objectOf: getShim,
|
|
1012
|
+
oneOf: getShim,
|
|
1013
|
+
oneOfType: getShim,
|
|
1014
|
+
shape: getShim,
|
|
1015
|
+
exact: getShim
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
ReactPropTypes.checkPropTypes = emptyFunction_1;
|
|
1019
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1020
|
+
|
|
1021
|
+
return ReactPropTypes;
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
var propTypes = createCommonjsModule(function (module) {
|
|
1025
|
+
/**
|
|
1026
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1027
|
+
*
|
|
1028
|
+
* This source code is licensed under the MIT license found in the
|
|
1029
|
+
* LICENSE file in the root directory of this source tree.
|
|
1030
|
+
*/
|
|
1031
|
+
|
|
1032
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1033
|
+
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
|
|
1034
|
+
Symbol.for &&
|
|
1035
|
+
Symbol.for('react.element')) ||
|
|
1036
|
+
0xeac7;
|
|
1037
|
+
|
|
1038
|
+
var isValidElement = function(object) {
|
|
1039
|
+
return typeof object === 'object' &&
|
|
1040
|
+
object !== null &&
|
|
1041
|
+
object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
1045
|
+
// http://fb.me/prop-types-in-prod
|
|
1046
|
+
var throwOnDirectAccess = true;
|
|
1047
|
+
module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
|
|
1048
|
+
} else {
|
|
1049
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1050
|
+
// http://fb.me/prop-types-in-prod
|
|
1051
|
+
module.exports = factoryWithThrowingShims();
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
var CONSTANT = {
|
|
1056
|
+
GLOBAL: {
|
|
1057
|
+
HIDE: "__react_tooltip_hide_event",
|
|
1058
|
+
REBUILD: "__react_tooltip_rebuild_event",
|
|
1059
|
+
SHOW: "__react_tooltip_show_event"
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Static methods for react-tooltip
|
|
1065
|
+
*/
|
|
1066
|
+
|
|
1067
|
+
var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) {
|
|
1068
|
+
// Compatible with IE
|
|
1069
|
+
// @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
|
|
1070
|
+
var event;
|
|
1071
|
+
|
|
1072
|
+
if (typeof window.CustomEvent === "function") {
|
|
1073
|
+
event = new window.CustomEvent(eventName, {
|
|
1074
|
+
detail: opts
|
|
1075
|
+
});
|
|
1076
|
+
} else {
|
|
1077
|
+
event = document.createEvent("Event");
|
|
1078
|
+
event.initEvent(eventName, false, true);
|
|
1079
|
+
event.detail = opts;
|
|
1080
|
+
}
|
|
11
1081
|
|
|
12
|
-
|
|
1082
|
+
window.dispatchEvent(event);
|
|
1083
|
+
};
|
|
13
1084
|
|
|
1085
|
+
function staticMethods (target) {
|
|
1086
|
+
/**
|
|
1087
|
+
* Hide all tooltip
|
|
1088
|
+
* @trigger ReactTooltip.hide()
|
|
1089
|
+
*/
|
|
1090
|
+
target.hide = function (target) {
|
|
1091
|
+
dispatchGlobalEvent(CONSTANT.GLOBAL.HIDE, {
|
|
1092
|
+
target: target
|
|
1093
|
+
});
|
|
1094
|
+
};
|
|
1095
|
+
/**
|
|
1096
|
+
* Rebuild all tooltip
|
|
1097
|
+
* @trigger ReactTooltip.rebuild()
|
|
1098
|
+
*/
|
|
14
1099
|
|
|
15
|
-
/* CSS */
|
|
16
1100
|
|
|
1101
|
+
target.rebuild = function () {
|
|
1102
|
+
dispatchGlobalEvent(CONSTANT.GLOBAL.REBUILD);
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Show specific tooltip
|
|
1106
|
+
* @trigger ReactTooltip.show()
|
|
1107
|
+
*/
|
|
17
1108
|
|
|
18
|
-
var _react = require('react');
|
|
19
1109
|
|
|
20
|
-
|
|
1110
|
+
target.show = function (target) {
|
|
1111
|
+
dispatchGlobalEvent(CONSTANT.GLOBAL.SHOW, {
|
|
1112
|
+
target: target
|
|
1113
|
+
});
|
|
1114
|
+
};
|
|
21
1115
|
|
|
22
|
-
|
|
1116
|
+
target.prototype.globalRebuild = function () {
|
|
1117
|
+
if (this.mount) {
|
|
1118
|
+
this.unbindListener();
|
|
1119
|
+
this.bindListener();
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
target.prototype.globalShow = function (event) {
|
|
1124
|
+
if (this.mount) {
|
|
1125
|
+
// Create a fake event, specific show will limit the type to `solid`
|
|
1126
|
+
// only `float` type cares e.clientX e.clientY
|
|
1127
|
+
var e = {
|
|
1128
|
+
currentTarget: event.detail.target
|
|
1129
|
+
};
|
|
1130
|
+
this.showTooltip(e, true);
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
target.prototype.globalHide = function (event) {
|
|
1135
|
+
if (this.mount) {
|
|
1136
|
+
var hasTarget = event && event.detail && event.detail.target && true || false;
|
|
1137
|
+
this.hideTooltip({
|
|
1138
|
+
currentTarget: hasTarget && event.detail.target
|
|
1139
|
+
}, hasTarget);
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Events that should be bound to the window
|
|
1146
|
+
*/
|
|
1147
|
+
function windowListener (target) {
|
|
1148
|
+
target.prototype.bindWindowEvents = function (resizeHide) {
|
|
1149
|
+
// ReactTooltip.hide
|
|
1150
|
+
window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
|
|
1151
|
+
window.addEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide, false); // ReactTooltip.rebuild
|
|
1152
|
+
|
|
1153
|
+
window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
|
|
1154
|
+
window.addEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild, false); // ReactTooltip.show
|
|
1155
|
+
|
|
1156
|
+
window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
|
|
1157
|
+
window.addEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow, false); // Resize
|
|
1158
|
+
|
|
1159
|
+
if (resizeHide) {
|
|
1160
|
+
window.removeEventListener("resize", this.onWindowResize);
|
|
1161
|
+
window.addEventListener("resize", this.onWindowResize, false);
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
target.prototype.unbindWindowEvents = function () {
|
|
1166
|
+
window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
|
|
1167
|
+
window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
|
|
1168
|
+
window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
|
|
1169
|
+
window.removeEventListener("resize", this.onWindowResize);
|
|
1170
|
+
};
|
|
1171
|
+
/**
|
|
1172
|
+
* invoked by resize event of window
|
|
1173
|
+
*/
|
|
23
1174
|
|
|
24
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
25
1175
|
|
|
26
|
-
|
|
1176
|
+
target.prototype.onWindowResize = function () {
|
|
1177
|
+
if (!this.mount) return;
|
|
1178
|
+
this.hideTooltip();
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Custom events to control showing and hiding of tooltip
|
|
1184
|
+
*
|
|
1185
|
+
* @attributes
|
|
1186
|
+
* - `event` {String}
|
|
1187
|
+
* - `eventOff` {String}
|
|
1188
|
+
*/
|
|
1189
|
+
var checkStatus = function checkStatus(dataEventOff, e) {
|
|
1190
|
+
var show = this.state.show;
|
|
1191
|
+
var id = this.props.id;
|
|
1192
|
+
var isCapture = this.isCapture(e.currentTarget);
|
|
1193
|
+
var currentItem = e.currentTarget.getAttribute("currentItem");
|
|
1194
|
+
if (!isCapture) e.stopPropagation();
|
|
1195
|
+
|
|
1196
|
+
if (show && currentItem === "true") {
|
|
1197
|
+
if (!dataEventOff) this.hideTooltip(e);
|
|
1198
|
+
} else {
|
|
1199
|
+
e.currentTarget.setAttribute("currentItem", "true");
|
|
1200
|
+
setUntargetItems(e.currentTarget, this.getTargetArray(id));
|
|
1201
|
+
this.showTooltip(e);
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
var setUntargetItems = function setUntargetItems(currentTarget, targetArray) {
|
|
1206
|
+
for (var i = 0; i < targetArray.length; i++) {
|
|
1207
|
+
if (currentTarget !== targetArray[i]) {
|
|
1208
|
+
targetArray[i].setAttribute("currentItem", "false");
|
|
1209
|
+
} else {
|
|
1210
|
+
targetArray[i].setAttribute("currentItem", "true");
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
var customListeners = {
|
|
1216
|
+
id: "9b69f92e-d3fe-498b-b1b4-c5e63a51b0cf",
|
|
1217
|
+
set: function set(target, event, listener) {
|
|
1218
|
+
if (this.id in target) {
|
|
1219
|
+
var map = target[this.id];
|
|
1220
|
+
map[event] = listener;
|
|
1221
|
+
} else {
|
|
1222
|
+
// this is workaround for WeakMap, which is not supported in older browsers, such as IE
|
|
1223
|
+
Object.defineProperty(target, this.id, {
|
|
1224
|
+
configurable: true,
|
|
1225
|
+
value: _defineProperty({}, event, listener)
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
get: function get(target, event) {
|
|
1230
|
+
var map = target[this.id];
|
|
27
1231
|
|
|
28
|
-
|
|
1232
|
+
if (map !== undefined) {
|
|
1233
|
+
return map[event];
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
function customEvent (target) {
|
|
1238
|
+
target.prototype.isCustomEvent = function (ele) {
|
|
1239
|
+
var event = this.state.event;
|
|
1240
|
+
return event || !!ele.getAttribute("data-event");
|
|
1241
|
+
};
|
|
1242
|
+
/* Bind listener for custom event */
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
target.prototype.customBindListener = function (ele) {
|
|
1246
|
+
var _this = this;
|
|
1247
|
+
|
|
1248
|
+
var _this$state = this.state,
|
|
1249
|
+
event = _this$state.event,
|
|
1250
|
+
eventOff = _this$state.eventOff;
|
|
1251
|
+
var dataEvent = ele.getAttribute("data-event") || event;
|
|
1252
|
+
var dataEventOff = ele.getAttribute("data-event-off") || eventOff;
|
|
1253
|
+
dataEvent.split(" ").forEach(function (event) {
|
|
1254
|
+
ele.removeEventListener(event, customListeners.get(ele, event));
|
|
1255
|
+
var customListener = checkStatus.bind(_this, dataEventOff);
|
|
1256
|
+
customListeners.set(ele, event, customListener);
|
|
1257
|
+
ele.addEventListener(event, customListener, false);
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
if (dataEventOff) {
|
|
1261
|
+
dataEventOff.split(" ").forEach(function (event) {
|
|
1262
|
+
ele.removeEventListener(event, _this.hideTooltip);
|
|
1263
|
+
ele.addEventListener(event, _this.hideTooltip, false);
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
/* Unbind listener for custom event */
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
target.prototype.customUnbindListener = function (ele) {
|
|
1271
|
+
var _this$state2 = this.state,
|
|
1272
|
+
event = _this$state2.event,
|
|
1273
|
+
eventOff = _this$state2.eventOff;
|
|
1274
|
+
var dataEvent = event || ele.getAttribute("data-event");
|
|
1275
|
+
var dataEventOff = eventOff || ele.getAttribute("data-event-off");
|
|
1276
|
+
ele.removeEventListener(dataEvent, customListeners.get(ele, event));
|
|
1277
|
+
if (dataEventOff) ele.removeEventListener(dataEventOff, this.hideTooltip);
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* Util method to judge if it should follow capture model
|
|
1283
|
+
*/
|
|
1284
|
+
function isCapture (target) {
|
|
1285
|
+
target.prototype.isCapture = function (currentTarget) {
|
|
1286
|
+
return currentTarget && currentTarget.getAttribute("data-iscapture") === "true" || this.props.isCapture || false;
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Util method to get effect
|
|
1292
|
+
*/
|
|
1293
|
+
function getEffect (target) {
|
|
1294
|
+
target.prototype.getEffect = function (currentTarget) {
|
|
1295
|
+
var dataEffect = currentTarget.getAttribute("data-effect");
|
|
1296
|
+
return dataEffect || this.props.effect || "float";
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Util method to get effect
|
|
1302
|
+
*/
|
|
1303
|
+
|
|
1304
|
+
var makeProxy = function makeProxy(e) {
|
|
1305
|
+
var proxy = {};
|
|
1306
|
+
|
|
1307
|
+
for (var key in e) {
|
|
1308
|
+
if (typeof e[key] === "function") {
|
|
1309
|
+
proxy[key] = e[key].bind(e);
|
|
1310
|
+
} else {
|
|
1311
|
+
proxy[key] = e[key];
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
29
1314
|
|
|
30
|
-
|
|
1315
|
+
return proxy;
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
var bodyListener = function bodyListener(callback, options, e) {
|
|
1319
|
+
var _options$respectEffec = options.respectEffect,
|
|
1320
|
+
respectEffect = _options$respectEffec === void 0 ? false : _options$respectEffec,
|
|
1321
|
+
_options$customEvent = options.customEvent,
|
|
1322
|
+
customEvent = _options$customEvent === void 0 ? false : _options$customEvent;
|
|
1323
|
+
var id = this.props.id;
|
|
1324
|
+
var tip = e.target.getAttribute("data-tip") || null;
|
|
1325
|
+
var forId = e.target.getAttribute("data-for") || null;
|
|
1326
|
+
var target = e.target;
|
|
1327
|
+
|
|
1328
|
+
if (this.isCustomEvent(target) && !customEvent) {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
31
1331
|
|
|
32
|
-
var
|
|
1332
|
+
var isTargetBelongsToTooltip = id == null && forId == null || forId === id;
|
|
33
1333
|
|
|
34
|
-
|
|
1334
|
+
if (tip != null && (!respectEffect || this.getEffect(target) === "float") && isTargetBelongsToTooltip) {
|
|
1335
|
+
var proxy = makeProxy(e);
|
|
1336
|
+
proxy.currentTarget = target;
|
|
1337
|
+
callback(proxy);
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
var findCustomEvents = function findCustomEvents(targetArray, dataAttribute) {
|
|
1342
|
+
var events = {};
|
|
1343
|
+
targetArray.forEach(function (target) {
|
|
1344
|
+
var event = target.getAttribute(dataAttribute);
|
|
1345
|
+
if (event) event.split(" ").forEach(function (event) {
|
|
1346
|
+
return events[event] = true;
|
|
1347
|
+
});
|
|
1348
|
+
});
|
|
1349
|
+
return events;
|
|
1350
|
+
};
|
|
1351
|
+
|
|
1352
|
+
var getBody = function getBody() {
|
|
1353
|
+
return document.getElementsByTagName("body")[0];
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
function bodyMode (target) {
|
|
1357
|
+
target.prototype.isBodyMode = function () {
|
|
1358
|
+
return !!this.props.bodyMode;
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
target.prototype.bindBodyListener = function (targetArray) {
|
|
1362
|
+
var _this = this;
|
|
1363
|
+
|
|
1364
|
+
var _this$state = this.state,
|
|
1365
|
+
event = _this$state.event,
|
|
1366
|
+
eventOff = _this$state.eventOff,
|
|
1367
|
+
possibleCustomEvents = _this$state.possibleCustomEvents,
|
|
1368
|
+
possibleCustomEventsOff = _this$state.possibleCustomEventsOff;
|
|
1369
|
+
var body = getBody();
|
|
1370
|
+
var customEvents = findCustomEvents(targetArray, "data-event");
|
|
1371
|
+
var customEventsOff = findCustomEvents(targetArray, "data-event-off");
|
|
1372
|
+
if (event != null) customEvents[event] = true;
|
|
1373
|
+
if (eventOff != null) customEventsOff[eventOff] = true;
|
|
1374
|
+
possibleCustomEvents.split(" ").forEach(function (event) {
|
|
1375
|
+
return customEvents[event] = true;
|
|
1376
|
+
});
|
|
1377
|
+
possibleCustomEventsOff.split(" ").forEach(function (event) {
|
|
1378
|
+
return customEventsOff[event] = true;
|
|
1379
|
+
});
|
|
1380
|
+
this.unbindBodyListener(body);
|
|
1381
|
+
var listeners = this.bodyModeListeners = {};
|
|
1382
|
+
|
|
1383
|
+
if (event == null) {
|
|
1384
|
+
listeners.mouseover = bodyListener.bind(this, this.showTooltip, {});
|
|
1385
|
+
listeners.mousemove = bodyListener.bind(this, this.updateTooltip, {
|
|
1386
|
+
respectEffect: true
|
|
1387
|
+
});
|
|
1388
|
+
listeners.mouseout = bodyListener.bind(this, this.hideTooltip, {});
|
|
1389
|
+
}
|
|
35
1390
|
|
|
36
|
-
var
|
|
1391
|
+
for (var _event in customEvents) {
|
|
1392
|
+
listeners[_event] = bodyListener.bind(this, function (e) {
|
|
1393
|
+
var targetEventOff = e.currentTarget.getAttribute("data-event-off") || eventOff;
|
|
1394
|
+
checkStatus.call(_this, targetEventOff, e);
|
|
1395
|
+
}, {
|
|
1396
|
+
customEvent: true
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
37
1399
|
|
|
38
|
-
var
|
|
1400
|
+
for (var _event2 in customEventsOff) {
|
|
1401
|
+
listeners[_event2] = bodyListener.bind(this, this.hideTooltip, {
|
|
1402
|
+
customEvent: true
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
39
1405
|
|
|
40
|
-
var
|
|
1406
|
+
for (var _event3 in listeners) {
|
|
1407
|
+
body.addEventListener(_event3, listeners[_event3]);
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
41
1410
|
|
|
42
|
-
|
|
1411
|
+
target.prototype.unbindBodyListener = function (body) {
|
|
1412
|
+
body = body || getBody();
|
|
1413
|
+
var listeners = this.bodyModeListeners;
|
|
43
1414
|
|
|
44
|
-
var
|
|
1415
|
+
for (var event in listeners) {
|
|
1416
|
+
body.removeEventListener(event, listeners[event]);
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Tracking target removing from DOM.
|
|
1423
|
+
* It's necessary to hide tooltip when it's target disappears.
|
|
1424
|
+
* Otherwise, the tooltip would be shown forever until another target
|
|
1425
|
+
* is triggered.
|
|
1426
|
+
*
|
|
1427
|
+
* If MutationObserver is not available, this feature just doesn't work.
|
|
1428
|
+
*/
|
|
1429
|
+
// https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/
|
|
1430
|
+
var getMutationObserverClass = function getMutationObserverClass() {
|
|
1431
|
+
return window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
function trackRemoval (target) {
|
|
1435
|
+
target.prototype.bindRemovalTracker = function () {
|
|
1436
|
+
var _this = this;
|
|
1437
|
+
|
|
1438
|
+
var MutationObserver = getMutationObserverClass();
|
|
1439
|
+
if (MutationObserver == null) return;
|
|
1440
|
+
var observer = new MutationObserver(function (mutations) {
|
|
1441
|
+
for (var m1 = 0; m1 < mutations.length; m1++) {
|
|
1442
|
+
var mutation = mutations[m1];
|
|
1443
|
+
|
|
1444
|
+
for (var m2 = 0; m2 < mutation.removedNodes.length; m2++) {
|
|
1445
|
+
var element = mutation.removedNodes[m2];
|
|
1446
|
+
|
|
1447
|
+
if (element === _this.state.currentTarget) {
|
|
1448
|
+
_this.hideTooltip();
|
|
45
1449
|
|
|
46
|
-
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
observer.observe(window.document, {
|
|
1456
|
+
childList: true,
|
|
1457
|
+
subtree: true
|
|
1458
|
+
});
|
|
1459
|
+
this.removalTracker = observer;
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1462
|
+
target.prototype.unbindRemovalTracker = function () {
|
|
1463
|
+
if (this.removalTracker) {
|
|
1464
|
+
this.removalTracker.disconnect();
|
|
1465
|
+
this.removalTracker = null;
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* Calculate the position of tooltip
|
|
1472
|
+
*
|
|
1473
|
+
* @params
|
|
1474
|
+
* - `e` {Event} the event of current mouse
|
|
1475
|
+
* - `target` {Element} the currentTarget of the event
|
|
1476
|
+
* - `node` {DOM} the react-tooltip object
|
|
1477
|
+
* - `place` {String} top / right / bottom / left
|
|
1478
|
+
* - `effect` {String} float / solid
|
|
1479
|
+
* - `offset` {Object} the offset to default position
|
|
1480
|
+
*
|
|
1481
|
+
* @return {Object}
|
|
1482
|
+
* - `isNewState` {Bool} required
|
|
1483
|
+
* - `newState` {Object}
|
|
1484
|
+
* - `position` {Object} {left: {Number}, top: {Number}}
|
|
1485
|
+
*/
|
|
1486
|
+
function getPosition (e, target, node, place, desiredPlace, effect, offset) {
|
|
1487
|
+
var _getDimensions = getDimensions(node),
|
|
1488
|
+
tipWidth = _getDimensions.width,
|
|
1489
|
+
tipHeight = _getDimensions.height;
|
|
1490
|
+
|
|
1491
|
+
var _getDimensions2 = getDimensions(target),
|
|
1492
|
+
targetWidth = _getDimensions2.width,
|
|
1493
|
+
targetHeight = _getDimensions2.height;
|
|
1494
|
+
|
|
1495
|
+
var _getCurrentOffset = getCurrentOffset(e, target, effect),
|
|
1496
|
+
mouseX = _getCurrentOffset.mouseX,
|
|
1497
|
+
mouseY = _getCurrentOffset.mouseY;
|
|
1498
|
+
|
|
1499
|
+
var defaultOffset = getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight);
|
|
1500
|
+
|
|
1501
|
+
var _calculateOffset = calculateOffset(offset),
|
|
1502
|
+
extraOffset_X = _calculateOffset.extraOffset_X,
|
|
1503
|
+
extraOffset_Y = _calculateOffset.extraOffset_Y;
|
|
1504
|
+
|
|
1505
|
+
var windowWidth = window.innerWidth;
|
|
1506
|
+
var windowHeight = window.innerHeight;
|
|
1507
|
+
|
|
1508
|
+
var _getParent = getParent(node),
|
|
1509
|
+
parentTop = _getParent.parentTop,
|
|
1510
|
+
parentLeft = _getParent.parentLeft; // Get the edge offset of the tooltip
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
var getTipOffsetLeft = function getTipOffsetLeft(place) {
|
|
1514
|
+
var offset_X = defaultOffset[place].l;
|
|
1515
|
+
return mouseX + offset_X + extraOffset_X;
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
var getTipOffsetRight = function getTipOffsetRight(place) {
|
|
1519
|
+
var offset_X = defaultOffset[place].r;
|
|
1520
|
+
return mouseX + offset_X + extraOffset_X;
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
var getTipOffsetTop = function getTipOffsetTop(place) {
|
|
1524
|
+
var offset_Y = defaultOffset[place].t;
|
|
1525
|
+
return mouseY + offset_Y + extraOffset_Y;
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
var getTipOffsetBottom = function getTipOffsetBottom(place) {
|
|
1529
|
+
var offset_Y = defaultOffset[place].b;
|
|
1530
|
+
return mouseY + offset_Y + extraOffset_Y;
|
|
1531
|
+
}; //
|
|
1532
|
+
// Functions to test whether the tooltip's sides are inside
|
|
1533
|
+
// the client window for a given orientation p
|
|
1534
|
+
//
|
|
1535
|
+
// _____________
|
|
1536
|
+
// | | <-- Right side
|
|
1537
|
+
// | p = 'left' |\
|
|
1538
|
+
// | |/ |\
|
|
1539
|
+
// |_____________| |_\ <-- Mouse
|
|
1540
|
+
// / \ |
|
|
1541
|
+
// |
|
|
1542
|
+
// |
|
|
1543
|
+
// Bottom side
|
|
1544
|
+
//
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
var outsideLeft = function outsideLeft(p) {
|
|
1548
|
+
return getTipOffsetLeft(p) < 0;
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
var outsideRight = function outsideRight(p) {
|
|
1552
|
+
return getTipOffsetRight(p) > windowWidth;
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1555
|
+
var outsideTop = function outsideTop(p) {
|
|
1556
|
+
return getTipOffsetTop(p) < 0;
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
var outsideBottom = function outsideBottom(p) {
|
|
1560
|
+
return getTipOffsetBottom(p) > windowHeight;
|
|
1561
|
+
}; // Check whether the tooltip with orientation p is completely inside the client window
|
|
1562
|
+
|
|
1563
|
+
|
|
1564
|
+
var outside = function outside(p) {
|
|
1565
|
+
return outsideLeft(p) || outsideRight(p) || outsideTop(p) || outsideBottom(p);
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
var inside = function inside(p) {
|
|
1569
|
+
return !outside(p);
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
var placesList = ["top", "bottom", "left", "right"];
|
|
1573
|
+
var insideList = [];
|
|
1574
|
+
|
|
1575
|
+
for (var i = 0; i < 4; i++) {
|
|
1576
|
+
var p = placesList[i];
|
|
1577
|
+
|
|
1578
|
+
if (inside(p)) {
|
|
1579
|
+
insideList.push(p);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
47
1582
|
|
|
48
|
-
var
|
|
1583
|
+
var isNewState = false;
|
|
1584
|
+
var newPlace;
|
|
1585
|
+
var shouldUpdatePlace = desiredPlace !== place;
|
|
49
1586
|
|
|
50
|
-
|
|
1587
|
+
if (inside(desiredPlace) && shouldUpdatePlace) {
|
|
1588
|
+
isNewState = true;
|
|
1589
|
+
newPlace = desiredPlace;
|
|
1590
|
+
} else if (insideList.length > 0 && shouldUpdatePlace && outside(desiredPlace) && outside(place)) {
|
|
1591
|
+
isNewState = true;
|
|
1592
|
+
newPlace = insideList[0];
|
|
1593
|
+
}
|
|
51
1594
|
|
|
52
|
-
|
|
1595
|
+
if (isNewState) {
|
|
1596
|
+
return {
|
|
1597
|
+
isNewState: true,
|
|
1598
|
+
newState: {
|
|
1599
|
+
place: newPlace
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
53
1603
|
|
|
54
|
-
|
|
1604
|
+
return {
|
|
1605
|
+
isNewState: false,
|
|
1606
|
+
position: {
|
|
1607
|
+
left: parseInt(getTipOffsetLeft(place) - parentLeft, 10),
|
|
1608
|
+
top: parseInt(getTipOffsetTop(place) - parentTop, 10)
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
var getDimensions = function getDimensions(node) {
|
|
1614
|
+
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
1615
|
+
height = _node$getBoundingClie.height,
|
|
1616
|
+
width = _node$getBoundingClie.width;
|
|
1617
|
+
|
|
1618
|
+
return {
|
|
1619
|
+
height: parseInt(height, 10),
|
|
1620
|
+
width: parseInt(width, 10)
|
|
1621
|
+
};
|
|
1622
|
+
}; // Get current mouse offset
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
|
|
1626
|
+
var boundingClientRect = currentTarget.getBoundingClientRect();
|
|
1627
|
+
var targetTop = boundingClientRect.top;
|
|
1628
|
+
var targetLeft = boundingClientRect.left;
|
|
1629
|
+
|
|
1630
|
+
var _getDimensions3 = getDimensions(currentTarget),
|
|
1631
|
+
targetWidth = _getDimensions3.width,
|
|
1632
|
+
targetHeight = _getDimensions3.height;
|
|
1633
|
+
|
|
1634
|
+
if (effect === "float") {
|
|
1635
|
+
return {
|
|
1636
|
+
mouseX: e.clientX,
|
|
1637
|
+
mouseY: e.clientY
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
55
1640
|
|
|
56
|
-
|
|
1641
|
+
return {
|
|
1642
|
+
mouseX: targetLeft + targetWidth / 2,
|
|
1643
|
+
mouseY: targetTop + targetHeight / 2
|
|
1644
|
+
};
|
|
1645
|
+
}; // List all possibility of tooltip final offset
|
|
1646
|
+
// This is useful in judging if it is necessary for tooltip to switch position when out of window
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
var getDefaultPosition = function getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight) {
|
|
1650
|
+
var top;
|
|
1651
|
+
var right;
|
|
1652
|
+
var bottom;
|
|
1653
|
+
var left;
|
|
1654
|
+
var disToMouse = 3;
|
|
1655
|
+
var triangleHeight = 2;
|
|
1656
|
+
var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip
|
|
1657
|
+
|
|
1658
|
+
if (effect === "float") {
|
|
1659
|
+
top = {
|
|
1660
|
+
l: -(tipWidth / 2),
|
|
1661
|
+
r: tipWidth / 2,
|
|
1662
|
+
t: -(tipHeight + disToMouse + triangleHeight),
|
|
1663
|
+
b: -disToMouse
|
|
1664
|
+
};
|
|
1665
|
+
bottom = {
|
|
1666
|
+
l: -(tipWidth / 2),
|
|
1667
|
+
r: tipWidth / 2,
|
|
1668
|
+
t: disToMouse + cursorHeight,
|
|
1669
|
+
b: tipHeight + disToMouse + triangleHeight + cursorHeight
|
|
1670
|
+
};
|
|
1671
|
+
left = {
|
|
1672
|
+
l: -(tipWidth + disToMouse + triangleHeight),
|
|
1673
|
+
r: -disToMouse,
|
|
1674
|
+
t: -(tipHeight / 2),
|
|
1675
|
+
b: tipHeight / 2
|
|
1676
|
+
};
|
|
1677
|
+
right = {
|
|
1678
|
+
l: disToMouse,
|
|
1679
|
+
r: tipWidth + disToMouse + triangleHeight,
|
|
1680
|
+
t: -(tipHeight / 2),
|
|
1681
|
+
b: tipHeight / 2
|
|
1682
|
+
};
|
|
1683
|
+
} else if (effect === "solid") {
|
|
1684
|
+
top = {
|
|
1685
|
+
l: -(tipWidth / 2),
|
|
1686
|
+
r: tipWidth / 2,
|
|
1687
|
+
t: -(targetHeight / 2 + tipHeight + triangleHeight),
|
|
1688
|
+
b: -(targetHeight / 2)
|
|
1689
|
+
};
|
|
1690
|
+
bottom = {
|
|
1691
|
+
l: -(tipWidth / 2),
|
|
1692
|
+
r: tipWidth / 2,
|
|
1693
|
+
t: targetHeight / 2,
|
|
1694
|
+
b: targetHeight / 2 + tipHeight + triangleHeight
|
|
1695
|
+
};
|
|
1696
|
+
left = {
|
|
1697
|
+
l: -(tipWidth + targetWidth / 2 + triangleHeight),
|
|
1698
|
+
r: -(targetWidth / 2),
|
|
1699
|
+
t: -(tipHeight / 2),
|
|
1700
|
+
b: tipHeight / 2
|
|
1701
|
+
};
|
|
1702
|
+
right = {
|
|
1703
|
+
l: targetWidth / 2,
|
|
1704
|
+
r: tipWidth + targetWidth / 2 + triangleHeight,
|
|
1705
|
+
t: -(tipHeight / 2),
|
|
1706
|
+
b: tipHeight / 2
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
57
1709
|
|
|
58
|
-
|
|
1710
|
+
return {
|
|
1711
|
+
top: top,
|
|
1712
|
+
bottom: bottom,
|
|
1713
|
+
left: left,
|
|
1714
|
+
right: right
|
|
1715
|
+
};
|
|
1716
|
+
}; // Consider additional offset into position calculation
|
|
59
1717
|
|
|
60
|
-
var _getPosition2 = _interopRequireDefault(_getPosition);
|
|
61
1718
|
|
|
62
|
-
var
|
|
1719
|
+
var calculateOffset = function calculateOffset(offset) {
|
|
1720
|
+
var extraOffset_X = 0;
|
|
1721
|
+
var extraOffset_Y = 0;
|
|
63
1722
|
|
|
64
|
-
|
|
1723
|
+
if (Object.prototype.toString.apply(offset) === "[object String]") {
|
|
1724
|
+
offset = JSON.parse(offset.toString().replace(/\'/g, '"'));
|
|
1725
|
+
}
|
|
65
1726
|
|
|
66
|
-
var
|
|
1727
|
+
for (var key in offset) {
|
|
1728
|
+
if (key === "top") {
|
|
1729
|
+
extraOffset_Y -= parseInt(offset[key], 10);
|
|
1730
|
+
} else if (key === "bottom") {
|
|
1731
|
+
extraOffset_Y += parseInt(offset[key], 10);
|
|
1732
|
+
} else if (key === "left") {
|
|
1733
|
+
extraOffset_X -= parseInt(offset[key], 10);
|
|
1734
|
+
} else if (key === "right") {
|
|
1735
|
+
extraOffset_X += parseInt(offset[key], 10);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
67
1738
|
|
|
68
|
-
|
|
1739
|
+
return {
|
|
1740
|
+
extraOffset_X: extraOffset_X,
|
|
1741
|
+
extraOffset_Y: extraOffset_Y
|
|
1742
|
+
};
|
|
1743
|
+
}; // Get the offset of the parent elements
|
|
69
1744
|
|
|
70
|
-
var _nodeListToArray2 = _interopRequireDefault(_nodeListToArray);
|
|
71
1745
|
|
|
72
|
-
var
|
|
1746
|
+
var getParent = function getParent(currentTarget) {
|
|
1747
|
+
var currentParent = currentTarget;
|
|
73
1748
|
|
|
74
|
-
|
|
1749
|
+
while (currentParent) {
|
|
1750
|
+
if (window.getComputedStyle(currentParent).getPropertyValue("transform") !== "none") break;
|
|
1751
|
+
currentParent = currentParent.parentElement;
|
|
1752
|
+
}
|
|
75
1753
|
|
|
76
|
-
|
|
1754
|
+
var parentTop = currentParent && currentParent.getBoundingClientRect().top || 0;
|
|
1755
|
+
var parentLeft = currentParent && currentParent.getBoundingClientRect().left || 0;
|
|
1756
|
+
return {
|
|
1757
|
+
parentTop: parentTop,
|
|
1758
|
+
parentLeft: parentLeft
|
|
1759
|
+
};
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
/**
|
|
1763
|
+
* To get the tooltip content
|
|
1764
|
+
* it may comes from data-tip or this.props.children
|
|
1765
|
+
* it should support multiline
|
|
1766
|
+
*
|
|
1767
|
+
* @params
|
|
1768
|
+
* - `tip` {String} value of data-tip
|
|
1769
|
+
* - `children` {ReactElement} this.props.children
|
|
1770
|
+
* - `multiline` {Any} could be Bool(true/false) or String('true'/'false')
|
|
1771
|
+
*
|
|
1772
|
+
* @return
|
|
1773
|
+
* - String or react component
|
|
1774
|
+
*/
|
|
1775
|
+
function getTipContent (tip, children, getContent, multiline) {
|
|
1776
|
+
if (children) return children;
|
|
1777
|
+
if (getContent !== undefined && getContent !== null) return getContent; // getContent can be 0, '', etc.
|
|
1778
|
+
|
|
1779
|
+
if (getContent === null) return null; // Tip not exist and children is null or undefined
|
|
1780
|
+
|
|
1781
|
+
var regexp = /<br\s*\/?>/;
|
|
1782
|
+
|
|
1783
|
+
if (!multiline || multiline === "false" || !regexp.test(tip)) {
|
|
1784
|
+
// No trim(), so that user can keep their input
|
|
1785
|
+
return tip;
|
|
1786
|
+
} // Multiline tooltip content
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
return tip.split(regexp).map(function (d, i) {
|
|
1790
|
+
return React.createElement("span", {
|
|
1791
|
+
key: i,
|
|
1792
|
+
className: "multi-line"
|
|
1793
|
+
}, d);
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* Support aria- and role in ReactTooltip
|
|
1799
|
+
*
|
|
1800
|
+
* @params props {Object}
|
|
1801
|
+
* @return {Object}
|
|
1802
|
+
*/
|
|
1803
|
+
function parseAria(props) {
|
|
1804
|
+
var ariaObj = {};
|
|
1805
|
+
Object.keys(props).filter(function (prop) {
|
|
1806
|
+
// aria-xxx and role is acceptable
|
|
1807
|
+
return /(^aria-\w+$|^role$)/.test(prop);
|
|
1808
|
+
}).forEach(function (prop) {
|
|
1809
|
+
ariaObj[prop] = props[prop];
|
|
1810
|
+
});
|
|
1811
|
+
return ariaObj;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Convert nodelist to array
|
|
1816
|
+
* @see https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/core/createArrayFromMixed.js#L24
|
|
1817
|
+
* NodeLists are functions in Safari
|
|
1818
|
+
*/
|
|
1819
|
+
function nodeListToArray (nodeList) {
|
|
1820
|
+
var length = nodeList.length;
|
|
1821
|
+
|
|
1822
|
+
if (nodeList.hasOwnProperty) {
|
|
1823
|
+
return Array.prototype.slice.call(nodeList);
|
|
1824
|
+
}
|
|
77
1825
|
|
|
78
|
-
|
|
1826
|
+
return new Array(length).fill().map(function (index) {
|
|
1827
|
+
return nodeList[index];
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
79
1830
|
|
|
80
|
-
|
|
1831
|
+
___$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}");
|
|
81
1832
|
|
|
82
|
-
|
|
1833
|
+
var _class, _class2, _temp;
|
|
83
1834
|
|
|
84
|
-
var ReactTooltip = (
|
|
1835
|
+
var ReactTooltip = staticMethods(_class = windowListener(_class = customEvent(_class = isCapture(_class = getEffect(_class = bodyMode(_class = trackRemoval(_class = (_temp = _class2 =
|
|
1836
|
+
/*#__PURE__*/
|
|
1837
|
+
function (_React$Component) {
|
|
85
1838
|
_inherits(ReactTooltip, _React$Component);
|
|
86
1839
|
|
|
87
1840
|
function ReactTooltip(props) {
|
|
88
|
-
|
|
1841
|
+
var _this;
|
|
89
1842
|
|
|
90
|
-
|
|
1843
|
+
_classCallCheck(this, ReactTooltip);
|
|
91
1844
|
|
|
1845
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactTooltip).call(this, props));
|
|
92
1846
|
_this.state = {
|
|
93
|
-
place: props.place ||
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1847
|
+
place: props.place || "top",
|
|
1848
|
+
// Direction of tooltip
|
|
1849
|
+
desiredPlace: props.place || "top",
|
|
1850
|
+
type: "dark",
|
|
1851
|
+
// Color theme of tooltip
|
|
1852
|
+
effect: "float",
|
|
1853
|
+
// float or fixed
|
|
97
1854
|
show: false,
|
|
98
1855
|
border: false,
|
|
99
1856
|
offset: {},
|
|
100
|
-
extraClass:
|
|
1857
|
+
extraClass: "",
|
|
101
1858
|
html: false,
|
|
102
1859
|
delayHide: 0,
|
|
103
1860
|
delayShow: 0,
|
|
104
1861
|
event: props.event || null,
|
|
105
1862
|
eventOff: props.eventOff || null,
|
|
106
|
-
currentEvent: null,
|
|
107
|
-
|
|
108
|
-
|
|
1863
|
+
currentEvent: null,
|
|
1864
|
+
// Current mouse event
|
|
1865
|
+
currentTarget: null,
|
|
1866
|
+
// Current target of mouse event
|
|
1867
|
+
ariaProps: parseAria(props),
|
|
1868
|
+
// aria- and role attributes
|
|
109
1869
|
isEmptyTip: false,
|
|
110
1870
|
disable: false,
|
|
111
|
-
possibleCustomEvents: props.possibleCustomEvents ||
|
|
112
|
-
possibleCustomEventsOff: props.possibleCustomEventsOff ||
|
|
1871
|
+
possibleCustomEvents: props.possibleCustomEvents || "",
|
|
1872
|
+
possibleCustomEventsOff: props.possibleCustomEventsOff || "",
|
|
113
1873
|
originTooltip: null,
|
|
114
1874
|
isMultiline: false
|
|
115
1875
|
};
|
|
116
1876
|
|
|
117
|
-
_this.bind([
|
|
1877
|
+
_this.bind(["showTooltip", "updateTooltip", "hideTooltip", "hideTooltipOnScroll", "getTooltipContent", "globalRebuild", "globalShow", "globalHide", "onWindowResize", "mouseOnToolTip"]);
|
|
118
1878
|
|
|
119
1879
|
_this.mount = true;
|
|
120
1880
|
_this.delayShowLoop = null;
|
|
@@ -123,14 +1883,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
123
1883
|
_this.intervalUpdateContent = null;
|
|
124
1884
|
return _this;
|
|
125
1885
|
}
|
|
126
|
-
|
|
127
1886
|
/**
|
|
128
1887
|
* For unify the bind and unbind listener
|
|
129
1888
|
*/
|
|
130
1889
|
|
|
131
1890
|
|
|
132
1891
|
_createClass(ReactTooltip, [{
|
|
133
|
-
key:
|
|
1892
|
+
key: "bind",
|
|
134
1893
|
value: function bind(methodArray) {
|
|
135
1894
|
var _this2 = this;
|
|
136
1895
|
|
|
@@ -139,42 +1898,35 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
139
1898
|
});
|
|
140
1899
|
}
|
|
141
1900
|
}, {
|
|
142
|
-
key:
|
|
1901
|
+
key: "componentDidMount",
|
|
143
1902
|
value: function componentDidMount() {
|
|
144
|
-
var
|
|
145
|
-
insecure =
|
|
146
|
-
resizeHide =
|
|
147
|
-
|
|
148
|
-
if (insecure) {
|
|
149
|
-
this.setStyleHeader(); // Set the style to the <link>
|
|
150
|
-
}
|
|
1903
|
+
var _this$props = this.props,
|
|
1904
|
+
insecure = _this$props.insecure,
|
|
1905
|
+
resizeHide = _this$props.resizeHide;
|
|
151
1906
|
|
|
152
1907
|
this.bindListener(); // Bind listener for tooltip
|
|
1908
|
+
|
|
153
1909
|
this.bindWindowEvents(resizeHide); // Bind global event for static method
|
|
154
1910
|
}
|
|
155
1911
|
}, {
|
|
156
|
-
key:
|
|
1912
|
+
key: "componentWillUnmount",
|
|
157
1913
|
value: function componentWillUnmount() {
|
|
158
1914
|
this.mount = false;
|
|
159
|
-
|
|
160
1915
|
this.clearTimer();
|
|
161
|
-
|
|
162
1916
|
this.unbindListener();
|
|
163
1917
|
this.removeScrollListener();
|
|
164
1918
|
this.unbindWindowEvents();
|
|
165
1919
|
}
|
|
166
|
-
|
|
167
1920
|
/**
|
|
168
1921
|
* Return if the mouse is on the tooltip.
|
|
169
1922
|
* @returns {boolean} true - mouse is on the tooltip
|
|
170
1923
|
*/
|
|
171
1924
|
|
|
172
1925
|
}, {
|
|
173
|
-
key:
|
|
1926
|
+
key: "mouseOnToolTip",
|
|
174
1927
|
value: function mouseOnToolTip() {
|
|
175
1928
|
var show = this.state.show;
|
|
176
1929
|
|
|
177
|
-
|
|
178
1930
|
if (show && this.tooltipRef) {
|
|
179
1931
|
/* old IE or Firefox work around */
|
|
180
1932
|
if (!this.tooltipRef.matches) {
|
|
@@ -186,8 +1938,10 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
186
1938
|
this.tooltipRef.matches = this.tooltipRef.mozMatchesSelector;
|
|
187
1939
|
}
|
|
188
1940
|
}
|
|
189
|
-
|
|
1941
|
+
|
|
1942
|
+
return this.tooltipRef.matches(":hover");
|
|
190
1943
|
}
|
|
1944
|
+
|
|
191
1945
|
return false;
|
|
192
1946
|
}
|
|
193
1947
|
/**
|
|
@@ -195,41 +1949,42 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
195
1949
|
*/
|
|
196
1950
|
|
|
197
1951
|
}, {
|
|
198
|
-
key:
|
|
1952
|
+
key: "getTargetArray",
|
|
199
1953
|
value: function getTargetArray(id) {
|
|
200
|
-
var targetArray
|
|
1954
|
+
var targetArray;
|
|
1955
|
+
|
|
201
1956
|
if (!id) {
|
|
202
|
-
targetArray = document.querySelectorAll(
|
|
1957
|
+
targetArray = document.querySelectorAll("[data-tip]:not([data-for])");
|
|
203
1958
|
} else {
|
|
204
|
-
var escaped = id.replace(/\\/g,
|
|
205
|
-
targetArray = document.querySelectorAll(
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return (0, _nodeListToArray2.default)(targetArray);
|
|
209
|
-
}
|
|
1959
|
+
var escaped = id.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
1960
|
+
targetArray = document.querySelectorAll("[data-tip][data-for=\"".concat(escaped, "\"]"));
|
|
1961
|
+
} // targetArray is a NodeList, convert it to a real array
|
|
1962
|
+
|
|
210
1963
|
|
|
1964
|
+
return nodeListToArray(targetArray);
|
|
1965
|
+
}
|
|
211
1966
|
/**
|
|
212
1967
|
* Bind listener to the target elements
|
|
213
1968
|
* These listeners used to trigger showing or hiding the tooltip
|
|
214
1969
|
*/
|
|
215
1970
|
|
|
216
1971
|
}, {
|
|
217
|
-
key:
|
|
1972
|
+
key: "bindListener",
|
|
218
1973
|
value: function bindListener() {
|
|
219
1974
|
var _this3 = this;
|
|
220
1975
|
|
|
221
|
-
var
|
|
222
|
-
id =
|
|
223
|
-
globalEventOff =
|
|
224
|
-
isCapture =
|
|
225
|
-
|
|
1976
|
+
var _this$props2 = this.props,
|
|
1977
|
+
id = _this$props2.id,
|
|
1978
|
+
globalEventOff = _this$props2.globalEventOff,
|
|
1979
|
+
isCapture = _this$props2.isCapture;
|
|
226
1980
|
var targetArray = this.getTargetArray(id);
|
|
227
|
-
|
|
228
1981
|
targetArray.forEach(function (target) {
|
|
229
|
-
if (target.getAttribute(
|
|
230
|
-
target.setAttribute(
|
|
1982
|
+
if (target.getAttribute("currentItem") === null) {
|
|
1983
|
+
target.setAttribute("currentItem", "false");
|
|
231
1984
|
}
|
|
1985
|
+
|
|
232
1986
|
_this3.unbindBasicListener(target);
|
|
1987
|
+
|
|
233
1988
|
if (_this3.isCustomEvent(target)) {
|
|
234
1989
|
_this3.customUnbindListener(target);
|
|
235
1990
|
}
|
|
@@ -240,42 +1995,46 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
240
1995
|
} else {
|
|
241
1996
|
targetArray.forEach(function (target) {
|
|
242
1997
|
var isCaptureMode = _this3.isCapture(target);
|
|
1998
|
+
|
|
243
1999
|
var effect = _this3.getEffect(target);
|
|
2000
|
+
|
|
244
2001
|
if (_this3.isCustomEvent(target)) {
|
|
245
2002
|
_this3.customBindListener(target);
|
|
2003
|
+
|
|
246
2004
|
return;
|
|
247
2005
|
}
|
|
248
2006
|
|
|
249
|
-
target.addEventListener(
|
|
250
|
-
|
|
251
|
-
|
|
2007
|
+
target.addEventListener("mouseenter", _this3.showTooltip, isCaptureMode);
|
|
2008
|
+
|
|
2009
|
+
if (effect === "float") {
|
|
2010
|
+
target.addEventListener("mousemove", _this3.updateTooltip, isCaptureMode);
|
|
252
2011
|
}
|
|
253
|
-
|
|
2012
|
+
|
|
2013
|
+
target.addEventListener("mouseleave", _this3.hideTooltip, isCaptureMode);
|
|
254
2014
|
});
|
|
255
|
-
}
|
|
2015
|
+
} // Global event to hide tooltip
|
|
2016
|
+
|
|
256
2017
|
|
|
257
|
-
// Global event to hide tooltip
|
|
258
2018
|
if (globalEventOff) {
|
|
259
2019
|
window.removeEventListener(globalEventOff, this.hideTooltip);
|
|
260
2020
|
window.addEventListener(globalEventOff, this.hideTooltip, isCapture);
|
|
261
|
-
}
|
|
2021
|
+
} // Track removal of targetArray elements from DOM
|
|
2022
|
+
|
|
262
2023
|
|
|
263
|
-
// Track removal of targetArray elements from DOM
|
|
264
2024
|
this.bindRemovalTracker();
|
|
265
2025
|
}
|
|
266
|
-
|
|
267
2026
|
/**
|
|
268
2027
|
* Unbind listeners on target elements
|
|
269
2028
|
*/
|
|
270
2029
|
|
|
271
2030
|
}, {
|
|
272
|
-
key:
|
|
2031
|
+
key: "unbindListener",
|
|
273
2032
|
value: function unbindListener() {
|
|
274
2033
|
var _this4 = this;
|
|
275
2034
|
|
|
276
|
-
var
|
|
277
|
-
id =
|
|
278
|
-
globalEventOff =
|
|
2035
|
+
var _this$props3 = this.props,
|
|
2036
|
+
id = _this$props3.id,
|
|
2037
|
+
globalEventOff = _this$props3.globalEventOff;
|
|
279
2038
|
|
|
280
2039
|
if (this.isBodyMode()) {
|
|
281
2040
|
this.unbindBodyListener();
|
|
@@ -283,6 +2042,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
283
2042
|
var targetArray = this.getTargetArray(id);
|
|
284
2043
|
targetArray.forEach(function (target) {
|
|
285
2044
|
_this4.unbindBasicListener(target);
|
|
2045
|
+
|
|
286
2046
|
if (_this4.isCustomEvent(target)) _this4.customUnbindListener(target);
|
|
287
2047
|
});
|
|
288
2048
|
}
|
|
@@ -290,7 +2050,6 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
290
2050
|
if (globalEventOff) window.removeEventListener(globalEventOff, this.hideTooltip);
|
|
291
2051
|
this.unbindRemovalTracker();
|
|
292
2052
|
}
|
|
293
|
-
|
|
294
2053
|
/**
|
|
295
2054
|
* Invoke this before bind listener and unmount the component
|
|
296
2055
|
* it is necessary to invoke this even when binding custom event
|
|
@@ -298,23 +2057,22 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
298
2057
|
*/
|
|
299
2058
|
|
|
300
2059
|
}, {
|
|
301
|
-
key:
|
|
2060
|
+
key: "unbindBasicListener",
|
|
302
2061
|
value: function unbindBasicListener(target) {
|
|
303
2062
|
var isCaptureMode = this.isCapture(target);
|
|
304
|
-
target.removeEventListener(
|
|
305
|
-
target.removeEventListener(
|
|
306
|
-
target.removeEventListener(
|
|
2063
|
+
target.removeEventListener("mouseenter", this.showTooltip, isCaptureMode);
|
|
2064
|
+
target.removeEventListener("mousemove", this.updateTooltip, isCaptureMode);
|
|
2065
|
+
target.removeEventListener("mouseleave", this.hideTooltip, isCaptureMode);
|
|
307
2066
|
}
|
|
308
2067
|
}, {
|
|
309
|
-
key:
|
|
2068
|
+
key: "getTooltipContent",
|
|
310
2069
|
value: function getTooltipContent() {
|
|
311
|
-
var
|
|
312
|
-
getContent =
|
|
313
|
-
children =
|
|
2070
|
+
var _this$props4 = this.props,
|
|
2071
|
+
getContent = _this$props4.getContent,
|
|
2072
|
+
children = _this$props4.children; // Generate tooltip content
|
|
314
2073
|
|
|
315
|
-
|
|
2074
|
+
var content;
|
|
316
2075
|
|
|
317
|
-
var content = void 0;
|
|
318
2076
|
if (getContent) {
|
|
319
2077
|
if (Array.isArray(getContent)) {
|
|
320
2078
|
content = getContent[0] && getContent[0](this.state.originTooltip);
|
|
@@ -323,20 +2081,19 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
323
2081
|
}
|
|
324
2082
|
}
|
|
325
2083
|
|
|
326
|
-
return (
|
|
2084
|
+
return getTipContent(this.state.originTooltip, children, content, this.state.isMultiline);
|
|
327
2085
|
}
|
|
328
2086
|
}, {
|
|
329
|
-
key:
|
|
2087
|
+
key: "isEmptyTip",
|
|
330
2088
|
value: function isEmptyTip(placeholder) {
|
|
331
|
-
return typeof placeholder ===
|
|
2089
|
+
return typeof placeholder === "string" && placeholder === "" || placeholder === null;
|
|
332
2090
|
}
|
|
333
|
-
|
|
334
2091
|
/**
|
|
335
2092
|
* When mouse enter, show the tooltip
|
|
336
2093
|
*/
|
|
337
2094
|
|
|
338
2095
|
}, {
|
|
339
|
-
key:
|
|
2096
|
+
key: "showTooltip",
|
|
340
2097
|
value: function showTooltip(e, isGlobalCall) {
|
|
341
2098
|
if (isGlobalCall) {
|
|
342
2099
|
// Don't trigger other elements belongs to other ReactTooltip
|
|
@@ -345,45 +2102,41 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
345
2102
|
return ele === e.currentTarget;
|
|
346
2103
|
});
|
|
347
2104
|
if (!isMyElement) return;
|
|
348
|
-
}
|
|
349
|
-
// Get the tooltip content
|
|
2105
|
+
} // Get the tooltip content
|
|
350
2106
|
// calculate in this phrase so that tip width height can be detected
|
|
351
|
-
var _props5 = this.props,
|
|
352
|
-
multiline = _props5.multiline,
|
|
353
|
-
getContent = _props5.getContent;
|
|
354
2107
|
|
|
355
|
-
var originTooltip = e.currentTarget.getAttribute('data-tip');
|
|
356
|
-
var isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false;
|
|
357
2108
|
|
|
358
|
-
|
|
359
|
-
|
|
2109
|
+
var _this$props5 = this.props,
|
|
2110
|
+
multiline = _this$props5.multiline,
|
|
2111
|
+
getContent = _this$props5.getContent;
|
|
2112
|
+
var originTooltip = e.currentTarget.getAttribute("data-tip");
|
|
2113
|
+
var isMultiline = e.currentTarget.getAttribute("data-multiline") || multiline || false; // If it is focus event or called by ReactTooltip.show, switch to `solid` effect
|
|
2114
|
+
|
|
2115
|
+
var switchToSolid = e instanceof window.FocusEvent || isGlobalCall; // if it needs to skip adding hide listener to scroll
|
|
360
2116
|
|
|
361
|
-
// if it needs to skip adding hide listener to scroll
|
|
362
2117
|
var scrollHide = true;
|
|
363
|
-
|
|
364
|
-
|
|
2118
|
+
|
|
2119
|
+
if (e.currentTarget.getAttribute("data-scroll-hide")) {
|
|
2120
|
+
scrollHide = e.currentTarget.getAttribute("data-scroll-hide") === "true";
|
|
365
2121
|
} else if (this.props.scrollHide != null) {
|
|
366
2122
|
scrollHide = this.props.scrollHide;
|
|
367
|
-
}
|
|
2123
|
+
} // Make sure the correct place is set
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
var desiredPlace = e.currentTarget.getAttribute("data-place") || this.props.place || "top";
|
|
2127
|
+
var effect = switchToSolid && "solid" || this.getEffect(e.currentTarget);
|
|
2128
|
+
var offset = e.currentTarget.getAttribute("data-offset") || this.props.offset || {};
|
|
2129
|
+
var result = getPosition(e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
368
2130
|
|
|
369
|
-
// Make sure the correct place is set
|
|
370
|
-
var desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top';
|
|
371
|
-
var effect = switchToSolid && 'solid' || this.getEffect(e.currentTarget);
|
|
372
|
-
var offset = e.currentTarget.getAttribute('data-offset') || this.props.offset || {};
|
|
373
|
-
var result = (0, _getPosition2.default)(e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
374
2131
|
if (result.position && this.props.overridePosition) {
|
|
375
2132
|
result.position = this.props.overridePosition(result.position, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
|
|
376
2133
|
}
|
|
377
2134
|
|
|
378
|
-
var place = result.isNewState ? result.newState.place : desiredPlace;
|
|
2135
|
+
var place = result.isNewState ? result.newState.place : desiredPlace; // To prevent previously created timers from triggering
|
|
379
2136
|
|
|
380
|
-
// To prevent previously created timers from triggering
|
|
381
2137
|
this.clearTimer();
|
|
382
|
-
|
|
383
2138
|
var target = e.currentTarget;
|
|
384
|
-
|
|
385
|
-
var reshowDelay = this.state.show ? target.getAttribute('data-delay-update') || this.props.delayUpdate : 0;
|
|
386
|
-
|
|
2139
|
+
var reshowDelay = this.state.show ? target.getAttribute("data-delay-update") || this.props.delayUpdate : 0;
|
|
387
2140
|
var self = this;
|
|
388
2141
|
|
|
389
2142
|
var updateState = function updateState() {
|
|
@@ -392,16 +2145,16 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
392
2145
|
isMultiline: isMultiline,
|
|
393
2146
|
desiredPlace: desiredPlace,
|
|
394
2147
|
place: place,
|
|
395
|
-
type: target.getAttribute(
|
|
2148
|
+
type: target.getAttribute("data-type") || self.props.type || "dark",
|
|
396
2149
|
effect: effect,
|
|
397
2150
|
offset: offset,
|
|
398
|
-
html: target.getAttribute(
|
|
399
|
-
delayShow: target.getAttribute(
|
|
400
|
-
delayHide: target.getAttribute(
|
|
401
|
-
delayUpdate: target.getAttribute(
|
|
402
|
-
border: target.getAttribute(
|
|
403
|
-
extraClass: target.getAttribute(
|
|
404
|
-
disable: target.getAttribute(
|
|
2151
|
+
html: target.getAttribute("data-html") ? target.getAttribute("data-html") === "true" : self.props.html || false,
|
|
2152
|
+
delayShow: target.getAttribute("data-delay-show") || self.props.delayShow || 0,
|
|
2153
|
+
delayHide: target.getAttribute("data-delay-hide") || self.props.delayHide || 0,
|
|
2154
|
+
delayUpdate: target.getAttribute("data-delay-update") || self.props.delayUpdate || 0,
|
|
2155
|
+
border: target.getAttribute("data-border") ? target.getAttribute("data-border") === "true" : self.props.border || false,
|
|
2156
|
+
extraClass: target.getAttribute("data-class") || self.props["class"] || self.props.className || "",
|
|
2157
|
+
disable: target.getAttribute("data-tip-disable") ? target.getAttribute("data-tip-disable") === "true" : self.props.disable || false,
|
|
405
2158
|
currentTarget: target
|
|
406
2159
|
}, function () {
|
|
407
2160
|
if (scrollHide) self.addScrollListener(self.state.currentTarget);
|
|
@@ -411,8 +2164,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
411
2164
|
self.intervalUpdateContent = setInterval(function () {
|
|
412
2165
|
if (self.mount) {
|
|
413
2166
|
var _getContent = self.props.getContent;
|
|
414
|
-
|
|
415
|
-
var placeholder = (0, _getTipContent2.default)(originTooltip, '', _getContent[0](), isMultiline);
|
|
2167
|
+
var placeholder = getTipContent(originTooltip, "", _getContent[0](), isMultiline);
|
|
416
2168
|
var isEmptyTip = self.isEmptyTip(placeholder);
|
|
417
2169
|
self.setState({
|
|
418
2170
|
isEmptyTip: isEmptyTip
|
|
@@ -422,106 +2174,104 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
422
2174
|
}, getContent[1]);
|
|
423
2175
|
}
|
|
424
2176
|
});
|
|
425
|
-
};
|
|
2177
|
+
}; // If there is no delay call immediately, don't allow events to get in first.
|
|
2178
|
+
|
|
426
2179
|
|
|
427
|
-
// If there is no delay call immediately, don't allow events to get in first.
|
|
428
2180
|
if (reshowDelay) {
|
|
429
2181
|
this.delayReshow = setTimeout(updateState, reshowDelay);
|
|
430
2182
|
} else {
|
|
431
2183
|
updateState();
|
|
432
2184
|
}
|
|
433
2185
|
}
|
|
434
|
-
|
|
435
2186
|
/**
|
|
436
2187
|
* When mouse hover, update tool tip
|
|
437
2188
|
*/
|
|
438
2189
|
|
|
439
2190
|
}, {
|
|
440
|
-
key:
|
|
2191
|
+
key: "updateTooltip",
|
|
441
2192
|
value: function updateTooltip(e) {
|
|
442
2193
|
var _this5 = this;
|
|
443
2194
|
|
|
444
|
-
var
|
|
445
|
-
delayShow =
|
|
446
|
-
disable =
|
|
2195
|
+
var _this$state = this.state,
|
|
2196
|
+
delayShow = _this$state.delayShow,
|
|
2197
|
+
disable = _this$state.disable;
|
|
447
2198
|
var afterShow = this.props.afterShow;
|
|
448
|
-
|
|
449
2199
|
var placeholder = this.getTooltipContent();
|
|
450
2200
|
var delayTime = parseInt(delayShow, 10);
|
|
451
|
-
var eventTarget = e.currentTarget || e.target;
|
|
2201
|
+
var eventTarget = e.currentTarget || e.target; // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
|
|
452
2202
|
|
|
453
|
-
// Check if the mouse is actually over the tooltip, if so don't hide the tooltip
|
|
454
2203
|
if (this.mouseOnToolTip()) {
|
|
455
2204
|
return;
|
|
456
2205
|
}
|
|
457
2206
|
|
|
458
2207
|
if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip
|
|
2208
|
+
|
|
459
2209
|
var updateState = function updateState() {
|
|
460
2210
|
if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) {
|
|
461
2211
|
var isInvisible = !_this5.state.show;
|
|
2212
|
+
|
|
462
2213
|
_this5.setState({
|
|
463
2214
|
currentEvent: e,
|
|
464
2215
|
currentTarget: eventTarget,
|
|
465
2216
|
show: true
|
|
466
2217
|
}, function () {
|
|
467
2218
|
_this5.updatePosition();
|
|
2219
|
+
|
|
468
2220
|
if (isInvisible && afterShow) afterShow(e);
|
|
469
2221
|
});
|
|
470
2222
|
}
|
|
471
2223
|
};
|
|
472
2224
|
|
|
473
2225
|
clearTimeout(this.delayShowLoop);
|
|
2226
|
+
|
|
474
2227
|
if (delayShow) {
|
|
475
2228
|
this.delayShowLoop = setTimeout(updateState, delayTime);
|
|
476
2229
|
} else {
|
|
477
2230
|
updateState();
|
|
478
2231
|
}
|
|
479
2232
|
}
|
|
480
|
-
|
|
481
2233
|
/*
|
|
482
|
-
|
|
2234
|
+
* If we're mousing over the tooltip remove it when we leave.
|
|
483
2235
|
*/
|
|
484
2236
|
|
|
485
2237
|
}, {
|
|
486
|
-
key:
|
|
2238
|
+
key: "listenForTooltipExit",
|
|
487
2239
|
value: function listenForTooltipExit() {
|
|
488
2240
|
var show = this.state.show;
|
|
489
2241
|
|
|
490
|
-
|
|
491
2242
|
if (show && this.tooltipRef) {
|
|
492
|
-
this.tooltipRef.addEventListener(
|
|
2243
|
+
this.tooltipRef.addEventListener("mouseleave", this.hideTooltip);
|
|
493
2244
|
}
|
|
494
2245
|
}
|
|
495
2246
|
}, {
|
|
496
|
-
key:
|
|
2247
|
+
key: "removeListenerForTooltipExit",
|
|
497
2248
|
value: function removeListenerForTooltipExit() {
|
|
498
2249
|
var show = this.state.show;
|
|
499
2250
|
|
|
500
|
-
|
|
501
2251
|
if (show && this.tooltipRef) {
|
|
502
|
-
this.tooltipRef.removeEventListener(
|
|
2252
|
+
this.tooltipRef.removeEventListener("mouseleave", this.hideTooltip);
|
|
503
2253
|
}
|
|
504
2254
|
}
|
|
505
|
-
|
|
506
2255
|
/**
|
|
507
2256
|
* When mouse leave, hide tooltip
|
|
508
2257
|
*/
|
|
509
2258
|
|
|
510
2259
|
}, {
|
|
511
|
-
key:
|
|
2260
|
+
key: "hideTooltip",
|
|
512
2261
|
value: function hideTooltip(e, hasTarget) {
|
|
513
2262
|
var _this6 = this;
|
|
514
2263
|
|
|
515
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
2264
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
2265
|
+
isScroll: false
|
|
2266
|
+
};
|
|
516
2267
|
var disable = this.state.disable;
|
|
517
2268
|
var isScroll = options.isScroll;
|
|
518
|
-
|
|
519
2269
|
var delayHide = isScroll ? 0 : this.state.delayHide;
|
|
520
2270
|
var afterHide = this.props.afterHide;
|
|
521
|
-
|
|
522
2271
|
var placeholder = this.getTooltipContent();
|
|
523
2272
|
if (!this.mount) return;
|
|
524
2273
|
if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip
|
|
2274
|
+
|
|
525
2275
|
if (hasTarget) {
|
|
526
2276
|
// Don't trigger other elements belongs to other ReactTooltip
|
|
527
2277
|
var targetArray = this.getTargetArray(this.props.id);
|
|
@@ -532,74 +2282,76 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
532
2282
|
}
|
|
533
2283
|
|
|
534
2284
|
var resetState = function resetState() {
|
|
535
|
-
var isVisible = _this6.state.show;
|
|
536
|
-
|
|
2285
|
+
var isVisible = _this6.state.show; // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
|
|
2286
|
+
|
|
537
2287
|
if (_this6.mouseOnToolTip()) {
|
|
538
2288
|
_this6.listenForTooltipExit();
|
|
2289
|
+
|
|
539
2290
|
return;
|
|
540
2291
|
}
|
|
2292
|
+
|
|
541
2293
|
_this6.removeListenerForTooltipExit();
|
|
542
2294
|
|
|
543
2295
|
_this6.setState({
|
|
544
2296
|
show: false
|
|
545
2297
|
}, function () {
|
|
546
2298
|
_this6.removeScrollListener();
|
|
2299
|
+
|
|
547
2300
|
if (isVisible && afterHide) afterHide(e);
|
|
548
2301
|
});
|
|
549
2302
|
};
|
|
550
2303
|
|
|
551
2304
|
this.clearTimer();
|
|
2305
|
+
|
|
552
2306
|
if (delayHide) {
|
|
553
2307
|
this.delayHideLoop = setTimeout(resetState, parseInt(delayHide, 10));
|
|
554
2308
|
} else {
|
|
555
2309
|
resetState();
|
|
556
2310
|
}
|
|
557
2311
|
}
|
|
558
|
-
|
|
559
2312
|
/**
|
|
560
2313
|
* When scroll, hide tooltip
|
|
561
2314
|
*/
|
|
562
2315
|
|
|
563
2316
|
}, {
|
|
564
|
-
key:
|
|
2317
|
+
key: "hideTooltipOnScroll",
|
|
565
2318
|
value: function hideTooltipOnScroll(event, hasTarget) {
|
|
566
|
-
this.hideTooltip(event, hasTarget, {
|
|
2319
|
+
this.hideTooltip(event, hasTarget, {
|
|
2320
|
+
isScroll: true
|
|
2321
|
+
});
|
|
567
2322
|
}
|
|
568
|
-
|
|
569
2323
|
/**
|
|
570
2324
|
* Add scroll event listener when tooltip show
|
|
571
2325
|
* automatically hide the tooltip when scrolling
|
|
572
2326
|
*/
|
|
573
2327
|
|
|
574
2328
|
}, {
|
|
575
|
-
key:
|
|
2329
|
+
key: "addScrollListener",
|
|
576
2330
|
value: function addScrollListener(currentTarget) {
|
|
577
2331
|
var isCaptureMode = this.isCapture(currentTarget);
|
|
578
|
-
window.addEventListener(
|
|
2332
|
+
window.addEventListener("scroll", this.hideTooltipOnScroll, isCaptureMode);
|
|
579
2333
|
}
|
|
580
2334
|
}, {
|
|
581
|
-
key:
|
|
2335
|
+
key: "removeScrollListener",
|
|
582
2336
|
value: function removeScrollListener() {
|
|
583
|
-
window.removeEventListener(
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// Calculation the position
|
|
2337
|
+
window.removeEventListener("scroll", this.hideTooltipOnScroll);
|
|
2338
|
+
} // Calculation the position
|
|
587
2339
|
|
|
588
2340
|
}, {
|
|
589
|
-
key:
|
|
2341
|
+
key: "updatePosition",
|
|
590
2342
|
value: function updatePosition() {
|
|
591
2343
|
var _this7 = this;
|
|
592
2344
|
|
|
593
|
-
var
|
|
594
|
-
currentEvent =
|
|
595
|
-
currentTarget =
|
|
596
|
-
place =
|
|
597
|
-
desiredPlace =
|
|
598
|
-
effect =
|
|
599
|
-
offset =
|
|
600
|
-
|
|
2345
|
+
var _this$state2 = this.state,
|
|
2346
|
+
currentEvent = _this$state2.currentEvent,
|
|
2347
|
+
currentTarget = _this$state2.currentTarget,
|
|
2348
|
+
place = _this$state2.place,
|
|
2349
|
+
desiredPlace = _this$state2.desiredPlace,
|
|
2350
|
+
effect = _this$state2.effect,
|
|
2351
|
+
offset = _this$state2.offset;
|
|
601
2352
|
var node = this.tooltipRef;
|
|
602
|
-
var result = (
|
|
2353
|
+
var result = getPosition(currentEvent, currentTarget, node, place, desiredPlace, effect, offset);
|
|
2354
|
+
|
|
603
2355
|
if (result.position && this.props.overridePosition) {
|
|
604
2356
|
result.position = this.props.overridePosition(result.position, currentEvent, currentTarget, node, place, desiredPlace, effect, offset);
|
|
605
2357
|
}
|
|
@@ -609,40 +2361,42 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
609
2361
|
return this.setState(result.newState, function () {
|
|
610
2362
|
_this7.updatePosition();
|
|
611
2363
|
});
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
node.style.left = result.position.left + 'px';
|
|
615
|
-
node.style.top = result.position.top + 'px';
|
|
616
|
-
}
|
|
2364
|
+
} // Set tooltip position
|
|
2365
|
+
|
|
617
2366
|
|
|
2367
|
+
node.style.left = result.position.left + "px";
|
|
2368
|
+
node.style.top = result.position.top + "px";
|
|
2369
|
+
}
|
|
618
2370
|
/**
|
|
619
2371
|
* Set style tag in header
|
|
620
2372
|
* in this way we can insert default css
|
|
621
2373
|
*/
|
|
622
2374
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
value: function setStyleHeader() {
|
|
626
|
-
var head = document.getElementsByTagName('head')[0];
|
|
2375
|
+
/* setStyleHeader() {
|
|
2376
|
+
const head = document.getElementsByTagName("head")[0];
|
|
627
2377
|
if (!head.querySelector('style[id="react-tooltip"]')) {
|
|
628
|
-
|
|
629
|
-
tag.id =
|
|
630
|
-
tag.innerHTML =
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
2378
|
+
const tag = document.createElement("style");
|
|
2379
|
+
tag.id = "react-tooltip";
|
|
2380
|
+
tag.innerHTML = cssStyle; */
|
|
2381
|
+
|
|
2382
|
+
/* eslint-disable */
|
|
2383
|
+
|
|
2384
|
+
/* if (typeof __webpack_nonce__ !== 'undefined' && __webpack_nonce__) {
|
|
2385
|
+
tag.setAttribute('nonce', __webpack_nonce__)
|
|
2386
|
+
}*/
|
|
2387
|
+
|
|
2388
|
+
/* eslint-enable */
|
|
2389
|
+
|
|
2390
|
+
/* head.insertBefore(tag, head.firstChild);
|
|
637
2391
|
}
|
|
638
|
-
}
|
|
2392
|
+
} */
|
|
639
2393
|
|
|
640
2394
|
/**
|
|
641
2395
|
* CLear all kinds of timeout of interval
|
|
642
2396
|
*/
|
|
643
2397
|
|
|
644
2398
|
}, {
|
|
645
|
-
key:
|
|
2399
|
+
key: "clearTimer",
|
|
646
2400
|
value: function clearTimer() {
|
|
647
2401
|
clearTimeout(this.delayShowLoop);
|
|
648
2402
|
clearTimeout(this.delayHideLoop);
|
|
@@ -650,109 +2404,112 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
|
|
|
650
2404
|
clearInterval(this.intervalUpdateContent);
|
|
651
2405
|
}
|
|
652
2406
|
}, {
|
|
653
|
-
key:
|
|
2407
|
+
key: "render",
|
|
654
2408
|
value: function render() {
|
|
655
2409
|
var _this8 = this;
|
|
656
2410
|
|
|
657
|
-
var
|
|
658
|
-
extraClass =
|
|
659
|
-
html =
|
|
660
|
-
ariaProps =
|
|
661
|
-
disable =
|
|
662
|
-
|
|
2411
|
+
var _this$state3 = this.state,
|
|
2412
|
+
extraClass = _this$state3.extraClass,
|
|
2413
|
+
html = _this$state3.html,
|
|
2414
|
+
ariaProps = _this$state3.ariaProps,
|
|
2415
|
+
disable = _this$state3.disable;
|
|
663
2416
|
var placeholder = this.getTooltipContent();
|
|
664
2417
|
var isEmptyTip = this.isEmptyTip(placeholder);
|
|
665
|
-
var tooltipClass =
|
|
666
|
-
|
|
2418
|
+
var tooltipClass = "__react_component_tooltip" + (this.state.show && !disable && !isEmptyTip ? " show" : "") + (this.state.border ? " border" : "") + " place-".concat(this.state.place) + // top, bottom, left, right
|
|
2419
|
+
" type-".concat(this.state.type) + ( // dark, success, warning, error, info, light
|
|
2420
|
+
this.props.delayUpdate ? " allow_hover" : "") + (this.props.clickable ? " allow_click" : "");
|
|
667
2421
|
var Wrapper = this.props.wrapper;
|
|
2422
|
+
|
|
668
2423
|
if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) {
|
|
669
2424
|
Wrapper = ReactTooltip.defaultProps.wrapper;
|
|
670
2425
|
}
|
|
671
|
-
|
|
2426
|
+
|
|
2427
|
+
var wrapperClassName = [tooltipClass, extraClass].filter(Boolean).join(" ");
|
|
672
2428
|
|
|
673
2429
|
if (html) {
|
|
674
|
-
return
|
|
2430
|
+
return React.createElement(Wrapper, _extends({
|
|
2431
|
+
className: wrapperClassName,
|
|
675
2432
|
id: this.props.id,
|
|
676
2433
|
ref: function ref(_ref) {
|
|
677
2434
|
return _this8.tooltipRef = _ref;
|
|
678
2435
|
}
|
|
679
2436
|
}, ariaProps, {
|
|
680
|
-
|
|
681
|
-
dangerouslySetInnerHTML: {
|
|
2437
|
+
"data-id": "tooltip",
|
|
2438
|
+
dangerouslySetInnerHTML: {
|
|
2439
|
+
__html: placeholder
|
|
2440
|
+
}
|
|
2441
|
+
}));
|
|
682
2442
|
} else {
|
|
683
|
-
return
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
placeholder
|
|
693
|
-
);
|
|
2443
|
+
return React.createElement(Wrapper, _extends({
|
|
2444
|
+
className: wrapperClassName,
|
|
2445
|
+
id: this.props.id
|
|
2446
|
+
}, ariaProps, {
|
|
2447
|
+
ref: function ref(_ref2) {
|
|
2448
|
+
return _this8.tooltipRef = _ref2;
|
|
2449
|
+
},
|
|
2450
|
+
"data-id": "tooltip"
|
|
2451
|
+
}), placeholder);
|
|
694
2452
|
}
|
|
695
2453
|
}
|
|
696
2454
|
}], [{
|
|
697
|
-
key:
|
|
2455
|
+
key: "getDerivedStateFromProps",
|
|
698
2456
|
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
699
2457
|
var ariaProps = prevState.ariaProps;
|
|
700
|
-
|
|
701
|
-
var newAriaProps = (0, _aria.parseAria)(nextProps);
|
|
2458
|
+
var newAriaProps = parseAria(nextProps);
|
|
702
2459
|
var isChanged = Object.keys(newAriaProps).some(function (props) {
|
|
703
2460
|
return newAriaProps[props] !== ariaProps[props];
|
|
704
2461
|
});
|
|
2462
|
+
|
|
705
2463
|
if (!isChanged) {
|
|
706
2464
|
return null;
|
|
707
2465
|
}
|
|
708
|
-
|
|
2466
|
+
|
|
2467
|
+
return _objectSpread2({}, prevState, {
|
|
709
2468
|
ariaProps: newAriaProps
|
|
710
2469
|
});
|
|
711
2470
|
}
|
|
712
2471
|
}]);
|
|
713
2472
|
|
|
714
2473
|
return ReactTooltip;
|
|
715
|
-
}(
|
|
716
|
-
children:
|
|
717
|
-
place:
|
|
718
|
-
type:
|
|
719
|
-
effect:
|
|
720
|
-
offset:
|
|
721
|
-
multiline:
|
|
722
|
-
border:
|
|
723
|
-
insecure:
|
|
724
|
-
class:
|
|
725
|
-
className:
|
|
726
|
-
id:
|
|
727
|
-
html:
|
|
728
|
-
delayHide:
|
|
729
|
-
delayUpdate:
|
|
730
|
-
delayShow:
|
|
731
|
-
event:
|
|
732
|
-
eventOff:
|
|
733
|
-
watchWindow:
|
|
734
|
-
isCapture:
|
|
735
|
-
globalEventOff:
|
|
736
|
-
getContent:
|
|
737
|
-
afterShow:
|
|
738
|
-
afterHide:
|
|
739
|
-
overridePosition:
|
|
740
|
-
disable:
|
|
741
|
-
scrollHide:
|
|
742
|
-
resizeHide:
|
|
743
|
-
wrapper:
|
|
744
|
-
bodyMode:
|
|
745
|
-
possibleCustomEvents:
|
|
746
|
-
possibleCustomEventsOff:
|
|
747
|
-
clickable:
|
|
748
|
-
}, _class2
|
|
2474
|
+
}(React.Component), _defineProperty(_class2, "propTypes", {
|
|
2475
|
+
children: propTypes.any,
|
|
2476
|
+
place: propTypes.string,
|
|
2477
|
+
type: propTypes.string,
|
|
2478
|
+
effect: propTypes.string,
|
|
2479
|
+
offset: propTypes.object,
|
|
2480
|
+
multiline: propTypes.bool,
|
|
2481
|
+
border: propTypes.bool,
|
|
2482
|
+
insecure: propTypes.bool,
|
|
2483
|
+
"class": propTypes.string,
|
|
2484
|
+
className: propTypes.string,
|
|
2485
|
+
id: propTypes.string,
|
|
2486
|
+
html: propTypes.bool,
|
|
2487
|
+
delayHide: propTypes.number,
|
|
2488
|
+
delayUpdate: propTypes.number,
|
|
2489
|
+
delayShow: propTypes.number,
|
|
2490
|
+
event: propTypes.string,
|
|
2491
|
+
eventOff: propTypes.string,
|
|
2492
|
+
watchWindow: propTypes.bool,
|
|
2493
|
+
isCapture: propTypes.bool,
|
|
2494
|
+
globalEventOff: propTypes.string,
|
|
2495
|
+
getContent: propTypes.any,
|
|
2496
|
+
afterShow: propTypes.func,
|
|
2497
|
+
afterHide: propTypes.func,
|
|
2498
|
+
overridePosition: propTypes.func,
|
|
2499
|
+
disable: propTypes.bool,
|
|
2500
|
+
scrollHide: propTypes.bool,
|
|
2501
|
+
resizeHide: propTypes.bool,
|
|
2502
|
+
wrapper: propTypes.string,
|
|
2503
|
+
bodyMode: propTypes.bool,
|
|
2504
|
+
possibleCustomEvents: propTypes.string,
|
|
2505
|
+
possibleCustomEventsOff: propTypes.string,
|
|
2506
|
+
clickable: propTypes.bool
|
|
2507
|
+
}), _defineProperty(_class2, "defaultProps", {
|
|
749
2508
|
insecure: true,
|
|
750
2509
|
resizeHide: true,
|
|
751
|
-
wrapper:
|
|
2510
|
+
wrapper: "div",
|
|
752
2511
|
clickable: false
|
|
753
|
-
}, _class2
|
|
754
|
-
|
|
755
|
-
/* export default not fit for standalone, it will exports {default:...} */
|
|
756
|
-
|
|
2512
|
+
}), _defineProperty(_class2, "supportedWrappers", ["div", "span"]), _defineProperty(_class2, "displayName", "ReactTooltip"), _temp)) || _class) || _class) || _class) || _class) || _class) || _class) || _class;
|
|
757
2513
|
|
|
758
|
-
module.exports = ReactTooltip;
|
|
2514
|
+
module.exports = ReactTooltip;
|
|
2515
|
+
//# sourceMappingURL=index.js.map
|