react-tooltip 4.5.1 → 5.0.0-beta.1

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.
Files changed (110) hide show
  1. package/.editorconfig +25 -0
  2. package/.eslintrc.json +94 -0
  3. package/.gitattributes +3 -0
  4. package/.github/FUNDING.yml +13 -0
  5. package/.github/workflows/lint.yaml +35 -0
  6. package/.github/workflows/pull-request.yaml +11 -0
  7. package/.github/workflows/release.yaml +30 -0
  8. package/.husky/pre-commit +6 -0
  9. package/.prettierrc.json +10 -0
  10. package/.stylelintrc.json +19 -0
  11. package/.vscode/settings.json +27 -0
  12. package/bower.json +26 -0
  13. package/build/dist/react-tooltip.cjs.js +2909 -0
  14. package/build/dist/react-tooltip.cjs.min.js +6 -0
  15. package/build/dist/react-tooltip.css +73 -0
  16. package/build/dist/react-tooltip.esm.js +2901 -0
  17. package/build/dist/react-tooltip.esm.min.js +6 -0
  18. package/build/dist/react-tooltip.min.css +1 -0
  19. package/build/dist/react-tooltip.umd.js +2913 -0
  20. package/build/dist/react-tooltip.umd.min.js +6 -0
  21. package/build/index.css +79 -0
  22. package/build/index.html +19 -0
  23. package/build/index.js +36190 -0
  24. package/cli.js +30 -0
  25. package/contributing.md +40 -0
  26. package/dist/react-tooltip-tokens.css +8 -0
  27. package/dist/react-tooltip.cjs.js +2932 -0
  28. package/dist/react-tooltip.cjs.min.js +6 -0
  29. package/dist/react-tooltip.css +73 -0
  30. package/dist/react-tooltip.d.ts +21 -120
  31. package/dist/react-tooltip.esm.js +2924 -0
  32. package/dist/react-tooltip.esm.min.js +6 -0
  33. package/dist/react-tooltip.min.css +1 -0
  34. package/dist/react-tooltip.umd.js +2936 -0
  35. package/dist/react-tooltip.umd.min.js +6 -0
  36. package/docs/README.md +50 -0
  37. package/docs/babel.config.js +3 -0
  38. package/docs/docs/examples/_category_.json +7 -0
  39. package/docs/docs/examples/basic-examples.mdx +68 -0
  40. package/docs/docs/examples/children.mdx +67 -0
  41. package/docs/docs/examples/content.mdx +80 -0
  42. package/docs/docs/examples/delay.mdx +84 -0
  43. package/docs/docs/examples/events.mdx +85 -0
  44. package/docs/docs/examples/get-content.mdx +58 -0
  45. package/docs/docs/examples/html.mdx +75 -0
  46. package/docs/docs/examples/multiline.mdx +91 -0
  47. package/docs/docs/examples/offset.mdx +69 -0
  48. package/docs/docs/examples/place.mdx +55 -0
  49. package/docs/docs/examples/state.mdx +331 -0
  50. package/docs/docs/examples/styling.mdx +388 -0
  51. package/docs/docs/examples/variant.mdx +100 -0
  52. package/docs/docs/getting-started.mdx +100 -0
  53. package/docs/docs/options.mdx +105 -0
  54. package/docs/docs/upgrade-guide/_category_.json +7 -0
  55. package/docs/docs/upgrade-guide/basic-examples-v4-v5.mdx +119 -0
  56. package/docs/docs/upgrade-guide/changelog-v4-v5.md +86 -0
  57. package/docs/docusaurus.config.js +135 -0
  58. package/docs/package.json +47 -0
  59. package/docs/sidebars.js +33 -0
  60. package/docs/src/components/HomepageFeatures/index.tsx +71 -0
  61. package/docs/src/components/HomepageFeatures/styles.module.css +11 -0
  62. package/docs/src/css/custom.css +74 -0
  63. package/docs/src/pages/index.module.css +35 -0
  64. package/docs/src/pages/index.tsx +45 -0
  65. package/docs/src/pages/markdown-page.md +7 -0
  66. package/docs/static/.nojekyll +0 -0
  67. package/docs/static/img/Octocat.jpg +0 -0
  68. package/docs/static/img/Octocat.png +0 -0
  69. package/docs/static/img/Octocat.svg +9 -0
  70. package/docs/static/img/android-chrome-192x192.png +0 -0
  71. package/docs/static/img/android-chrome-512x512.png +0 -0
  72. package/docs/static/img/apple-touch-icon.png +0 -0
  73. package/docs/static/img/docusaurus.png +0 -0
  74. package/docs/static/img/favicon-16x16.png +0 -0
  75. package/docs/static/img/favicon-32x32.png +0 -0
  76. package/docs/static/img/favicon-old.ico +0 -0
  77. package/docs/static/img/favicon.ico +0 -0
  78. package/docs/static/img/github.svg +1 -0
  79. package/docs/static/img/happy-face-tooltip.png +0 -0
  80. package/docs/static/img/happy-face-tooltip.svg +21 -0
  81. package/docs/static/img/logo-dinossaur.svg +1 -0
  82. package/docs/static/img/logo.png +0 -0
  83. package/docs/static/img/logo.svg +21 -0
  84. package/docs/static/img/only-tooltip-top.png +0 -0
  85. package/docs/static/img/only-tooltip-top.svg +4 -0
  86. package/docs/static/img/only-tooltip.png +0 -0
  87. package/docs/static/img/only-tooltip.svg +4 -0
  88. package/docs/static/img/site.webmanifest +1 -0
  89. package/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
  90. package/docs/static/img/undraw_docusaurus_react.svg +170 -0
  91. package/docs/static/img/undraw_docusaurus_tree.svg +40 -0
  92. package/docs/tsconfig.json +7 -0
  93. package/docs/yarn.lock +7599 -0
  94. package/example-v5/package.json +21 -0
  95. package/example-v5/public/index.html +20 -0
  96. package/example-v5/public/manifest.json +8 -0
  97. package/example-v5/src/App.jsx +908 -0
  98. package/example-v5/src/index.css +238 -0
  99. package/example-v5/src/index.js +15 -0
  100. package/example-v5/src/index.scss +251 -0
  101. package/package.json +94 -146
  102. package/public/index.html +19 -0
  103. package/rollup.config.dev.js +88 -0
  104. package/rollup.config.prod.js +104 -0
  105. package/rollup.config.types.js +17 -0
  106. package/tsconfig.json +109 -0
  107. package/dist/index.es.js +0 -3185
  108. package/dist/index.es.js.map +0 -1
  109. package/dist/index.js +0 -3192
  110. package/dist/index.js.map +0 -1
package/dist/index.js DELETED
@@ -1,3192 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var PropTypes = require('prop-types');
5
- var uuid = require('uuid');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
11
-
12
- function ownKeys$2(object, enumerableOnly) {
13
- var keys = Object.keys(object);
14
- if (Object.getOwnPropertySymbols) {
15
- var symbols = Object.getOwnPropertySymbols(object);
16
- enumerableOnly && (symbols = symbols.filter(function (sym) {
17
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
18
- })), keys.push.apply(keys, symbols);
19
- }
20
- return keys;
21
- }
22
- function _objectSpread2(target) {
23
- for (var i = 1; i < arguments.length; i++) {
24
- var source = null != arguments[i] ? arguments[i] : {};
25
- i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
26
- _defineProperty(target, key, source[key]);
27
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
28
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
29
- });
30
- }
31
- return target;
32
- }
33
- function _classCallCheck(instance, Constructor) {
34
- if (!(instance instanceof Constructor)) {
35
- throw new TypeError("Cannot call a class as a function");
36
- }
37
- }
38
- function _defineProperties(target, props) {
39
- for (var i = 0; i < props.length; i++) {
40
- var descriptor = props[i];
41
- descriptor.enumerable = descriptor.enumerable || false;
42
- descriptor.configurable = true;
43
- if ("value" in descriptor) descriptor.writable = true;
44
- Object.defineProperty(target, descriptor.key, descriptor);
45
- }
46
- }
47
- function _createClass(Constructor, protoProps, staticProps) {
48
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
49
- if (staticProps) _defineProperties(Constructor, staticProps);
50
- Object.defineProperty(Constructor, "prototype", {
51
- writable: false
52
- });
53
- return Constructor;
54
- }
55
- function _defineProperty(obj, key, value) {
56
- if (key in obj) {
57
- Object.defineProperty(obj, key, {
58
- value: value,
59
- enumerable: true,
60
- configurable: true,
61
- writable: true
62
- });
63
- } else {
64
- obj[key] = value;
65
- }
66
- return obj;
67
- }
68
- function _extends() {
69
- _extends = Object.assign ? Object.assign.bind() : function (target) {
70
- for (var i = 1; i < arguments.length; i++) {
71
- var source = arguments[i];
72
- for (var key in source) {
73
- if (Object.prototype.hasOwnProperty.call(source, key)) {
74
- target[key] = source[key];
75
- }
76
- }
77
- }
78
- return target;
79
- };
80
- return _extends.apply(this, arguments);
81
- }
82
- function _inherits(subClass, superClass) {
83
- if (typeof superClass !== "function" && superClass !== null) {
84
- throw new TypeError("Super expression must either be null or a function");
85
- }
86
- subClass.prototype = Object.create(superClass && superClass.prototype, {
87
- constructor: {
88
- value: subClass,
89
- writable: true,
90
- configurable: true
91
- }
92
- });
93
- Object.defineProperty(subClass, "prototype", {
94
- writable: false
95
- });
96
- if (superClass) _setPrototypeOf(subClass, superClass);
97
- }
98
- function _getPrototypeOf(o) {
99
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
100
- return o.__proto__ || Object.getPrototypeOf(o);
101
- };
102
- return _getPrototypeOf(o);
103
- }
104
- function _setPrototypeOf(o, p) {
105
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
106
- o.__proto__ = p;
107
- return o;
108
- };
109
- return _setPrototypeOf(o, p);
110
- }
111
- function _isNativeReflectConstruct() {
112
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
113
- if (Reflect.construct.sham) return false;
114
- if (typeof Proxy === "function") return true;
115
- try {
116
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
117
- return true;
118
- } catch (e) {
119
- return false;
120
- }
121
- }
122
- function _assertThisInitialized(self) {
123
- if (self === void 0) {
124
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
125
- }
126
- return self;
127
- }
128
- function _possibleConstructorReturn(self, call) {
129
- if (call && (typeof call === "object" || typeof call === "function")) {
130
- return call;
131
- } else if (call !== void 0) {
132
- throw new TypeError("Derived constructors may only return object or undefined");
133
- }
134
- return _assertThisInitialized(self);
135
- }
136
- function _createSuper(Derived) {
137
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
138
- return function _createSuperInternal() {
139
- var Super = _getPrototypeOf(Derived),
140
- result;
141
- if (hasNativeReflectConstruct) {
142
- var NewTarget = _getPrototypeOf(this).constructor;
143
- result = Reflect.construct(Super, arguments, NewTarget);
144
- } else {
145
- result = Super.apply(this, arguments);
146
- }
147
- return _possibleConstructorReturn(this, result);
148
- };
149
- }
150
- function _unsupportedIterableToArray(o, minLen) {
151
- if (!o) return;
152
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
153
- var n = Object.prototype.toString.call(o).slice(8, -1);
154
- if (n === "Object" && o.constructor) n = o.constructor.name;
155
- if (n === "Map" || n === "Set") return Array.from(o);
156
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
157
- }
158
- function _arrayLikeToArray(arr, len) {
159
- if (len == null || len > arr.length) len = arr.length;
160
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
161
- return arr2;
162
- }
163
- function _createForOfIteratorHelper(o, allowArrayLike) {
164
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
165
- if (!it) {
166
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
167
- if (it) o = it;
168
- var i = 0;
169
- var F = function () {};
170
- return {
171
- s: F,
172
- n: function () {
173
- if (i >= o.length) return {
174
- done: true
175
- };
176
- return {
177
- done: false,
178
- value: o[i++]
179
- };
180
- },
181
- e: function (e) {
182
- throw e;
183
- },
184
- f: F
185
- };
186
- }
187
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
188
- }
189
- var normalCompletion = true,
190
- didErr = false,
191
- err;
192
- return {
193
- s: function () {
194
- it = it.call(o);
195
- },
196
- n: function () {
197
- var step = it.next();
198
- normalCompletion = step.done;
199
- return step;
200
- },
201
- e: function (e) {
202
- didErr = true;
203
- err = e;
204
- },
205
- f: function () {
206
- try {
207
- if (!normalCompletion && it.return != null) it.return();
208
- } finally {
209
- if (didErr) throw err;
210
- }
211
- }
212
- };
213
- }
214
-
215
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
216
-
217
- var check = function (it) {
218
- return it && it.Math == Math && it;
219
- };
220
-
221
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
222
- var global$a =
223
- // eslint-disable-next-line es/no-global-this -- safe
224
- check(typeof globalThis == 'object' && globalThis) ||
225
- check(typeof window == 'object' && window) ||
226
- // eslint-disable-next-line no-restricted-globals -- safe
227
- check(typeof self == 'object' && self) ||
228
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
229
- // eslint-disable-next-line no-new-func -- fallback
230
- (function () { return this; })() || Function('return this')();
231
-
232
- var objectGetOwnPropertyDescriptor = {};
233
-
234
- var fails$9 = function (exec) {
235
- try {
236
- return !!exec();
237
- } catch (error) {
238
- return true;
239
- }
240
- };
241
-
242
- var fails$8 = fails$9;
243
-
244
- // Detect IE8's incomplete defineProperty implementation
245
- var descriptors = !fails$8(function () {
246
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
247
- return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
248
- });
249
-
250
- var fails$7 = fails$9;
251
-
252
- var functionBindNative = !fails$7(function () {
253
- // eslint-disable-next-line es/no-function-prototype-bind -- safe
254
- var test = (function () { /* empty */ }).bind();
255
- // eslint-disable-next-line no-prototype-builtins -- safe
256
- return typeof test != 'function' || test.hasOwnProperty('prototype');
257
- });
258
-
259
- var NATIVE_BIND$2 = functionBindNative;
260
-
261
- var call$4 = Function.prototype.call;
262
-
263
- var functionCall = NATIVE_BIND$2 ? call$4.bind(call$4) : function () {
264
- return call$4.apply(call$4, arguments);
265
- };
266
-
267
- var objectPropertyIsEnumerable = {};
268
-
269
- var $propertyIsEnumerable = {}.propertyIsEnumerable;
270
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
271
- var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
272
-
273
- // Nashorn ~ JDK8 bug
274
- var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
275
-
276
- // `Object.prototype.propertyIsEnumerable` method implementation
277
- // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
278
- objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
279
- var descriptor = getOwnPropertyDescriptor$1(this, V);
280
- return !!descriptor && descriptor.enumerable;
281
- } : $propertyIsEnumerable;
282
-
283
- var createPropertyDescriptor$2 = function (bitmap, value) {
284
- return {
285
- enumerable: !(bitmap & 1),
286
- configurable: !(bitmap & 2),
287
- writable: !(bitmap & 4),
288
- value: value
289
- };
290
- };
291
-
292
- var NATIVE_BIND$1 = functionBindNative;
293
-
294
- var FunctionPrototype$1 = Function.prototype;
295
- var call$3 = FunctionPrototype$1.call;
296
- var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$3, call$3);
297
-
298
- var functionUncurryThisRaw = function (fn) {
299
- return NATIVE_BIND$1 ? uncurryThisWithBind(fn) : function () {
300
- return call$3.apply(fn, arguments);
301
- };
302
- };
303
-
304
- var uncurryThisRaw$1 = functionUncurryThisRaw;
305
-
306
- var toString$1 = uncurryThisRaw$1({}.toString);
307
- var stringSlice = uncurryThisRaw$1(''.slice);
308
-
309
- var classofRaw$2 = function (it) {
310
- return stringSlice(toString$1(it), 8, -1);
311
- };
312
-
313
- var classofRaw$1 = classofRaw$2;
314
- var uncurryThisRaw = functionUncurryThisRaw;
315
-
316
- var functionUncurryThis = function (fn) {
317
- // Nashorn bug:
318
- // https://github.com/zloirock/core-js/issues/1128
319
- // https://github.com/zloirock/core-js/issues/1130
320
- if (classofRaw$1(fn) === 'Function') return uncurryThisRaw(fn);
321
- };
322
-
323
- var uncurryThis$9 = functionUncurryThis;
324
- var fails$6 = fails$9;
325
- var classof$3 = classofRaw$2;
326
-
327
- var $Object$3 = Object;
328
- var split = uncurryThis$9(''.split);
329
-
330
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
331
- var indexedObject = fails$6(function () {
332
- // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
333
- // eslint-disable-next-line no-prototype-builtins -- safe
334
- return !$Object$3('z').propertyIsEnumerable(0);
335
- }) ? function (it) {
336
- return classof$3(it) == 'String' ? split(it, '') : $Object$3(it);
337
- } : $Object$3;
338
-
339
- // we can't use just `it == null` since of `document.all` special case
340
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
341
- var isNullOrUndefined$2 = function (it) {
342
- return it === null || it === undefined;
343
- };
344
-
345
- var isNullOrUndefined$1 = isNullOrUndefined$2;
346
-
347
- var $TypeError$5 = TypeError;
348
-
349
- // `RequireObjectCoercible` abstract operation
350
- // https://tc39.es/ecma262/#sec-requireobjectcoercible
351
- var requireObjectCoercible$2 = function (it) {
352
- if (isNullOrUndefined$1(it)) throw $TypeError$5("Can't call method on " + it);
353
- return it;
354
- };
355
-
356
- // toObject with fallback for non-array-like ES3 strings
357
- var IndexedObject$1 = indexedObject;
358
- var requireObjectCoercible$1 = requireObjectCoercible$2;
359
-
360
- var toIndexedObject$4 = function (it) {
361
- return IndexedObject$1(requireObjectCoercible$1(it));
362
- };
363
-
364
- var documentAll$2 = typeof document == 'object' && document.all;
365
-
366
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
367
- var IS_HTMLDDA = typeof documentAll$2 == 'undefined' && documentAll$2 !== undefined;
368
-
369
- var documentAll_1 = {
370
- all: documentAll$2,
371
- IS_HTMLDDA: IS_HTMLDDA
372
- };
373
-
374
- var $documentAll$1 = documentAll_1;
375
-
376
- var documentAll$1 = $documentAll$1.all;
377
-
378
- // `IsCallable` abstract operation
379
- // https://tc39.es/ecma262/#sec-iscallable
380
- var isCallable$c = $documentAll$1.IS_HTMLDDA ? function (argument) {
381
- return typeof argument == 'function' || argument === documentAll$1;
382
- } : function (argument) {
383
- return typeof argument == 'function';
384
- };
385
-
386
- var isCallable$b = isCallable$c;
387
- var $documentAll = documentAll_1;
388
-
389
- var documentAll = $documentAll.all;
390
-
391
- var isObject$6 = $documentAll.IS_HTMLDDA ? function (it) {
392
- return typeof it == 'object' ? it !== null : isCallable$b(it) || it === documentAll;
393
- } : function (it) {
394
- return typeof it == 'object' ? it !== null : isCallable$b(it);
395
- };
396
-
397
- var global$9 = global$a;
398
- var isCallable$a = isCallable$c;
399
-
400
- var aFunction = function (argument) {
401
- return isCallable$a(argument) ? argument : undefined;
402
- };
403
-
404
- var getBuiltIn$5 = function (namespace, method) {
405
- return arguments.length < 2 ? aFunction(global$9[namespace]) : global$9[namespace] && global$9[namespace][method];
406
- };
407
-
408
- var uncurryThis$8 = functionUncurryThis;
409
-
410
- var objectIsPrototypeOf = uncurryThis$8({}.isPrototypeOf);
411
-
412
- var getBuiltIn$4 = getBuiltIn$5;
413
-
414
- var engineUserAgent = getBuiltIn$4('navigator', 'userAgent') || '';
415
-
416
- var global$8 = global$a;
417
- var userAgent = engineUserAgent;
418
-
419
- var process = global$8.process;
420
- var Deno = global$8.Deno;
421
- var versions = process && process.versions || Deno && Deno.version;
422
- var v8 = versions && versions.v8;
423
- var match, version;
424
-
425
- if (v8) {
426
- match = v8.split('.');
427
- // in old Chrome, versions of V8 isn't V8 = Chrome / 10
428
- // but their correct versions are not interesting for us
429
- version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
430
- }
431
-
432
- // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
433
- // so check `userAgent` even if `.v8` exists, but 0
434
- if (!version && userAgent) {
435
- match = userAgent.match(/Edge\/(\d+)/);
436
- if (!match || match[1] >= 74) {
437
- match = userAgent.match(/Chrome\/(\d+)/);
438
- if (match) version = +match[1];
439
- }
440
- }
441
-
442
- var engineV8Version = version;
443
-
444
- /* eslint-disable es/no-symbol -- required for testing */
445
-
446
- var V8_VERSION = engineV8Version;
447
- var fails$5 = fails$9;
448
-
449
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
450
- var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$5(function () {
451
- var symbol = Symbol();
452
- // Chrome 38 Symbol has incorrect toString conversion
453
- // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
454
- return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
455
- // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
456
- !Symbol.sham && V8_VERSION && V8_VERSION < 41;
457
- });
458
-
459
- /* eslint-disable es/no-symbol -- required for testing */
460
-
461
- var NATIVE_SYMBOL$1 = symbolConstructorDetection;
462
-
463
- var useSymbolAsUid = NATIVE_SYMBOL$1
464
- && !Symbol.sham
465
- && typeof Symbol.iterator == 'symbol';
466
-
467
- var getBuiltIn$3 = getBuiltIn$5;
468
- var isCallable$9 = isCallable$c;
469
- var isPrototypeOf = objectIsPrototypeOf;
470
- var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
471
-
472
- var $Object$2 = Object;
473
-
474
- var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
475
- return typeof it == 'symbol';
476
- } : function (it) {
477
- var $Symbol = getBuiltIn$3('Symbol');
478
- return isCallable$9($Symbol) && isPrototypeOf($Symbol.prototype, $Object$2(it));
479
- };
480
-
481
- var $String$1 = String;
482
-
483
- var tryToString$1 = function (argument) {
484
- try {
485
- return $String$1(argument);
486
- } catch (error) {
487
- return 'Object';
488
- }
489
- };
490
-
491
- var isCallable$8 = isCallable$c;
492
- var tryToString = tryToString$1;
493
-
494
- var $TypeError$4 = TypeError;
495
-
496
- // `Assert: IsCallable(argument) is true`
497
- var aCallable$2 = function (argument) {
498
- if (isCallable$8(argument)) return argument;
499
- throw $TypeError$4(tryToString(argument) + ' is not a function');
500
- };
501
-
502
- var aCallable$1 = aCallable$2;
503
- var isNullOrUndefined = isNullOrUndefined$2;
504
-
505
- // `GetMethod` abstract operation
506
- // https://tc39.es/ecma262/#sec-getmethod
507
- var getMethod$1 = function (V, P) {
508
- var func = V[P];
509
- return isNullOrUndefined(func) ? undefined : aCallable$1(func);
510
- };
511
-
512
- var call$2 = functionCall;
513
- var isCallable$7 = isCallable$c;
514
- var isObject$5 = isObject$6;
515
-
516
- var $TypeError$3 = TypeError;
517
-
518
- // `OrdinaryToPrimitive` abstract operation
519
- // https://tc39.es/ecma262/#sec-ordinarytoprimitive
520
- var ordinaryToPrimitive$1 = function (input, pref) {
521
- var fn, val;
522
- if (pref === 'string' && isCallable$7(fn = input.toString) && !isObject$5(val = call$2(fn, input))) return val;
523
- if (isCallable$7(fn = input.valueOf) && !isObject$5(val = call$2(fn, input))) return val;
524
- if (pref !== 'string' && isCallable$7(fn = input.toString) && !isObject$5(val = call$2(fn, input))) return val;
525
- throw $TypeError$3("Can't convert object to primitive value");
526
- };
527
-
528
- var shared$3 = {exports: {}};
529
-
530
- var global$7 = global$a;
531
-
532
- // eslint-disable-next-line es/no-object-defineproperty -- safe
533
- var defineProperty$2 = Object.defineProperty;
534
-
535
- var defineGlobalProperty$3 = function (key, value) {
536
- try {
537
- defineProperty$2(global$7, key, { value: value, configurable: true, writable: true });
538
- } catch (error) {
539
- global$7[key] = value;
540
- } return value;
541
- };
542
-
543
- var global$6 = global$a;
544
- var defineGlobalProperty$2 = defineGlobalProperty$3;
545
-
546
- var SHARED = '__core-js_shared__';
547
- var store$3 = global$6[SHARED] || defineGlobalProperty$2(SHARED, {});
548
-
549
- var sharedStore = store$3;
550
-
551
- var store$2 = sharedStore;
552
-
553
- (shared$3.exports = function (key, value) {
554
- return store$2[key] || (store$2[key] = value !== undefined ? value : {});
555
- })('versions', []).push({
556
- version: '3.25.5',
557
- mode: 'global',
558
- copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
559
- license: 'https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE',
560
- source: 'https://github.com/zloirock/core-js'
561
- });
562
-
563
- var requireObjectCoercible = requireObjectCoercible$2;
564
-
565
- var $Object$1 = Object;
566
-
567
- // `ToObject` abstract operation
568
- // https://tc39.es/ecma262/#sec-toobject
569
- var toObject$2 = function (argument) {
570
- return $Object$1(requireObjectCoercible(argument));
571
- };
572
-
573
- var uncurryThis$7 = functionUncurryThis;
574
- var toObject$1 = toObject$2;
575
-
576
- var hasOwnProperty = uncurryThis$7({}.hasOwnProperty);
577
-
578
- // `HasOwnProperty` abstract operation
579
- // https://tc39.es/ecma262/#sec-hasownproperty
580
- // eslint-disable-next-line es/no-object-hasown -- safe
581
- var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
582
- return hasOwnProperty(toObject$1(it), key);
583
- };
584
-
585
- var uncurryThis$6 = functionUncurryThis;
586
-
587
- var id = 0;
588
- var postfix = Math.random();
589
- var toString = uncurryThis$6(1.0.toString);
590
-
591
- var uid$2 = function (key) {
592
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
593
- };
594
-
595
- var global$5 = global$a;
596
- var shared$2 = shared$3.exports;
597
- var hasOwn$6 = hasOwnProperty_1;
598
- var uid$1 = uid$2;
599
- var NATIVE_SYMBOL = symbolConstructorDetection;
600
- var USE_SYMBOL_AS_UID = useSymbolAsUid;
601
-
602
- var WellKnownSymbolsStore = shared$2('wks');
603
- var Symbol$1 = global$5.Symbol;
604
- var symbolFor = Symbol$1 && Symbol$1['for'];
605
- var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
606
-
607
- var wellKnownSymbol$5 = function (name) {
608
- if (!hasOwn$6(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
609
- var description = 'Symbol.' + name;
610
- if (NATIVE_SYMBOL && hasOwn$6(Symbol$1, name)) {
611
- WellKnownSymbolsStore[name] = Symbol$1[name];
612
- } else if (USE_SYMBOL_AS_UID && symbolFor) {
613
- WellKnownSymbolsStore[name] = symbolFor(description);
614
- } else {
615
- WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
616
- }
617
- } return WellKnownSymbolsStore[name];
618
- };
619
-
620
- var call$1 = functionCall;
621
- var isObject$4 = isObject$6;
622
- var isSymbol$1 = isSymbol$2;
623
- var getMethod = getMethod$1;
624
- var ordinaryToPrimitive = ordinaryToPrimitive$1;
625
- var wellKnownSymbol$4 = wellKnownSymbol$5;
626
-
627
- var $TypeError$2 = TypeError;
628
- var TO_PRIMITIVE = wellKnownSymbol$4('toPrimitive');
629
-
630
- // `ToPrimitive` abstract operation
631
- // https://tc39.es/ecma262/#sec-toprimitive
632
- var toPrimitive$1 = function (input, pref) {
633
- if (!isObject$4(input) || isSymbol$1(input)) return input;
634
- var exoticToPrim = getMethod(input, TO_PRIMITIVE);
635
- var result;
636
- if (exoticToPrim) {
637
- if (pref === undefined) pref = 'default';
638
- result = call$1(exoticToPrim, input, pref);
639
- if (!isObject$4(result) || isSymbol$1(result)) return result;
640
- throw $TypeError$2("Can't convert object to primitive value");
641
- }
642
- if (pref === undefined) pref = 'number';
643
- return ordinaryToPrimitive(input, pref);
644
- };
645
-
646
- var toPrimitive = toPrimitive$1;
647
- var isSymbol = isSymbol$2;
648
-
649
- // `ToPropertyKey` abstract operation
650
- // https://tc39.es/ecma262/#sec-topropertykey
651
- var toPropertyKey$2 = function (argument) {
652
- var key = toPrimitive(argument, 'string');
653
- return isSymbol(key) ? key : key + '';
654
- };
655
-
656
- var global$4 = global$a;
657
- var isObject$3 = isObject$6;
658
-
659
- var document$1 = global$4.document;
660
- // typeof document.createElement is 'object' in old IE
661
- var EXISTS$1 = isObject$3(document$1) && isObject$3(document$1.createElement);
662
-
663
- var documentCreateElement$1 = function (it) {
664
- return EXISTS$1 ? document$1.createElement(it) : {};
665
- };
666
-
667
- var DESCRIPTORS$7 = descriptors;
668
- var fails$4 = fails$9;
669
- var createElement = documentCreateElement$1;
670
-
671
- // Thanks to IE8 for its funny defineProperty
672
- var ie8DomDefine = !DESCRIPTORS$7 && !fails$4(function () {
673
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
674
- return Object.defineProperty(createElement('div'), 'a', {
675
- get: function () { return 7; }
676
- }).a != 7;
677
- });
678
-
679
- var DESCRIPTORS$6 = descriptors;
680
- var call = functionCall;
681
- var propertyIsEnumerableModule = objectPropertyIsEnumerable;
682
- var createPropertyDescriptor$1 = createPropertyDescriptor$2;
683
- var toIndexedObject$3 = toIndexedObject$4;
684
- var toPropertyKey$1 = toPropertyKey$2;
685
- var hasOwn$5 = hasOwnProperty_1;
686
- var IE8_DOM_DEFINE$1 = ie8DomDefine;
687
-
688
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
689
- var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
690
-
691
- // `Object.getOwnPropertyDescriptor` method
692
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
693
- objectGetOwnPropertyDescriptor.f = DESCRIPTORS$6 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
694
- O = toIndexedObject$3(O);
695
- P = toPropertyKey$1(P);
696
- if (IE8_DOM_DEFINE$1) try {
697
- return $getOwnPropertyDescriptor$1(O, P);
698
- } catch (error) { /* empty */ }
699
- if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!call(propertyIsEnumerableModule.f, O, P), O[P]);
700
- };
701
-
702
- var objectDefineProperty = {};
703
-
704
- var DESCRIPTORS$5 = descriptors;
705
- var fails$3 = fails$9;
706
-
707
- // V8 ~ Chrome 36-
708
- // https://bugs.chromium.org/p/v8/issues/detail?id=3334
709
- var v8PrototypeDefineBug = DESCRIPTORS$5 && fails$3(function () {
710
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
711
- return Object.defineProperty(function () { /* empty */ }, 'prototype', {
712
- value: 42,
713
- writable: false
714
- }).prototype != 42;
715
- });
716
-
717
- var isObject$2 = isObject$6;
718
-
719
- var $String = String;
720
- var $TypeError$1 = TypeError;
721
-
722
- // `Assert: Type(argument) is Object`
723
- var anObject$4 = function (argument) {
724
- if (isObject$2(argument)) return argument;
725
- throw $TypeError$1($String(argument) + ' is not an object');
726
- };
727
-
728
- var DESCRIPTORS$4 = descriptors;
729
- var IE8_DOM_DEFINE = ie8DomDefine;
730
- var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
731
- var anObject$3 = anObject$4;
732
- var toPropertyKey = toPropertyKey$2;
733
-
734
- var $TypeError = TypeError;
735
- // eslint-disable-next-line es/no-object-defineproperty -- safe
736
- var $defineProperty = Object.defineProperty;
737
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
738
- var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
739
- var ENUMERABLE = 'enumerable';
740
- var CONFIGURABLE$1 = 'configurable';
741
- var WRITABLE = 'writable';
742
-
743
- // `Object.defineProperty` method
744
- // https://tc39.es/ecma262/#sec-object.defineproperty
745
- objectDefineProperty.f = DESCRIPTORS$4 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
746
- anObject$3(O);
747
- P = toPropertyKey(P);
748
- anObject$3(Attributes);
749
- if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
750
- var current = $getOwnPropertyDescriptor(O, P);
751
- if (current && current[WRITABLE]) {
752
- O[P] = Attributes.value;
753
- Attributes = {
754
- configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
755
- enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
756
- writable: false
757
- };
758
- }
759
- } return $defineProperty(O, P, Attributes);
760
- } : $defineProperty : function defineProperty(O, P, Attributes) {
761
- anObject$3(O);
762
- P = toPropertyKey(P);
763
- anObject$3(Attributes);
764
- if (IE8_DOM_DEFINE) try {
765
- return $defineProperty(O, P, Attributes);
766
- } catch (error) { /* empty */ }
767
- if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported');
768
- if ('value' in Attributes) O[P] = Attributes.value;
769
- return O;
770
- };
771
-
772
- var DESCRIPTORS$3 = descriptors;
773
- var definePropertyModule$3 = objectDefineProperty;
774
- var createPropertyDescriptor = createPropertyDescriptor$2;
775
-
776
- var createNonEnumerableProperty$2 = DESCRIPTORS$3 ? function (object, key, value) {
777
- return definePropertyModule$3.f(object, key, createPropertyDescriptor(1, value));
778
- } : function (object, key, value) {
779
- object[key] = value;
780
- return object;
781
- };
782
-
783
- var makeBuiltIn$2 = {exports: {}};
784
-
785
- var DESCRIPTORS$2 = descriptors;
786
- var hasOwn$4 = hasOwnProperty_1;
787
-
788
- var FunctionPrototype = Function.prototype;
789
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
790
- var getDescriptor = DESCRIPTORS$2 && Object.getOwnPropertyDescriptor;
791
-
792
- var EXISTS = hasOwn$4(FunctionPrototype, 'name');
793
- // additional protection from minified / mangled / dropped function names
794
- var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
795
- var CONFIGURABLE = EXISTS && (!DESCRIPTORS$2 || (DESCRIPTORS$2 && getDescriptor(FunctionPrototype, 'name').configurable));
796
-
797
- var functionName = {
798
- EXISTS: EXISTS,
799
- PROPER: PROPER,
800
- CONFIGURABLE: CONFIGURABLE
801
- };
802
-
803
- var uncurryThis$5 = functionUncurryThis;
804
- var isCallable$6 = isCallable$c;
805
- var store$1 = sharedStore;
806
-
807
- var functionToString = uncurryThis$5(Function.toString);
808
-
809
- // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
810
- if (!isCallable$6(store$1.inspectSource)) {
811
- store$1.inspectSource = function (it) {
812
- return functionToString(it);
813
- };
814
- }
815
-
816
- var inspectSource$2 = store$1.inspectSource;
817
-
818
- var global$3 = global$a;
819
- var isCallable$5 = isCallable$c;
820
-
821
- var WeakMap$1 = global$3.WeakMap;
822
-
823
- var weakMapBasicDetection = isCallable$5(WeakMap$1) && /native code/.test(String(WeakMap$1));
824
-
825
- var shared$1 = shared$3.exports;
826
- var uid = uid$2;
827
-
828
- var keys = shared$1('keys');
829
-
830
- var sharedKey$2 = function (key) {
831
- return keys[key] || (keys[key] = uid(key));
832
- };
833
-
834
- var hiddenKeys$4 = {};
835
-
836
- var NATIVE_WEAK_MAP = weakMapBasicDetection;
837
- var global$2 = global$a;
838
- var isObject$1 = isObject$6;
839
- var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
840
- var hasOwn$3 = hasOwnProperty_1;
841
- var shared = sharedStore;
842
- var sharedKey$1 = sharedKey$2;
843
- var hiddenKeys$3 = hiddenKeys$4;
844
-
845
- var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
846
- var TypeError$1 = global$2.TypeError;
847
- var WeakMap = global$2.WeakMap;
848
- var set, get, has;
849
-
850
- var enforce = function (it) {
851
- return has(it) ? get(it) : set(it, {});
852
- };
853
-
854
- var getterFor = function (TYPE) {
855
- return function (it) {
856
- var state;
857
- if (!isObject$1(it) || (state = get(it)).type !== TYPE) {
858
- throw TypeError$1('Incompatible receiver, ' + TYPE + ' required');
859
- } return state;
860
- };
861
- };
862
-
863
- if (NATIVE_WEAK_MAP || shared.state) {
864
- var store = shared.state || (shared.state = new WeakMap());
865
- /* eslint-disable no-self-assign -- prototype methods protection */
866
- store.get = store.get;
867
- store.has = store.has;
868
- store.set = store.set;
869
- /* eslint-enable no-self-assign -- prototype methods protection */
870
- set = function (it, metadata) {
871
- if (store.has(it)) throw TypeError$1(OBJECT_ALREADY_INITIALIZED);
872
- metadata.facade = it;
873
- store.set(it, metadata);
874
- return metadata;
875
- };
876
- get = function (it) {
877
- return store.get(it) || {};
878
- };
879
- has = function (it) {
880
- return store.has(it);
881
- };
882
- } else {
883
- var STATE = sharedKey$1('state');
884
- hiddenKeys$3[STATE] = true;
885
- set = function (it, metadata) {
886
- if (hasOwn$3(it, STATE)) throw TypeError$1(OBJECT_ALREADY_INITIALIZED);
887
- metadata.facade = it;
888
- createNonEnumerableProperty$1(it, STATE, metadata);
889
- return metadata;
890
- };
891
- get = function (it) {
892
- return hasOwn$3(it, STATE) ? it[STATE] : {};
893
- };
894
- has = function (it) {
895
- return hasOwn$3(it, STATE);
896
- };
897
- }
898
-
899
- var internalState = {
900
- set: set,
901
- get: get,
902
- has: has,
903
- enforce: enforce,
904
- getterFor: getterFor
905
- };
906
-
907
- var fails$2 = fails$9;
908
- var isCallable$4 = isCallable$c;
909
- var hasOwn$2 = hasOwnProperty_1;
910
- var DESCRIPTORS$1 = descriptors;
911
- var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
912
- var inspectSource$1 = inspectSource$2;
913
- var InternalStateModule = internalState;
914
-
915
- var enforceInternalState = InternalStateModule.enforce;
916
- var getInternalState = InternalStateModule.get;
917
- // eslint-disable-next-line es/no-object-defineproperty -- safe
918
- var defineProperty$1 = Object.defineProperty;
919
-
920
- var CONFIGURABLE_LENGTH = DESCRIPTORS$1 && !fails$2(function () {
921
- return defineProperty$1(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
922
- });
923
-
924
- var TEMPLATE = String(String).split('String');
925
-
926
- var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
927
- if (String(name).slice(0, 7) === 'Symbol(') {
928
- name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
929
- }
930
- if (options && options.getter) name = 'get ' + name;
931
- if (options && options.setter) name = 'set ' + name;
932
- if (!hasOwn$2(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
933
- if (DESCRIPTORS$1) defineProperty$1(value, 'name', { value: name, configurable: true });
934
- else value.name = name;
935
- }
936
- if (CONFIGURABLE_LENGTH && options && hasOwn$2(options, 'arity') && value.length !== options.arity) {
937
- defineProperty$1(value, 'length', { value: options.arity });
938
- }
939
- try {
940
- if (options && hasOwn$2(options, 'constructor') && options.constructor) {
941
- if (DESCRIPTORS$1) defineProperty$1(value, 'prototype', { writable: false });
942
- // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
943
- } else if (value.prototype) value.prototype = undefined;
944
- } catch (error) { /* empty */ }
945
- var state = enforceInternalState(value);
946
- if (!hasOwn$2(state, 'source')) {
947
- state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
948
- } return value;
949
- };
950
-
951
- // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
952
- // eslint-disable-next-line no-extend-native -- required
953
- Function.prototype.toString = makeBuiltIn$1(function toString() {
954
- return isCallable$4(this) && getInternalState(this).source || inspectSource$1(this);
955
- }, 'toString');
956
-
957
- var isCallable$3 = isCallable$c;
958
- var definePropertyModule$2 = objectDefineProperty;
959
- var makeBuiltIn = makeBuiltIn$2.exports;
960
- var defineGlobalProperty$1 = defineGlobalProperty$3;
961
-
962
- var defineBuiltIn$1 = function (O, key, value, options) {
963
- if (!options) options = {};
964
- var simple = options.enumerable;
965
- var name = options.name !== undefined ? options.name : key;
966
- if (isCallable$3(value)) makeBuiltIn(value, name, options);
967
- if (options.global) {
968
- if (simple) O[key] = value;
969
- else defineGlobalProperty$1(key, value);
970
- } else {
971
- try {
972
- if (!options.unsafe) delete O[key];
973
- else if (O[key]) simple = true;
974
- } catch (error) { /* empty */ }
975
- if (simple) O[key] = value;
976
- else definePropertyModule$2.f(O, key, {
977
- value: value,
978
- enumerable: false,
979
- configurable: !options.nonConfigurable,
980
- writable: !options.nonWritable
981
- });
982
- } return O;
983
- };
984
-
985
- var objectGetOwnPropertyNames = {};
986
-
987
- var ceil = Math.ceil;
988
- var floor = Math.floor;
989
-
990
- // `Math.trunc` method
991
- // https://tc39.es/ecma262/#sec-math.trunc
992
- // eslint-disable-next-line es/no-math-trunc -- safe
993
- var mathTrunc = Math.trunc || function trunc(x) {
994
- var n = +x;
995
- return (n > 0 ? floor : ceil)(n);
996
- };
997
-
998
- var trunc = mathTrunc;
999
-
1000
- // `ToIntegerOrInfinity` abstract operation
1001
- // https://tc39.es/ecma262/#sec-tointegerorinfinity
1002
- var toIntegerOrInfinity$2 = function (argument) {
1003
- var number = +argument;
1004
- // eslint-disable-next-line no-self-compare -- NaN check
1005
- return number !== number || number === 0 ? 0 : trunc(number);
1006
- };
1007
-
1008
- var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
1009
-
1010
- var max = Math.max;
1011
- var min$1 = Math.min;
1012
-
1013
- // Helper for a popular repeating case of the spec:
1014
- // Let integer be ? ToInteger(index).
1015
- // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
1016
- var toAbsoluteIndex$1 = function (index, length) {
1017
- var integer = toIntegerOrInfinity$1(index);
1018
- return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
1019
- };
1020
-
1021
- var toIntegerOrInfinity = toIntegerOrInfinity$2;
1022
-
1023
- var min = Math.min;
1024
-
1025
- // `ToLength` abstract operation
1026
- // https://tc39.es/ecma262/#sec-tolength
1027
- var toLength$1 = function (argument) {
1028
- return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
1029
- };
1030
-
1031
- var toLength = toLength$1;
1032
-
1033
- // `LengthOfArrayLike` abstract operation
1034
- // https://tc39.es/ecma262/#sec-lengthofarraylike
1035
- var lengthOfArrayLike$2 = function (obj) {
1036
- return toLength(obj.length);
1037
- };
1038
-
1039
- var toIndexedObject$2 = toIndexedObject$4;
1040
- var toAbsoluteIndex = toAbsoluteIndex$1;
1041
- var lengthOfArrayLike$1 = lengthOfArrayLike$2;
1042
-
1043
- // `Array.prototype.{ indexOf, includes }` methods implementation
1044
- var createMethod$1 = function (IS_INCLUDES) {
1045
- return function ($this, el, fromIndex) {
1046
- var O = toIndexedObject$2($this);
1047
- var length = lengthOfArrayLike$1(O);
1048
- var index = toAbsoluteIndex(fromIndex, length);
1049
- var value;
1050
- // Array#includes uses SameValueZero equality algorithm
1051
- // eslint-disable-next-line no-self-compare -- NaN check
1052
- if (IS_INCLUDES && el != el) while (length > index) {
1053
- value = O[index++];
1054
- // eslint-disable-next-line no-self-compare -- NaN check
1055
- if (value != value) return true;
1056
- // Array#indexOf ignores holes, Array#includes - not
1057
- } else for (;length > index; index++) {
1058
- if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
1059
- } return !IS_INCLUDES && -1;
1060
- };
1061
- };
1062
-
1063
- var arrayIncludes = {
1064
- // `Array.prototype.includes` method
1065
- // https://tc39.es/ecma262/#sec-array.prototype.includes
1066
- includes: createMethod$1(true),
1067
- // `Array.prototype.indexOf` method
1068
- // https://tc39.es/ecma262/#sec-array.prototype.indexof
1069
- indexOf: createMethod$1(false)
1070
- };
1071
-
1072
- var uncurryThis$4 = functionUncurryThis;
1073
- var hasOwn$1 = hasOwnProperty_1;
1074
- var toIndexedObject$1 = toIndexedObject$4;
1075
- var indexOf = arrayIncludes.indexOf;
1076
- var hiddenKeys$2 = hiddenKeys$4;
1077
-
1078
- var push$1 = uncurryThis$4([].push);
1079
-
1080
- var objectKeysInternal = function (object, names) {
1081
- var O = toIndexedObject$1(object);
1082
- var i = 0;
1083
- var result = [];
1084
- var key;
1085
- for (key in O) !hasOwn$1(hiddenKeys$2, key) && hasOwn$1(O, key) && push$1(result, key);
1086
- // Don't enum bug & hidden keys
1087
- while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
1088
- ~indexOf(result, key) || push$1(result, key);
1089
- }
1090
- return result;
1091
- };
1092
-
1093
- // IE8- don't enum bug keys
1094
- var enumBugKeys$3 = [
1095
- 'constructor',
1096
- 'hasOwnProperty',
1097
- 'isPrototypeOf',
1098
- 'propertyIsEnumerable',
1099
- 'toLocaleString',
1100
- 'toString',
1101
- 'valueOf'
1102
- ];
1103
-
1104
- var internalObjectKeys$1 = objectKeysInternal;
1105
- var enumBugKeys$2 = enumBugKeys$3;
1106
-
1107
- var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
1108
-
1109
- // `Object.getOwnPropertyNames` method
1110
- // https://tc39.es/ecma262/#sec-object.getownpropertynames
1111
- // eslint-disable-next-line es/no-object-getownpropertynames -- safe
1112
- objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1113
- return internalObjectKeys$1(O, hiddenKeys$1);
1114
- };
1115
-
1116
- var objectGetOwnPropertySymbols = {};
1117
-
1118
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
1119
- objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
1120
-
1121
- var getBuiltIn$2 = getBuiltIn$5;
1122
- var uncurryThis$3 = functionUncurryThis;
1123
- var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
1124
- var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1125
- var anObject$2 = anObject$4;
1126
-
1127
- var concat = uncurryThis$3([].concat);
1128
-
1129
- // all object keys, includes non-enumerable and symbols
1130
- var ownKeys$1 = getBuiltIn$2('Reflect', 'ownKeys') || function ownKeys(it) {
1131
- var keys = getOwnPropertyNamesModule.f(anObject$2(it));
1132
- var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1133
- return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
1134
- };
1135
-
1136
- var hasOwn = hasOwnProperty_1;
1137
- var ownKeys = ownKeys$1;
1138
- var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
1139
- var definePropertyModule$1 = objectDefineProperty;
1140
-
1141
- var copyConstructorProperties$1 = function (target, source, exceptions) {
1142
- var keys = ownKeys(source);
1143
- var defineProperty = definePropertyModule$1.f;
1144
- var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1145
- for (var i = 0; i < keys.length; i++) {
1146
- var key = keys[i];
1147
- if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
1148
- defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1149
- }
1150
- }
1151
- };
1152
-
1153
- var fails$1 = fails$9;
1154
- var isCallable$2 = isCallable$c;
1155
-
1156
- var replacement = /#|\.prototype\./;
1157
-
1158
- var isForced$1 = function (feature, detection) {
1159
- var value = data[normalize(feature)];
1160
- return value == POLYFILL ? true
1161
- : value == NATIVE ? false
1162
- : isCallable$2(detection) ? fails$1(detection)
1163
- : !!detection;
1164
- };
1165
-
1166
- var normalize = isForced$1.normalize = function (string) {
1167
- return String(string).replace(replacement, '.').toLowerCase();
1168
- };
1169
-
1170
- var data = isForced$1.data = {};
1171
- var NATIVE = isForced$1.NATIVE = 'N';
1172
- var POLYFILL = isForced$1.POLYFILL = 'P';
1173
-
1174
- var isForced_1 = isForced$1;
1175
-
1176
- var global$1 = global$a;
1177
- var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1178
- var createNonEnumerableProperty = createNonEnumerableProperty$2;
1179
- var defineBuiltIn = defineBuiltIn$1;
1180
- var defineGlobalProperty = defineGlobalProperty$3;
1181
- var copyConstructorProperties = copyConstructorProperties$1;
1182
- var isForced = isForced_1;
1183
-
1184
- /*
1185
- options.target - name of the target object
1186
- options.global - target is the global object
1187
- options.stat - export as static methods of target
1188
- options.proto - export as prototype methods of target
1189
- options.real - real prototype method for the `pure` version
1190
- options.forced - export even if the native feature is available
1191
- options.bind - bind methods to the target, required for the `pure` version
1192
- options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
1193
- options.unsafe - use the simple assignment of property instead of delete + defineProperty
1194
- options.sham - add a flag to not completely full polyfills
1195
- options.enumerable - export as enumerable property
1196
- options.dontCallGetSet - prevent calling a getter on target
1197
- options.name - the .name of the function if it does not match the key
1198
- */
1199
- var _export = function (options, source) {
1200
- var TARGET = options.target;
1201
- var GLOBAL = options.global;
1202
- var STATIC = options.stat;
1203
- var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1204
- if (GLOBAL) {
1205
- target = global$1;
1206
- } else if (STATIC) {
1207
- target = global$1[TARGET] || defineGlobalProperty(TARGET, {});
1208
- } else {
1209
- target = (global$1[TARGET] || {}).prototype;
1210
- }
1211
- if (target) for (key in source) {
1212
- sourceProperty = source[key];
1213
- if (options.dontCallGetSet) {
1214
- descriptor = getOwnPropertyDescriptor(target, key);
1215
- targetProperty = descriptor && descriptor.value;
1216
- } else targetProperty = target[key];
1217
- FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1218
- // contained in target
1219
- if (!FORCED && targetProperty !== undefined) {
1220
- if (typeof sourceProperty == typeof targetProperty) continue;
1221
- copyConstructorProperties(sourceProperty, targetProperty);
1222
- }
1223
- // add a flag to not completely full polyfills
1224
- if (options.sham || (targetProperty && targetProperty.sham)) {
1225
- createNonEnumerableProperty(sourceProperty, 'sham', true);
1226
- }
1227
- defineBuiltIn(target, key, sourceProperty, options);
1228
- }
1229
- };
1230
-
1231
- var uncurryThis$2 = functionUncurryThis;
1232
- var aCallable = aCallable$2;
1233
- var NATIVE_BIND = functionBindNative;
1234
-
1235
- var bind$1 = uncurryThis$2(uncurryThis$2.bind);
1236
-
1237
- // optional / simple context binding
1238
- var functionBindContext = function (fn, that) {
1239
- aCallable(fn);
1240
- return that === undefined ? fn : NATIVE_BIND ? bind$1(fn, that) : function (/* ...args */) {
1241
- return fn.apply(that, arguments);
1242
- };
1243
- };
1244
-
1245
- var classof$2 = classofRaw$2;
1246
-
1247
- // `IsArray` abstract operation
1248
- // https://tc39.es/ecma262/#sec-isarray
1249
- // eslint-disable-next-line es/no-array-isarray -- safe
1250
- var isArray$1 = Array.isArray || function isArray(argument) {
1251
- return classof$2(argument) == 'Array';
1252
- };
1253
-
1254
- var wellKnownSymbol$3 = wellKnownSymbol$5;
1255
-
1256
- var TO_STRING_TAG$1 = wellKnownSymbol$3('toStringTag');
1257
- var test = {};
1258
-
1259
- test[TO_STRING_TAG$1] = 'z';
1260
-
1261
- var toStringTagSupport = String(test) === '[object z]';
1262
-
1263
- var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1264
- var isCallable$1 = isCallable$c;
1265
- var classofRaw = classofRaw$2;
1266
- var wellKnownSymbol$2 = wellKnownSymbol$5;
1267
-
1268
- var TO_STRING_TAG = wellKnownSymbol$2('toStringTag');
1269
- var $Object = Object;
1270
-
1271
- // ES3 wrong here
1272
- var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1273
-
1274
- // fallback for IE11 Script Access Denied error
1275
- var tryGet = function (it, key) {
1276
- try {
1277
- return it[key];
1278
- } catch (error) { /* empty */ }
1279
- };
1280
-
1281
- // getting tag from ES6+ `Object.prototype.toString`
1282
- var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1283
- var O, tag, result;
1284
- return it === undefined ? 'Undefined' : it === null ? 'Null'
1285
- // @@toStringTag case
1286
- : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
1287
- // builtinTag case
1288
- : CORRECT_ARGUMENTS ? classofRaw(O)
1289
- // ES3 arguments fallback
1290
- : (result = classofRaw(O)) == 'Object' && isCallable$1(O.callee) ? 'Arguments' : result;
1291
- };
1292
-
1293
- var uncurryThis$1 = functionUncurryThis;
1294
- var fails = fails$9;
1295
- var isCallable = isCallable$c;
1296
- var classof = classof$1;
1297
- var getBuiltIn$1 = getBuiltIn$5;
1298
- var inspectSource = inspectSource$2;
1299
-
1300
- var noop = function () { /* empty */ };
1301
- var empty = [];
1302
- var construct = getBuiltIn$1('Reflect', 'construct');
1303
- var constructorRegExp = /^\s*(?:class|function)\b/;
1304
- var exec = uncurryThis$1(constructorRegExp.exec);
1305
- var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
1306
-
1307
- var isConstructorModern = function isConstructor(argument) {
1308
- if (!isCallable(argument)) return false;
1309
- try {
1310
- construct(noop, empty, argument);
1311
- return true;
1312
- } catch (error) {
1313
- return false;
1314
- }
1315
- };
1316
-
1317
- var isConstructorLegacy = function isConstructor(argument) {
1318
- if (!isCallable(argument)) return false;
1319
- switch (classof(argument)) {
1320
- case 'AsyncFunction':
1321
- case 'GeneratorFunction':
1322
- case 'AsyncGeneratorFunction': return false;
1323
- }
1324
- try {
1325
- // we can't check .prototype since constructors produced by .bind haven't it
1326
- // `Function#toString` throws on some built-it function in some legacy engines
1327
- // (for example, `DOMQuad` and similar in FF41-)
1328
- return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
1329
- } catch (error) {
1330
- return true;
1331
- }
1332
- };
1333
-
1334
- isConstructorLegacy.sham = true;
1335
-
1336
- // `IsConstructor` abstract operation
1337
- // https://tc39.es/ecma262/#sec-isconstructor
1338
- var isConstructor$1 = !construct || fails(function () {
1339
- var called;
1340
- return isConstructorModern(isConstructorModern.call)
1341
- || !isConstructorModern(Object)
1342
- || !isConstructorModern(function () { called = true; })
1343
- || called;
1344
- }) ? isConstructorLegacy : isConstructorModern;
1345
-
1346
- var isArray = isArray$1;
1347
- var isConstructor = isConstructor$1;
1348
- var isObject = isObject$6;
1349
- var wellKnownSymbol$1 = wellKnownSymbol$5;
1350
-
1351
- var SPECIES = wellKnownSymbol$1('species');
1352
- var $Array = Array;
1353
-
1354
- // a part of `ArraySpeciesCreate` abstract operation
1355
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
1356
- var arraySpeciesConstructor$1 = function (originalArray) {
1357
- var C;
1358
- if (isArray(originalArray)) {
1359
- C = originalArray.constructor;
1360
- // cross-realm fallback
1361
- if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
1362
- else if (isObject(C)) {
1363
- C = C[SPECIES];
1364
- if (C === null) C = undefined;
1365
- }
1366
- } return C === undefined ? $Array : C;
1367
- };
1368
-
1369
- var arraySpeciesConstructor = arraySpeciesConstructor$1;
1370
-
1371
- // `ArraySpeciesCreate` abstract operation
1372
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
1373
- var arraySpeciesCreate$1 = function (originalArray, length) {
1374
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
1375
- };
1376
-
1377
- var bind = functionBindContext;
1378
- var uncurryThis = functionUncurryThis;
1379
- var IndexedObject = indexedObject;
1380
- var toObject = toObject$2;
1381
- var lengthOfArrayLike = lengthOfArrayLike$2;
1382
- var arraySpeciesCreate = arraySpeciesCreate$1;
1383
-
1384
- var push = uncurryThis([].push);
1385
-
1386
- // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
1387
- var createMethod = function (TYPE) {
1388
- var IS_MAP = TYPE == 1;
1389
- var IS_FILTER = TYPE == 2;
1390
- var IS_SOME = TYPE == 3;
1391
- var IS_EVERY = TYPE == 4;
1392
- var IS_FIND_INDEX = TYPE == 6;
1393
- var IS_FILTER_REJECT = TYPE == 7;
1394
- var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
1395
- return function ($this, callbackfn, that, specificCreate) {
1396
- var O = toObject($this);
1397
- var self = IndexedObject(O);
1398
- var boundFunction = bind(callbackfn, that);
1399
- var length = lengthOfArrayLike(self);
1400
- var index = 0;
1401
- var create = specificCreate || arraySpeciesCreate;
1402
- var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
1403
- var value, result;
1404
- for (;length > index; index++) if (NO_HOLES || index in self) {
1405
- value = self[index];
1406
- result = boundFunction(value, index, O);
1407
- if (TYPE) {
1408
- if (IS_MAP) target[index] = result; // map
1409
- else if (result) switch (TYPE) {
1410
- case 3: return true; // some
1411
- case 5: return value; // find
1412
- case 6: return index; // findIndex
1413
- case 2: push(target, value); // filter
1414
- } else switch (TYPE) {
1415
- case 4: return false; // every
1416
- case 7: push(target, value); // filterReject
1417
- }
1418
- }
1419
- }
1420
- return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
1421
- };
1422
- };
1423
-
1424
- var arrayIteration = {
1425
- // `Array.prototype.forEach` method
1426
- // https://tc39.es/ecma262/#sec-array.prototype.foreach
1427
- forEach: createMethod(0),
1428
- // `Array.prototype.map` method
1429
- // https://tc39.es/ecma262/#sec-array.prototype.map
1430
- map: createMethod(1),
1431
- // `Array.prototype.filter` method
1432
- // https://tc39.es/ecma262/#sec-array.prototype.filter
1433
- filter: createMethod(2),
1434
- // `Array.prototype.some` method
1435
- // https://tc39.es/ecma262/#sec-array.prototype.some
1436
- some: createMethod(3),
1437
- // `Array.prototype.every` method
1438
- // https://tc39.es/ecma262/#sec-array.prototype.every
1439
- every: createMethod(4),
1440
- // `Array.prototype.find` method
1441
- // https://tc39.es/ecma262/#sec-array.prototype.find
1442
- find: createMethod(5),
1443
- // `Array.prototype.findIndex` method
1444
- // https://tc39.es/ecma262/#sec-array.prototype.findIndex
1445
- findIndex: createMethod(6),
1446
- // `Array.prototype.filterReject` method
1447
- // https://github.com/tc39/proposal-array-filtering
1448
- filterReject: createMethod(7)
1449
- };
1450
-
1451
- var objectDefineProperties = {};
1452
-
1453
- var internalObjectKeys = objectKeysInternal;
1454
- var enumBugKeys$1 = enumBugKeys$3;
1455
-
1456
- // `Object.keys` method
1457
- // https://tc39.es/ecma262/#sec-object.keys
1458
- // eslint-disable-next-line es/no-object-keys -- safe
1459
- var objectKeys$1 = Object.keys || function keys(O) {
1460
- return internalObjectKeys(O, enumBugKeys$1);
1461
- };
1462
-
1463
- var DESCRIPTORS = descriptors;
1464
- var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
1465
- var definePropertyModule = objectDefineProperty;
1466
- var anObject$1 = anObject$4;
1467
- var toIndexedObject = toIndexedObject$4;
1468
- var objectKeys = objectKeys$1;
1469
-
1470
- // `Object.defineProperties` method
1471
- // https://tc39.es/ecma262/#sec-object.defineproperties
1472
- // eslint-disable-next-line es/no-object-defineproperties -- safe
1473
- objectDefineProperties.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
1474
- anObject$1(O);
1475
- var props = toIndexedObject(Properties);
1476
- var keys = objectKeys(Properties);
1477
- var length = keys.length;
1478
- var index = 0;
1479
- var key;
1480
- while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
1481
- return O;
1482
- };
1483
-
1484
- var getBuiltIn = getBuiltIn$5;
1485
-
1486
- var html$1 = getBuiltIn('document', 'documentElement');
1487
-
1488
- /* global ActiveXObject -- old IE, WSH */
1489
-
1490
- var anObject = anObject$4;
1491
- var definePropertiesModule = objectDefineProperties;
1492
- var enumBugKeys = enumBugKeys$3;
1493
- var hiddenKeys = hiddenKeys$4;
1494
- var html = html$1;
1495
- var documentCreateElement = documentCreateElement$1;
1496
- var sharedKey = sharedKey$2;
1497
-
1498
- var GT = '>';
1499
- var LT = '<';
1500
- var PROTOTYPE = 'prototype';
1501
- var SCRIPT = 'script';
1502
- var IE_PROTO = sharedKey('IE_PROTO');
1503
-
1504
- var EmptyConstructor = function () { /* empty */ };
1505
-
1506
- var scriptTag = function (content) {
1507
- return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
1508
- };
1509
-
1510
- // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
1511
- var NullProtoObjectViaActiveX = function (activeXDocument) {
1512
- activeXDocument.write(scriptTag(''));
1513
- activeXDocument.close();
1514
- var temp = activeXDocument.parentWindow.Object;
1515
- activeXDocument = null; // avoid memory leak
1516
- return temp;
1517
- };
1518
-
1519
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
1520
- var NullProtoObjectViaIFrame = function () {
1521
- // Thrash, waste and sodomy: IE GC bug
1522
- var iframe = documentCreateElement('iframe');
1523
- var JS = 'java' + SCRIPT + ':';
1524
- var iframeDocument;
1525
- iframe.style.display = 'none';
1526
- html.appendChild(iframe);
1527
- // https://github.com/zloirock/core-js/issues/475
1528
- iframe.src = String(JS);
1529
- iframeDocument = iframe.contentWindow.document;
1530
- iframeDocument.open();
1531
- iframeDocument.write(scriptTag('document.F=Object'));
1532
- iframeDocument.close();
1533
- return iframeDocument.F;
1534
- };
1535
-
1536
- // Check for document.domain and active x support
1537
- // No need to use active x approach when document.domain is not set
1538
- // see https://github.com/es-shims/es5-shim/issues/150
1539
- // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
1540
- // avoid IE GC bug
1541
- var activeXDocument;
1542
- var NullProtoObject = function () {
1543
- try {
1544
- activeXDocument = new ActiveXObject('htmlfile');
1545
- } catch (error) { /* ignore */ }
1546
- NullProtoObject = typeof document != 'undefined'
1547
- ? document.domain && activeXDocument
1548
- ? NullProtoObjectViaActiveX(activeXDocument) // old IE
1549
- : NullProtoObjectViaIFrame()
1550
- : NullProtoObjectViaActiveX(activeXDocument); // WSH
1551
- var length = enumBugKeys.length;
1552
- while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
1553
- return NullProtoObject();
1554
- };
1555
-
1556
- hiddenKeys[IE_PROTO] = true;
1557
-
1558
- // `Object.create` method
1559
- // https://tc39.es/ecma262/#sec-object.create
1560
- // eslint-disable-next-line es/no-object-create -- safe
1561
- var objectCreate = Object.create || function create(O, Properties) {
1562
- var result;
1563
- if (O !== null) {
1564
- EmptyConstructor[PROTOTYPE] = anObject(O);
1565
- result = new EmptyConstructor();
1566
- EmptyConstructor[PROTOTYPE] = null;
1567
- // add "__proto__" for Object.getPrototypeOf polyfill
1568
- result[IE_PROTO] = O;
1569
- } else result = NullProtoObject();
1570
- return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
1571
- };
1572
-
1573
- var wellKnownSymbol = wellKnownSymbol$5;
1574
- var create = objectCreate;
1575
- var defineProperty = objectDefineProperty.f;
1576
-
1577
- var UNSCOPABLES = wellKnownSymbol('unscopables');
1578
- var ArrayPrototype = Array.prototype;
1579
-
1580
- // Array.prototype[@@unscopables]
1581
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1582
- if (ArrayPrototype[UNSCOPABLES] == undefined) {
1583
- defineProperty(ArrayPrototype, UNSCOPABLES, {
1584
- configurable: true,
1585
- value: create(null)
1586
- });
1587
- }
1588
-
1589
- // add a key to Array.prototype[@@unscopables]
1590
- var addToUnscopables$1 = function (key) {
1591
- ArrayPrototype[UNSCOPABLES][key] = true;
1592
- };
1593
-
1594
- var $ = _export;
1595
- var $find = arrayIteration.find;
1596
- var addToUnscopables = addToUnscopables$1;
1597
-
1598
- var FIND = 'find';
1599
- var SKIPS_HOLES = true;
1600
-
1601
- // Shouldn't skip holes
1602
- if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
1603
-
1604
- // `Array.prototype.find` method
1605
- // https://tc39.es/ecma262/#sec-array.prototype.find
1606
- $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
1607
- find: function find(callbackfn /* , that = undefined */) {
1608
- return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
1609
- }
1610
- });
1611
-
1612
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1613
- addToUnscopables(FIND);
1614
-
1615
- var CONSTANT = {
1616
- GLOBAL: {
1617
- HIDE: '__react_tooltip_hide_event',
1618
- REBUILD: '__react_tooltip_rebuild_event',
1619
- SHOW: '__react_tooltip_show_event'
1620
- }
1621
- };
1622
-
1623
- /**
1624
- * Static methods for react-tooltip
1625
- */
1626
- var dispatchGlobalEvent = function dispatchGlobalEvent(eventName, opts) {
1627
- // Compatible with IE
1628
- // @see http://stackoverflow.com/questions/26596123/internet-explorer-9-10-11-event-constructor-doesnt-work
1629
- // @see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
1630
- var event;
1631
- if (typeof window.CustomEvent === 'function') {
1632
- event = new window.CustomEvent(eventName, {
1633
- detail: opts
1634
- });
1635
- } else {
1636
- event = document.createEvent('Event');
1637
- event.initEvent(eventName, false, true, opts);
1638
- }
1639
- window.dispatchEvent(event);
1640
- };
1641
- function staticMethods (target) {
1642
- /**
1643
- * Hide all tooltip
1644
- * @trigger ReactTooltip.hide()
1645
- */
1646
- target.hide = function (target) {
1647
- dispatchGlobalEvent(CONSTANT.GLOBAL.HIDE, {
1648
- target: target
1649
- });
1650
- };
1651
-
1652
- /**
1653
- * Rebuild all tooltip
1654
- * @trigger ReactTooltip.rebuild()
1655
- */
1656
- target.rebuild = function () {
1657
- dispatchGlobalEvent(CONSTANT.GLOBAL.REBUILD);
1658
- };
1659
-
1660
- /**
1661
- * Show specific tooltip
1662
- * @trigger ReactTooltip.show()
1663
- */
1664
- target.show = function (target) {
1665
- dispatchGlobalEvent(CONSTANT.GLOBAL.SHOW, {
1666
- target: target
1667
- });
1668
- };
1669
- target.prototype.globalRebuild = function () {
1670
- if (this.mount) {
1671
- this.unbindListener();
1672
- this.bindListener();
1673
- }
1674
- };
1675
- target.prototype.globalShow = function (event) {
1676
- if (this.mount) {
1677
- var hasTarget = event && event.detail && event.detail.target && true || false;
1678
- // Create a fake event, specific show will limit the type to `solid`
1679
- // only `float` type cares e.clientX e.clientY
1680
- this.showTooltip({
1681
- currentTarget: hasTarget && event.detail.target
1682
- }, true);
1683
- }
1684
- };
1685
- target.prototype.globalHide = function (event) {
1686
- if (this.mount) {
1687
- var hasTarget = event && event.detail && event.detail.target && true || false;
1688
- this.hideTooltip({
1689
- currentTarget: hasTarget && event.detail.target
1690
- }, hasTarget);
1691
- }
1692
- };
1693
- }
1694
-
1695
- /**
1696
- * Events that should be bound to the window
1697
- */
1698
- function windowListener (target) {
1699
- target.prototype.bindWindowEvents = function (resizeHide) {
1700
- // ReactTooltip.hide
1701
- window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
1702
- window.addEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide, false);
1703
-
1704
- // ReactTooltip.rebuild
1705
- window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
1706
- window.addEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild, false);
1707
-
1708
- // ReactTooltip.show
1709
- window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
1710
- window.addEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow, false);
1711
-
1712
- // Resize
1713
- if (resizeHide) {
1714
- window.removeEventListener('resize', this.onWindowResize);
1715
- window.addEventListener('resize', this.onWindowResize, false);
1716
- }
1717
- };
1718
- target.prototype.unbindWindowEvents = function () {
1719
- window.removeEventListener(CONSTANT.GLOBAL.HIDE, this.globalHide);
1720
- window.removeEventListener(CONSTANT.GLOBAL.REBUILD, this.globalRebuild);
1721
- window.removeEventListener(CONSTANT.GLOBAL.SHOW, this.globalShow);
1722
- window.removeEventListener('resize', this.onWindowResize);
1723
- };
1724
-
1725
- /**
1726
- * invoked by resize event of window
1727
- */
1728
- target.prototype.onWindowResize = function () {
1729
- if (!this.mount) return;
1730
- this.hideTooltip();
1731
- };
1732
- }
1733
-
1734
- /**
1735
- * Custom events to control showing and hiding of tooltip
1736
- *
1737
- * @attributes
1738
- * - `event` {String}
1739
- * - `eventOff` {String}
1740
- */
1741
-
1742
- var checkStatus = function checkStatus(dataEventOff, e) {
1743
- var show = this.state.show;
1744
- var id = this.props.id;
1745
- var isCapture = this.isCapture(e.currentTarget);
1746
- var currentItem = e.currentTarget.getAttribute('currentItem');
1747
- if (!isCapture) e.stopPropagation();
1748
- if (show && currentItem === 'true') {
1749
- if (!dataEventOff) this.hideTooltip(e);
1750
- } else {
1751
- e.currentTarget.setAttribute('currentItem', 'true');
1752
- setUntargetItems(e.currentTarget, this.getTargetArray(id));
1753
- this.showTooltip(e);
1754
- }
1755
- };
1756
- var setUntargetItems = function setUntargetItems(currentTarget, targetArray) {
1757
- for (var i = 0; i < targetArray.length; i++) {
1758
- if (currentTarget !== targetArray[i]) {
1759
- targetArray[i].setAttribute('currentItem', 'false');
1760
- } else {
1761
- targetArray[i].setAttribute('currentItem', 'true');
1762
- }
1763
- }
1764
- };
1765
- var customListeners = {
1766
- id: '9b69f92e-d3fe-498b-b1b4-c5e63a51b0cf',
1767
- set: function set(target, event, listener) {
1768
- if (this.id in target) {
1769
- var map = target[this.id];
1770
- map[event] = listener;
1771
- } else {
1772
- // this is workaround for WeakMap, which is not supported in older browsers, such as IE
1773
- Object.defineProperty(target, this.id, {
1774
- configurable: true,
1775
- value: _defineProperty({}, event, listener)
1776
- });
1777
- }
1778
- },
1779
- get: function get(target, event) {
1780
- var map = target[this.id];
1781
- if (map !== undefined) {
1782
- return map[event];
1783
- }
1784
- }
1785
- };
1786
- function customEvent (target) {
1787
- target.prototype.isCustomEvent = function (ele) {
1788
- var event = this.state.event;
1789
- return event || !!ele.getAttribute('data-event');
1790
- };
1791
-
1792
- /* Bind listener for custom event */
1793
- target.prototype.customBindListener = function (ele) {
1794
- var _this = this;
1795
- var _this$state = this.state,
1796
- event = _this$state.event,
1797
- eventOff = _this$state.eventOff;
1798
- var dataEvent = ele.getAttribute('data-event') || event;
1799
- var dataEventOff = ele.getAttribute('data-event-off') || eventOff;
1800
- dataEvent.split(' ').forEach(function (event) {
1801
- ele.removeEventListener(event, customListeners.get(ele, event));
1802
- var customListener = checkStatus.bind(_this, dataEventOff);
1803
- customListeners.set(ele, event, customListener);
1804
- ele.addEventListener(event, customListener, false);
1805
- });
1806
- if (dataEventOff) {
1807
- dataEventOff.split(' ').forEach(function (event) {
1808
- ele.removeEventListener(event, _this.hideTooltip);
1809
- ele.addEventListener(event, _this.hideTooltip, false);
1810
- });
1811
- }
1812
- };
1813
-
1814
- /* Unbind listener for custom event */
1815
- target.prototype.customUnbindListener = function (ele) {
1816
- var _this$state2 = this.state,
1817
- event = _this$state2.event,
1818
- eventOff = _this$state2.eventOff;
1819
- var dataEvent = event || ele.getAttribute('data-event');
1820
- var dataEventOff = eventOff || ele.getAttribute('data-event-off');
1821
- ele.removeEventListener(dataEvent, customListeners.get(ele, event));
1822
- if (dataEventOff) ele.removeEventListener(dataEventOff, this.hideTooltip);
1823
- };
1824
- }
1825
-
1826
- /**
1827
- * Util method to judge if it should follow capture model
1828
- */
1829
-
1830
- function isCapture (target) {
1831
- target.prototype.isCapture = function (currentTarget) {
1832
- return currentTarget && currentTarget.getAttribute('data-iscapture') === 'true' || this.props.isCapture || false;
1833
- };
1834
- }
1835
-
1836
- /**
1837
- * Util method to get effect
1838
- */
1839
-
1840
- function getEffect (target) {
1841
- target.prototype.getEffect = function (currentTarget) {
1842
- var dataEffect = currentTarget.getAttribute('data-effect');
1843
- return dataEffect || this.props.effect || 'float';
1844
- };
1845
- }
1846
-
1847
- /**
1848
- * Util method to get effect
1849
- */
1850
- var makeProxy = function makeProxy(e) {
1851
- var proxy = {};
1852
- for (var key in e) {
1853
- if (typeof e[key] === 'function') {
1854
- proxy[key] = e[key].bind(e);
1855
- } else {
1856
- proxy[key] = e[key];
1857
- }
1858
- }
1859
- return proxy;
1860
- };
1861
- var bodyListener = function bodyListener(callback, options, e) {
1862
- var _options$respectEffec = options.respectEffect,
1863
- respectEffect = _options$respectEffec === void 0 ? false : _options$respectEffec,
1864
- _options$customEvent = options.customEvent,
1865
- customEvent = _options$customEvent === void 0 ? false : _options$customEvent;
1866
- var id = this.props.id;
1867
- var tip = null;
1868
- var forId;
1869
- var target = e.target;
1870
- var lastTarget;
1871
- // walk up parent chain until tip is found
1872
- // there is no match if parent visible area is matched by mouse position, so some corner cases might not work as expected
1873
- while (tip === null && target !== null) {
1874
- lastTarget = target;
1875
- tip = target.getAttribute('data-tip') || null;
1876
- forId = target.getAttribute('data-for') || null;
1877
- target = target.parentElement;
1878
- }
1879
- target = lastTarget || e.target;
1880
- if (this.isCustomEvent(target) && !customEvent) {
1881
- return;
1882
- }
1883
- var isTargetBelongsToTooltip = id == null && forId == null || forId === id;
1884
- if (tip != null && (!respectEffect || this.getEffect(target) === 'float') && isTargetBelongsToTooltip) {
1885
- var proxy = makeProxy(e);
1886
- proxy.currentTarget = target;
1887
- callback(proxy);
1888
- }
1889
- };
1890
- var findCustomEvents = function findCustomEvents(targetArray, dataAttribute) {
1891
- var events = {};
1892
- targetArray.forEach(function (target) {
1893
- var event = target.getAttribute(dataAttribute);
1894
- if (event) event.split(' ').forEach(function (event) {
1895
- return events[event] = true;
1896
- });
1897
- });
1898
- return events;
1899
- };
1900
- var getBody = function getBody() {
1901
- return document.getElementsByTagName('body')[0];
1902
- };
1903
- function bodyMode (target) {
1904
- target.prototype.isBodyMode = function () {
1905
- return !!this.props.bodyMode;
1906
- };
1907
- target.prototype.bindBodyListener = function (targetArray) {
1908
- var _this = this;
1909
- var _this$state = this.state,
1910
- event = _this$state.event,
1911
- eventOff = _this$state.eventOff,
1912
- possibleCustomEvents = _this$state.possibleCustomEvents,
1913
- possibleCustomEventsOff = _this$state.possibleCustomEventsOff;
1914
- var body = getBody();
1915
- var customEvents = findCustomEvents(targetArray, 'data-event');
1916
- var customEventsOff = findCustomEvents(targetArray, 'data-event-off');
1917
- if (event != null) customEvents[event] = true;
1918
- if (eventOff != null) customEventsOff[eventOff] = true;
1919
- possibleCustomEvents.split(' ').forEach(function (event) {
1920
- return customEvents[event] = true;
1921
- });
1922
- possibleCustomEventsOff.split(' ').forEach(function (event) {
1923
- return customEventsOff[event] = true;
1924
- });
1925
- this.unbindBodyListener(body);
1926
- var listeners = this.bodyModeListeners = {};
1927
- if (event == null) {
1928
- listeners.mouseover = bodyListener.bind(this, this.showTooltip, {});
1929
- listeners.mousemove = bodyListener.bind(this, this.updateTooltip, {
1930
- respectEffect: true
1931
- });
1932
- listeners.mouseout = bodyListener.bind(this, this.hideTooltip, {});
1933
- }
1934
- for (var _event in customEvents) {
1935
- listeners[_event] = bodyListener.bind(this, function (e) {
1936
- var targetEventOff = e.currentTarget.getAttribute('data-event-off') || eventOff;
1937
- checkStatus.call(_this, targetEventOff, e);
1938
- }, {
1939
- customEvent: true
1940
- });
1941
- }
1942
- for (var _event2 in customEventsOff) {
1943
- listeners[_event2] = bodyListener.bind(this, this.hideTooltip, {
1944
- customEvent: true
1945
- });
1946
- }
1947
- for (var _event3 in listeners) {
1948
- body.addEventListener(_event3, listeners[_event3]);
1949
- }
1950
- };
1951
- target.prototype.unbindBodyListener = function (body) {
1952
- body = body || getBody();
1953
- var listeners = this.bodyModeListeners;
1954
- for (var event in listeners) {
1955
- body.removeEventListener(event, listeners[event]);
1956
- }
1957
- };
1958
- }
1959
-
1960
- /**
1961
- * Tracking target removing from DOM.
1962
- * It's necessary to hide tooltip when it's target disappears.
1963
- * Otherwise, the tooltip would be shown forever until another target
1964
- * is triggered.
1965
- *
1966
- * If MutationObserver is not available, this feature just doesn't work.
1967
- */
1968
-
1969
- // https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/
1970
- var getMutationObserverClass = function getMutationObserverClass() {
1971
- return window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
1972
- };
1973
- function trackRemoval (target) {
1974
- target.prototype.bindRemovalTracker = function () {
1975
- var _this = this;
1976
- var MutationObserver = getMutationObserverClass();
1977
- if (MutationObserver == null) return;
1978
- var observer = new MutationObserver(function (mutations) {
1979
- for (var m1 = 0; m1 < mutations.length; m1++) {
1980
- var mutation = mutations[m1];
1981
- for (var m2 = 0; m2 < mutation.removedNodes.length; m2++) {
1982
- var element = mutation.removedNodes[m2];
1983
- if (element === _this.state.currentTarget) {
1984
- _this.hideTooltip();
1985
- return;
1986
- }
1987
- }
1988
- }
1989
- });
1990
- observer.observe(window.document, {
1991
- childList: true,
1992
- subtree: true
1993
- });
1994
- this.removalTracker = observer;
1995
- };
1996
- target.prototype.unbindRemovalTracker = function () {
1997
- if (this.removalTracker) {
1998
- this.removalTracker.disconnect();
1999
- this.removalTracker = null;
2000
- }
2001
- };
2002
- }
2003
-
2004
- /**
2005
- * Calculate the position of tooltip
2006
- *
2007
- * @params
2008
- * - `e` {Event} the event of current mouse
2009
- * - `target` {Element} the currentTarget of the event
2010
- * - `node` {DOM} the react-tooltip object
2011
- * - `place` {String} top / right / bottom / left
2012
- * - `effect` {String} float / solid
2013
- * - `offset` {Object} the offset to default position
2014
- *
2015
- * @return {Object}
2016
- * - `isNewState` {Bool} required
2017
- * - `newState` {Object}
2018
- * - `position` {Object} {left: {Number}, top: {Number}}
2019
- */
2020
- function getPosition (e, target, node, place, desiredPlace, effect, offset) {
2021
- var _getDimensions = getDimensions(node),
2022
- tipWidth = _getDimensions.width,
2023
- tipHeight = _getDimensions.height;
2024
- var _getDimensions2 = getDimensions(target),
2025
- targetWidth = _getDimensions2.width,
2026
- targetHeight = _getDimensions2.height;
2027
- var _getCurrentOffset = getCurrentOffset(e, target, effect),
2028
- mouseX = _getCurrentOffset.mouseX,
2029
- mouseY = _getCurrentOffset.mouseY;
2030
- var defaultOffset = getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight);
2031
- var _calculateOffset = calculateOffset(offset),
2032
- extraOffsetX = _calculateOffset.extraOffsetX,
2033
- extraOffsetY = _calculateOffset.extraOffsetY;
2034
- var windowWidth = window.innerWidth;
2035
- var windowHeight = window.innerHeight;
2036
- var _getParent = getParent(node),
2037
- parentTop = _getParent.parentTop,
2038
- parentLeft = _getParent.parentLeft;
2039
-
2040
- // Get the edge offset of the tooltip
2041
- var getTipOffsetLeft = function getTipOffsetLeft(place) {
2042
- var offsetX = defaultOffset[place].l;
2043
- return mouseX + offsetX + extraOffsetX;
2044
- };
2045
- var getTipOffsetRight = function getTipOffsetRight(place) {
2046
- var offsetX = defaultOffset[place].r;
2047
- return mouseX + offsetX + extraOffsetX;
2048
- };
2049
- var getTipOffsetTop = function getTipOffsetTop(place) {
2050
- var offsetY = defaultOffset[place].t;
2051
- return mouseY + offsetY + extraOffsetY;
2052
- };
2053
- var getTipOffsetBottom = function getTipOffsetBottom(place) {
2054
- var offsetY = defaultOffset[place].b;
2055
- return mouseY + offsetY + extraOffsetY;
2056
- };
2057
-
2058
- //
2059
- // Functions to test whether the tooltip's sides are inside
2060
- // the client window for a given orientation p
2061
- //
2062
- // _____________
2063
- // | | <-- Right side
2064
- // | p = 'left' |\
2065
- // | |/ |\
2066
- // |_____________| |_\ <-- Mouse
2067
- // / \ |
2068
- // |
2069
- // |
2070
- // Bottom side
2071
- //
2072
- var outsideLeft = function outsideLeft(p) {
2073
- return getTipOffsetLeft(p) < 0;
2074
- };
2075
- var outsideRight = function outsideRight(p) {
2076
- return getTipOffsetRight(p) > windowWidth;
2077
- };
2078
- var outsideTop = function outsideTop(p) {
2079
- return getTipOffsetTop(p) < 0;
2080
- };
2081
- var outsideBottom = function outsideBottom(p) {
2082
- return getTipOffsetBottom(p) > windowHeight;
2083
- };
2084
-
2085
- // Check whether the tooltip with orientation p is completely inside the client window
2086
- var outside = function outside(p) {
2087
- return outsideLeft(p) || outsideRight(p) || outsideTop(p) || outsideBottom(p);
2088
- };
2089
- var inside = function inside(p) {
2090
- return !outside(p);
2091
- };
2092
- var placeIsInside = {
2093
- top: inside('top'),
2094
- bottom: inside('bottom'),
2095
- left: inside('left'),
2096
- right: inside('right')
2097
- };
2098
- function choose() {
2099
- var allPlaces = desiredPlace.split(',').concat(place, ['top', 'bottom', 'left', 'right']);
2100
- var _iterator = _createForOfIteratorHelper(allPlaces),
2101
- _step;
2102
- try {
2103
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2104
- var d = _step.value;
2105
- if (placeIsInside[d]) return d;
2106
- }
2107
- // if nothing is inside, just use the old place.
2108
- } catch (err) {
2109
- _iterator.e(err);
2110
- } finally {
2111
- _iterator.f();
2112
- }
2113
- return place;
2114
- }
2115
- var chosen = choose();
2116
- var isNewState = false;
2117
- var newPlace;
2118
- if (chosen && chosen !== place) {
2119
- isNewState = true;
2120
- newPlace = chosen;
2121
- }
2122
- if (isNewState) {
2123
- return {
2124
- isNewState: true,
2125
- newState: {
2126
- place: newPlace
2127
- }
2128
- };
2129
- }
2130
- return {
2131
- isNewState: false,
2132
- position: {
2133
- left: parseInt(getTipOffsetLeft(place) - parentLeft, 10),
2134
- top: parseInt(getTipOffsetTop(place) - parentTop, 10)
2135
- }
2136
- };
2137
- }
2138
- var getDimensions = function getDimensions(node) {
2139
- var _node$getBoundingClie = node.getBoundingClientRect(),
2140
- height = _node$getBoundingClie.height,
2141
- width = _node$getBoundingClie.width;
2142
- return {
2143
- height: parseInt(height, 10),
2144
- width: parseInt(width, 10)
2145
- };
2146
- };
2147
-
2148
- // Get current mouse offset
2149
- var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
2150
- var boundingClientRect = currentTarget.getBoundingClientRect();
2151
- var targetTop = boundingClientRect.top;
2152
- var targetLeft = boundingClientRect.left;
2153
- var _getDimensions3 = getDimensions(currentTarget),
2154
- targetWidth = _getDimensions3.width,
2155
- targetHeight = _getDimensions3.height;
2156
- if (effect === 'float') {
2157
- return {
2158
- mouseX: e.clientX,
2159
- mouseY: e.clientY
2160
- };
2161
- }
2162
- return {
2163
- mouseX: targetLeft + targetWidth / 2,
2164
- mouseY: targetTop + targetHeight / 2
2165
- };
2166
- };
2167
-
2168
- // List all possibility of tooltip final offset
2169
- // This is useful in judging if it is necessary for tooltip to switch position when out of window
2170
- var getDefaultPosition = function getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight) {
2171
- var top;
2172
- var right;
2173
- var bottom;
2174
- var left;
2175
- var disToMouse = 3;
2176
- var triangleHeight = 2;
2177
- var cursorHeight = 12; // Optimize for float bottom only, cause the cursor will hide the tooltip
2178
-
2179
- if (effect === 'float') {
2180
- top = {
2181
- l: -(tipWidth / 2),
2182
- r: tipWidth / 2,
2183
- t: -(tipHeight + disToMouse + triangleHeight),
2184
- b: -disToMouse
2185
- };
2186
- bottom = {
2187
- l: -(tipWidth / 2),
2188
- r: tipWidth / 2,
2189
- t: disToMouse + cursorHeight,
2190
- b: tipHeight + disToMouse + triangleHeight + cursorHeight
2191
- };
2192
- left = {
2193
- l: -(tipWidth + disToMouse + triangleHeight),
2194
- r: -disToMouse,
2195
- t: -(tipHeight / 2),
2196
- b: tipHeight / 2
2197
- };
2198
- right = {
2199
- l: disToMouse,
2200
- r: tipWidth + disToMouse + triangleHeight,
2201
- t: -(tipHeight / 2),
2202
- b: tipHeight / 2
2203
- };
2204
- } else if (effect === 'solid') {
2205
- top = {
2206
- l: -(tipWidth / 2),
2207
- r: tipWidth / 2,
2208
- t: -(targetHeight / 2 + tipHeight + triangleHeight),
2209
- b: -(targetHeight / 2)
2210
- };
2211
- bottom = {
2212
- l: -(tipWidth / 2),
2213
- r: tipWidth / 2,
2214
- t: targetHeight / 2,
2215
- b: targetHeight / 2 + tipHeight + triangleHeight
2216
- };
2217
- left = {
2218
- l: -(tipWidth + targetWidth / 2 + triangleHeight),
2219
- r: -(targetWidth / 2),
2220
- t: -(tipHeight / 2),
2221
- b: tipHeight / 2
2222
- };
2223
- right = {
2224
- l: targetWidth / 2,
2225
- r: tipWidth + targetWidth / 2 + triangleHeight,
2226
- t: -(tipHeight / 2),
2227
- b: tipHeight / 2
2228
- };
2229
- }
2230
- return {
2231
- top: top,
2232
- bottom: bottom,
2233
- left: left,
2234
- right: right
2235
- };
2236
- };
2237
-
2238
- // Consider additional offset into position calculation
2239
- var calculateOffset = function calculateOffset(offset) {
2240
- var extraOffsetX = 0;
2241
- var extraOffsetY = 0;
2242
- if (Object.prototype.toString.apply(offset) === '[object String]') {
2243
- offset = JSON.parse(offset.toString().replace(/'/g, '"'));
2244
- }
2245
- for (var key in offset) {
2246
- if (key === 'top') {
2247
- extraOffsetY -= parseInt(offset[key], 10);
2248
- } else if (key === 'bottom') {
2249
- extraOffsetY += parseInt(offset[key], 10);
2250
- } else if (key === 'left') {
2251
- extraOffsetX -= parseInt(offset[key], 10);
2252
- } else if (key === 'right') {
2253
- extraOffsetX += parseInt(offset[key], 10);
2254
- }
2255
- }
2256
- return {
2257
- extraOffsetX: extraOffsetX,
2258
- extraOffsetY: extraOffsetY
2259
- };
2260
- };
2261
-
2262
- // Get the offset of the parent elements
2263
- var getParent = function getParent(currentTarget) {
2264
- var currentParent = currentTarget;
2265
- while (currentParent) {
2266
- var computedStyle = window.getComputedStyle(currentParent);
2267
- // transform and will-change: transform change the containing block
2268
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_Block
2269
- if (computedStyle.getPropertyValue('transform') !== 'none' || computedStyle.getPropertyValue('will-change') === 'transform') break;
2270
- currentParent = currentParent.parentElement;
2271
- }
2272
- var parentTop = currentParent && currentParent.getBoundingClientRect().top || 0;
2273
- var parentLeft = currentParent && currentParent.getBoundingClientRect().left || 0;
2274
- return {
2275
- parentTop: parentTop,
2276
- parentLeft: parentLeft
2277
- };
2278
- };
2279
-
2280
- /**
2281
- * To get the tooltip content
2282
- * it may comes from data-tip or this.props.children
2283
- * it should support multiline
2284
- *
2285
- * @params
2286
- * - `tip` {String} value of data-tip
2287
- * - `children` {ReactElement} this.props.children
2288
- * - `multiline` {Any} could be Bool(true/false) or String('true'/'false')
2289
- *
2290
- * @return
2291
- * - String or react component
2292
- */
2293
- function TipContent(tip, children, getContent, multiline) {
2294
- if (children) return children;
2295
- if (getContent !== undefined && getContent !== null) return getContent; // getContent can be 0, '', etc.
2296
- if (getContent === null) return null; // Tip not exist and children is null or undefined
2297
-
2298
- var regexp = /<br\s*\/?>/;
2299
- if (!multiline || multiline === 'false' || !regexp.test(tip)) {
2300
- // No trim(), so that user can keep their input
2301
- return tip;
2302
- }
2303
-
2304
- // Multiline tooltip content
2305
- return tip.split(regexp).map(function (d, i) {
2306
- return /*#__PURE__*/React__default["default"].createElement("span", {
2307
- key: i,
2308
- className: "multi-line"
2309
- }, d);
2310
- });
2311
- }
2312
-
2313
- /**
2314
- * Support aria- and role in ReactTooltip
2315
- *
2316
- * @params props {Object}
2317
- * @return {Object}
2318
- */
2319
- function parseAria(props) {
2320
- var ariaObj = {};
2321
- Object.keys(props).filter(function (prop) {
2322
- // aria-xxx and role is acceptable
2323
- return /(^aria-\w+$|^role$)/.test(prop);
2324
- }).forEach(function (prop) {
2325
- ariaObj[prop] = props[prop];
2326
- });
2327
- return ariaObj;
2328
- }
2329
-
2330
- /**
2331
- * Convert nodelist to array
2332
- * @see https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/core/createArrayFromMixed.js#L24
2333
- * NodeLists are functions in Safari
2334
- */
2335
-
2336
- function nodeListToArray (nodeList) {
2337
- var length = nodeList.length;
2338
- if (nodeList.hasOwnProperty) {
2339
- return Array.prototype.slice.call(nodeList);
2340
- }
2341
- return new Array(length).fill().map(function (index) {
2342
- return nodeList[index];
2343
- });
2344
- }
2345
-
2346
- function generateUUID() {
2347
- return 't' + uuid.v4();
2348
- }
2349
-
2350
- var baseCss = ".__react_component_tooltip {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n left: -999em;\n opacity: 0;\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: 0;\n margin-left: 0;\n visibility: visible;\n}\n.__react_component_tooltip.place-top::before {\n bottom: 0;\n left: 50%;\n margin-left: -11px;\n}\n.__react_component_tooltip.place-bottom::before {\n top: 0;\n left: 50%;\n margin-left: -11px;\n}\n.__react_component_tooltip.place-left::before {\n right: 0;\n top: 50%;\n margin-top: -9px;\n}\n.__react_component_tooltip.place-right::before {\n left: 0;\n top: 50%;\n margin-top: -9px;\n}\n.__react_component_tooltip .multi-line {\n display: block;\n padding: 2px 0;\n text-align: center;\n}";
2351
-
2352
- /**
2353
- * Default pop-up style values (text color, background color).
2354
- */
2355
- var defaultColors = {
2356
- dark: {
2357
- text: '#fff',
2358
- background: '#222',
2359
- border: 'transparent',
2360
- arrow: '#222'
2361
- },
2362
- success: {
2363
- text: '#fff',
2364
- background: '#8DC572',
2365
- border: 'transparent',
2366
- arrow: '#8DC572'
2367
- },
2368
- warning: {
2369
- text: '#fff',
2370
- background: '#F0AD4E',
2371
- border: 'transparent',
2372
- arrow: '#F0AD4E'
2373
- },
2374
- error: {
2375
- text: '#fff',
2376
- background: '#BE6464',
2377
- border: 'transparent',
2378
- arrow: '#BE6464'
2379
- },
2380
- info: {
2381
- text: '#fff',
2382
- background: '#337AB7',
2383
- border: 'transparent',
2384
- arrow: '#337AB7'
2385
- },
2386
- light: {
2387
- text: '#222',
2388
- background: '#fff',
2389
- border: 'transparent',
2390
- arrow: '#fff'
2391
- }
2392
- };
2393
- function getDefaultPopupColors(type) {
2394
- return defaultColors[type] ? _objectSpread2({}, defaultColors[type]) : undefined;
2395
- }
2396
- var DEFAULT_PADDING = '8px 21px';
2397
- var DEFAULT_RADIUS = {
2398
- tooltip: 3,
2399
- arrow: 0
2400
- };
2401
-
2402
- /**
2403
- * Generates the specific tooltip style for use on render.
2404
- */
2405
- function generateTooltipStyle(uuid, customColors, type, hasBorder, padding, radius) {
2406
- return generateStyle(uuid, getPopupColors(customColors, type, hasBorder), padding, radius);
2407
- }
2408
-
2409
- /**
2410
- * Generates the tooltip style rules based on the element-specified "data-type" property.
2411
- */
2412
- function generateStyle(uuid, colors) {
2413
- var padding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_PADDING;
2414
- var radius = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_RADIUS;
2415
- var textColor = colors.text;
2416
- var backgroundColor = colors.background;
2417
- var borderColor = colors.border;
2418
- var arrowColor = colors.arrow;
2419
- var arrowRadius = radius.arrow;
2420
- var tooltipRadius = radius.tooltip;
2421
- return "\n \t.".concat(uuid, " {\n\t color: ").concat(textColor, ";\n\t background: ").concat(backgroundColor, ";\n\t border: 1px solid ").concat(borderColor, ";\n\t border-radius: ").concat(tooltipRadius, "px;\n\t padding: ").concat(padding, ";\n \t}\n\n \t.").concat(uuid, ".place-top {\n margin-top: -10px;\n }\n .").concat(uuid, ".place-top::before {\n content: \"\";\n background-color: inherit;\n position: absolute;\n z-index: 2;\n width: 20px;\n height: 12px;\n }\n .").concat(uuid, ".place-top::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 10px;\n border-top-right-radius: ").concat(arrowRadius, "px;\n border: 1px solid ").concat(borderColor, ";\n background-color: ").concat(arrowColor, ";\n z-index: -2;\n bottom: -6px;\n left: 50%;\n margin-left: -6px;\n transform: rotate(135deg);\n }\n\n .").concat(uuid, ".place-bottom {\n margin-top: 10px;\n }\n .").concat(uuid, ".place-bottom::before {\n content: \"\";\n background-color: inherit;\n position: absolute;\n z-index: -1;\n width: 18px;\n height: 10px;\n }\n .").concat(uuid, ".place-bottom::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 10px;\n border-top-right-radius: ").concat(arrowRadius, "px;\n border: 1px solid ").concat(borderColor, ";\n background-color: ").concat(arrowColor, ";\n z-index: -2;\n top: -6px;\n left: 50%;\n margin-left: -6px;\n transform: rotate(45deg);\n }\n\n .").concat(uuid, ".place-left {\n margin-left: -10px;\n }\n .").concat(uuid, ".place-left::before {\n content: \"\";\n background-color: inherit;\n position: absolute;\n z-index: -1;\n width: 10px;\n height: 18px;\n }\n .").concat(uuid, ".place-left::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 10px;\n border-top-right-radius: ").concat(arrowRadius, "px;\n border: 1px solid ").concat(borderColor, ";\n background-color: ").concat(arrowColor, ";\n z-index: -2;\n right: -6px;\n top: 50%;\n margin-top: -6px;\n transform: rotate(45deg);\n }\n\n .").concat(uuid, ".place-right {\n margin-left: 10px;\n }\n .").concat(uuid, ".place-right::before {\n content: \"\";\n background-color: inherit;\n position: absolute;\n z-index: -1;\n width: 10px;\n height: 18px;\n }\n .").concat(uuid, ".place-right::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 10px;\n border-top-right-radius: ").concat(arrowRadius, "px;\n border: 1px solid ").concat(borderColor, ";\n background-color: ").concat(arrowColor, ";\n z-index: -2;\n left: -6px;\n top: 50%;\n margin-top: -6px;\n transform: rotate(-135deg);\n }\n ");
2422
- }
2423
- function getPopupColors(customColors, type, hasBorder) {
2424
- var textColor = customColors.text;
2425
- var backgroundColor = customColors.background;
2426
- var borderColor = customColors.border;
2427
- var arrowColor = customColors.arrow ? customColors.arrow : customColors.background;
2428
- var colors = getDefaultPopupColors(type);
2429
- if (textColor) {
2430
- colors.text = textColor;
2431
- }
2432
- if (backgroundColor) {
2433
- colors.background = backgroundColor;
2434
- }
2435
- if (hasBorder) {
2436
- if (borderColor) {
2437
- colors.border = borderColor;
2438
- } else {
2439
- colors.border = type === 'light' ? 'black' : 'white';
2440
- }
2441
- }
2442
- if (arrowColor) {
2443
- colors.arrow = arrowColor;
2444
- }
2445
- return colors;
2446
- }
2447
-
2448
- var _class, _class2;
2449
-
2450
- /* Polyfill */
2451
- var ReactTooltip = staticMethods(_class = windowListener(_class = customEvent(_class = isCapture(_class = getEffect(_class = bodyMode(_class = trackRemoval(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
2452
- _inherits(ReactTooltip, _React$Component);
2453
- var _super = _createSuper(ReactTooltip);
2454
- function ReactTooltip(props) {
2455
- var _this;
2456
- _classCallCheck(this, ReactTooltip);
2457
- _this = _super.call(this, props);
2458
- _this.state = {
2459
- uuid: props.uuid || generateUUID(),
2460
- place: props.place || 'top',
2461
- // Direction of tooltip
2462
- desiredPlace: props.place || 'top',
2463
- type: props.type || 'dark',
2464
- // Color theme of tooltip
2465
- effect: props.effect || 'float',
2466
- // float or fixed
2467
- show: false,
2468
- border: false,
2469
- borderClass: 'border',
2470
- customColors: {},
2471
- customRadius: {},
2472
- offset: {},
2473
- padding: props.padding,
2474
- extraClass: '',
2475
- html: false,
2476
- delayHide: 0,
2477
- delayShow: 0,
2478
- event: props.event || null,
2479
- eventOff: props.eventOff || null,
2480
- currentEvent: null,
2481
- // Current mouse event
2482
- currentTarget: null,
2483
- // Current target of mouse event
2484
- ariaProps: parseAria(props),
2485
- // aria- and role attributes
2486
- isEmptyTip: false,
2487
- disable: false,
2488
- possibleCustomEvents: props.possibleCustomEvents || '',
2489
- possibleCustomEventsOff: props.possibleCustomEventsOff || '',
2490
- originTooltip: null,
2491
- isMultiline: false
2492
- };
2493
- _this.bind(['showTooltip', 'updateTooltip', 'hideTooltip', 'hideTooltipOnScroll', 'getTooltipContent', 'globalRebuild', 'globalShow', 'globalHide', 'onWindowResize', 'mouseOnToolTip']);
2494
- _this.mount = true;
2495
- _this.delayShowLoop = null;
2496
- _this.delayHideLoop = null;
2497
- _this.delayReshow = null;
2498
- _this.intervalUpdateContent = null;
2499
- return _this;
2500
- }
2501
-
2502
- /**
2503
- * For unify the bind and unbind listener
2504
- */
2505
- _createClass(ReactTooltip, [{
2506
- key: "bind",
2507
- value: function bind(methodArray) {
2508
- var _this2 = this;
2509
- methodArray.forEach(function (method) {
2510
- _this2[method] = _this2[method].bind(_this2);
2511
- });
2512
- }
2513
- }, {
2514
- key: "componentDidMount",
2515
- value: function componentDidMount() {
2516
- var _this$props = this.props;
2517
- _this$props.insecure;
2518
- var resizeHide = _this$props.resizeHide,
2519
- disableInternalStyle = _this$props.disableInternalStyle;
2520
- this.mount = true;
2521
- this.bindListener(); // Bind listener for tooltip
2522
- this.bindWindowEvents(resizeHide); // Bind global event for static method
2523
-
2524
- if (!disableInternalStyle) {
2525
- this.injectStyles(); // Inject styles for each DOM root having tooltip.
2526
- }
2527
- }
2528
- }, {
2529
- key: "componentWillUnmount",
2530
- value: function componentWillUnmount() {
2531
- this.mount = false;
2532
- this.clearTimer();
2533
- this.unbindListener();
2534
- this.removeScrollListener(this.state.currentTarget);
2535
- this.unbindWindowEvents();
2536
- }
2537
-
2538
- /* Look for the closest DOM root having tooltip and inject styles. */
2539
- }, {
2540
- key: "injectStyles",
2541
- value: function injectStyles() {
2542
- var tooltipRef = this.tooltipRef;
2543
- if (!tooltipRef) {
2544
- return;
2545
- }
2546
- var parentNode = tooltipRef.parentNode;
2547
- while (parentNode.parentNode) {
2548
- parentNode = parentNode.parentNode;
2549
- }
2550
- var domRoot;
2551
- switch (parentNode.constructor.name) {
2552
- case 'Document':
2553
- case 'HTMLDocument':
2554
- case undefined:
2555
- domRoot = parentNode.head;
2556
- break;
2557
- case 'ShadowRoot':
2558
- default:
2559
- domRoot = parentNode;
2560
- break;
2561
- }
2562
-
2563
- // Prevent styles duplication.
2564
- if (!domRoot.querySelector('style[data-react-tooltip]')) {
2565
- var style = document.createElement('style');
2566
- style.textContent = baseCss;
2567
- style.setAttribute('data-react-tooltip', 'true');
2568
- domRoot.appendChild(style);
2569
- }
2570
- }
2571
-
2572
- /**
2573
- * Return if the mouse is on the tooltip.
2574
- * @returns {boolean} true - mouse is on the tooltip
2575
- */
2576
- }, {
2577
- key: "mouseOnToolTip",
2578
- value: function mouseOnToolTip() {
2579
- var show = this.state.show;
2580
- if (show && this.tooltipRef) {
2581
- /* old IE or Firefox work around */
2582
- if (!this.tooltipRef.matches) {
2583
- /* old IE work around */
2584
- if (this.tooltipRef.msMatchesSelector) {
2585
- this.tooltipRef.matches = this.tooltipRef.msMatchesSelector;
2586
- } else {
2587
- /* old Firefox work around */
2588
- this.tooltipRef.matches = this.tooltipRef.mozMatchesSelector;
2589
- }
2590
- }
2591
- return this.tooltipRef.matches(':hover');
2592
- }
2593
- return false;
2594
- }
2595
-
2596
- /**
2597
- * Pick out corresponded target elements
2598
- */
2599
- }, {
2600
- key: "getTargetArray",
2601
- value: function getTargetArray(id) {
2602
- var targetArray = [];
2603
- var selector;
2604
- if (!id) {
2605
- selector = '[data-tip]:not([data-for])';
2606
- } else {
2607
- var escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
2608
- selector = "[data-tip][data-for=\"".concat(escaped, "\"]");
2609
- }
2610
-
2611
- // Scan document for shadow DOM elements
2612
- nodeListToArray(document.getElementsByTagName('*')).filter(function (element) {
2613
- return element.shadowRoot;
2614
- }).forEach(function (element) {
2615
- targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector)));
2616
- });
2617
- return targetArray.concat(nodeListToArray(document.querySelectorAll(selector)));
2618
- }
2619
-
2620
- /**
2621
- * Bind listener to the target elements
2622
- * These listeners used to trigger showing or hiding the tooltip
2623
- */
2624
- }, {
2625
- key: "bindListener",
2626
- value: function bindListener() {
2627
- var _this3 = this;
2628
- var _this$props2 = this.props,
2629
- id = _this$props2.id,
2630
- globalEventOff = _this$props2.globalEventOff,
2631
- isCapture = _this$props2.isCapture;
2632
- var targetArray = this.getTargetArray(id);
2633
- targetArray.forEach(function (target) {
2634
- if (target.getAttribute('currentItem') === null) {
2635
- target.setAttribute('currentItem', 'false');
2636
- }
2637
- _this3.unbindBasicListener(target);
2638
- if (_this3.isCustomEvent(target)) {
2639
- _this3.customUnbindListener(target);
2640
- }
2641
- });
2642
- if (this.isBodyMode()) {
2643
- this.bindBodyListener(targetArray);
2644
- } else {
2645
- targetArray.forEach(function (target) {
2646
- var isCaptureMode = _this3.isCapture(target);
2647
- var effect = _this3.getEffect(target);
2648
- if (_this3.isCustomEvent(target)) {
2649
- _this3.customBindListener(target);
2650
- return;
2651
- }
2652
- target.addEventListener('mouseenter', _this3.showTooltip, isCaptureMode);
2653
- target.addEventListener('focus', _this3.showTooltip, isCaptureMode);
2654
- if (effect === 'float') {
2655
- target.addEventListener('mousemove', _this3.updateTooltip, isCaptureMode);
2656
- }
2657
- target.addEventListener('mouseleave', _this3.hideTooltip, isCaptureMode);
2658
- target.addEventListener('blur', _this3.hideTooltip, isCaptureMode);
2659
- });
2660
- }
2661
-
2662
- // Global event to hide tooltip
2663
- if (globalEventOff) {
2664
- window.removeEventListener(globalEventOff, this.hideTooltip);
2665
- window.addEventListener(globalEventOff, this.hideTooltip, isCapture);
2666
- }
2667
-
2668
- // Track removal of targetArray elements from DOM
2669
- this.bindRemovalTracker();
2670
- }
2671
-
2672
- /**
2673
- * Unbind listeners on target elements
2674
- */
2675
- }, {
2676
- key: "unbindListener",
2677
- value: function unbindListener() {
2678
- var _this4 = this;
2679
- var _this$props3 = this.props,
2680
- id = _this$props3.id,
2681
- globalEventOff = _this$props3.globalEventOff;
2682
- if (this.isBodyMode()) {
2683
- this.unbindBodyListener();
2684
- } else {
2685
- var targetArray = this.getTargetArray(id);
2686
- targetArray.forEach(function (target) {
2687
- _this4.unbindBasicListener(target);
2688
- if (_this4.isCustomEvent(target)) _this4.customUnbindListener(target);
2689
- });
2690
- }
2691
- if (globalEventOff) window.removeEventListener(globalEventOff, this.hideTooltip);
2692
- this.unbindRemovalTracker();
2693
- }
2694
-
2695
- /**
2696
- * Invoke this before bind listener and unmount the component
2697
- * it is necessary to invoke this even when binding custom event
2698
- * so that the tooltip can switch between custom and default listener
2699
- */
2700
- }, {
2701
- key: "unbindBasicListener",
2702
- value: function unbindBasicListener(target) {
2703
- var isCaptureMode = this.isCapture(target);
2704
- target.removeEventListener('mouseenter', this.showTooltip, isCaptureMode);
2705
- target.removeEventListener('mousemove', this.updateTooltip, isCaptureMode);
2706
- target.removeEventListener('mouseleave', this.hideTooltip, isCaptureMode);
2707
- }
2708
- }, {
2709
- key: "getTooltipContent",
2710
- value: function getTooltipContent() {
2711
- var _this$props4 = this.props,
2712
- getContent = _this$props4.getContent,
2713
- children = _this$props4.children;
2714
-
2715
- // Generate tooltip content
2716
- var content;
2717
- if (getContent) {
2718
- if (Array.isArray(getContent)) {
2719
- content = getContent[0] && getContent[0](this.state.originTooltip);
2720
- } else {
2721
- content = getContent(this.state.originTooltip);
2722
- }
2723
- }
2724
- return TipContent(this.state.originTooltip, children, content, this.state.isMultiline);
2725
- }
2726
- }, {
2727
- key: "isEmptyTip",
2728
- value: function isEmptyTip(placeholder) {
2729
- return typeof placeholder === 'string' && placeholder === '' || placeholder === null;
2730
- }
2731
-
2732
- /**
2733
- * When mouse enter, show the tooltip
2734
- */
2735
- }, {
2736
- key: "showTooltip",
2737
- value: function showTooltip(e, isGlobalCall) {
2738
- if (!this.tooltipRef) {
2739
- return;
2740
- }
2741
- if (isGlobalCall) {
2742
- // Don't trigger other elements belongs to other ReactTooltip
2743
- var targetArray = this.getTargetArray(this.props.id);
2744
- var isMyElement = targetArray.some(function (ele) {
2745
- return ele === e.currentTarget;
2746
- });
2747
- if (!isMyElement) return;
2748
- }
2749
- // Get the tooltip content
2750
- // calculate in this phrase so that tip width height can be detected
2751
- var _this$props5 = this.props,
2752
- multiline = _this$props5.multiline,
2753
- getContent = _this$props5.getContent;
2754
- var originTooltip = e.currentTarget.getAttribute('data-tip');
2755
- var isMultiline = e.currentTarget.getAttribute('data-multiline') || multiline || false;
2756
-
2757
- // If it is focus event or called by ReactTooltip.show, switch to `solid` effect
2758
- var switchToSolid = e instanceof window.FocusEvent || isGlobalCall;
2759
-
2760
- // if it needs to skip adding hide listener to scroll
2761
- var scrollHide = true;
2762
- if (e.currentTarget.getAttribute('data-scroll-hide')) {
2763
- scrollHide = e.currentTarget.getAttribute('data-scroll-hide') === 'true';
2764
- } else if (this.props.scrollHide != null) {
2765
- scrollHide = this.props.scrollHide;
2766
- }
2767
-
2768
- // adding aria-describedby to target to make tooltips read by screen readers
2769
- if (e && e.currentTarget && e.currentTarget.setAttribute) {
2770
- e.currentTarget.setAttribute('aria-describedby', this.props.id || this.state.uuid);
2771
- }
2772
-
2773
- // Make sure the correct place is set
2774
- var desiredPlace = e.currentTarget.getAttribute('data-place') || this.props.place || 'top';
2775
- var effect = switchToSolid && 'solid' || this.getEffect(e.currentTarget);
2776
- var offset = e.currentTarget.getAttribute('data-offset') || this.props.offset || {};
2777
- var result = getPosition(e, e.currentTarget, this.tooltipRef, desiredPlace.split(',')[0], desiredPlace, effect, offset);
2778
- if (result.position && this.props.overridePosition) {
2779
- result.position = this.props.overridePosition(result.position, e, e.currentTarget, this.tooltipRef, desiredPlace, desiredPlace, effect, offset);
2780
- }
2781
- var place = result.isNewState ? result.newState.place : desiredPlace.split(',')[0];
2782
-
2783
- // To prevent previously created timers from triggering
2784
- this.clearTimer();
2785
- var target = e.currentTarget;
2786
- var reshowDelay = this.state.show ? target.getAttribute('data-delay-update') || this.props.delayUpdate : 0;
2787
- var self = this;
2788
- var updateState = function updateState() {
2789
- self.setState({
2790
- originTooltip: originTooltip,
2791
- isMultiline: isMultiline,
2792
- desiredPlace: desiredPlace,
2793
- place: place,
2794
- type: target.getAttribute('data-type') || self.props.type || 'dark',
2795
- customColors: {
2796
- text: target.getAttribute('data-text-color') || self.props.textColor || null,
2797
- background: target.getAttribute('data-background-color') || self.props.backgroundColor || null,
2798
- border: target.getAttribute('data-border-color') || self.props.borderColor || null,
2799
- arrow: target.getAttribute('data-arrow-color') || self.props.arrowColor || null
2800
- },
2801
- customRadius: {
2802
- tooltip: target.getAttribute('data-tooltip-radius') || self.props.tooltipRadius || '3',
2803
- arrow: target.getAttribute('data-arrow-radius') || self.props.arrowRadius || '0'
2804
- },
2805
- effect: effect,
2806
- offset: offset,
2807
- padding: target.getAttribute('data-padding') || self.props.padding,
2808
- html: (target.getAttribute('data-html') ? target.getAttribute('data-html') === 'true' : self.props.html) || false,
2809
- delayShow: target.getAttribute('data-delay-show') || self.props.delayShow || 0,
2810
- delayHide: target.getAttribute('data-delay-hide') || self.props.delayHide || 0,
2811
- delayUpdate: target.getAttribute('data-delay-update') || self.props.delayUpdate || 0,
2812
- border: (target.getAttribute('data-border') ? target.getAttribute('data-border') === 'true' : self.props.border) || false,
2813
- borderClass: target.getAttribute('data-border-class') || self.props.borderClass || 'border',
2814
- extraClass: target.getAttribute('data-class') || self.props["class"] || self.props.className || '',
2815
- disable: (target.getAttribute('data-tip-disable') ? target.getAttribute('data-tip-disable') === 'true' : self.props.disable) || false,
2816
- currentTarget: target
2817
- }, function () {
2818
- if (scrollHide) {
2819
- self.addScrollListener(self.state.currentTarget);
2820
- }
2821
- self.updateTooltip(e);
2822
- if (getContent && Array.isArray(getContent)) {
2823
- self.intervalUpdateContent = setInterval(function () {
2824
- if (self.mount) {
2825
- var _getContent = self.props.getContent;
2826
- var placeholder = TipContent(originTooltip, '', _getContent[0](), isMultiline);
2827
- var isEmptyTip = self.isEmptyTip(placeholder);
2828
- self.setState({
2829
- isEmptyTip: isEmptyTip
2830
- });
2831
- self.updatePosition();
2832
- }
2833
- }, getContent[1]);
2834
- }
2835
- });
2836
- };
2837
-
2838
- // If there is no delay call immediately, don't allow events to get in first.
2839
- if (reshowDelay) {
2840
- this.delayReshow = setTimeout(updateState, reshowDelay);
2841
- } else {
2842
- updateState();
2843
- }
2844
- }
2845
-
2846
- /**
2847
- * When mouse hover, update tool tip
2848
- */
2849
- }, {
2850
- key: "updateTooltip",
2851
- value: function updateTooltip(e) {
2852
- var _this5 = this;
2853
- var _this$state = this.state,
2854
- delayShow = _this$state.delayShow,
2855
- disable = _this$state.disable;
2856
- var _this$props6 = this.props,
2857
- afterShow = _this$props6.afterShow,
2858
- disableProp = _this$props6.disable;
2859
- var placeholder = this.getTooltipContent();
2860
- var eventTarget = e.currentTarget || e.target;
2861
-
2862
- // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
2863
- if (this.mouseOnToolTip()) {
2864
- return;
2865
- }
2866
-
2867
- // if the tooltip is empty, disable the tooltip
2868
- if (this.isEmptyTip(placeholder) || disable || disableProp) {
2869
- return;
2870
- }
2871
- var delayTime = !this.state.show ? parseInt(delayShow, 10) : 0;
2872
- var updateState = function updateState() {
2873
- if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) {
2874
- var isInvisible = !_this5.state.show;
2875
- _this5.setState({
2876
- currentEvent: e,
2877
- currentTarget: eventTarget,
2878
- show: true
2879
- }, function () {
2880
- _this5.updatePosition(function () {
2881
- if (isInvisible && afterShow) {
2882
- afterShow(e);
2883
- }
2884
- });
2885
- });
2886
- }
2887
- };
2888
- if (this.delayShowLoop) {
2889
- clearTimeout(this.delayShowLoop);
2890
- }
2891
- if (delayTime) {
2892
- this.delayShowLoop = setTimeout(updateState, delayTime);
2893
- } else {
2894
- this.delayShowLoop = null;
2895
- updateState();
2896
- }
2897
- }
2898
-
2899
- /*
2900
- * If we're mousing over the tooltip remove it when we leave.
2901
- */
2902
- }, {
2903
- key: "listenForTooltipExit",
2904
- value: function listenForTooltipExit() {
2905
- var show = this.state.show;
2906
- if (show && this.tooltipRef) {
2907
- this.tooltipRef.addEventListener('mouseleave', this.hideTooltip);
2908
- }
2909
- }
2910
- }, {
2911
- key: "removeListenerForTooltipExit",
2912
- value: function removeListenerForTooltipExit() {
2913
- var show = this.state.show;
2914
- if (show && this.tooltipRef) {
2915
- this.tooltipRef.removeEventListener('mouseleave', this.hideTooltip);
2916
- }
2917
- }
2918
-
2919
- /**
2920
- * When mouse leave, hide tooltip
2921
- */
2922
- }, {
2923
- key: "hideTooltip",
2924
- value: function hideTooltip(e, hasTarget) {
2925
- var _this6 = this;
2926
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2927
- isScroll: false
2928
- };
2929
- var disable = this.state.disable;
2930
- var isScroll = options.isScroll;
2931
- var delayHide = isScroll ? 0 : this.state.delayHide;
2932
- var _this$props7 = this.props,
2933
- afterHide = _this$props7.afterHide,
2934
- disableProp = _this$props7.disable;
2935
- var placeholder = this.getTooltipContent();
2936
- if (!this.mount) return;
2937
- if (this.isEmptyTip(placeholder) || disable || disableProp) return; // if the tooltip is empty, disable the tooltip
2938
- if (hasTarget) {
2939
- // Don't trigger other elements belongs to other ReactTooltip
2940
- var targetArray = this.getTargetArray(this.props.id);
2941
- var isMyElement = targetArray.some(function (ele) {
2942
- return ele === e.currentTarget;
2943
- });
2944
- if (!isMyElement || !this.state.show) return;
2945
- }
2946
-
2947
- // clean up aria-describedby when hiding tooltip
2948
- if (e && e.currentTarget && e.currentTarget.removeAttribute) {
2949
- e.currentTarget.removeAttribute('aria-describedby');
2950
- }
2951
- var resetState = function resetState() {
2952
- var isVisible = _this6.state.show;
2953
- // Check if the mouse is actually over the tooltip, if so don't hide the tooltip
2954
- if (_this6.mouseOnToolTip()) {
2955
- _this6.listenForTooltipExit();
2956
- return;
2957
- }
2958
- _this6.removeListenerForTooltipExit();
2959
- _this6.setState({
2960
- show: false
2961
- }, function () {
2962
- _this6.removeScrollListener(_this6.state.currentTarget);
2963
- if (isVisible && afterHide) {
2964
- afterHide(e);
2965
- }
2966
- });
2967
- };
2968
- this.clearTimer();
2969
- if (delayHide) {
2970
- this.delayHideLoop = setTimeout(resetState, parseInt(delayHide, 10));
2971
- } else {
2972
- resetState();
2973
- }
2974
- }
2975
-
2976
- /**
2977
- * When scroll, hide tooltip
2978
- */
2979
- }, {
2980
- key: "hideTooltipOnScroll",
2981
- value: function hideTooltipOnScroll(event, hasTarget) {
2982
- this.hideTooltip(event, hasTarget, {
2983
- isScroll: true
2984
- });
2985
- }
2986
-
2987
- /**
2988
- * Add scroll event listener when tooltip show
2989
- * automatically hide the tooltip when scrolling
2990
- */
2991
- }, {
2992
- key: "addScrollListener",
2993
- value: function addScrollListener(currentTarget) {
2994
- var isCaptureMode = this.isCapture(currentTarget);
2995
- window.addEventListener('scroll', this.hideTooltipOnScroll, isCaptureMode);
2996
- }
2997
- }, {
2998
- key: "removeScrollListener",
2999
- value: function removeScrollListener(currentTarget) {
3000
- var isCaptureMode = this.isCapture(currentTarget);
3001
- window.removeEventListener('scroll', this.hideTooltipOnScroll, isCaptureMode);
3002
- }
3003
-
3004
- // Calculation the position
3005
- }, {
3006
- key: "updatePosition",
3007
- value: function updatePosition(callbackAfter) {
3008
- var _this7 = this;
3009
- var _this$state2 = this.state,
3010
- currentEvent = _this$state2.currentEvent,
3011
- currentTarget = _this$state2.currentTarget,
3012
- place = _this$state2.place,
3013
- desiredPlace = _this$state2.desiredPlace,
3014
- effect = _this$state2.effect,
3015
- offset = _this$state2.offset;
3016
- var node = this.tooltipRef;
3017
- var result = getPosition(currentEvent, currentTarget, node, place, desiredPlace, effect, offset);
3018
- if (result.position && this.props.overridePosition) {
3019
- result.position = this.props.overridePosition(result.position, currentEvent, currentTarget, node, place, desiredPlace, effect, offset);
3020
- }
3021
- if (result.isNewState) {
3022
- // Switch to reverse placement
3023
- return this.setState(result.newState, function () {
3024
- _this7.updatePosition(callbackAfter);
3025
- });
3026
- }
3027
- if (callbackAfter && typeof callbackAfter === 'function') {
3028
- callbackAfter();
3029
- }
3030
-
3031
- // Set tooltip position
3032
- node.style.left = result.position.left + 'px';
3033
- node.style.top = result.position.top + 'px';
3034
- }
3035
-
3036
- /**
3037
- * CLear all kinds of timeout of interval
3038
- */
3039
- }, {
3040
- key: "clearTimer",
3041
- value: function clearTimer() {
3042
- if (this.delayShowLoop) {
3043
- clearTimeout(this.delayShowLoop);
3044
- this.delayShowLoop = null;
3045
- }
3046
- if (this.delayHideLoop) {
3047
- clearTimeout(this.delayHideLoop);
3048
- this.delayHideLoop = null;
3049
- }
3050
- if (this.delayReshow) {
3051
- clearTimeout(this.delayReshow);
3052
- this.delayReshow = null;
3053
- }
3054
- if (this.intervalUpdateContent) {
3055
- clearInterval(this.intervalUpdateContent);
3056
- this.intervalUpdateContent = null;
3057
- }
3058
- }
3059
- }, {
3060
- key: "hasCustomColors",
3061
- value: function hasCustomColors() {
3062
- var _this8 = this;
3063
- return Boolean(Object.keys(this.state.customColors).find(function (color) {
3064
- return color !== 'border' && _this8.state.customColors[color];
3065
- }) || this.state.border && this.state.customColors['border']);
3066
- }
3067
- }, {
3068
- key: "render",
3069
- value: function render() {
3070
- var _this9 = this;
3071
- var _this$state3 = this.state,
3072
- extraClass = _this$state3.extraClass,
3073
- html = _this$state3.html,
3074
- ariaProps = _this$state3.ariaProps,
3075
- disable = _this$state3.disable,
3076
- uuid = _this$state3.uuid;
3077
- var content = this.getTooltipContent();
3078
- var isEmptyTip = this.isEmptyTip(content);
3079
- var style = this.props.disableInternalStyle ? '' : generateTooltipStyle(this.state.uuid, this.state.customColors, this.state.type, this.state.border, this.state.padding, this.state.customRadius);
3080
- var tooltipClass = '__react_component_tooltip' + " ".concat(this.state.uuid) + (this.state.show && !disable && !isEmptyTip ? ' show' : '') + (this.state.border ? ' ' + this.state.borderClass : '') + " place-".concat(this.state.place) + // top, bottom, left, right
3081
- " type-".concat(this.hasCustomColors() ? 'custom' : this.state.type) + (
3082
- // dark, success, warning, error, info, light, custom
3083
- this.props.delayUpdate ? ' allow_hover' : '') + (this.props.clickable ? ' allow_click' : '');
3084
- var Wrapper = this.props.wrapper;
3085
- if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) {
3086
- Wrapper = ReactTooltip.defaultProps.wrapper;
3087
- }
3088
- var wrapperClassName = [tooltipClass, extraClass].filter(Boolean).join(' ');
3089
- if (html) {
3090
- var htmlContent = "".concat(content).concat(style ? "\n<style aria-hidden=\"true\">".concat(style, "</style>") : '');
3091
- return /*#__PURE__*/React__default["default"].createElement(Wrapper, _extends({
3092
- className: "".concat(wrapperClassName),
3093
- id: this.props.id || uuid,
3094
- ref: function ref(_ref) {
3095
- return _this9.tooltipRef = _ref;
3096
- }
3097
- }, ariaProps, {
3098
- "data-id": "tooltip",
3099
- dangerouslySetInnerHTML: {
3100
- __html: htmlContent
3101
- }
3102
- }));
3103
- } else {
3104
- return /*#__PURE__*/React__default["default"].createElement(Wrapper, _extends({
3105
- className: "".concat(wrapperClassName),
3106
- id: this.props.id || uuid
3107
- }, ariaProps, {
3108
- ref: function ref(_ref2) {
3109
- return _this9.tooltipRef = _ref2;
3110
- },
3111
- "data-id": "tooltip"
3112
- }), style && /*#__PURE__*/React__default["default"].createElement("style", {
3113
- dangerouslySetInnerHTML: {
3114
- __html: style
3115
- },
3116
- "aria-hidden": "true"
3117
- }), content);
3118
- }
3119
- }
3120
- }], [{
3121
- key: "propTypes",
3122
- get: function get() {
3123
- return {
3124
- uuid: PropTypes__default["default"].string,
3125
- children: PropTypes__default["default"].any,
3126
- place: PropTypes__default["default"].string,
3127
- type: PropTypes__default["default"].string,
3128
- effect: PropTypes__default["default"].string,
3129
- offset: PropTypes__default["default"].object,
3130
- padding: PropTypes__default["default"].string,
3131
- multiline: PropTypes__default["default"].bool,
3132
- border: PropTypes__default["default"].bool,
3133
- borderClass: PropTypes__default["default"].string,
3134
- textColor: PropTypes__default["default"].string,
3135
- backgroundColor: PropTypes__default["default"].string,
3136
- borderColor: PropTypes__default["default"].string,
3137
- arrowColor: PropTypes__default["default"].string,
3138
- arrowRadius: PropTypes__default["default"].string,
3139
- tooltipRadius: PropTypes__default["default"].string,
3140
- insecure: PropTypes__default["default"].bool,
3141
- "class": PropTypes__default["default"].string,
3142
- className: PropTypes__default["default"].string,
3143
- id: PropTypes__default["default"].string,
3144
- html: PropTypes__default["default"].bool,
3145
- delayHide: PropTypes__default["default"].number,
3146
- delayUpdate: PropTypes__default["default"].number,
3147
- delayShow: PropTypes__default["default"].number,
3148
- event: PropTypes__default["default"].string,
3149
- eventOff: PropTypes__default["default"].string,
3150
- isCapture: PropTypes__default["default"].bool,
3151
- globalEventOff: PropTypes__default["default"].string,
3152
- getContent: PropTypes__default["default"].any,
3153
- afterShow: PropTypes__default["default"].func,
3154
- afterHide: PropTypes__default["default"].func,
3155
- overridePosition: PropTypes__default["default"].func,
3156
- disable: PropTypes__default["default"].bool,
3157
- scrollHide: PropTypes__default["default"].bool,
3158
- resizeHide: PropTypes__default["default"].bool,
3159
- wrapper: PropTypes__default["default"].string,
3160
- bodyMode: PropTypes__default["default"].bool,
3161
- possibleCustomEvents: PropTypes__default["default"].string,
3162
- possibleCustomEventsOff: PropTypes__default["default"].string,
3163
- clickable: PropTypes__default["default"].bool,
3164
- disableInternalStyle: PropTypes__default["default"].bool
3165
- };
3166
- }
3167
- }, {
3168
- key: "getDerivedStateFromProps",
3169
- value: function getDerivedStateFromProps(nextProps, prevState) {
3170
- var ariaProps = prevState.ariaProps;
3171
- var newAriaProps = parseAria(nextProps);
3172
- var isChanged = Object.keys(newAriaProps).some(function (props) {
3173
- return newAriaProps[props] !== ariaProps[props];
3174
- });
3175
- if (!isChanged) {
3176
- return null;
3177
- }
3178
- return _objectSpread2(_objectSpread2({}, prevState), {}, {
3179
- ariaProps: newAriaProps
3180
- });
3181
- }
3182
- }]);
3183
- return ReactTooltip;
3184
- }(React__default["default"].Component), _defineProperty(_class2, "defaultProps", {
3185
- insecure: true,
3186
- resizeHide: true,
3187
- wrapper: 'div',
3188
- clickable: false
3189
- }), _defineProperty(_class2, "supportedWrappers", ['div', 'span']), _defineProperty(_class2, "displayName", 'ReactTooltip'), _class2)) || _class) || _class) || _class) || _class) || _class) || _class) || _class;
3190
-
3191
- module.exports = ReactTooltip;
3192
- //# sourceMappingURL=index.js.map