react-tooltip 5.10.1-beta-7 → 5.10.1-beta-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/react-tooltip.cjs +2969 -1269
- package/dist/react-tooltip.css +32 -23
- package/dist/react-tooltip.min.cjs +15 -11
- package/dist/react-tooltip.min.css +1 -0
- package/dist/react-tooltip.min.mjs +15 -11
- package/dist/react-tooltip.mjs +2959 -1265
- package/dist/react-tooltip.umd.js +3097 -0
- package/dist/react-tooltip.umd.min.js +15 -0
- package/package.json +7 -7
- package/dist/react-tooltip.cjs.map +0 -7
- package/dist/react-tooltip.css.map +0 -7
- package/dist/react-tooltip.iife.js +0 -1388
- package/dist/react-tooltip.iife.js.map +0 -7
- package/dist/react-tooltip.min.cjs.map +0 -7
- package/dist/react-tooltip.min.iife.js +0 -11
- package/dist/react-tooltip.min.iife.js.map +0 -7
- package/dist/react-tooltip.min.mjs.map +0 -7
- package/dist/react-tooltip.mjs.map +0 -7
package/dist/react-tooltip.mjs
CHANGED
|
@@ -1,1389 +1,3083 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import require$$0, { createContext, useState, useCallback, useMemo, useContext, useRef, useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = {exports: {}};
|
|
4
|
+
|
|
5
|
+
var reactJsxRuntime_development = {};
|
|
6
|
+
|
|
7
|
+
/** @license React v16.14.0
|
|
8
|
+
* react-jsx-runtime.development.js
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
(function (exports) {
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
(function() {
|
|
20
|
+
|
|
21
|
+
var React = require$$0;
|
|
22
|
+
|
|
23
|
+
// ATTENTION
|
|
24
|
+
// When adding new symbols to this file,
|
|
25
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
26
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
27
|
+
// nor polyfill, then a plain number is used for performance.
|
|
28
|
+
var REACT_ELEMENT_TYPE = 0xeac7;
|
|
29
|
+
var REACT_PORTAL_TYPE = 0xeaca;
|
|
30
|
+
exports.Fragment = 0xeacb;
|
|
31
|
+
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
|
32
|
+
var REACT_PROFILER_TYPE = 0xead2;
|
|
33
|
+
var REACT_PROVIDER_TYPE = 0xeacd;
|
|
34
|
+
var REACT_CONTEXT_TYPE = 0xeace;
|
|
35
|
+
var REACT_FORWARD_REF_TYPE = 0xead0;
|
|
36
|
+
var REACT_SUSPENSE_TYPE = 0xead1;
|
|
37
|
+
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
|
38
|
+
var REACT_MEMO_TYPE = 0xead3;
|
|
39
|
+
var REACT_LAZY_TYPE = 0xead4;
|
|
40
|
+
var REACT_BLOCK_TYPE = 0xead9;
|
|
41
|
+
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
|
42
|
+
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
|
43
|
+
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
|
44
|
+
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
|
45
|
+
|
|
46
|
+
if (typeof Symbol === 'function' && Symbol.for) {
|
|
47
|
+
var symbolFor = Symbol.for;
|
|
48
|
+
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
|
49
|
+
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
|
50
|
+
exports.Fragment = symbolFor('react.fragment');
|
|
51
|
+
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
|
52
|
+
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
|
53
|
+
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
|
54
|
+
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
|
55
|
+
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
|
56
|
+
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
|
57
|
+
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
|
58
|
+
REACT_MEMO_TYPE = symbolFor('react.memo');
|
|
59
|
+
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
|
60
|
+
REACT_BLOCK_TYPE = symbolFor('react.block');
|
|
61
|
+
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
|
62
|
+
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
|
63
|
+
symbolFor('react.scope');
|
|
64
|
+
symbolFor('react.opaque.id');
|
|
65
|
+
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
|
66
|
+
symbolFor('react.offscreen');
|
|
67
|
+
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
71
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
72
|
+
function getIteratorFn(maybeIterable) {
|
|
73
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
78
|
+
|
|
79
|
+
if (typeof maybeIterator === 'function') {
|
|
80
|
+
return maybeIterator;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
87
|
+
|
|
88
|
+
function error(format) {
|
|
89
|
+
{
|
|
90
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
91
|
+
args[_key2 - 1] = arguments[_key2];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
printWarning('error', format, args);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function printWarning(level, format, args) {
|
|
99
|
+
// When changing this logic, you might want to also
|
|
100
|
+
// update consoleWithStackDev.www.js as well.
|
|
101
|
+
{
|
|
102
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
103
|
+
var stack = '';
|
|
104
|
+
|
|
105
|
+
if (currentlyValidatingElement) {
|
|
106
|
+
var name = getComponentName(currentlyValidatingElement.type);
|
|
107
|
+
var owner = currentlyValidatingElement._owner;
|
|
108
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
stack += ReactDebugCurrentFrame.getStackAddendum();
|
|
112
|
+
|
|
113
|
+
if (stack !== '') {
|
|
114
|
+
format += '%s';
|
|
115
|
+
args = args.concat([stack]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
var argsWithFormat = args.map(function (item) {
|
|
119
|
+
return '' + item;
|
|
120
|
+
}); // Careful: RN currently depends on this prefix
|
|
121
|
+
|
|
122
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
123
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
124
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
125
|
+
|
|
126
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
|
131
|
+
|
|
132
|
+
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
133
|
+
|
|
134
|
+
function isValidElementType(type) {
|
|
135
|
+
if (typeof type === 'string' || typeof type === 'function') {
|
|
136
|
+
return true;
|
|
137
|
+
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (typeof type === 'object' && type !== null) {
|
|
145
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
155
|
+
function describeComponentFrame (name, source, ownerName) {
|
|
156
|
+
var sourceInfo = '';
|
|
157
|
+
|
|
158
|
+
if (source) {
|
|
159
|
+
var path = source.fileName;
|
|
160
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
161
|
+
|
|
162
|
+
{
|
|
163
|
+
// In DEV, include code for a common special case:
|
|
164
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
165
|
+
if (/^index\./.test(fileName)) {
|
|
166
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
167
|
+
|
|
168
|
+
if (match) {
|
|
169
|
+
var pathBeforeSlash = match[1];
|
|
170
|
+
|
|
171
|
+
if (pathBeforeSlash) {
|
|
172
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
173
|
+
fileName = folderName + '/' + fileName;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
180
|
+
} else if (ownerName) {
|
|
181
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var Resolved = 1;
|
|
188
|
+
function refineResolvedLazyComponent(lazyComponent) {
|
|
189
|
+
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
193
|
+
var functionName = innerType.displayName || innerType.name || '';
|
|
194
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function getComponentName(type) {
|
|
198
|
+
if (type == null) {
|
|
199
|
+
// Host root, text node or just invalid type.
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
{
|
|
204
|
+
if (typeof type.tag === 'number') {
|
|
205
|
+
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (typeof type === 'function') {
|
|
210
|
+
return type.displayName || type.name || null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (typeof type === 'string') {
|
|
214
|
+
return type;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
switch (type) {
|
|
218
|
+
case exports.Fragment:
|
|
219
|
+
return 'Fragment';
|
|
220
|
+
|
|
221
|
+
case REACT_PORTAL_TYPE:
|
|
222
|
+
return 'Portal';
|
|
223
|
+
|
|
224
|
+
case REACT_PROFILER_TYPE:
|
|
225
|
+
return "Profiler";
|
|
226
|
+
|
|
227
|
+
case REACT_STRICT_MODE_TYPE:
|
|
228
|
+
return 'StrictMode';
|
|
229
|
+
|
|
230
|
+
case REACT_SUSPENSE_TYPE:
|
|
231
|
+
return 'Suspense';
|
|
232
|
+
|
|
233
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
234
|
+
return 'SuspenseList';
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (typeof type === 'object') {
|
|
238
|
+
switch (type.$$typeof) {
|
|
239
|
+
case REACT_CONTEXT_TYPE:
|
|
240
|
+
return 'Context.Consumer';
|
|
241
|
+
|
|
242
|
+
case REACT_PROVIDER_TYPE:
|
|
243
|
+
return 'Context.Provider';
|
|
244
|
+
|
|
245
|
+
case REACT_FORWARD_REF_TYPE:
|
|
246
|
+
return getWrappedName(type, type.render, 'ForwardRef');
|
|
247
|
+
|
|
248
|
+
case REACT_MEMO_TYPE:
|
|
249
|
+
return getComponentName(type.type);
|
|
250
|
+
|
|
251
|
+
case REACT_BLOCK_TYPE:
|
|
252
|
+
return getComponentName(type.render);
|
|
253
|
+
|
|
254
|
+
case REACT_LAZY_TYPE:
|
|
255
|
+
{
|
|
256
|
+
var thenable = type;
|
|
257
|
+
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
258
|
+
|
|
259
|
+
if (resolvedThenable) {
|
|
260
|
+
return getComponentName(resolvedThenable);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
var loggedTypeFailures = {};
|
|
272
|
+
ReactSharedInternals.ReactDebugCurrentFrame;
|
|
273
|
+
var currentlyValidatingElement = null;
|
|
274
|
+
|
|
275
|
+
function setCurrentlyValidatingElement(element) {
|
|
276
|
+
{
|
|
277
|
+
currentlyValidatingElement = element;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
282
|
+
{
|
|
283
|
+
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
284
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
285
|
+
|
|
286
|
+
for (var typeSpecName in typeSpecs) {
|
|
287
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
288
|
+
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
289
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
290
|
+
// After these have been cleaned up, we'll let them throw.
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
294
|
+
// behavior as without this statement except with a better message.
|
|
295
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
296
|
+
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
297
|
+
err.name = 'Invariant Violation';
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
302
|
+
} catch (ex) {
|
|
303
|
+
error$1 = ex;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
307
|
+
setCurrentlyValidatingElement(element);
|
|
308
|
+
|
|
309
|
+
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
310
|
+
|
|
311
|
+
setCurrentlyValidatingElement(null);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
315
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
316
|
+
// same error.
|
|
317
|
+
loggedTypeFailures[error$1.message] = true;
|
|
318
|
+
setCurrentlyValidatingElement(element);
|
|
319
|
+
|
|
320
|
+
error('Failed %s type: %s', location, error$1.message);
|
|
321
|
+
|
|
322
|
+
setCurrentlyValidatingElement(null);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
330
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
331
|
+
var RESERVED_PROPS = {
|
|
332
|
+
key: true,
|
|
333
|
+
ref: true,
|
|
334
|
+
__self: true,
|
|
335
|
+
__source: true
|
|
336
|
+
};
|
|
337
|
+
var specialPropKeyWarningShown;
|
|
338
|
+
var specialPropRefWarningShown;
|
|
339
|
+
var didWarnAboutStringRefs;
|
|
340
|
+
|
|
341
|
+
{
|
|
342
|
+
didWarnAboutStringRefs = {};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function hasValidRef(config) {
|
|
346
|
+
{
|
|
347
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
348
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
349
|
+
|
|
350
|
+
if (getter && getter.isReactWarning) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return config.ref !== undefined;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function hasValidKey(config) {
|
|
360
|
+
{
|
|
361
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
362
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
363
|
+
|
|
364
|
+
if (getter && getter.isReactWarning) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return config.key !== undefined;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
374
|
+
{
|
|
375
|
+
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
376
|
+
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
377
|
+
|
|
378
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
|
379
|
+
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
|
|
380
|
+
|
|
381
|
+
didWarnAboutStringRefs[componentName] = true;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
388
|
+
{
|
|
389
|
+
var warnAboutAccessingKey = function () {
|
|
390
|
+
if (!specialPropKeyWarningShown) {
|
|
391
|
+
specialPropKeyWarningShown = true;
|
|
392
|
+
|
|
393
|
+
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
398
|
+
Object.defineProperty(props, 'key', {
|
|
399
|
+
get: warnAboutAccessingKey,
|
|
400
|
+
configurable: true
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
406
|
+
{
|
|
407
|
+
var warnAboutAccessingRef = function () {
|
|
408
|
+
if (!specialPropRefWarningShown) {
|
|
409
|
+
specialPropRefWarningShown = true;
|
|
410
|
+
|
|
411
|
+
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
416
|
+
Object.defineProperty(props, 'ref', {
|
|
417
|
+
get: warnAboutAccessingRef,
|
|
418
|
+
configurable: true
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
424
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
425
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
426
|
+
* if something is a React Element.
|
|
427
|
+
*
|
|
428
|
+
* @param {*} type
|
|
429
|
+
* @param {*} props
|
|
430
|
+
* @param {*} key
|
|
431
|
+
* @param {string|object} ref
|
|
432
|
+
* @param {*} owner
|
|
433
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
434
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
435
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
436
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
437
|
+
* change in behavior.
|
|
438
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
439
|
+
* indicating filename, line number, and/or other information.
|
|
440
|
+
* @internal
|
|
441
|
+
*/
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
445
|
+
var element = {
|
|
446
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
447
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
448
|
+
// Built-in properties that belong on the element
|
|
449
|
+
type: type,
|
|
450
|
+
key: key,
|
|
451
|
+
ref: ref,
|
|
452
|
+
props: props,
|
|
453
|
+
// Record the component responsible for creating this element.
|
|
454
|
+
_owner: owner
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
{
|
|
458
|
+
// The validation flag is currently mutative. We put it on
|
|
459
|
+
// an external backing store so that we can freeze the whole object.
|
|
460
|
+
// This can be replaced with a WeakMap once they are implemented in
|
|
461
|
+
// commonly used development environments.
|
|
462
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
463
|
+
// the validation flag non-enumerable (where possible, which should
|
|
464
|
+
// include every environment we run tests in), so the test framework
|
|
465
|
+
// ignores it.
|
|
466
|
+
|
|
467
|
+
Object.defineProperty(element._store, 'validated', {
|
|
468
|
+
configurable: false,
|
|
469
|
+
enumerable: false,
|
|
470
|
+
writable: true,
|
|
471
|
+
value: false
|
|
472
|
+
}); // self and source are DEV only properties.
|
|
473
|
+
|
|
474
|
+
Object.defineProperty(element, '_self', {
|
|
475
|
+
configurable: false,
|
|
476
|
+
enumerable: false,
|
|
477
|
+
writable: false,
|
|
478
|
+
value: self
|
|
479
|
+
}); // Two elements created in two different places should be considered
|
|
480
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
|
481
|
+
|
|
482
|
+
Object.defineProperty(element, '_source', {
|
|
483
|
+
configurable: false,
|
|
484
|
+
enumerable: false,
|
|
485
|
+
writable: false,
|
|
486
|
+
value: source
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
if (Object.freeze) {
|
|
490
|
+
Object.freeze(element.props);
|
|
491
|
+
Object.freeze(element);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return element;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
499
|
+
* @param {*} type
|
|
500
|
+
* @param {object} props
|
|
501
|
+
* @param {string} key
|
|
502
|
+
*/
|
|
503
|
+
|
|
504
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
505
|
+
{
|
|
506
|
+
var propName; // Reserved names are extracted
|
|
507
|
+
|
|
508
|
+
var props = {};
|
|
509
|
+
var key = null;
|
|
510
|
+
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
511
|
+
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
512
|
+
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
513
|
+
// but as an intermediary step, we will use jsxDEV for everything except
|
|
514
|
+
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
515
|
+
// key is explicitly declared to be undefined or not.
|
|
516
|
+
|
|
517
|
+
if (maybeKey !== undefined) {
|
|
518
|
+
key = '' + maybeKey;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (hasValidKey(config)) {
|
|
522
|
+
key = '' + config.key;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (hasValidRef(config)) {
|
|
526
|
+
ref = config.ref;
|
|
527
|
+
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
528
|
+
} // Remaining properties are added to a new props object
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
for (propName in config) {
|
|
532
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
533
|
+
props[propName] = config[propName];
|
|
534
|
+
}
|
|
535
|
+
} // Resolve default props
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
if (type && type.defaultProps) {
|
|
539
|
+
var defaultProps = type.defaultProps;
|
|
540
|
+
|
|
541
|
+
for (propName in defaultProps) {
|
|
542
|
+
if (props[propName] === undefined) {
|
|
543
|
+
props[propName] = defaultProps[propName];
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (key || ref) {
|
|
549
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
550
|
+
|
|
551
|
+
if (key) {
|
|
552
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (ref) {
|
|
556
|
+
defineRefPropWarningGetter(props, displayName);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
565
|
+
ReactSharedInternals.ReactDebugCurrentFrame;
|
|
566
|
+
|
|
567
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
568
|
+
currentlyValidatingElement = element;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
var propTypesMisspellWarningShown;
|
|
572
|
+
|
|
573
|
+
{
|
|
574
|
+
propTypesMisspellWarningShown = false;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Verifies the object is a ReactElement.
|
|
578
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
579
|
+
* @param {?object} object
|
|
580
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
581
|
+
* @final
|
|
582
|
+
*/
|
|
583
|
+
|
|
584
|
+
function isValidElement(object) {
|
|
585
|
+
{
|
|
586
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function getDeclarationErrorAddendum() {
|
|
591
|
+
{
|
|
592
|
+
if (ReactCurrentOwner$1.current) {
|
|
593
|
+
var name = getComponentName(ReactCurrentOwner$1.current.type);
|
|
594
|
+
|
|
595
|
+
if (name) {
|
|
596
|
+
return '\n\nCheck the render method of `' + name + '`.';
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return '';
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function getSourceInfoErrorAddendum(source) {
|
|
605
|
+
{
|
|
606
|
+
if (source !== undefined) {
|
|
607
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
608
|
+
var lineNumber = source.lineNumber;
|
|
609
|
+
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
return '';
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
617
|
+
* object keys are not valid. This allows us to keep track of children between
|
|
618
|
+
* updates.
|
|
619
|
+
*/
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
var ownerHasKeyUseWarning = {};
|
|
623
|
+
|
|
624
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
625
|
+
{
|
|
626
|
+
var info = getDeclarationErrorAddendum();
|
|
627
|
+
|
|
628
|
+
if (!info) {
|
|
629
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
630
|
+
|
|
631
|
+
if (parentName) {
|
|
632
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return info;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
641
|
+
* This element is in an array. The array could grow and shrink or be
|
|
642
|
+
* reordered. All children that haven't already been validated are required to
|
|
643
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
644
|
+
* will only be shown once.
|
|
645
|
+
*
|
|
646
|
+
* @internal
|
|
647
|
+
* @param {ReactElement} element Element that requires a key.
|
|
648
|
+
* @param {*} parentType element's parent's type.
|
|
649
|
+
*/
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
function validateExplicitKey(element, parentType) {
|
|
653
|
+
{
|
|
654
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
element._store.validated = true;
|
|
659
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
660
|
+
|
|
661
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
666
|
+
// property, it may be the creator of the child that's responsible for
|
|
667
|
+
// assigning it a key.
|
|
668
|
+
|
|
669
|
+
var childOwner = '';
|
|
670
|
+
|
|
671
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
672
|
+
// Give the component that originally created this child.
|
|
673
|
+
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
setCurrentlyValidatingElement$1(element);
|
|
677
|
+
|
|
678
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
679
|
+
|
|
680
|
+
setCurrentlyValidatingElement$1(null);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Ensure that every element either is passed in a static location, in an
|
|
685
|
+
* array with an explicit keys property defined, or in an object literal
|
|
686
|
+
* with valid key property.
|
|
687
|
+
*
|
|
688
|
+
* @internal
|
|
689
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
690
|
+
* @param {*} parentType node's parent's type.
|
|
691
|
+
*/
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
function validateChildKeys(node, parentType) {
|
|
695
|
+
{
|
|
696
|
+
if (typeof node !== 'object') {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (Array.isArray(node)) {
|
|
701
|
+
for (var i = 0; i < node.length; i++) {
|
|
702
|
+
var child = node[i];
|
|
703
|
+
|
|
704
|
+
if (isValidElement(child)) {
|
|
705
|
+
validateExplicitKey(child, parentType);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
} else if (isValidElement(node)) {
|
|
709
|
+
// This element was passed in a valid location.
|
|
710
|
+
if (node._store) {
|
|
711
|
+
node._store.validated = true;
|
|
712
|
+
}
|
|
713
|
+
} else if (node) {
|
|
714
|
+
var iteratorFn = getIteratorFn(node);
|
|
715
|
+
|
|
716
|
+
if (typeof iteratorFn === 'function') {
|
|
717
|
+
// Entry iterators used to provide implicit keys,
|
|
718
|
+
// but now we print a separate warning for them later.
|
|
719
|
+
if (iteratorFn !== node.entries) {
|
|
720
|
+
var iterator = iteratorFn.call(node);
|
|
721
|
+
var step;
|
|
722
|
+
|
|
723
|
+
while (!(step = iterator.next()).done) {
|
|
724
|
+
if (isValidElement(step.value)) {
|
|
725
|
+
validateExplicitKey(step.value, parentType);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Given an element, validate that its props follow the propTypes definition,
|
|
735
|
+
* provided by the type.
|
|
736
|
+
*
|
|
737
|
+
* @param {ReactElement} element
|
|
738
|
+
*/
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
function validatePropTypes(element) {
|
|
742
|
+
{
|
|
743
|
+
var type = element.type;
|
|
744
|
+
|
|
745
|
+
if (type === null || type === undefined || typeof type === 'string') {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
var propTypes;
|
|
750
|
+
|
|
751
|
+
if (typeof type === 'function') {
|
|
752
|
+
propTypes = type.propTypes;
|
|
753
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
754
|
+
// Inner props are checked in the reconciler.
|
|
755
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
756
|
+
propTypes = type.propTypes;
|
|
757
|
+
} else {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (propTypes) {
|
|
762
|
+
// Intentionally inside to avoid triggering lazy initializers:
|
|
763
|
+
var name = getComponentName(type);
|
|
764
|
+
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
765
|
+
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
766
|
+
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
767
|
+
|
|
768
|
+
var _name = getComponentName(type);
|
|
769
|
+
|
|
770
|
+
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
774
|
+
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
|
780
|
+
* @param {ReactElement} fragment
|
|
781
|
+
*/
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
function validateFragmentProps(fragment) {
|
|
785
|
+
{
|
|
786
|
+
var keys = Object.keys(fragment.props);
|
|
787
|
+
|
|
788
|
+
for (var i = 0; i < keys.length; i++) {
|
|
789
|
+
var key = keys[i];
|
|
790
|
+
|
|
791
|
+
if (key !== 'children' && key !== 'key') {
|
|
792
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
793
|
+
|
|
794
|
+
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
795
|
+
|
|
796
|
+
setCurrentlyValidatingElement$1(null);
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (fragment.ref !== null) {
|
|
802
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
803
|
+
|
|
804
|
+
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
805
|
+
|
|
806
|
+
setCurrentlyValidatingElement$1(null);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
812
|
+
{
|
|
813
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
814
|
+
// succeed and there will likely be errors in render.
|
|
815
|
+
|
|
816
|
+
if (!validType) {
|
|
817
|
+
var info = '';
|
|
818
|
+
|
|
819
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
820
|
+
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
824
|
+
|
|
825
|
+
if (sourceInfo) {
|
|
826
|
+
info += sourceInfo;
|
|
827
|
+
} else {
|
|
828
|
+
info += getDeclarationErrorAddendum();
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
var typeString;
|
|
832
|
+
|
|
833
|
+
if (type === null) {
|
|
834
|
+
typeString = 'null';
|
|
835
|
+
} else if (Array.isArray(type)) {
|
|
836
|
+
typeString = 'array';
|
|
837
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
838
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
839
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
840
|
+
} else {
|
|
841
|
+
typeString = typeof type;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
848
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
849
|
+
|
|
850
|
+
if (element == null) {
|
|
851
|
+
return element;
|
|
852
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
853
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
854
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
855
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
856
|
+
// fixed, the key warnings will appear.)
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
if (validType) {
|
|
860
|
+
var children = props.children;
|
|
861
|
+
|
|
862
|
+
if (children !== undefined) {
|
|
863
|
+
if (isStaticChildren) {
|
|
864
|
+
if (Array.isArray(children)) {
|
|
865
|
+
for (var i = 0; i < children.length; i++) {
|
|
866
|
+
validateChildKeys(children[i], type);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (Object.freeze) {
|
|
870
|
+
Object.freeze(children);
|
|
871
|
+
}
|
|
872
|
+
} else {
|
|
873
|
+
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
874
|
+
}
|
|
875
|
+
} else {
|
|
876
|
+
validateChildKeys(children, type);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
if (type === exports.Fragment) {
|
|
882
|
+
validateFragmentProps(element);
|
|
883
|
+
} else {
|
|
884
|
+
validatePropTypes(element);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
return element;
|
|
888
|
+
}
|
|
889
|
+
} // These two functions exist to still get child warnings in dev
|
|
890
|
+
// even with the prod transform. This means that jsxDEV is purely
|
|
891
|
+
// opt-in behavior for better messages but that we won't stop
|
|
892
|
+
// giving you warnings if you use production apis.
|
|
893
|
+
|
|
894
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
895
|
+
{
|
|
896
|
+
return jsxWithValidation(type, props, key, true);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
900
|
+
{
|
|
901
|
+
return jsxWithValidation(type, props, key, false);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
|
906
|
+
// for now we can ship identical prod functions
|
|
907
|
+
|
|
908
|
+
var jsxs = jsxWithValidationStatic ;
|
|
909
|
+
|
|
910
|
+
exports.jsx = jsx;
|
|
911
|
+
exports.jsxs = jsxs;
|
|
912
|
+
})();
|
|
913
|
+
}
|
|
914
|
+
} (reactJsxRuntime_development));
|
|
915
|
+
|
|
916
|
+
(function (module) {
|
|
917
|
+
|
|
918
|
+
{
|
|
919
|
+
module.exports = reactJsxRuntime_development;
|
|
920
|
+
}
|
|
921
|
+
} (jsxRuntime));
|
|
922
|
+
|
|
923
|
+
var classnames = {exports: {}};
|
|
924
|
+
|
|
925
|
+
/*!
|
|
926
|
+
Copyright (c) 2018 Jed Watson.
|
|
927
|
+
Licensed under the MIT License (MIT), see
|
|
928
|
+
http://jedwatson.github.io/classnames
|
|
929
|
+
*/
|
|
930
|
+
|
|
931
|
+
(function (module) {
|
|
932
|
+
/* global define */
|
|
933
|
+
|
|
934
|
+
(function () {
|
|
935
|
+
|
|
936
|
+
var hasOwn = {}.hasOwnProperty;
|
|
937
|
+
|
|
938
|
+
function classNames() {
|
|
939
|
+
var classes = [];
|
|
940
|
+
|
|
941
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
942
|
+
var arg = arguments[i];
|
|
943
|
+
if (!arg) continue;
|
|
944
|
+
|
|
945
|
+
var argType = typeof arg;
|
|
946
|
+
|
|
947
|
+
if (argType === 'string' || argType === 'number') {
|
|
948
|
+
classes.push(arg);
|
|
949
|
+
} else if (Array.isArray(arg)) {
|
|
950
|
+
if (arg.length) {
|
|
951
|
+
var inner = classNames.apply(null, arg);
|
|
952
|
+
if (inner) {
|
|
953
|
+
classes.push(inner);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
} else if (argType === 'object') {
|
|
957
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
958
|
+
classes.push(arg.toString());
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
for (var key in arg) {
|
|
963
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
964
|
+
classes.push(key);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
return classes.join(' ');
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
if (module.exports) {
|
|
974
|
+
classNames.default = classNames;
|
|
975
|
+
module.exports = classNames;
|
|
976
|
+
} else {
|
|
977
|
+
window.classNames = classNames;
|
|
978
|
+
}
|
|
979
|
+
}());
|
|
980
|
+
} (classnames));
|
|
981
|
+
|
|
982
|
+
var classNames = classnames.exports;
|
|
983
|
+
|
|
984
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
985
|
+
/**
|
|
986
|
+
* This function debounce the received function
|
|
987
|
+
* @param { function } func Function to be debounced
|
|
988
|
+
* @param { number } wait Time to wait before execut the function
|
|
989
|
+
* @param { boolean } immediate Param to define if the function will be executed immediately
|
|
990
|
+
*/
|
|
991
|
+
const debounce = (func, wait, immediate) => {
|
|
992
|
+
let timeout = null;
|
|
993
|
+
return function debounced(...args) {
|
|
994
|
+
const later = () => {
|
|
995
|
+
timeout = null;
|
|
996
|
+
if (!immediate) {
|
|
997
|
+
func.apply(this, args);
|
|
59
998
|
}
|
|
60
|
-
|
|
999
|
+
};
|
|
1000
|
+
if (timeout) {
|
|
1001
|
+
clearTimeout(timeout);
|
|
61
1002
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
if (typeof module !== "undefined" && module.exports) {
|
|
65
|
-
classNames3.default = classNames3;
|
|
66
|
-
module.exports = classNames3;
|
|
67
|
-
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
68
|
-
define("classnames", [], function() {
|
|
69
|
-
return classNames3;
|
|
70
|
-
});
|
|
71
|
-
} else {
|
|
72
|
-
window.classNames = classNames3;
|
|
73
|
-
}
|
|
74
|
-
})();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// src/components/TooltipController/TooltipController.tsx
|
|
79
|
-
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
80
|
-
|
|
81
|
-
// src/components/Tooltip/Tooltip.tsx
|
|
82
|
-
var import_classnames2 = __toESM(require_classnames());
|
|
83
|
-
import { useEffect as useEffect3, useState as useState2, useRef as useRef2 } from "react";
|
|
84
|
-
|
|
85
|
-
// src/utils/debounce.ts
|
|
86
|
-
var debounce = (func, wait, immediate) => {
|
|
87
|
-
let timeout = null;
|
|
88
|
-
return function debounced(...args) {
|
|
89
|
-
const later = () => {
|
|
90
|
-
timeout = null;
|
|
91
|
-
if (!immediate) {
|
|
92
|
-
func.apply(this, args);
|
|
93
|
-
}
|
|
1003
|
+
timeout = setTimeout(later, wait);
|
|
94
1004
|
};
|
|
95
|
-
if (timeout) {
|
|
96
|
-
clearTimeout(timeout);
|
|
97
|
-
}
|
|
98
|
-
timeout = setTimeout(later, wait);
|
|
99
|
-
};
|
|
100
1005
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
activeAnchor: { current: null },
|
|
116
|
-
attach: () => {
|
|
117
|
-
},
|
|
118
|
-
detach: () => {
|
|
119
|
-
},
|
|
120
|
-
setActiveAnchor: () => {
|
|
121
|
-
}
|
|
1006
|
+
|
|
1007
|
+
const DEFAULT_TOOLTIP_ID = 'DEFAULT_TOOLTIP_ID';
|
|
1008
|
+
const DEFAULT_CONTEXT_DATA = {
|
|
1009
|
+
anchorRefs: new Set(),
|
|
1010
|
+
activeAnchor: { current: null },
|
|
1011
|
+
attach: () => {
|
|
1012
|
+
/* attach anchor element */
|
|
1013
|
+
},
|
|
1014
|
+
detach: () => {
|
|
1015
|
+
/* detach anchor element */
|
|
1016
|
+
},
|
|
1017
|
+
setActiveAnchor: () => {
|
|
1018
|
+
/* set active anchor */
|
|
1019
|
+
},
|
|
122
1020
|
};
|
|
123
|
-
|
|
124
|
-
|
|
1021
|
+
const DEFAULT_CONTEXT_DATA_WRAPPER = {
|
|
1022
|
+
getTooltipData: () => DEFAULT_CONTEXT_DATA,
|
|
125
1023
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
[
|
|
133
|
-
|
|
134
|
-
const attach = (tooltipId, ...refs) => {
|
|
135
|
-
setAnchorRefMap((oldMap) => {
|
|
136
|
-
var _a;
|
|
137
|
-
const tooltipRefs = (_a = oldMap[tooltipId]) != null ? _a : /* @__PURE__ */ new Set();
|
|
138
|
-
refs.forEach((ref) => tooltipRefs.add(ref));
|
|
139
|
-
return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
const detach = (tooltipId, ...refs) => {
|
|
143
|
-
setAnchorRefMap((oldMap) => {
|
|
144
|
-
const tooltipRefs = oldMap[tooltipId];
|
|
145
|
-
if (!tooltipRefs) {
|
|
146
|
-
return oldMap;
|
|
147
|
-
}
|
|
148
|
-
refs.forEach((ref) => tooltipRefs.delete(ref));
|
|
149
|
-
return { ...oldMap };
|
|
1024
|
+
const TooltipContext = createContext(DEFAULT_CONTEXT_DATA_WRAPPER);
|
|
1025
|
+
/**
|
|
1026
|
+
* @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
|
|
1027
|
+
* See https://react-tooltip.com/docs/getting-started
|
|
1028
|
+
*/
|
|
1029
|
+
const TooltipProvider = ({ children }) => {
|
|
1030
|
+
const [anchorRefMap, setAnchorRefMap] = useState({
|
|
1031
|
+
[DEFAULT_TOOLTIP_ID]: new Set(),
|
|
150
1032
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
setActiveAnchorMap((oldMap) => {
|
|
154
|
-
var _a;
|
|
155
|
-
if (((_a = oldMap[tooltipId]) == null ? void 0 : _a.current) === ref.current) {
|
|
156
|
-
return oldMap;
|
|
157
|
-
}
|
|
158
|
-
return { ...oldMap, [tooltipId]: ref };
|
|
1033
|
+
const [activeAnchorMap, setActiveAnchorMap] = useState({
|
|
1034
|
+
[DEFAULT_TOOLTIP_ID]: { current: null },
|
|
159
1035
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
1036
|
+
const attach = (tooltipId, ...refs) => {
|
|
1037
|
+
setAnchorRefMap((oldMap) => {
|
|
1038
|
+
var _a;
|
|
1039
|
+
const tooltipRefs = (_a = oldMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set();
|
|
1040
|
+
refs.forEach((ref) => tooltipRefs.add(ref));
|
|
1041
|
+
// create new object to trigger re-render
|
|
1042
|
+
return { ...oldMap, [tooltipId]: new Set(tooltipRefs) };
|
|
1043
|
+
});
|
|
1044
|
+
};
|
|
1045
|
+
const detach = (tooltipId, ...refs) => {
|
|
1046
|
+
setAnchorRefMap((oldMap) => {
|
|
1047
|
+
const tooltipRefs = oldMap[tooltipId];
|
|
1048
|
+
if (!tooltipRefs) {
|
|
1049
|
+
// tooltip not found
|
|
1050
|
+
// maybe thow error?
|
|
1051
|
+
return oldMap;
|
|
1052
|
+
}
|
|
1053
|
+
refs.forEach((ref) => tooltipRefs.delete(ref));
|
|
1054
|
+
// create new object to trigger re-render
|
|
1055
|
+
return { ...oldMap };
|
|
1056
|
+
});
|
|
177
1057
|
};
|
|
178
|
-
|
|
179
|
-
|
|
1058
|
+
const setActiveAnchor = (tooltipId, ref) => {
|
|
1059
|
+
setActiveAnchorMap((oldMap) => {
|
|
1060
|
+
var _a;
|
|
1061
|
+
if (((_a = oldMap[tooltipId]) === null || _a === void 0 ? void 0 : _a.current) === ref.current) {
|
|
1062
|
+
return oldMap;
|
|
1063
|
+
}
|
|
1064
|
+
// create new object to trigger re-render
|
|
1065
|
+
return { ...oldMap, [tooltipId]: ref };
|
|
1066
|
+
});
|
|
1067
|
+
};
|
|
1068
|
+
const getTooltipData = useCallback((tooltipId = DEFAULT_TOOLTIP_ID) => {
|
|
1069
|
+
var _a, _b;
|
|
1070
|
+
return ({
|
|
1071
|
+
anchorRefs: (_a = anchorRefMap[tooltipId]) !== null && _a !== void 0 ? _a : new Set(),
|
|
1072
|
+
activeAnchor: (_b = activeAnchorMap[tooltipId]) !== null && _b !== void 0 ? _b : { current: null },
|
|
1073
|
+
attach: (...refs) => attach(tooltipId, ...refs),
|
|
1074
|
+
detach: (...refs) => detach(tooltipId, ...refs),
|
|
1075
|
+
setActiveAnchor: (ref) => setActiveAnchor(tooltipId, ref),
|
|
1076
|
+
});
|
|
1077
|
+
}, [anchorRefMap, activeAnchorMap, attach, detach]);
|
|
1078
|
+
const context = useMemo(() => {
|
|
1079
|
+
return {
|
|
1080
|
+
getTooltipData,
|
|
1081
|
+
};
|
|
1082
|
+
}, [getTooltipData]);
|
|
1083
|
+
return jsxRuntime.exports.jsx(TooltipContext.Provider, { value: context, children: children });
|
|
180
1084
|
};
|
|
181
1085
|
function useTooltip(tooltipId = DEFAULT_TOOLTIP_ID) {
|
|
182
|
-
|
|
1086
|
+
return useContext(TooltipContext).getTooltipData(tooltipId);
|
|
183
1087
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
wrapper,
|
|
200
|
-
events,
|
|
201
|
-
positionStrategy,
|
|
202
|
-
delayShow,
|
|
203
|
-
delayHide
|
|
204
|
-
}) => {
|
|
205
|
-
const { attach, detach } = useTooltip(tooltipId);
|
|
206
|
-
const anchorRef = useRef(null);
|
|
207
|
-
useEffect(() => {
|
|
208
|
-
attach(anchorRef);
|
|
209
|
-
return () => {
|
|
210
|
-
detach(anchorRef);
|
|
211
|
-
};
|
|
212
|
-
}, []);
|
|
213
|
-
return /* @__PURE__ */ jsx2(
|
|
214
|
-
"span",
|
|
215
|
-
{
|
|
216
|
-
ref: anchorRef,
|
|
217
|
-
className: (0, import_classnames.default)("react-tooltip-wrapper", className),
|
|
218
|
-
"data-tooltip-place": place,
|
|
219
|
-
"data-tooltip-content": content,
|
|
220
|
-
"data-tooltip-html": html,
|
|
221
|
-
"data-tooltip-variant": variant,
|
|
222
|
-
"data-tooltip-offset": offset,
|
|
223
|
-
"data-tooltip-wrapper": wrapper,
|
|
224
|
-
"data-tooltip-events": events,
|
|
225
|
-
"data-tooltip-position-strategy": positionStrategy,
|
|
226
|
-
"data-tooltip-delay-show": delayShow,
|
|
227
|
-
"data-tooltip-delay-hide": delayHide,
|
|
228
|
-
children
|
|
229
|
-
}
|
|
230
|
-
);
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
|
|
1091
|
+
* See https://react-tooltip.com/docs/getting-started
|
|
1092
|
+
*/
|
|
1093
|
+
const TooltipWrapper = ({ tooltipId, children, className, place, content, html, variant, offset, wrapper, events, positionStrategy, delayShow, delayHide, }) => {
|
|
1094
|
+
const { attach, detach } = useTooltip(tooltipId);
|
|
1095
|
+
const anchorRef = useRef(null);
|
|
1096
|
+
useEffect(() => {
|
|
1097
|
+
attach(anchorRef);
|
|
1098
|
+
return () => {
|
|
1099
|
+
detach(anchorRef);
|
|
1100
|
+
};
|
|
1101
|
+
}, []);
|
|
1102
|
+
return (jsxRuntime.exports.jsx("span", { ref: anchorRef, className: classNames('react-tooltip-wrapper', className), "data-tooltip-place": place, "data-tooltip-content": content, "data-tooltip-html": html, "data-tooltip-variant": variant, "data-tooltip-offset": offset, "data-tooltip-wrapper": wrapper, "data-tooltip-events": events, "data-tooltip-position-strategy": positionStrategy, "data-tooltip-delay-show": delayShow, "data-tooltip-delay-hide": delayHide, children: children }));
|
|
231
1103
|
};
|
|
232
|
-
var TooltipWrapper_default = TooltipWrapper;
|
|
233
1104
|
|
|
234
|
-
|
|
235
|
-
import { useLayoutEffect, useEffect as useEffect2 } from "react";
|
|
236
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect2;
|
|
237
|
-
var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
|
|
1105
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
238
1106
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return t2.split("-")[1];
|
|
1107
|
+
function getAlignment(placement) {
|
|
1108
|
+
return placement.split('-')[1];
|
|
242
1109
|
}
|
|
243
|
-
|
|
244
|
-
|
|
1110
|
+
|
|
1111
|
+
function getLengthFromAxis(axis) {
|
|
1112
|
+
return axis === 'y' ? 'height' : 'width';
|
|
245
1113
|
}
|
|
246
|
-
|
|
247
|
-
|
|
1114
|
+
|
|
1115
|
+
function getSide(placement) {
|
|
1116
|
+
return placement.split('-')[0];
|
|
248
1117
|
}
|
|
249
|
-
|
|
250
|
-
|
|
1118
|
+
|
|
1119
|
+
function getMainAxisFromPlacement(placement) {
|
|
1120
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
251
1121
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
1122
|
+
|
|
1123
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
1124
|
+
let {
|
|
1125
|
+
reference,
|
|
1126
|
+
floating
|
|
1127
|
+
} = _ref;
|
|
1128
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
1129
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
1130
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
1131
|
+
const length = getLengthFromAxis(mainAxis);
|
|
1132
|
+
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
1133
|
+
const side = getSide(placement);
|
|
1134
|
+
const isVertical = mainAxis === 'x';
|
|
1135
|
+
let coords;
|
|
1136
|
+
switch (side) {
|
|
1137
|
+
case 'top':
|
|
1138
|
+
coords = {
|
|
1139
|
+
x: commonX,
|
|
1140
|
+
y: reference.y - floating.height
|
|
1141
|
+
};
|
|
259
1142
|
break;
|
|
260
|
-
case
|
|
261
|
-
|
|
1143
|
+
case 'bottom':
|
|
1144
|
+
coords = {
|
|
1145
|
+
x: commonX,
|
|
1146
|
+
y: reference.y + reference.height
|
|
1147
|
+
};
|
|
262
1148
|
break;
|
|
263
|
-
case
|
|
264
|
-
|
|
1149
|
+
case 'right':
|
|
1150
|
+
coords = {
|
|
1151
|
+
x: reference.x + reference.width,
|
|
1152
|
+
y: commonY
|
|
1153
|
+
};
|
|
265
1154
|
break;
|
|
266
|
-
case
|
|
267
|
-
|
|
1155
|
+
case 'left':
|
|
1156
|
+
coords = {
|
|
1157
|
+
x: reference.x - floating.width,
|
|
1158
|
+
y: commonY
|
|
1159
|
+
};
|
|
268
1160
|
break;
|
|
269
1161
|
default:
|
|
270
|
-
|
|
1162
|
+
coords = {
|
|
1163
|
+
x: reference.x,
|
|
1164
|
+
y: reference.y
|
|
1165
|
+
};
|
|
271
1166
|
}
|
|
272
|
-
switch (
|
|
273
|
-
case
|
|
274
|
-
|
|
1167
|
+
switch (getAlignment(placement)) {
|
|
1168
|
+
case 'start':
|
|
1169
|
+
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
1170
|
+
break;
|
|
1171
|
+
case 'end':
|
|
1172
|
+
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
275
1173
|
break;
|
|
276
|
-
case "end":
|
|
277
|
-
p3[m3] += g3 * (a3 && d3 ? -1 : 1);
|
|
278
1174
|
}
|
|
279
|
-
return
|
|
1175
|
+
return coords;
|
|
280
1176
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1180
|
+
* next to a reference element when it is given a certain positioning strategy.
|
|
1181
|
+
*
|
|
1182
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
1183
|
+
* write one for the platform you are using Floating UI with.
|
|
1184
|
+
*/
|
|
1185
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
1186
|
+
const {
|
|
1187
|
+
placement = 'bottom',
|
|
1188
|
+
strategy = 'absolute',
|
|
1189
|
+
middleware = [],
|
|
1190
|
+
platform
|
|
1191
|
+
} = config;
|
|
1192
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
1193
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
1194
|
+
{
|
|
1195
|
+
if (platform == null) {
|
|
1196
|
+
console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
|
|
1197
|
+
}
|
|
1198
|
+
if (validMiddleware.filter(_ref => {
|
|
1199
|
+
let {
|
|
1200
|
+
name
|
|
1201
|
+
} = _ref;
|
|
1202
|
+
return name === 'autoPlacement' || name === 'flip';
|
|
1203
|
+
}).length > 1) {
|
|
1204
|
+
throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement` middleware', 'detected. This will lead to an infinite loop. Ensure only one of', 'either has been passed to the `middleware` array.'].join(' '));
|
|
1205
|
+
}
|
|
1206
|
+
if (!reference || !floating) {
|
|
1207
|
+
console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));
|
|
1208
|
+
}
|
|
287
1209
|
}
|
|
288
|
-
|
|
1210
|
+
let rects = await platform.getElementRects({
|
|
1211
|
+
reference,
|
|
1212
|
+
floating,
|
|
1213
|
+
strategy
|
|
1214
|
+
});
|
|
1215
|
+
let {
|
|
1216
|
+
x,
|
|
1217
|
+
y
|
|
1218
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
1219
|
+
let statefulPlacement = placement;
|
|
1220
|
+
let middlewareData = {};
|
|
1221
|
+
let resetCount = 0;
|
|
1222
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
1223
|
+
const {
|
|
1224
|
+
name,
|
|
1225
|
+
fn
|
|
1226
|
+
} = validMiddleware[i];
|
|
1227
|
+
const {
|
|
1228
|
+
x: nextX,
|
|
1229
|
+
y: nextY,
|
|
1230
|
+
data,
|
|
1231
|
+
reset
|
|
1232
|
+
} = await fn({
|
|
1233
|
+
x,
|
|
1234
|
+
y,
|
|
1235
|
+
initialPlacement: placement,
|
|
1236
|
+
placement: statefulPlacement,
|
|
1237
|
+
strategy,
|
|
1238
|
+
middlewareData,
|
|
1239
|
+
rects,
|
|
1240
|
+
platform,
|
|
1241
|
+
elements: {
|
|
1242
|
+
reference,
|
|
1243
|
+
floating
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
x = nextX != null ? nextX : x;
|
|
1247
|
+
y = nextY != null ? nextY : y;
|
|
1248
|
+
middlewareData = {
|
|
1249
|
+
...middlewareData,
|
|
1250
|
+
[name]: {
|
|
1251
|
+
...middlewareData[name],
|
|
1252
|
+
...data
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
{
|
|
1256
|
+
if (resetCount > 50) {
|
|
1257
|
+
console.warn(['Floating UI: The middleware lifecycle appears to be running in an', 'infinite loop. This is usually caused by a `reset` continually', 'being returned without a break condition.'].join(' '));
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
if (reset && resetCount <= 50) {
|
|
1261
|
+
resetCount++;
|
|
1262
|
+
if (typeof reset === 'object') {
|
|
1263
|
+
if (reset.placement) {
|
|
1264
|
+
statefulPlacement = reset.placement;
|
|
1265
|
+
}
|
|
1266
|
+
if (reset.rects) {
|
|
1267
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
1268
|
+
reference,
|
|
1269
|
+
floating,
|
|
1270
|
+
strategy
|
|
1271
|
+
}) : reset.rects;
|
|
1272
|
+
}
|
|
1273
|
+
({
|
|
1274
|
+
x,
|
|
1275
|
+
y
|
|
1276
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1277
|
+
}
|
|
1278
|
+
i = -1;
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return {
|
|
1283
|
+
x,
|
|
1284
|
+
y,
|
|
1285
|
+
placement: statefulPlacement,
|
|
1286
|
+
strategy,
|
|
1287
|
+
middlewareData
|
|
1288
|
+
};
|
|
289
1289
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
1290
|
+
|
|
1291
|
+
function expandPaddingObject(padding) {
|
|
1292
|
+
return {
|
|
1293
|
+
top: 0,
|
|
1294
|
+
right: 0,
|
|
1295
|
+
bottom: 0,
|
|
1296
|
+
left: 0,
|
|
1297
|
+
...padding
|
|
1298
|
+
};
|
|
294
1299
|
}
|
|
295
|
-
|
|
296
|
-
|
|
1300
|
+
|
|
1301
|
+
function getSideObjectFromPadding(padding) {
|
|
1302
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
1303
|
+
top: padding,
|
|
1304
|
+
right: padding,
|
|
1305
|
+
bottom: padding,
|
|
1306
|
+
left: padding
|
|
1307
|
+
};
|
|
297
1308
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
1309
|
+
|
|
1310
|
+
function rectToClientRect(rect) {
|
|
1311
|
+
return {
|
|
1312
|
+
...rect,
|
|
1313
|
+
top: rect.y,
|
|
1314
|
+
left: rect.x,
|
|
1315
|
+
right: rect.x + rect.width,
|
|
1316
|
+
bottom: rect.y + rect.height
|
|
1317
|
+
};
|
|
303
1318
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
1322
|
+
* element is overflowing a given clipping boundary on each side.
|
|
1323
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
1324
|
+
* - negative = how many pixels left before it will overflow
|
|
1325
|
+
* - 0 = lies flush with the boundary
|
|
1326
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
1327
|
+
*/
|
|
1328
|
+
async function detectOverflow(state, options) {
|
|
1329
|
+
var _await$platform$isEle;
|
|
1330
|
+
if (options === void 0) {
|
|
1331
|
+
options = {};
|
|
1332
|
+
}
|
|
1333
|
+
const {
|
|
1334
|
+
x,
|
|
1335
|
+
y,
|
|
1336
|
+
platform,
|
|
1337
|
+
rects,
|
|
1338
|
+
elements,
|
|
1339
|
+
strategy
|
|
1340
|
+
} = state;
|
|
1341
|
+
const {
|
|
1342
|
+
boundary = 'clippingAncestors',
|
|
1343
|
+
rootBoundary = 'viewport',
|
|
1344
|
+
elementContext = 'floating',
|
|
1345
|
+
altBoundary = false,
|
|
1346
|
+
padding = 0
|
|
1347
|
+
} = options;
|
|
1348
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
1349
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
1350
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
1351
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
1352
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
1353
|
+
boundary,
|
|
1354
|
+
rootBoundary,
|
|
1355
|
+
strategy
|
|
1356
|
+
}));
|
|
1357
|
+
const rect = elementContext === 'floating' ? {
|
|
1358
|
+
...rects.floating,
|
|
1359
|
+
x,
|
|
1360
|
+
y
|
|
1361
|
+
} : rects.reference;
|
|
1362
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
1363
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
1364
|
+
x: 1,
|
|
1365
|
+
y: 1
|
|
1366
|
+
} : {
|
|
1367
|
+
x: 1,
|
|
1368
|
+
y: 1
|
|
1369
|
+
};
|
|
1370
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1371
|
+
rect,
|
|
1372
|
+
offsetParent,
|
|
1373
|
+
strategy
|
|
1374
|
+
}) : rect);
|
|
1375
|
+
return {
|
|
1376
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
1377
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
1378
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
1379
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
1380
|
+
};
|
|
308
1381
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
E3 && await (null == g3.isElement ? void 0 : g3.isElement(O3)) || (E3 = d3.floating[A2] || u3.floating[x3]);
|
|
316
|
-
const D3 = P2 / 2 - T3 / 2, L3 = p3[b3], k2 = E3 - w3[x3] - p3[R2], B = E3 / 2 - w3[x3] / 2 + D3, C2 = m(L3, B, k2), H2 = null != t(f3) && B != C2 && u3.reference[x3] / 2 - (B < L3 ? p3[b3] : p3[R2]) - w3[x3] / 2 < 0;
|
|
317
|
-
return { [y3]: h3[y3] - (H2 ? B < L3 ? L3 - B : k2 - B : 0), data: { [y3]: C2, centerOffset: B - C2 } };
|
|
318
|
-
} });
|
|
319
|
-
var g = ["top", "right", "bottom", "left"];
|
|
320
|
-
var d = g.reduce((t2, e2) => t2.concat(e2, e2 + "-start", e2 + "-end"), []);
|
|
321
|
-
var p = { left: "right", right: "left", bottom: "top", top: "bottom" };
|
|
322
|
-
function h(t2) {
|
|
323
|
-
return t2.replace(/left|right|bottom|top/g, (t3) => p[t3]);
|
|
1382
|
+
|
|
1383
|
+
const min$1 = Math.min;
|
|
1384
|
+
const max$1 = Math.max;
|
|
1385
|
+
|
|
1386
|
+
function within(min$1$1, value, max$1$1) {
|
|
1387
|
+
return max$1(min$1$1, min$1(value, max$1$1));
|
|
324
1388
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1392
|
+
* appears centered to the reference element.
|
|
1393
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1394
|
+
*/
|
|
1395
|
+
const arrow = options => ({
|
|
1396
|
+
name: 'arrow',
|
|
1397
|
+
options,
|
|
1398
|
+
async fn(state) {
|
|
1399
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
1400
|
+
const {
|
|
1401
|
+
element,
|
|
1402
|
+
padding = 0
|
|
1403
|
+
} = options || {};
|
|
1404
|
+
const {
|
|
1405
|
+
x,
|
|
1406
|
+
y,
|
|
1407
|
+
placement,
|
|
1408
|
+
rects,
|
|
1409
|
+
platform,
|
|
1410
|
+
elements
|
|
1411
|
+
} = state;
|
|
1412
|
+
if (element == null) {
|
|
1413
|
+
{
|
|
1414
|
+
console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
|
|
1415
|
+
}
|
|
1416
|
+
return {};
|
|
1417
|
+
}
|
|
1418
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
1419
|
+
const coords = {
|
|
1420
|
+
x,
|
|
1421
|
+
y
|
|
1422
|
+
};
|
|
1423
|
+
const axis = getMainAxisFromPlacement(placement);
|
|
1424
|
+
const length = getLengthFromAxis(axis);
|
|
1425
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
1426
|
+
const isYAxis = axis === 'y';
|
|
1427
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
1428
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
1429
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
1430
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1431
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1432
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
1433
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
1434
|
+
|
|
1435
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
1436
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
1437
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1438
|
+
}
|
|
1439
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1440
|
+
|
|
1441
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
1442
|
+
// point is outside the floating element's bounds.
|
|
1443
|
+
const min = paddingObject[minProp];
|
|
1444
|
+
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
1445
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1446
|
+
const offset = within(min, center, max);
|
|
1447
|
+
|
|
1448
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
1449
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1450
|
+
// floating element itself. This stops `shift()` from taking action, but can
|
|
1451
|
+
// be worked around by calling it again after the `arrow()` if desired.
|
|
1452
|
+
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
|
|
1453
|
+
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
|
1454
|
+
return {
|
|
1455
|
+
[axis]: coords[axis] - alignmentOffset,
|
|
1456
|
+
data: {
|
|
1457
|
+
[axis]: offset,
|
|
1458
|
+
centerOffset: center - offset
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
|
|
1464
|
+
const oppositeSideMap = {
|
|
1465
|
+
left: 'right',
|
|
1466
|
+
right: 'left',
|
|
1467
|
+
bottom: 'top',
|
|
1468
|
+
top: 'bottom'
|
|
1469
|
+
};
|
|
1470
|
+
function getOppositePlacement(placement) {
|
|
1471
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
330
1472
|
}
|
|
331
|
-
|
|
332
|
-
function
|
|
333
|
-
|
|
1473
|
+
|
|
1474
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
1475
|
+
if (rtl === void 0) {
|
|
1476
|
+
rtl = false;
|
|
1477
|
+
}
|
|
1478
|
+
const alignment = getAlignment(placement);
|
|
1479
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
1480
|
+
const length = getLengthFromAxis(mainAxis);
|
|
1481
|
+
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
1482
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
1483
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
1484
|
+
}
|
|
1485
|
+
return {
|
|
1486
|
+
main: mainAlignmentSide,
|
|
1487
|
+
cross: getOppositePlacement(mainAlignmentSide)
|
|
1488
|
+
};
|
|
334
1489
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
1490
|
+
|
|
1491
|
+
const oppositeAlignmentMap = {
|
|
1492
|
+
start: 'end',
|
|
1493
|
+
end: 'start'
|
|
1494
|
+
};
|
|
1495
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
1496
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
function getExpandedPlacements(placement) {
|
|
1500
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
1501
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
function getSideList(side, isStart, rtl) {
|
|
1505
|
+
const lr = ['left', 'right'];
|
|
1506
|
+
const rl = ['right', 'left'];
|
|
1507
|
+
const tb = ['top', 'bottom'];
|
|
1508
|
+
const bt = ['bottom', 'top'];
|
|
1509
|
+
switch (side) {
|
|
1510
|
+
case 'top':
|
|
1511
|
+
case 'bottom':
|
|
1512
|
+
if (rtl) return isStart ? rl : lr;
|
|
1513
|
+
return isStart ? lr : rl;
|
|
1514
|
+
case 'left':
|
|
1515
|
+
case 'right':
|
|
1516
|
+
return isStart ? tb : bt;
|
|
1517
|
+
default:
|
|
1518
|
+
return [];
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
1522
|
+
const alignment = getAlignment(placement);
|
|
1523
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
1524
|
+
if (alignment) {
|
|
1525
|
+
list = list.map(side => side + "-" + alignment);
|
|
1526
|
+
if (flipAlignment) {
|
|
1527
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
364
1528
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
1529
|
+
}
|
|
1530
|
+
return list;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1535
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1536
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1537
|
+
* @see https://floating-ui.com/docs/flip
|
|
1538
|
+
*/
|
|
1539
|
+
const flip = function (options) {
|
|
1540
|
+
if (options === void 0) {
|
|
1541
|
+
options = {};
|
|
1542
|
+
}
|
|
1543
|
+
return {
|
|
1544
|
+
name: 'flip',
|
|
1545
|
+
options,
|
|
1546
|
+
async fn(state) {
|
|
1547
|
+
var _middlewareData$flip;
|
|
1548
|
+
const {
|
|
1549
|
+
placement,
|
|
1550
|
+
middlewareData,
|
|
1551
|
+
rects,
|
|
1552
|
+
initialPlacement,
|
|
1553
|
+
platform,
|
|
1554
|
+
elements
|
|
1555
|
+
} = state;
|
|
1556
|
+
const {
|
|
1557
|
+
mainAxis: checkMainAxis = true,
|
|
1558
|
+
crossAxis: checkCrossAxis = true,
|
|
1559
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1560
|
+
fallbackStrategy = 'bestFit',
|
|
1561
|
+
fallbackAxisSideDirection = 'none',
|
|
1562
|
+
flipAlignment = true,
|
|
1563
|
+
...detectOverflowOptions
|
|
1564
|
+
} = options;
|
|
1565
|
+
const side = getSide(placement);
|
|
1566
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1567
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1568
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1569
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
1570
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1571
|
+
}
|
|
1572
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1573
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1574
|
+
const overflows = [];
|
|
1575
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1576
|
+
if (checkMainAxis) {
|
|
1577
|
+
overflows.push(overflow[side]);
|
|
1578
|
+
}
|
|
1579
|
+
if (checkCrossAxis) {
|
|
1580
|
+
const {
|
|
1581
|
+
main,
|
|
1582
|
+
cross
|
|
1583
|
+
} = getAlignmentSides(placement, rects, rtl);
|
|
1584
|
+
overflows.push(overflow[main], overflow[cross]);
|
|
1585
|
+
}
|
|
1586
|
+
overflowsData = [...overflowsData, {
|
|
1587
|
+
placement,
|
|
1588
|
+
overflows
|
|
1589
|
+
}];
|
|
1590
|
+
|
|
1591
|
+
// One or more sides is overflowing.
|
|
1592
|
+
if (!overflows.every(side => side <= 0)) {
|
|
1593
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
1594
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1595
|
+
const nextPlacement = placements[nextIndex];
|
|
1596
|
+
if (nextPlacement) {
|
|
1597
|
+
// Try next placement and re-run the lifecycle.
|
|
1598
|
+
return {
|
|
1599
|
+
data: {
|
|
1600
|
+
index: nextIndex,
|
|
1601
|
+
overflows: overflowsData
|
|
1602
|
+
},
|
|
1603
|
+
reset: {
|
|
1604
|
+
placement: nextPlacement
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
1610
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
1611
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
1612
|
+
|
|
1613
|
+
// Otherwise fallback.
|
|
1614
|
+
if (!resetPlacement) {
|
|
1615
|
+
switch (fallbackStrategy) {
|
|
1616
|
+
case 'bestFit':
|
|
1617
|
+
{
|
|
1618
|
+
var _overflowsData$map$so;
|
|
1619
|
+
const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
|
|
1620
|
+
if (placement) {
|
|
1621
|
+
resetPlacement = placement;
|
|
1622
|
+
}
|
|
1623
|
+
break;
|
|
1624
|
+
}
|
|
1625
|
+
case 'initialPlacement':
|
|
1626
|
+
resetPlacement = initialPlacement;
|
|
1627
|
+
break;
|
|
378
1628
|
}
|
|
379
|
-
case "initialPlacement":
|
|
380
|
-
n3 = c3;
|
|
381
1629
|
}
|
|
382
|
-
|
|
383
|
-
|
|
1630
|
+
if (placement !== resetPlacement) {
|
|
1631
|
+
return {
|
|
1632
|
+
reset: {
|
|
1633
|
+
placement: resetPlacement
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
return {};
|
|
384
1639
|
}
|
|
385
|
-
|
|
386
|
-
} };
|
|
387
|
-
};
|
|
388
|
-
var O = function(e2) {
|
|
389
|
-
return void 0 === e2 && (e2 = 0), { name: "offset", options: e2, async fn(i3) {
|
|
390
|
-
const { x: r3, y: a3 } = i3, l3 = await async function(e3, i4) {
|
|
391
|
-
const { placement: r4, platform: a4, elements: l4 } = e3, s3 = await (null == a4.isRTL ? void 0 : a4.isRTL(l4.floating)), c3 = n(r4), f3 = t(r4), m3 = "x" === o(r4), u3 = ["left", "top"].includes(c3) ? -1 : 1, g3 = s3 && m3 ? -1 : 1, d3 = "function" == typeof i4 ? i4(e3) : i4;
|
|
392
|
-
let { mainAxis: p3, crossAxis: h3, alignmentAxis: y3 } = "number" == typeof d3 ? { mainAxis: d3, crossAxis: 0, alignmentAxis: null } : { mainAxis: 0, crossAxis: 0, alignmentAxis: null, ...d3 };
|
|
393
|
-
return f3 && "number" == typeof y3 && (h3 = "end" === f3 ? -1 * y3 : y3), m3 ? { x: h3 * g3, y: p3 * u3 } : { x: p3 * u3, y: h3 * g3 };
|
|
394
|
-
}(i3, e2);
|
|
395
|
-
return { x: r3 + l3.x, y: a3 + l3.y, data: l3 };
|
|
396
|
-
} };
|
|
1640
|
+
};
|
|
397
1641
|
};
|
|
398
|
-
|
|
399
|
-
|
|
1642
|
+
|
|
1643
|
+
async function convertValueToCoords(state, value) {
|
|
1644
|
+
const {
|
|
1645
|
+
placement,
|
|
1646
|
+
platform,
|
|
1647
|
+
elements
|
|
1648
|
+
} = state;
|
|
1649
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1650
|
+
const side = getSide(placement);
|
|
1651
|
+
const alignment = getAlignment(placement);
|
|
1652
|
+
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
1653
|
+
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
1654
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1655
|
+
const rawValue = typeof value === 'function' ? value(state) : value;
|
|
1656
|
+
|
|
1657
|
+
// eslint-disable-next-line prefer-const
|
|
1658
|
+
let {
|
|
1659
|
+
mainAxis,
|
|
1660
|
+
crossAxis,
|
|
1661
|
+
alignmentAxis
|
|
1662
|
+
} = typeof rawValue === 'number' ? {
|
|
1663
|
+
mainAxis: rawValue,
|
|
1664
|
+
crossAxis: 0,
|
|
1665
|
+
alignmentAxis: null
|
|
1666
|
+
} : {
|
|
1667
|
+
mainAxis: 0,
|
|
1668
|
+
crossAxis: 0,
|
|
1669
|
+
alignmentAxis: null,
|
|
1670
|
+
...rawValue
|
|
1671
|
+
};
|
|
1672
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
1673
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1674
|
+
}
|
|
1675
|
+
return isVertical ? {
|
|
1676
|
+
x: crossAxis * crossAxisMulti,
|
|
1677
|
+
y: mainAxis * mainAxisMulti
|
|
1678
|
+
} : {
|
|
1679
|
+
x: mainAxis * mainAxisMulti,
|
|
1680
|
+
y: crossAxis * crossAxisMulti
|
|
1681
|
+
};
|
|
400
1682
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Modifies the placement by translating the floating element along the
|
|
1686
|
+
* specified axes.
|
|
1687
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1688
|
+
* object may be passed.
|
|
1689
|
+
* @see https://floating-ui.com/docs/offset
|
|
1690
|
+
*/
|
|
1691
|
+
const offset = function (value) {
|
|
1692
|
+
if (value === void 0) {
|
|
1693
|
+
value = 0;
|
|
1694
|
+
}
|
|
1695
|
+
return {
|
|
1696
|
+
name: 'offset',
|
|
1697
|
+
options: value,
|
|
1698
|
+
async fn(state) {
|
|
1699
|
+
const {
|
|
1700
|
+
x,
|
|
1701
|
+
y
|
|
1702
|
+
} = state;
|
|
1703
|
+
const diffCoords = await convertValueToCoords(state, value);
|
|
1704
|
+
return {
|
|
1705
|
+
x: x + diffCoords.x,
|
|
1706
|
+
y: y + diffCoords.y,
|
|
1707
|
+
data: diffCoords
|
|
1708
|
+
};
|
|
411
1709
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
1710
|
+
};
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
function getCrossAxis(axis) {
|
|
1714
|
+
return axis === 'x' ? 'y' : 'x';
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1719
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1720
|
+
* @see https://floating-ui.com/docs/shift
|
|
1721
|
+
*/
|
|
1722
|
+
const shift = function (options) {
|
|
1723
|
+
if (options === void 0) {
|
|
1724
|
+
options = {};
|
|
1725
|
+
}
|
|
1726
|
+
return {
|
|
1727
|
+
name: 'shift',
|
|
1728
|
+
options,
|
|
1729
|
+
async fn(state) {
|
|
1730
|
+
const {
|
|
1731
|
+
x,
|
|
1732
|
+
y,
|
|
1733
|
+
placement
|
|
1734
|
+
} = state;
|
|
1735
|
+
const {
|
|
1736
|
+
mainAxis: checkMainAxis = true,
|
|
1737
|
+
crossAxis: checkCrossAxis = false,
|
|
1738
|
+
limiter = {
|
|
1739
|
+
fn: _ref => {
|
|
1740
|
+
let {
|
|
1741
|
+
x,
|
|
1742
|
+
y
|
|
1743
|
+
} = _ref;
|
|
1744
|
+
return {
|
|
1745
|
+
x,
|
|
1746
|
+
y
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
...detectOverflowOptions
|
|
1751
|
+
} = options;
|
|
1752
|
+
const coords = {
|
|
1753
|
+
x,
|
|
1754
|
+
y
|
|
1755
|
+
};
|
|
1756
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1757
|
+
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
1758
|
+
const crossAxis = getCrossAxis(mainAxis);
|
|
1759
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1760
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1761
|
+
if (checkMainAxis) {
|
|
1762
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
1763
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1764
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
1765
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
1766
|
+
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
1767
|
+
}
|
|
1768
|
+
if (checkCrossAxis) {
|
|
1769
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1770
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1771
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
1772
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
1773
|
+
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
1774
|
+
}
|
|
1775
|
+
const limitedCoords = limiter.fn({
|
|
1776
|
+
...state,
|
|
1777
|
+
[mainAxis]: mainAxisCoord,
|
|
1778
|
+
[crossAxis]: crossAxisCoord
|
|
1779
|
+
});
|
|
1780
|
+
return {
|
|
1781
|
+
...limitedCoords,
|
|
1782
|
+
data: {
|
|
1783
|
+
x: limitedCoords.x - x,
|
|
1784
|
+
y: limitedCoords.y - y
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
415
1787
|
}
|
|
416
|
-
|
|
417
|
-
return { ...w3, data: { x: w3.x - i3, y: w3.y - r3 } };
|
|
418
|
-
} };
|
|
1788
|
+
};
|
|
419
1789
|
};
|
|
420
1790
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return (null == (e2 = t2.ownerDocument) ? void 0 : e2.defaultView) || window;
|
|
1791
|
+
function getWindow(node) {
|
|
1792
|
+
var _node$ownerDocument;
|
|
1793
|
+
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
425
1794
|
}
|
|
426
|
-
|
|
427
|
-
|
|
1795
|
+
|
|
1796
|
+
function getComputedStyle$1(element) {
|
|
1797
|
+
return getWindow(element).getComputedStyle(element);
|
|
428
1798
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
|
|
1799
|
+
|
|
1800
|
+
const min = Math.min;
|
|
1801
|
+
const max = Math.max;
|
|
1802
|
+
const round = Math.round;
|
|
1803
|
+
|
|
1804
|
+
function getCssDimensions(element) {
|
|
1805
|
+
const css = getComputedStyle$1(element);
|
|
1806
|
+
let width = parseFloat(css.width);
|
|
1807
|
+
let height = parseFloat(css.height);
|
|
1808
|
+
const offsetWidth = element.offsetWidth;
|
|
1809
|
+
const offsetHeight = element.offsetHeight;
|
|
1810
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1811
|
+
if (shouldFallback) {
|
|
1812
|
+
width = offsetWidth;
|
|
1813
|
+
height = offsetHeight;
|
|
1814
|
+
}
|
|
1815
|
+
return {
|
|
1816
|
+
width,
|
|
1817
|
+
height,
|
|
1818
|
+
fallback: shouldFallback
|
|
1819
|
+
};
|
|
437
1820
|
}
|
|
438
|
-
|
|
439
|
-
|
|
1821
|
+
|
|
1822
|
+
function getNodeName(node) {
|
|
1823
|
+
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
440
1824
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
1825
|
+
|
|
1826
|
+
let uaString;
|
|
1827
|
+
function getUAString() {
|
|
1828
|
+
if (uaString) {
|
|
1829
|
+
return uaString;
|
|
1830
|
+
}
|
|
1831
|
+
const uaData = navigator.userAgentData;
|
|
1832
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
1833
|
+
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
1834
|
+
return uaString;
|
|
1835
|
+
}
|
|
1836
|
+
return navigator.userAgent;
|
|
447
1837
|
}
|
|
448
|
-
|
|
449
|
-
|
|
1838
|
+
|
|
1839
|
+
function isHTMLElement(value) {
|
|
1840
|
+
return value instanceof getWindow(value).HTMLElement;
|
|
450
1841
|
}
|
|
451
|
-
function
|
|
452
|
-
return
|
|
1842
|
+
function isElement(value) {
|
|
1843
|
+
return value instanceof getWindow(value).Element;
|
|
453
1844
|
}
|
|
454
|
-
function
|
|
455
|
-
return
|
|
1845
|
+
function isNode(value) {
|
|
1846
|
+
return value instanceof getWindow(value).Node;
|
|
456
1847
|
}
|
|
457
|
-
function
|
|
458
|
-
|
|
1848
|
+
function isShadowRoot(node) {
|
|
1849
|
+
// Browsers without `ShadowRoot` support.
|
|
1850
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
459
1851
|
return false;
|
|
460
|
-
|
|
1852
|
+
}
|
|
1853
|
+
const OwnElement = getWindow(node).ShadowRoot;
|
|
1854
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
1855
|
+
}
|
|
1856
|
+
function isOverflowElement(element) {
|
|
1857
|
+
const {
|
|
1858
|
+
overflow,
|
|
1859
|
+
overflowX,
|
|
1860
|
+
overflowY,
|
|
1861
|
+
display
|
|
1862
|
+
} = getComputedStyle$1(element);
|
|
1863
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
1864
|
+
}
|
|
1865
|
+
function isTableElement(element) {
|
|
1866
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
1867
|
+
}
|
|
1868
|
+
function isContainingBlock(element) {
|
|
1869
|
+
// TODO: Try to use feature detection here instead.
|
|
1870
|
+
const isFirefox = /firefox/i.test(getUAString());
|
|
1871
|
+
const css = getComputedStyle$1(element);
|
|
1872
|
+
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
1873
|
+
|
|
1874
|
+
// This is non-exhaustive but covers the most common CSS properties that
|
|
1875
|
+
// create a containing block.
|
|
1876
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1877
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
|
|
1878
|
+
// Add type check for old browsers.
|
|
1879
|
+
const contain = css.contain;
|
|
1880
|
+
return contain != null ? contain.includes(value) : false;
|
|
1881
|
+
});
|
|
461
1882
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* Determines whether or not `.getBoundingClientRect()` is affected by visual
|
|
1886
|
+
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
|
|
1887
|
+
* visual viewport, while in other engines, they are values relative to the
|
|
1888
|
+
* layout viewport.
|
|
1889
|
+
*/
|
|
1890
|
+
function isClientRectVisualViewportBased() {
|
|
1891
|
+
// TODO: Try to use feature detection here instead. Feature detection for
|
|
1892
|
+
// this can fail in various ways, making the userAgent check the most
|
|
1893
|
+
// reliable:
|
|
1894
|
+
// • Always-visible scrollbar or not
|
|
1895
|
+
// • Width of <html>
|
|
1896
|
+
|
|
1897
|
+
// Is Safari.
|
|
1898
|
+
return /^((?!chrome|android).)*safari/i.test(getUAString());
|
|
1899
|
+
}
|
|
1900
|
+
function isLastTraversableNode(node) {
|
|
1901
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
465
1902
|
}
|
|
466
|
-
|
|
467
|
-
|
|
1903
|
+
|
|
1904
|
+
function unwrapElement(element) {
|
|
1905
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
const FALLBACK_SCALE = {
|
|
1909
|
+
x: 1,
|
|
1910
|
+
y: 1
|
|
1911
|
+
};
|
|
1912
|
+
function getScale(element) {
|
|
1913
|
+
const domElement = unwrapElement(element);
|
|
1914
|
+
if (!isHTMLElement(domElement)) {
|
|
1915
|
+
return FALLBACK_SCALE;
|
|
1916
|
+
}
|
|
1917
|
+
const rect = domElement.getBoundingClientRect();
|
|
1918
|
+
const {
|
|
1919
|
+
width,
|
|
1920
|
+
height,
|
|
1921
|
+
fallback
|
|
1922
|
+
} = getCssDimensions(domElement);
|
|
1923
|
+
let x = (fallback ? round(rect.width) : rect.width) / width;
|
|
1924
|
+
let y = (fallback ? round(rect.height) : rect.height) / height;
|
|
1925
|
+
|
|
1926
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
1927
|
+
|
|
1928
|
+
if (!x || !Number.isFinite(x)) {
|
|
1929
|
+
x = 1;
|
|
1930
|
+
}
|
|
1931
|
+
if (!y || !Number.isFinite(y)) {
|
|
1932
|
+
y = 1;
|
|
1933
|
+
}
|
|
1934
|
+
return {
|
|
1935
|
+
x,
|
|
1936
|
+
y
|
|
1937
|
+
};
|
|
468
1938
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
1939
|
+
|
|
1940
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1941
|
+
var _win$visualViewport, _win$visualViewport2;
|
|
1942
|
+
if (includeScale === void 0) {
|
|
1943
|
+
includeScale = false;
|
|
1944
|
+
}
|
|
1945
|
+
if (isFixedStrategy === void 0) {
|
|
1946
|
+
isFixedStrategy = false;
|
|
1947
|
+
}
|
|
1948
|
+
const clientRect = element.getBoundingClientRect();
|
|
1949
|
+
const domElement = unwrapElement(element);
|
|
1950
|
+
let scale = FALLBACK_SCALE;
|
|
1951
|
+
if (includeScale) {
|
|
1952
|
+
if (offsetParent) {
|
|
1953
|
+
if (isElement(offsetParent)) {
|
|
1954
|
+
scale = getScale(offsetParent);
|
|
1955
|
+
}
|
|
1956
|
+
} else {
|
|
1957
|
+
scale = getScale(element);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
const win = domElement ? getWindow(domElement) : window;
|
|
1961
|
+
const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
|
|
1962
|
+
let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
|
|
1963
|
+
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
1964
|
+
let width = clientRect.width / scale.x;
|
|
1965
|
+
let height = clientRect.height / scale.y;
|
|
1966
|
+
if (domElement) {
|
|
1967
|
+
const win = getWindow(domElement);
|
|
1968
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1969
|
+
let currentIFrame = win.frameElement;
|
|
1970
|
+
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
1971
|
+
const iframeScale = getScale(currentIFrame);
|
|
1972
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1973
|
+
const css = getComputedStyle(currentIFrame);
|
|
1974
|
+
iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1975
|
+
iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1976
|
+
x *= iframeScale.x;
|
|
1977
|
+
y *= iframeScale.y;
|
|
1978
|
+
width *= iframeScale.x;
|
|
1979
|
+
height *= iframeScale.y;
|
|
1980
|
+
x += iframeRect.x;
|
|
1981
|
+
y += iframeRect.y;
|
|
1982
|
+
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
return rectToClientRect({
|
|
1986
|
+
width,
|
|
1987
|
+
height,
|
|
1988
|
+
x,
|
|
1989
|
+
y
|
|
474
1990
|
});
|
|
475
1991
|
}
|
|
476
|
-
|
|
477
|
-
|
|
1992
|
+
|
|
1993
|
+
function getDocumentElement(node) {
|
|
1994
|
+
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
478
1995
|
}
|
|
479
|
-
|
|
480
|
-
|
|
1996
|
+
|
|
1997
|
+
function getNodeScroll(element) {
|
|
1998
|
+
if (isElement(element)) {
|
|
1999
|
+
return {
|
|
2000
|
+
scrollLeft: element.scrollLeft,
|
|
2001
|
+
scrollTop: element.scrollTop
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
return {
|
|
2005
|
+
scrollLeft: element.pageXOffset,
|
|
2006
|
+
scrollTop: element.pageYOffset
|
|
2007
|
+
};
|
|
481
2008
|
}
|
|
482
|
-
|
|
483
|
-
|
|
2009
|
+
|
|
2010
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2011
|
+
let {
|
|
2012
|
+
rect,
|
|
2013
|
+
offsetParent,
|
|
2014
|
+
strategy
|
|
2015
|
+
} = _ref;
|
|
2016
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2017
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2018
|
+
if (offsetParent === documentElement) {
|
|
2019
|
+
return rect;
|
|
2020
|
+
}
|
|
2021
|
+
let scroll = {
|
|
2022
|
+
scrollLeft: 0,
|
|
2023
|
+
scrollTop: 0
|
|
2024
|
+
};
|
|
2025
|
+
let scale = {
|
|
2026
|
+
x: 1,
|
|
2027
|
+
y: 1
|
|
2028
|
+
};
|
|
2029
|
+
const offsets = {
|
|
2030
|
+
x: 0,
|
|
2031
|
+
y: 0
|
|
2032
|
+
};
|
|
2033
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
2034
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2035
|
+
scroll = getNodeScroll(offsetParent);
|
|
2036
|
+
}
|
|
2037
|
+
if (isHTMLElement(offsetParent)) {
|
|
2038
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2039
|
+
scale = getScale(offsetParent);
|
|
2040
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2041
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
return {
|
|
2045
|
+
width: rect.width * scale.x,
|
|
2046
|
+
height: rect.height * scale.y,
|
|
2047
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
2048
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
2049
|
+
};
|
|
484
2050
|
}
|
|
485
|
-
|
|
486
|
-
function
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const n3 = e2.getBoundingClientRect(), { width: o3, height: i3, fallback: r3 } = c2(e2);
|
|
491
|
-
let s3 = (r3 ? l2(n3.width) : n3.width) / o3, f3 = (r3 ? l2(n3.height) : n3.height) / i3;
|
|
492
|
-
return s3 && Number.isFinite(s3) || (s3 = 1), f3 && Number.isFinite(f3) || (f3 = 1), { x: s3, y: f3 };
|
|
2051
|
+
|
|
2052
|
+
function getWindowScrollBarX(element) {
|
|
2053
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2054
|
+
// incorrect for RTL.
|
|
2055
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
493
2056
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
e4.x += (o4.clientLeft + parseFloat(i4.paddingLeft)) * t3.x, e4.y += (o4.clientTop + parseFloat(i4.paddingTop)) * t3.y, p3 *= t3.x, g3 *= t3.y, m3 *= t3.x, y3 *= t3.y, p3 += e4.x, g3 += e4.y, o4 = n2(o4).frameElement;
|
|
508
|
-
}
|
|
2057
|
+
|
|
2058
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
2059
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
2060
|
+
function getDocumentRect(element) {
|
|
2061
|
+
const html = getDocumentElement(element);
|
|
2062
|
+
const scroll = getNodeScroll(element);
|
|
2063
|
+
const body = element.ownerDocument.body;
|
|
2064
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
2065
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2066
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2067
|
+
const y = -scroll.scrollTop;
|
|
2068
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
2069
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
509
2070
|
}
|
|
510
|
-
return
|
|
2071
|
+
return {
|
|
2072
|
+
width,
|
|
2073
|
+
height,
|
|
2074
|
+
x,
|
|
2075
|
+
y
|
|
2076
|
+
};
|
|
511
2077
|
}
|
|
512
|
-
|
|
513
|
-
|
|
2078
|
+
|
|
2079
|
+
function getParentNode(node) {
|
|
2080
|
+
if (getNodeName(node) === 'html') {
|
|
2081
|
+
return node;
|
|
2082
|
+
}
|
|
2083
|
+
const result =
|
|
2084
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
2085
|
+
node.assignedSlot ||
|
|
2086
|
+
// DOM Element detected.
|
|
2087
|
+
node.parentNode ||
|
|
2088
|
+
// ShadowRoot detected.
|
|
2089
|
+
isShadowRoot(node) && node.host ||
|
|
2090
|
+
// Fallback.
|
|
2091
|
+
getDocumentElement(node);
|
|
2092
|
+
return isShadowRoot(result) ? result.host : result;
|
|
514
2093
|
}
|
|
515
|
-
|
|
516
|
-
|
|
2094
|
+
|
|
2095
|
+
function getNearestOverflowAncestor(node) {
|
|
2096
|
+
const parentNode = getParentNode(node);
|
|
2097
|
+
if (isLastTraversableNode(parentNode)) {
|
|
2098
|
+
// `getParentNode` will never return a `Document` due to the fallback
|
|
2099
|
+
// check, so it's either the <html> or <body> element.
|
|
2100
|
+
return parentNode.ownerDocument.body;
|
|
2101
|
+
}
|
|
2102
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
2103
|
+
return parentNode;
|
|
2104
|
+
}
|
|
2105
|
+
return getNearestOverflowAncestor(parentNode);
|
|
517
2106
|
}
|
|
518
|
-
|
|
519
|
-
|
|
2107
|
+
|
|
2108
|
+
function getOverflowAncestors(node, list) {
|
|
2109
|
+
var _node$ownerDocument;
|
|
2110
|
+
if (list === void 0) {
|
|
2111
|
+
list = [];
|
|
2112
|
+
}
|
|
2113
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
2114
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
2115
|
+
const win = getWindow(scrollableAncestor);
|
|
2116
|
+
if (isBody) {
|
|
2117
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
2118
|
+
}
|
|
2119
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
520
2120
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const
|
|
525
|
-
|
|
2121
|
+
|
|
2122
|
+
function getViewportRect(element, strategy) {
|
|
2123
|
+
const win = getWindow(element);
|
|
2124
|
+
const html = getDocumentElement(element);
|
|
2125
|
+
const visualViewport = win.visualViewport;
|
|
2126
|
+
let width = html.clientWidth;
|
|
2127
|
+
let height = html.clientHeight;
|
|
2128
|
+
let x = 0;
|
|
2129
|
+
let y = 0;
|
|
2130
|
+
if (visualViewport) {
|
|
2131
|
+
width = visualViewport.width;
|
|
2132
|
+
height = visualViewport.height;
|
|
2133
|
+
const visualViewportBased = isClientRectVisualViewportBased();
|
|
2134
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
2135
|
+
x = visualViewport.offsetLeft;
|
|
2136
|
+
y = visualViewport.offsetTop;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
return {
|
|
2140
|
+
width,
|
|
2141
|
+
height,
|
|
2142
|
+
x,
|
|
2143
|
+
y
|
|
2144
|
+
};
|
|
526
2145
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
2146
|
+
|
|
2147
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
2148
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
2149
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
2150
|
+
const top = clientRect.top + element.clientTop;
|
|
2151
|
+
const left = clientRect.left + element.clientLeft;
|
|
2152
|
+
const scale = isHTMLElement(element) ? getScale(element) : {
|
|
2153
|
+
x: 1,
|
|
2154
|
+
y: 1
|
|
2155
|
+
};
|
|
2156
|
+
const width = element.clientWidth * scale.x;
|
|
2157
|
+
const height = element.clientHeight * scale.y;
|
|
2158
|
+
const x = left * scale.x;
|
|
2159
|
+
const y = top * scale.y;
|
|
2160
|
+
return {
|
|
2161
|
+
width,
|
|
2162
|
+
height,
|
|
2163
|
+
x,
|
|
2164
|
+
y
|
|
2165
|
+
};
|
|
530
2166
|
}
|
|
531
|
-
function
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
2167
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
2168
|
+
let rect;
|
|
2169
|
+
if (clippingAncestor === 'viewport') {
|
|
2170
|
+
rect = getViewportRect(element, strategy);
|
|
2171
|
+
} else if (clippingAncestor === 'document') {
|
|
2172
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
2173
|
+
} else if (isElement(clippingAncestor)) {
|
|
2174
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
2175
|
+
} else {
|
|
2176
|
+
const mutableRect = {
|
|
2177
|
+
...clippingAncestor
|
|
2178
|
+
};
|
|
2179
|
+
if (isClientRectVisualViewportBased()) {
|
|
2180
|
+
var _win$visualViewport, _win$visualViewport2;
|
|
2181
|
+
const win = getWindow(element);
|
|
2182
|
+
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
2183
|
+
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
2184
|
+
}
|
|
2185
|
+
rect = mutableRect;
|
|
2186
|
+
}
|
|
2187
|
+
return rectToClientRect(rect);
|
|
536
2188
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
2189
|
+
|
|
2190
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
2191
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
2192
|
+
// of the given element up the tree.
|
|
2193
|
+
function getClippingElementAncestors(element, cache) {
|
|
2194
|
+
const cachedResult = cache.get(element);
|
|
2195
|
+
if (cachedResult) {
|
|
2196
|
+
return cachedResult;
|
|
2197
|
+
}
|
|
2198
|
+
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
2199
|
+
let currentContainingBlockComputedStyle = null;
|
|
2200
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
2201
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
2202
|
+
|
|
2203
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2204
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2205
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
2206
|
+
const containingBlock = isContainingBlock(currentNode);
|
|
2207
|
+
const shouldIgnoreCurrentNode = computedStyle.position === 'fixed';
|
|
2208
|
+
if (shouldIgnoreCurrentNode) {
|
|
2209
|
+
currentContainingBlockComputedStyle = null;
|
|
2210
|
+
} else {
|
|
2211
|
+
const shouldDropCurrentNode = elementIsFixed ? !containingBlock && !currentContainingBlockComputedStyle : !containingBlock && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position);
|
|
2212
|
+
if (shouldDropCurrentNode) {
|
|
2213
|
+
// Drop non-containing blocks.
|
|
2214
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
2215
|
+
} else {
|
|
2216
|
+
// Record last containing block for next iteration.
|
|
2217
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
547
2218
|
}
|
|
548
|
-
return { width: l4, height: c4, x: s4, y: f4 };
|
|
549
|
-
}(e2, l3);
|
|
550
|
-
else if ("document" === i3)
|
|
551
|
-
c3 = function(t2) {
|
|
552
|
-
const e3 = R(t2), n3 = T2(t2), i4 = t2.ownerDocument.body, l4 = r2(e3.scrollWidth, e3.clientWidth, i4.scrollWidth, i4.clientWidth), c4 = r2(e3.scrollHeight, e3.clientHeight, i4.scrollHeight, i4.clientHeight);
|
|
553
|
-
let s4 = -n3.scrollLeft + C(t2);
|
|
554
|
-
const f4 = -n3.scrollTop;
|
|
555
|
-
return "rtl" === o2(i4).direction && (s4 += r2(e3.clientWidth, i4.clientWidth) - l4), { width: l4, height: c4, x: s4, y: f4 };
|
|
556
|
-
}(R(e2));
|
|
557
|
-
else if (d2(i3))
|
|
558
|
-
c3 = function(t2, e3) {
|
|
559
|
-
const n3 = E2(t2, true, "fixed" === e3), o3 = n3.top + t2.clientTop, i4 = n3.left + t2.clientLeft, r3 = a2(t2) ? L2(t2) : { x: 1, y: 1 };
|
|
560
|
-
return { width: t2.clientWidth * r3.x, height: t2.clientHeight * r3.y, x: i4 * r3.x, y: o3 * r3.y };
|
|
561
|
-
}(i3, l3);
|
|
562
|
-
else {
|
|
563
|
-
const t2 = { ...i3 };
|
|
564
|
-
if (x2()) {
|
|
565
|
-
var s3, f3;
|
|
566
|
-
const o3 = n2(e2);
|
|
567
|
-
t2.x -= (null == (s3 = o3.visualViewport) ? void 0 : s3.offsetLeft) || 0, t2.y -= (null == (f3 = o3.visualViewport) ? void 0 : f3.offsetTop) || 0;
|
|
568
2219
|
}
|
|
569
|
-
|
|
2220
|
+
currentNode = getParentNode(currentNode);
|
|
570
2221
|
}
|
|
571
|
-
|
|
2222
|
+
cache.set(element, result);
|
|
2223
|
+
return result;
|
|
572
2224
|
}
|
|
573
|
-
|
|
574
|
-
|
|
2225
|
+
|
|
2226
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
2227
|
+
// clipping ancestors.
|
|
2228
|
+
function getClippingRect(_ref) {
|
|
2229
|
+
let {
|
|
2230
|
+
element,
|
|
2231
|
+
boundary,
|
|
2232
|
+
rootBoundary,
|
|
2233
|
+
strategy
|
|
2234
|
+
} = _ref;
|
|
2235
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2236
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2237
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
2238
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
2239
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
2240
|
+
accRect.top = max(rect.top, accRect.top);
|
|
2241
|
+
accRect.right = min(rect.right, accRect.right);
|
|
2242
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
2243
|
+
accRect.left = max(rect.left, accRect.left);
|
|
2244
|
+
return accRect;
|
|
2245
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
2246
|
+
return {
|
|
2247
|
+
width: clippingRect.right - clippingRect.left,
|
|
2248
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
2249
|
+
x: clippingRect.left,
|
|
2250
|
+
y: clippingRect.top
|
|
2251
|
+
};
|
|
575
2252
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (
|
|
579
|
-
return
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
r3 = A(r3, e2);
|
|
583
|
-
return r3 && ("html" === s2(r3) || "body" === s2(r3) && "static" === o2(r3).position && !y2(r3)) ? i3 : r3 || function(t3) {
|
|
584
|
-
let e3 = F(t3);
|
|
585
|
-
for (; a2(e3) && !w2(e3); ) {
|
|
586
|
-
if (y2(e3))
|
|
587
|
-
return e3;
|
|
588
|
-
e3 = F(e3);
|
|
589
|
-
}
|
|
590
|
-
return null;
|
|
591
|
-
}(t2) || i3;
|
|
2253
|
+
|
|
2254
|
+
function getDimensions(element) {
|
|
2255
|
+
if (isHTMLElement(element)) {
|
|
2256
|
+
return getCssDimensions(element);
|
|
2257
|
+
}
|
|
2258
|
+
return element.getBoundingClientRect();
|
|
592
2259
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
i3 && (c3.x = C(i3));
|
|
603
|
-
return { x: r3.left + l3.scrollLeft - c3.x, y: r3.top + l3.scrollTop - c3.y, width: r3.width, height: r3.height };
|
|
2260
|
+
|
|
2261
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
2262
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
2263
|
+
return null;
|
|
2264
|
+
}
|
|
2265
|
+
if (polyfill) {
|
|
2266
|
+
return polyfill(element);
|
|
2267
|
+
}
|
|
2268
|
+
return element.offsetParent;
|
|
604
2269
|
}
|
|
605
|
-
|
|
606
|
-
let
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
const l4 = "fixed" === o2(t3).position;
|
|
613
|
-
let c4 = l4 ? F(t3) : t3;
|
|
614
|
-
for (; d2(c4) && !w2(c4); ) {
|
|
615
|
-
const t4 = o2(c4), e4 = y2(c4);
|
|
616
|
-
"fixed" === t4.position ? r3 = null : (l4 ? e4 || r3 : e4 || "static" !== t4.position || !r3 || !["absolute", "fixed"].includes(r3.position)) ? r3 = t4 : i3 = i3.filter((t5) => t5 !== c4), c4 = F(c4);
|
|
2270
|
+
function getContainingBlock(element) {
|
|
2271
|
+
let currentNode = getParentNode(element);
|
|
2272
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2273
|
+
if (isContainingBlock(currentNode)) {
|
|
2274
|
+
return currentNode;
|
|
2275
|
+
} else {
|
|
2276
|
+
currentNode = getParentNode(currentNode);
|
|
617
2277
|
}
|
|
618
|
-
return e3.set(t3, i3), i3;
|
|
619
|
-
}(e2, this._c) : [].concat(n3), u3 = [...f3, l3], a3 = u3[0], h3 = u3.reduce((t3, n4) => {
|
|
620
|
-
const o3 = S(e2, n4, c3);
|
|
621
|
-
return t3.top = r2(o3.top, t3.top), t3.right = i2(o3.right, t3.right), t3.bottom = i2(o3.bottom, t3.bottom), t3.left = r2(o3.left, t3.left), t3;
|
|
622
|
-
}, S(e2, a3, c3));
|
|
623
|
-
return { width: h3.right - h3.left, height: h3.bottom - h3.top, x: h3.left, y: h3.top };
|
|
624
|
-
}, convertOffsetParentRelativeRectToViewportRelativeRect: function(t2) {
|
|
625
|
-
let { rect: e2, offsetParent: n3, strategy: o3 } = t2;
|
|
626
|
-
const i3 = a2(n3), r3 = R(n3);
|
|
627
|
-
if (n3 === r3)
|
|
628
|
-
return e2;
|
|
629
|
-
let l3 = { scrollLeft: 0, scrollTop: 0 }, c3 = { x: 1, y: 1 };
|
|
630
|
-
const f3 = { x: 0, y: 0 };
|
|
631
|
-
if ((i3 || !i3 && "fixed" !== o3) && (("body" !== s2(n3) || g2(r3)) && (l3 = T2(n3)), a2(n3))) {
|
|
632
|
-
const t3 = E2(n3);
|
|
633
|
-
c3 = L2(n3), f3.x = t3.x + n3.clientLeft, f3.y = t3.y + n3.clientTop;
|
|
634
2278
|
}
|
|
635
|
-
return
|
|
636
|
-
}
|
|
637
|
-
return a2(t2) ? c2(t2) : t2.getBoundingClientRect();
|
|
638
|
-
}, getOffsetParent: H, getDocumentElement: R, getScale: L2, async getElementRects(t2) {
|
|
639
|
-
let { reference: e2, floating: n3, strategy: o3 } = t2;
|
|
640
|
-
const i3 = this.getOffsetParent || H, r3 = this.getDimensions;
|
|
641
|
-
return { reference: V(e2, await i3(n3), o3), floating: { x: 0, y: 0, ...await r3(n3) } };
|
|
642
|
-
}, getClientRects: (t2) => Array.from(t2.getClientRects()), isRTL: (t2) => "rtl" === o2(t2).direction };
|
|
643
|
-
var z = (t2, n3, o3) => {
|
|
644
|
-
const i3 = /* @__PURE__ */ new Map(), r3 = { platform: O2, ...o3 }, l3 = { ...r3.platform, _c: i3 };
|
|
645
|
-
return r(t2, n3, { ...r3, platform: l3 });
|
|
646
|
-
};
|
|
2279
|
+
return null;
|
|
2280
|
+
}
|
|
647
2281
|
|
|
648
|
-
//
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
offset: offsetValue = 10,
|
|
655
|
-
strategy = "absolute",
|
|
656
|
-
middlewares = [O(Number(offsetValue)), b(), D({ padding: 5 })]
|
|
657
|
-
}) => {
|
|
658
|
-
if (!elementReference) {
|
|
659
|
-
return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
|
|
2282
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2283
|
+
// such as table ancestors and cross browser bugs.
|
|
2284
|
+
function getOffsetParent(element, polyfill) {
|
|
2285
|
+
const window = getWindow(element);
|
|
2286
|
+
if (!isHTMLElement(element)) {
|
|
2287
|
+
return window;
|
|
660
2288
|
}
|
|
661
|
-
|
|
662
|
-
|
|
2289
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
2290
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
|
|
2291
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
663
2292
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
middleware.push(u({ element: tooltipArrowReference, padding: 5 }));
|
|
667
|
-
return z(elementReference, tooltipReference, {
|
|
668
|
-
placement: place,
|
|
669
|
-
strategy,
|
|
670
|
-
middleware
|
|
671
|
-
}).then(({ x: x3, y: y3, placement, middlewareData }) => {
|
|
672
|
-
var _a, _b;
|
|
673
|
-
const styles = { left: `${x3}px`, top: `${y3}px` };
|
|
674
|
-
const { x: arrowX, y: arrowY } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
|
|
675
|
-
const staticSide = (_b = {
|
|
676
|
-
top: "bottom",
|
|
677
|
-
right: "left",
|
|
678
|
-
bottom: "top",
|
|
679
|
-
left: "right"
|
|
680
|
-
}[placement.split("-")[0]]) != null ? _b : "bottom";
|
|
681
|
-
const arrowStyle = {
|
|
682
|
-
left: arrowX != null ? `${arrowX}px` : "",
|
|
683
|
-
top: arrowY != null ? `${arrowY}px` : "",
|
|
684
|
-
right: "",
|
|
685
|
-
bottom: "",
|
|
686
|
-
[staticSide]: "-4px"
|
|
687
|
-
};
|
|
688
|
-
return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
|
|
689
|
-
});
|
|
2293
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
2294
|
+
return window;
|
|
690
2295
|
}
|
|
691
|
-
return
|
|
692
|
-
|
|
693
|
-
strategy,
|
|
694
|
-
middleware
|
|
695
|
-
}).then(({ x: x3, y: y3, placement }) => {
|
|
696
|
-
const styles = { left: `${x3}px`, top: `${y3}px` };
|
|
697
|
-
return { tooltipStyles: styles, tooltipArrowStyles: {}, place: placement };
|
|
698
|
-
});
|
|
699
|
-
};
|
|
2296
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
2297
|
+
}
|
|
700
2298
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
id,
|
|
709
|
-
className,
|
|
710
|
-
classNameArrow,
|
|
711
|
-
variant = "dark",
|
|
712
|
-
anchorId,
|
|
713
|
-
anchorSelect,
|
|
714
|
-
place = "top",
|
|
715
|
-
offset = 10,
|
|
716
|
-
events = ["hover"],
|
|
717
|
-
openOnClick = false,
|
|
718
|
-
positionStrategy = "absolute",
|
|
719
|
-
middlewares,
|
|
720
|
-
wrapper: WrapperElement,
|
|
721
|
-
delayShow = 0,
|
|
722
|
-
delayHide = 0,
|
|
723
|
-
float = false,
|
|
724
|
-
noArrow = false,
|
|
725
|
-
clickable = false,
|
|
726
|
-
closeOnEsc = false,
|
|
727
|
-
style: externalStyles,
|
|
728
|
-
position,
|
|
729
|
-
afterShow,
|
|
730
|
-
afterHide,
|
|
731
|
-
// props handled by controller
|
|
732
|
-
content,
|
|
733
|
-
isOpen,
|
|
734
|
-
setIsOpen,
|
|
735
|
-
activeAnchor,
|
|
736
|
-
setActiveAnchor
|
|
737
|
-
}) => {
|
|
738
|
-
const tooltipRef = useRef2(null);
|
|
739
|
-
const tooltipArrowRef = useRef2(null);
|
|
740
|
-
const tooltipShowDelayTimerRef = useRef2(null);
|
|
741
|
-
const tooltipHideDelayTimerRef = useRef2(null);
|
|
742
|
-
const [actualPlacement, setActualPlacement] = useState2(place);
|
|
743
|
-
const [inlineStyles, setInlineStyles] = useState2({});
|
|
744
|
-
const [inlineArrowStyles, setInlineArrowStyles] = useState2({});
|
|
745
|
-
const [show, setShow] = useState2(false);
|
|
746
|
-
const [rendered, setRendered] = useState2(false);
|
|
747
|
-
const wasShowing = useRef2(false);
|
|
748
|
-
const lastFloatPosition = useRef2(null);
|
|
749
|
-
const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id);
|
|
750
|
-
const hoveringTooltip = useRef2(false);
|
|
751
|
-
const [anchorsBySelect, setAnchorsBySelect] = useState2([]);
|
|
752
|
-
const mounted = useRef2(false);
|
|
753
|
-
const shouldOpenOnClick = openOnClick || events.includes("click");
|
|
754
|
-
use_isomorphic_layout_effect_default(() => {
|
|
755
|
-
mounted.current = true;
|
|
756
|
-
return () => {
|
|
757
|
-
mounted.current = false;
|
|
758
|
-
};
|
|
759
|
-
}, []);
|
|
760
|
-
useEffect3(() => {
|
|
761
|
-
if (!show) {
|
|
762
|
-
const timeout = setTimeout(() => {
|
|
763
|
-
setRendered(false);
|
|
764
|
-
}, 150);
|
|
765
|
-
return () => {
|
|
766
|
-
clearTimeout(timeout);
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
return () => null;
|
|
770
|
-
}, [show]);
|
|
771
|
-
const handleShow = (value) => {
|
|
772
|
-
if (!mounted.current) {
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
if (value) {
|
|
776
|
-
setRendered(true);
|
|
777
|
-
}
|
|
778
|
-
setTimeout(() => {
|
|
779
|
-
if (!mounted.current) {
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
setIsOpen == null ? void 0 : setIsOpen(value);
|
|
783
|
-
if (isOpen === void 0) {
|
|
784
|
-
setShow(value);
|
|
785
|
-
}
|
|
786
|
-
}, 10);
|
|
787
|
-
};
|
|
788
|
-
useEffect3(() => {
|
|
789
|
-
if (isOpen === void 0) {
|
|
790
|
-
return () => null;
|
|
791
|
-
}
|
|
792
|
-
if (isOpen) {
|
|
793
|
-
setRendered(true);
|
|
794
|
-
}
|
|
795
|
-
const timeout = setTimeout(() => {
|
|
796
|
-
setShow(isOpen);
|
|
797
|
-
}, 10);
|
|
798
|
-
return () => {
|
|
799
|
-
clearTimeout(timeout);
|
|
800
|
-
};
|
|
801
|
-
}, [isOpen]);
|
|
802
|
-
useEffect3(() => {
|
|
803
|
-
if (show === wasShowing.current) {
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
wasShowing.current = show;
|
|
807
|
-
if (show) {
|
|
808
|
-
afterShow == null ? void 0 : afterShow();
|
|
809
|
-
} else {
|
|
810
|
-
afterHide == null ? void 0 : afterHide();
|
|
811
|
-
}
|
|
812
|
-
}, [show]);
|
|
813
|
-
const handleShowTooltipDelayed = () => {
|
|
814
|
-
if (tooltipShowDelayTimerRef.current) {
|
|
815
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
816
|
-
}
|
|
817
|
-
tooltipShowDelayTimerRef.current = setTimeout(() => {
|
|
818
|
-
handleShow(true);
|
|
819
|
-
}, delayShow);
|
|
820
|
-
};
|
|
821
|
-
const handleHideTooltipDelayed = (delay = delayHide) => {
|
|
822
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
823
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
824
|
-
}
|
|
825
|
-
tooltipHideDelayTimerRef.current = setTimeout(() => {
|
|
826
|
-
if (hoveringTooltip.current) {
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
handleShow(false);
|
|
830
|
-
}, delay);
|
|
2299
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
2300
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2301
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
2302
|
+
const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
|
|
2303
|
+
let scroll = {
|
|
2304
|
+
scrollLeft: 0,
|
|
2305
|
+
scrollTop: 0
|
|
831
2306
|
};
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
if (delayShow) {
|
|
838
|
-
handleShowTooltipDelayed();
|
|
839
|
-
} else {
|
|
840
|
-
handleShow(true);
|
|
841
|
-
}
|
|
842
|
-
const target = (_a = event.currentTarget) != null ? _a : event.target;
|
|
843
|
-
setActiveAnchor(target);
|
|
844
|
-
setProviderActiveAnchor({ current: target });
|
|
845
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
846
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
847
|
-
}
|
|
2307
|
+
const offsets = {
|
|
2308
|
+
x: 0,
|
|
2309
|
+
y: 0
|
|
848
2310
|
};
|
|
849
|
-
|
|
850
|
-
if (
|
|
851
|
-
|
|
852
|
-
} else if (delayHide) {
|
|
853
|
-
handleHideTooltipDelayed();
|
|
854
|
-
} else {
|
|
855
|
-
handleShow(false);
|
|
2311
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
2312
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2313
|
+
scroll = getNodeScroll(offsetParent);
|
|
856
2314
|
}
|
|
857
|
-
if (
|
|
858
|
-
|
|
2315
|
+
if (isHTMLElement(offsetParent)) {
|
|
2316
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
2317
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2318
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2319
|
+
} else if (documentElement) {
|
|
2320
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
859
2321
|
}
|
|
2322
|
+
}
|
|
2323
|
+
return {
|
|
2324
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
2325
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
2326
|
+
width: rect.width,
|
|
2327
|
+
height: rect.height
|
|
860
2328
|
};
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
886
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
887
|
-
}
|
|
888
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
889
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
const platform = {
|
|
2332
|
+
getClippingRect,
|
|
2333
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
2334
|
+
isElement,
|
|
2335
|
+
getDimensions,
|
|
2336
|
+
getOffsetParent,
|
|
2337
|
+
getDocumentElement,
|
|
2338
|
+
getScale,
|
|
2339
|
+
async getElementRects(_ref) {
|
|
2340
|
+
let {
|
|
2341
|
+
reference,
|
|
2342
|
+
floating,
|
|
2343
|
+
strategy
|
|
2344
|
+
} = _ref;
|
|
2345
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2346
|
+
const getDimensionsFn = this.getDimensions;
|
|
2347
|
+
return {
|
|
2348
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
2349
|
+
floating: {
|
|
2350
|
+
x: 0,
|
|
2351
|
+
y: 0,
|
|
2352
|
+
...(await getDimensionsFn(floating))
|
|
890
2353
|
}
|
|
891
|
-
setActualPlacement(computedStylesData.place);
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
const handleMouseMove = (event) => {
|
|
895
|
-
if (!event) {
|
|
896
|
-
return;
|
|
897
|
-
}
|
|
898
|
-
const mouseEvent = event;
|
|
899
|
-
const mousePosition = {
|
|
900
|
-
x: mouseEvent.clientX,
|
|
901
|
-
y: mouseEvent.clientY
|
|
902
2354
|
};
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
handleShow(false);
|
|
2355
|
+
},
|
|
2356
|
+
getClientRects: element => Array.from(element.getClientRects()),
|
|
2357
|
+
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
2358
|
+
};
|
|
2359
|
+
|
|
2360
|
+
/**
|
|
2361
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2362
|
+
* next to a reference element when it is given a certain CSS positioning
|
|
2363
|
+
* strategy.
|
|
2364
|
+
*/
|
|
2365
|
+
const computePosition = (reference, floating, options) => {
|
|
2366
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
2367
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
2368
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
2369
|
+
const cache = new Map();
|
|
2370
|
+
const mergedOptions = {
|
|
2371
|
+
platform,
|
|
2372
|
+
...options
|
|
923
2373
|
};
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
}
|
|
928
|
-
handleShow(false);
|
|
2374
|
+
const platformWithCache = {
|
|
2375
|
+
...mergedOptions.platform,
|
|
2376
|
+
_c: cache
|
|
929
2377
|
};
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
2378
|
+
return computePosition$1(reference, floating, {
|
|
2379
|
+
...mergedOptions,
|
|
2380
|
+
platform: platformWithCache
|
|
2381
|
+
});
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
const computeTooltipPosition = async ({ elementReference = null, tooltipReference = null, tooltipArrowReference = null, place = 'top', offset: offsetValue = 10, strategy = 'absolute', middlewares = [offset(Number(offsetValue)), flip(), shift({ padding: 5 })], }) => {
|
|
2385
|
+
if (!elementReference) {
|
|
2386
|
+
// elementReference can be null or undefined and we will not compute the position
|
|
2387
|
+
// eslint-disable-next-line no-console
|
|
2388
|
+
// console.error('The reference element for tooltip was not defined: ', elementReference)
|
|
2389
|
+
return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
|
|
941
2390
|
}
|
|
942
|
-
if (
|
|
943
|
-
|
|
2391
|
+
if (tooltipReference === null) {
|
|
2392
|
+
return { tooltipStyles: {}, tooltipArrowStyles: {}, place };
|
|
944
2393
|
}
|
|
945
|
-
const
|
|
946
|
-
if (
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
{
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
2394
|
+
const middleware = middlewares;
|
|
2395
|
+
if (tooltipArrowReference) {
|
|
2396
|
+
middleware.push(arrow({ element: tooltipArrowReference, padding: 5 }));
|
|
2397
|
+
return computePosition(elementReference, tooltipReference, {
|
|
2398
|
+
placement: place,
|
|
2399
|
+
strategy,
|
|
2400
|
+
middleware,
|
|
2401
|
+
}).then(({ x, y, placement, middlewareData }) => {
|
|
2402
|
+
var _a, _b;
|
|
2403
|
+
const styles = { left: `${x}px`, top: `${y}px` };
|
|
2404
|
+
const { x: arrowX, y: arrowY } = (_a = middlewareData.arrow) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
|
|
2405
|
+
const staticSide = (_b = {
|
|
2406
|
+
top: 'bottom',
|
|
2407
|
+
right: 'left',
|
|
2408
|
+
bottom: 'top',
|
|
2409
|
+
left: 'right',
|
|
2410
|
+
}[placement.split('-')[0]]) !== null && _b !== void 0 ? _b : 'bottom';
|
|
2411
|
+
const arrowStyle = {
|
|
2412
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
2413
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
2414
|
+
right: '',
|
|
2415
|
+
bottom: '',
|
|
2416
|
+
[staticSide]: '-4px',
|
|
2417
|
+
};
|
|
2418
|
+
return { tooltipStyles: styles, tooltipArrowStyles: arrowStyle, place: placement };
|
|
960
2419
|
});
|
|
961
|
-
}
|
|
962
2420
|
}
|
|
963
|
-
|
|
964
|
-
|
|
2421
|
+
return computePosition(elementReference, tooltipReference, {
|
|
2422
|
+
placement: 'bottom',
|
|
2423
|
+
strategy,
|
|
2424
|
+
middleware,
|
|
2425
|
+
}).then(({ x, y, placement }) => {
|
|
2426
|
+
const styles = { left: `${x}px`, top: `${y}px` };
|
|
2427
|
+
return { tooltipStyles: styles, tooltipArrowStyles: {}, place: placement };
|
|
2428
|
+
});
|
|
2429
|
+
};
|
|
2430
|
+
|
|
2431
|
+
var styles = {"tooltip":"styles-module_tooltip__mnnfp","fixed":"styles-module_fixed__7ciUi","arrow":"styles-module_arrow__K0L3T","no-arrow":"styles-module_no-arrow__KcFZN","clickable":"styles-module_clickable__Bv9o7","show":"styles-module_show__2NboJ","dark":"styles-module_dark__xNqje","light":"styles-module_light__Z6W-X","success":"styles-module_success__A2AKt","warning":"styles-module_warning__SCK0X","error":"styles-module_error__JvumD","info":"styles-module_info__BWdHW"};
|
|
2432
|
+
|
|
2433
|
+
const Tooltip = ({
|
|
2434
|
+
// props
|
|
2435
|
+
id, className, classNameArrow, variant = 'dark', anchorId, anchorSelect, place = 'top', offset = 10, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, wrapper: WrapperElement, delayShow = 0, delayHide = 0, float = false, noArrow = false, clickable = false, closeOnEsc = false, style: externalStyles, position, afterShow, afterHide,
|
|
2436
|
+
// props handled by controller
|
|
2437
|
+
content, isOpen, setIsOpen, activeAnchor, setActiveAnchor, }) => {
|
|
2438
|
+
const tooltipRef = useRef(null);
|
|
2439
|
+
const tooltipArrowRef = useRef(null);
|
|
2440
|
+
const tooltipShowDelayTimerRef = useRef(null);
|
|
2441
|
+
const tooltipHideDelayTimerRef = useRef(null);
|
|
2442
|
+
const [actualPlacement, setActualPlacement] = useState(place);
|
|
2443
|
+
const [inlineStyles, setInlineStyles] = useState({});
|
|
2444
|
+
const [inlineArrowStyles, setInlineArrowStyles] = useState({});
|
|
2445
|
+
const [show, setShow] = useState(false);
|
|
2446
|
+
const [rendered, setRendered] = useState(false);
|
|
2447
|
+
const wasShowing = useRef(false);
|
|
2448
|
+
const lastFloatPosition = useRef(null);
|
|
2449
|
+
/**
|
|
2450
|
+
* @todo Remove this in a future version (provider/wrapper method is deprecated)
|
|
2451
|
+
*/
|
|
2452
|
+
const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id);
|
|
2453
|
+
const hoveringTooltip = useRef(false);
|
|
2454
|
+
const [anchorsBySelect, setAnchorsBySelect] = useState([]);
|
|
2455
|
+
const mounted = useRef(false);
|
|
2456
|
+
const shouldOpenOnClick = openOnClick || events.includes('click');
|
|
2457
|
+
/**
|
|
2458
|
+
* useLayoutEffect runs before useEffect,
|
|
2459
|
+
* but should be used carefully because of caveats
|
|
2460
|
+
* https://beta.reactjs.org/reference/react/useLayoutEffect#caveats
|
|
2461
|
+
*/
|
|
2462
|
+
useIsomorphicLayoutEffect(() => {
|
|
2463
|
+
mounted.current = true;
|
|
2464
|
+
return () => {
|
|
2465
|
+
mounted.current = false;
|
|
2466
|
+
};
|
|
2467
|
+
}, []);
|
|
2468
|
+
useEffect(() => {
|
|
2469
|
+
if (!show) {
|
|
2470
|
+
/**
|
|
2471
|
+
* this fixes weird behavior when switching between two anchor elements very quickly
|
|
2472
|
+
* remove the timeout and switch quickly between two adjancent anchor elements to see it
|
|
2473
|
+
*
|
|
2474
|
+
* in practice, this means the tooltip is not immediately removed from the DOM on hide
|
|
2475
|
+
*/
|
|
2476
|
+
const timeout = setTimeout(() => {
|
|
2477
|
+
setRendered(false);
|
|
2478
|
+
}, 150);
|
|
2479
|
+
return () => {
|
|
2480
|
+
clearTimeout(timeout);
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
return () => null;
|
|
2484
|
+
}, [show]);
|
|
2485
|
+
const handleShow = (value) => {
|
|
2486
|
+
if (!mounted.current) {
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
if (value) {
|
|
2490
|
+
setRendered(true);
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* wait for the component to render and calculate position
|
|
2494
|
+
* before actually showing
|
|
2495
|
+
*/
|
|
2496
|
+
setTimeout(() => {
|
|
2497
|
+
if (!mounted.current) {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
setIsOpen === null || setIsOpen === void 0 ? void 0 : setIsOpen(value);
|
|
2501
|
+
if (isOpen === undefined) {
|
|
2502
|
+
setShow(value);
|
|
2503
|
+
}
|
|
2504
|
+
}, 10);
|
|
965
2505
|
};
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
2506
|
+
/**
|
|
2507
|
+
* this replicates the effect from `handleShow()`
|
|
2508
|
+
* when `isOpen` is changed from outside
|
|
2509
|
+
*/
|
|
2510
|
+
useEffect(() => {
|
|
2511
|
+
if (isOpen === undefined) {
|
|
2512
|
+
return () => null;
|
|
2513
|
+
}
|
|
2514
|
+
if (isOpen) {
|
|
2515
|
+
setRendered(true);
|
|
2516
|
+
}
|
|
2517
|
+
const timeout = setTimeout(() => {
|
|
2518
|
+
setShow(isOpen);
|
|
2519
|
+
}, 10);
|
|
2520
|
+
return () => {
|
|
2521
|
+
clearTimeout(timeout);
|
|
2522
|
+
};
|
|
2523
|
+
}, [isOpen]);
|
|
2524
|
+
useEffect(() => {
|
|
2525
|
+
if (show === wasShowing.current) {
|
|
2526
|
+
return;
|
|
2527
|
+
}
|
|
2528
|
+
wasShowing.current = show;
|
|
2529
|
+
if (show) {
|
|
2530
|
+
afterShow === null || afterShow === void 0 ? void 0 : afterShow();
|
|
2531
|
+
}
|
|
2532
|
+
else {
|
|
2533
|
+
afterHide === null || afterHide === void 0 ? void 0 : afterHide();
|
|
2534
|
+
}
|
|
2535
|
+
}, [show]);
|
|
2536
|
+
const handleShowTooltipDelayed = () => {
|
|
2537
|
+
if (tooltipShowDelayTimerRef.current) {
|
|
2538
|
+
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
2539
|
+
}
|
|
2540
|
+
tooltipShowDelayTimerRef.current = setTimeout(() => {
|
|
2541
|
+
handleShow(true);
|
|
2542
|
+
}, delayShow);
|
|
969
2543
|
};
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
2544
|
+
const handleHideTooltipDelayed = (delay = delayHide) => {
|
|
2545
|
+
if (tooltipHideDelayTimerRef.current) {
|
|
2546
|
+
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
2547
|
+
}
|
|
2548
|
+
tooltipHideDelayTimerRef.current = setTimeout(() => {
|
|
2549
|
+
if (hoveringTooltip.current) {
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
2552
|
+
handleShow(false);
|
|
2553
|
+
}, delay);
|
|
2554
|
+
};
|
|
2555
|
+
const handleShowTooltip = (event) => {
|
|
2556
|
+
var _a;
|
|
2557
|
+
if (!event) {
|
|
2558
|
+
return;
|
|
2559
|
+
}
|
|
2560
|
+
if (delayShow) {
|
|
2561
|
+
handleShowTooltipDelayed();
|
|
2562
|
+
}
|
|
2563
|
+
else {
|
|
2564
|
+
handleShow(true);
|
|
2565
|
+
}
|
|
2566
|
+
const target = (_a = event.currentTarget) !== null && _a !== void 0 ? _a : event.target;
|
|
2567
|
+
setActiveAnchor(target);
|
|
2568
|
+
setProviderActiveAnchor({ current: target });
|
|
2569
|
+
if (tooltipHideDelayTimerRef.current) {
|
|
2570
|
+
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
2571
|
+
}
|
|
2572
|
+
};
|
|
2573
|
+
const handleHideTooltip = () => {
|
|
2574
|
+
if (clickable) {
|
|
2575
|
+
// allow time for the mouse to reach the tooltip, in case there's a gap
|
|
2576
|
+
handleHideTooltipDelayed(delayHide || 100);
|
|
2577
|
+
}
|
|
2578
|
+
else if (delayHide) {
|
|
2579
|
+
handleHideTooltipDelayed();
|
|
2580
|
+
}
|
|
2581
|
+
else {
|
|
2582
|
+
handleShow(false);
|
|
2583
|
+
}
|
|
2584
|
+
if (tooltipShowDelayTimerRef.current) {
|
|
2585
|
+
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
const handleTooltipPosition = ({ x, y }) => {
|
|
2589
|
+
const virtualElement = {
|
|
2590
|
+
getBoundingClientRect() {
|
|
2591
|
+
return {
|
|
2592
|
+
x,
|
|
2593
|
+
y,
|
|
2594
|
+
width: 0,
|
|
2595
|
+
height: 0,
|
|
2596
|
+
top: y,
|
|
2597
|
+
left: x,
|
|
2598
|
+
right: x,
|
|
2599
|
+
bottom: y,
|
|
2600
|
+
};
|
|
2601
|
+
},
|
|
2602
|
+
};
|
|
2603
|
+
computeTooltipPosition({
|
|
2604
|
+
place,
|
|
2605
|
+
offset,
|
|
2606
|
+
elementReference: virtualElement,
|
|
2607
|
+
tooltipReference: tooltipRef.current,
|
|
2608
|
+
tooltipArrowReference: tooltipArrowRef.current,
|
|
2609
|
+
strategy: positionStrategy,
|
|
2610
|
+
middlewares,
|
|
2611
|
+
}).then((computedStylesData) => {
|
|
2612
|
+
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
2613
|
+
setInlineStyles(computedStylesData.tooltipStyles);
|
|
2614
|
+
}
|
|
2615
|
+
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
2616
|
+
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
2617
|
+
}
|
|
2618
|
+
setActualPlacement(computedStylesData.place);
|
|
996
2619
|
});
|
|
997
|
-
});
|
|
998
2620
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
2621
|
+
const handleMouseMove = (event) => {
|
|
2622
|
+
if (!event) {
|
|
2623
|
+
return;
|
|
2624
|
+
}
|
|
2625
|
+
const mouseEvent = event;
|
|
2626
|
+
const mousePosition = {
|
|
2627
|
+
x: mouseEvent.clientX,
|
|
2628
|
+
y: mouseEvent.clientY,
|
|
2629
|
+
};
|
|
2630
|
+
handleTooltipPosition(mousePosition);
|
|
2631
|
+
lastFloatPosition.current = mousePosition;
|
|
2632
|
+
};
|
|
2633
|
+
const handleClickTooltipAnchor = (event) => {
|
|
2634
|
+
handleShowTooltip(event);
|
|
2635
|
+
if (delayHide) {
|
|
2636
|
+
handleHideTooltipDelayed();
|
|
2637
|
+
}
|
|
2638
|
+
};
|
|
2639
|
+
const handleClickOutsideAnchors = (event) => {
|
|
2640
|
+
var _a;
|
|
2641
|
+
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
2642
|
+
const anchors = [anchorById, ...anchorsBySelect];
|
|
2643
|
+
if (anchors.some((anchor) => anchor === null || anchor === void 0 ? void 0 : anchor.contains(event.target))) {
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
if ((_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) {
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2649
|
+
handleShow(false);
|
|
2650
|
+
};
|
|
2651
|
+
const handleEsc = (event) => {
|
|
2652
|
+
if (event.key !== 'Escape') {
|
|
2653
|
+
return;
|
|
2654
|
+
}
|
|
2655
|
+
handleShow(false);
|
|
2656
|
+
};
|
|
2657
|
+
// debounce handler to prevent call twice when
|
|
2658
|
+
// mouse enter and focus events being triggered toggether
|
|
2659
|
+
const debouncedHandleShowTooltip = debounce(handleShowTooltip, 50);
|
|
2660
|
+
const debouncedHandleHideTooltip = debounce(handleHideTooltip, 50);
|
|
2661
|
+
useEffect(() => {
|
|
2662
|
+
var _a, _b;
|
|
2663
|
+
const elementRefs = new Set(anchorRefs);
|
|
2664
|
+
anchorsBySelect.forEach((anchor) => {
|
|
2665
|
+
elementRefs.add({ current: anchor });
|
|
2666
|
+
});
|
|
2667
|
+
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
2668
|
+
if (anchorById) {
|
|
2669
|
+
elementRefs.add({ current: anchorById });
|
|
2670
|
+
}
|
|
2671
|
+
if (closeOnEsc) {
|
|
2672
|
+
window.addEventListener('keydown', handleEsc);
|
|
2673
|
+
}
|
|
2674
|
+
const enabledEvents = [];
|
|
2675
|
+
if (shouldOpenOnClick) {
|
|
2676
|
+
window.addEventListener('click', handleClickOutsideAnchors);
|
|
2677
|
+
enabledEvents.push({ event: 'click', listener: handleClickTooltipAnchor });
|
|
2678
|
+
}
|
|
2679
|
+
else {
|
|
2680
|
+
enabledEvents.push({ event: 'mouseenter', listener: debouncedHandleShowTooltip }, { event: 'mouseleave', listener: debouncedHandleHideTooltip }, { event: 'focus', listener: debouncedHandleShowTooltip }, { event: 'blur', listener: debouncedHandleHideTooltip });
|
|
2681
|
+
if (float) {
|
|
2682
|
+
enabledEvents.push({
|
|
2683
|
+
event: 'mousemove',
|
|
2684
|
+
listener: handleMouseMove,
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
const handleMouseEnterTooltip = () => {
|
|
2689
|
+
hoveringTooltip.current = true;
|
|
2690
|
+
};
|
|
2691
|
+
const handleMouseLeaveTooltip = () => {
|
|
2692
|
+
hoveringTooltip.current = false;
|
|
2693
|
+
handleHideTooltip();
|
|
2694
|
+
};
|
|
2695
|
+
if (clickable && !shouldOpenOnClick) {
|
|
2696
|
+
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', handleMouseEnterTooltip);
|
|
2697
|
+
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', handleMouseLeaveTooltip);
|
|
2698
|
+
}
|
|
2699
|
+
enabledEvents.forEach(({ event, listener }) => {
|
|
2700
|
+
elementRefs.forEach((ref) => {
|
|
2701
|
+
var _a;
|
|
2702
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener(event, listener);
|
|
2703
|
+
});
|
|
2704
|
+
});
|
|
2705
|
+
return () => {
|
|
2706
|
+
var _a, _b;
|
|
2707
|
+
if (shouldOpenOnClick) {
|
|
2708
|
+
window.removeEventListener('click', handleClickOutsideAnchors);
|
|
2709
|
+
}
|
|
2710
|
+
if (closeOnEsc) {
|
|
2711
|
+
window.removeEventListener('keydown', handleEsc);
|
|
2712
|
+
}
|
|
2713
|
+
if (clickable && !shouldOpenOnClick) {
|
|
2714
|
+
(_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', handleMouseEnterTooltip);
|
|
2715
|
+
(_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', handleMouseLeaveTooltip);
|
|
2716
|
+
}
|
|
2717
|
+
enabledEvents.forEach(({ event, listener }) => {
|
|
2718
|
+
elementRefs.forEach((ref) => {
|
|
2719
|
+
var _a;
|
|
2720
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener(event, listener);
|
|
2721
|
+
});
|
|
2722
|
+
});
|
|
2723
|
+
};
|
|
2724
|
+
/**
|
|
2725
|
+
* rendered is also a dependency to ensure anchor observers are re-registered
|
|
2726
|
+
* since `tooltipRef` becomes stale after removing/adding the tooltip to the DOM
|
|
2727
|
+
*/
|
|
2728
|
+
}, [rendered, anchorRefs, anchorsBySelect, closeOnEsc, events]);
|
|
2729
|
+
useEffect(() => {
|
|
2730
|
+
let selector = anchorSelect !== null && anchorSelect !== void 0 ? anchorSelect : '';
|
|
2731
|
+
if (!selector && id) {
|
|
2732
|
+
selector = `[data-tooltip-id='${id}']`;
|
|
2733
|
+
}
|
|
2734
|
+
const documentObserverCallback = (mutationList) => {
|
|
2735
|
+
const newAnchors = [];
|
|
2736
|
+
mutationList.forEach((mutation) => {
|
|
2737
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'data-tooltip-id') {
|
|
2738
|
+
const newId = mutation.target.getAttribute('data-tooltip-id');
|
|
2739
|
+
if (newId === id) {
|
|
2740
|
+
newAnchors.push(mutation.target);
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
if (mutation.type !== 'childList') {
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
if (activeAnchor) {
|
|
2747
|
+
[...mutation.removedNodes].some((node) => {
|
|
2748
|
+
if (node.contains(activeAnchor)) {
|
|
2749
|
+
setRendered(false);
|
|
2750
|
+
handleShow(false);
|
|
2751
|
+
setActiveAnchor(null);
|
|
2752
|
+
return true;
|
|
2753
|
+
}
|
|
2754
|
+
return false;
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
if (!selector) {
|
|
2758
|
+
return;
|
|
2759
|
+
}
|
|
2760
|
+
try {
|
|
2761
|
+
const elements = [...mutation.addedNodes].filter((node) => node.nodeType === 1);
|
|
2762
|
+
newAnchors.push(
|
|
2763
|
+
// the element itself is an anchor
|
|
2764
|
+
...elements.filter((element) => element.matches(selector)));
|
|
2765
|
+
newAnchors.push(
|
|
2766
|
+
// the element has children which are anchors
|
|
2767
|
+
...elements.flatMap((element) => [...element.querySelectorAll(selector)]));
|
|
2768
|
+
}
|
|
2769
|
+
catch (_a) {
|
|
2770
|
+
/**
|
|
2771
|
+
* invalid CSS selector.
|
|
2772
|
+
* already warned on tooltip controller
|
|
2773
|
+
*/
|
|
2774
|
+
}
|
|
2775
|
+
});
|
|
2776
|
+
if (newAnchors.length) {
|
|
2777
|
+
setAnchorsBySelect((anchors) => [...anchors, ...newAnchors]);
|
|
2778
|
+
}
|
|
2779
|
+
};
|
|
2780
|
+
const documentObserver = new MutationObserver(documentObserverCallback);
|
|
2781
|
+
// watch for anchor being removed from the DOM
|
|
2782
|
+
documentObserver.observe(document.body, {
|
|
2783
|
+
childList: true,
|
|
2784
|
+
subtree: true,
|
|
2785
|
+
attributes: true,
|
|
2786
|
+
attributeFilter: ['data-tooltip-id'],
|
|
2787
|
+
});
|
|
2788
|
+
return () => {
|
|
2789
|
+
documentObserver.disconnect();
|
|
2790
|
+
};
|
|
2791
|
+
}, [id, anchorSelect, activeAnchor]);
|
|
2792
|
+
useEffect(() => {
|
|
2793
|
+
if (position) {
|
|
2794
|
+
// if `position` is set, override regular and `float` positioning
|
|
2795
|
+
handleTooltipPosition(position);
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
if (float) {
|
|
2799
|
+
if (lastFloatPosition.current) {
|
|
2800
|
+
/*
|
|
2801
|
+
Without this, changes to `content`, `place`, `offset`, ..., will only
|
|
2802
|
+
trigger a position calculation after a `mousemove` event.
|
|
2803
|
+
|
|
2804
|
+
To see why this matters, comment this line, run `yarn dev` and click the
|
|
2805
|
+
"Hover me!" anchor.
|
|
2806
|
+
*/
|
|
2807
|
+
handleTooltipPosition(lastFloatPosition.current);
|
|
2808
|
+
}
|
|
2809
|
+
// if `float` is set, override regular positioning
|
|
2810
|
+
return;
|
|
1013
2811
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
2812
|
+
computeTooltipPosition({
|
|
2813
|
+
place,
|
|
2814
|
+
offset,
|
|
2815
|
+
elementReference: activeAnchor,
|
|
2816
|
+
tooltipReference: tooltipRef.current,
|
|
2817
|
+
tooltipArrowReference: tooltipArrowRef.current,
|
|
2818
|
+
strategy: positionStrategy,
|
|
2819
|
+
middlewares,
|
|
2820
|
+
}).then((computedStylesData) => {
|
|
2821
|
+
if (!mounted.current) {
|
|
2822
|
+
// invalidate computed positions after remount
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
2826
|
+
setInlineStyles(computedStylesData.tooltipStyles);
|
|
2827
|
+
}
|
|
2828
|
+
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
2829
|
+
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
2830
|
+
}
|
|
2831
|
+
setActualPlacement(computedStylesData.place);
|
|
2832
|
+
});
|
|
2833
|
+
}, [show, activeAnchor, content, place, offset, positionStrategy, position]);
|
|
2834
|
+
useEffect(() => {
|
|
2835
|
+
var _a;
|
|
2836
|
+
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
2837
|
+
const anchors = [...anchorsBySelect, anchorById];
|
|
2838
|
+
if (!activeAnchor || !anchors.includes(activeAnchor)) {
|
|
2839
|
+
/**
|
|
2840
|
+
* if there is no active anchor,
|
|
2841
|
+
* or if the current active anchor is not amongst the allowed ones,
|
|
2842
|
+
* reset it
|
|
2843
|
+
*/
|
|
2844
|
+
setActiveAnchor((_a = anchorsBySelect[0]) !== null && _a !== void 0 ? _a : anchorById);
|
|
1016
2845
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
if (
|
|
1021
|
-
|
|
1022
|
-
handleShow(false);
|
|
1023
|
-
setActiveAnchor(null);
|
|
1024
|
-
return true;
|
|
2846
|
+
}, [anchorId, anchorsBySelect, activeAnchor]);
|
|
2847
|
+
useEffect(() => {
|
|
2848
|
+
return () => {
|
|
2849
|
+
if (tooltipShowDelayTimerRef.current) {
|
|
2850
|
+
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
1025
2851
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
2852
|
+
if (tooltipHideDelayTimerRef.current) {
|
|
2853
|
+
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
2854
|
+
}
|
|
2855
|
+
};
|
|
2856
|
+
}, []);
|
|
2857
|
+
useEffect(() => {
|
|
2858
|
+
let selector = anchorSelect;
|
|
2859
|
+
if (!selector && id) {
|
|
2860
|
+
selector = `[data-tooltip-id='${id}']`;
|
|
1028
2861
|
}
|
|
1029
2862
|
if (!selector) {
|
|
1030
|
-
|
|
2863
|
+
return;
|
|
1031
2864
|
}
|
|
1032
2865
|
try {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
...elements.filter(
|
|
1036
|
-
(element) => element.matches(selector)
|
|
1037
|
-
)
|
|
1038
|
-
);
|
|
1039
|
-
newAnchors.push(
|
|
1040
|
-
...elements.flatMap(
|
|
1041
|
-
(element) => [...element.querySelectorAll(selector)]
|
|
1042
|
-
)
|
|
1043
|
-
);
|
|
1044
|
-
} catch (e2) {
|
|
2866
|
+
const anchors = Array.from(document.querySelectorAll(selector));
|
|
2867
|
+
setAnchorsBySelect(anchors);
|
|
1045
2868
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
const documentObserver = new MutationObserver(documentObserverCallback);
|
|
1052
|
-
documentObserver.observe(document.body, {
|
|
1053
|
-
childList: true,
|
|
1054
|
-
subtree: true,
|
|
1055
|
-
attributes: true,
|
|
1056
|
-
attributeFilter: ["data-tooltip-id"]
|
|
1057
|
-
});
|
|
1058
|
-
return () => {
|
|
1059
|
-
documentObserver.disconnect();
|
|
1060
|
-
};
|
|
1061
|
-
}, [id, anchorSelect, activeAnchor]);
|
|
1062
|
-
useEffect3(() => {
|
|
1063
|
-
if (position) {
|
|
1064
|
-
handleTooltipPosition(position);
|
|
1065
|
-
return;
|
|
1066
|
-
}
|
|
1067
|
-
if (float) {
|
|
1068
|
-
if (lastFloatPosition.current) {
|
|
1069
|
-
handleTooltipPosition(lastFloatPosition.current);
|
|
1070
|
-
}
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
1073
|
-
computeTooltipPosition({
|
|
1074
|
-
place,
|
|
1075
|
-
offset,
|
|
1076
|
-
elementReference: activeAnchor,
|
|
1077
|
-
tooltipReference: tooltipRef.current,
|
|
1078
|
-
tooltipArrowReference: tooltipArrowRef.current,
|
|
1079
|
-
strategy: positionStrategy,
|
|
1080
|
-
middlewares
|
|
1081
|
-
}).then((computedStylesData) => {
|
|
1082
|
-
if (!mounted.current) {
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
if (Object.keys(computedStylesData.tooltipStyles).length) {
|
|
1086
|
-
setInlineStyles(computedStylesData.tooltipStyles);
|
|
1087
|
-
}
|
|
1088
|
-
if (Object.keys(computedStylesData.tooltipArrowStyles).length) {
|
|
1089
|
-
setInlineArrowStyles(computedStylesData.tooltipArrowStyles);
|
|
1090
|
-
}
|
|
1091
|
-
setActualPlacement(computedStylesData.place);
|
|
1092
|
-
});
|
|
1093
|
-
}, [show, activeAnchor, content, place, offset, positionStrategy, position]);
|
|
1094
|
-
useEffect3(() => {
|
|
1095
|
-
var _a;
|
|
1096
|
-
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
1097
|
-
const anchors = [...anchorsBySelect, anchorById];
|
|
1098
|
-
if (!activeAnchor || !anchors.includes(activeAnchor)) {
|
|
1099
|
-
setActiveAnchor((_a = anchorsBySelect[0]) != null ? _a : anchorById);
|
|
1100
|
-
}
|
|
1101
|
-
}, [anchorId, anchorsBySelect, activeAnchor]);
|
|
1102
|
-
useEffect3(() => {
|
|
1103
|
-
return () => {
|
|
1104
|
-
if (tooltipShowDelayTimerRef.current) {
|
|
1105
|
-
clearTimeout(tooltipShowDelayTimerRef.current);
|
|
1106
|
-
}
|
|
1107
|
-
if (tooltipHideDelayTimerRef.current) {
|
|
1108
|
-
clearTimeout(tooltipHideDelayTimerRef.current);
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
}, []);
|
|
1112
|
-
useEffect3(() => {
|
|
1113
|
-
let selector = anchorSelect;
|
|
1114
|
-
if (!selector && id) {
|
|
1115
|
-
selector = `[data-tooltip-id='${id}']`;
|
|
1116
|
-
}
|
|
1117
|
-
if (!selector) {
|
|
1118
|
-
return;
|
|
1119
|
-
}
|
|
1120
|
-
try {
|
|
1121
|
-
const anchors = Array.from(document.querySelectorAll(selector));
|
|
1122
|
-
setAnchorsBySelect(anchors);
|
|
1123
|
-
} catch (e2) {
|
|
1124
|
-
setAnchorsBySelect([]);
|
|
1125
|
-
}
|
|
1126
|
-
}, [id, anchorSelect]);
|
|
1127
|
-
const canShow = content && show && Object.keys(inlineStyles).length > 0;
|
|
1128
|
-
return rendered ? /* @__PURE__ */ jsxs(
|
|
1129
|
-
WrapperElement,
|
|
1130
|
-
{
|
|
1131
|
-
id,
|
|
1132
|
-
role: "tooltip",
|
|
1133
|
-
className: (0, import_classnames2.default)(
|
|
1134
|
-
"react-tooltip",
|
|
1135
|
-
styles_module_default["tooltip"],
|
|
1136
|
-
styles_module_default[variant],
|
|
1137
|
-
className,
|
|
1138
|
-
`react-tooltip__place-${actualPlacement}`,
|
|
1139
|
-
{
|
|
1140
|
-
[styles_module_default["show"]]: canShow,
|
|
1141
|
-
[styles_module_default["fixed"]]: positionStrategy === "fixed",
|
|
1142
|
-
[styles_module_default["clickable"]]: clickable
|
|
2869
|
+
catch (_a) {
|
|
2870
|
+
// warning was already issued in the controller
|
|
2871
|
+
setAnchorsBySelect([]);
|
|
1143
2872
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
[styles_module_default["noArrow"]]: noArrow
|
|
1158
|
-
}),
|
|
1159
|
-
style: inlineArrowStyles,
|
|
1160
|
-
ref: tooltipArrowRef
|
|
1161
|
-
}
|
|
1162
|
-
)
|
|
1163
|
-
]
|
|
1164
|
-
}
|
|
1165
|
-
) : null;
|
|
2873
|
+
}, [id, anchorSelect]);
|
|
2874
|
+
const canShow = content && show && Object.keys(inlineStyles).length > 0;
|
|
2875
|
+
return rendered ? (jsxRuntime.exports.jsxs(WrapperElement, { id: id, role: "tooltip", className: classNames('react-tooltip', styles['tooltip'], styles[variant], className, `react-tooltip__place-${actualPlacement}`, {
|
|
2876
|
+
[styles['show']]: canShow,
|
|
2877
|
+
[styles['fixed']]: positionStrategy === 'fixed',
|
|
2878
|
+
[styles['clickable']]: clickable,
|
|
2879
|
+
}), style: { ...externalStyles, ...inlineStyles }, ref: tooltipRef, children: [content, jsxRuntime.exports.jsx(WrapperElement, { className: classNames('react-tooltip-arrow', styles['arrow'], classNameArrow, {
|
|
2880
|
+
/**
|
|
2881
|
+
* changed from dash `no-arrow` to camelcase because of:
|
|
2882
|
+
* https://github.com/indooorsman/esbuild-css-modules-plugin/issues/42
|
|
2883
|
+
*/
|
|
2884
|
+
[styles['noArrow']]: noArrow,
|
|
2885
|
+
}), style: inlineArrowStyles, ref: tooltipArrowRef })] })) : null;
|
|
1166
2886
|
};
|
|
1167
|
-
var Tooltip_default = Tooltip;
|
|
1168
2887
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
var TooltipContent = ({ content }) => {
|
|
1172
|
-
return /* @__PURE__ */ jsx4("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
2888
|
+
const TooltipContent = ({ content }) => {
|
|
2889
|
+
return jsxRuntime.exports.jsx("span", { dangerouslySetInnerHTML: { __html: content } });
|
|
1173
2890
|
};
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
style,
|
|
1203
|
-
position,
|
|
1204
|
-
isOpen,
|
|
1205
|
-
setIsOpen,
|
|
1206
|
-
afterShow,
|
|
1207
|
-
afterHide
|
|
1208
|
-
}) => {
|
|
1209
|
-
const [tooltipContent, setTooltipContent] = useState3(content);
|
|
1210
|
-
const [tooltipHtml, setTooltipHtml] = useState3(html);
|
|
1211
|
-
const [tooltipPlace, setTooltipPlace] = useState3(place);
|
|
1212
|
-
const [tooltipVariant, setTooltipVariant] = useState3(variant);
|
|
1213
|
-
const [tooltipOffset, setTooltipOffset] = useState3(offset);
|
|
1214
|
-
const [tooltipDelayShow, setTooltipDelayShow] = useState3(delayShow);
|
|
1215
|
-
const [tooltipDelayHide, setTooltipDelayHide] = useState3(delayHide);
|
|
1216
|
-
const [tooltipFloat, setTooltipFloat] = useState3(float);
|
|
1217
|
-
const [tooltipWrapper, setTooltipWrapper] = useState3(wrapper);
|
|
1218
|
-
const [tooltipEvents, setTooltipEvents] = useState3(events);
|
|
1219
|
-
const [tooltipPositionStrategy, setTooltipPositionStrategy] = useState3(positionStrategy);
|
|
1220
|
-
const [activeAnchor, setActiveAnchor] = useState3(null);
|
|
1221
|
-
const { anchorRefs, activeAnchor: providerActiveAnchor } = useTooltip(id);
|
|
1222
|
-
const getDataAttributesFromAnchorElement = (elementReference) => {
|
|
1223
|
-
const dataAttributes = elementReference == null ? void 0 : elementReference.getAttributeNames().reduce((acc, name) => {
|
|
1224
|
-
var _a;
|
|
1225
|
-
if (name.startsWith("data-tooltip-")) {
|
|
1226
|
-
const parsedAttribute = name.replace(/^data-tooltip-/, "");
|
|
1227
|
-
acc[parsedAttribute] = (_a = elementReference == null ? void 0 : elementReference.getAttribute(name)) != null ? _a : null;
|
|
1228
|
-
}
|
|
1229
|
-
return acc;
|
|
1230
|
-
}, {});
|
|
1231
|
-
return dataAttributes;
|
|
1232
|
-
};
|
|
1233
|
-
const applyAllDataAttributesFromAnchorElement = (dataAttributes) => {
|
|
1234
|
-
const handleDataAttributes = {
|
|
1235
|
-
place: (value) => {
|
|
1236
|
-
setTooltipPlace(value != null ? value : place);
|
|
1237
|
-
},
|
|
1238
|
-
content: (value) => {
|
|
1239
|
-
setTooltipContent(value != null ? value : content);
|
|
1240
|
-
},
|
|
1241
|
-
html: (value) => {
|
|
1242
|
-
setTooltipHtml(value != null ? value : html);
|
|
1243
|
-
},
|
|
1244
|
-
variant: (value) => {
|
|
1245
|
-
setTooltipVariant(value != null ? value : variant);
|
|
1246
|
-
},
|
|
1247
|
-
offset: (value) => {
|
|
1248
|
-
setTooltipOffset(value === null ? offset : Number(value));
|
|
1249
|
-
},
|
|
1250
|
-
wrapper: (value) => {
|
|
1251
|
-
setTooltipWrapper(value != null ? value : wrapper);
|
|
1252
|
-
},
|
|
1253
|
-
events: (value) => {
|
|
1254
|
-
const parsed = value == null ? void 0 : value.split(" ");
|
|
1255
|
-
setTooltipEvents(parsed != null ? parsed : events);
|
|
1256
|
-
},
|
|
1257
|
-
"position-strategy": (value) => {
|
|
1258
|
-
setTooltipPositionStrategy(value != null ? value : positionStrategy);
|
|
1259
|
-
},
|
|
1260
|
-
"delay-show": (value) => {
|
|
1261
|
-
setTooltipDelayShow(value === null ? delayShow : Number(value));
|
|
1262
|
-
},
|
|
1263
|
-
"delay-hide": (value) => {
|
|
1264
|
-
setTooltipDelayHide(value === null ? delayHide : Number(value));
|
|
1265
|
-
},
|
|
1266
|
-
float: (value) => {
|
|
1267
|
-
setTooltipFloat(value === null ? float : value === "true");
|
|
1268
|
-
}
|
|
2891
|
+
|
|
2892
|
+
const TooltipController = ({ id, anchorId, anchorSelect, content, html, render, className, classNameArrow, variant = 'dark', place = 'top', offset = 10, wrapper = 'div', children = null, events = ['hover'], openOnClick = false, positionStrategy = 'absolute', middlewares, delayShow = 0, delayHide = 0, float = false, noArrow = false, clickable = false, closeOnEsc = false, style, position, isOpen, setIsOpen, afterShow, afterHide, }) => {
|
|
2893
|
+
const [tooltipContent, setTooltipContent] = useState(content);
|
|
2894
|
+
const [tooltipHtml, setTooltipHtml] = useState(html);
|
|
2895
|
+
const [tooltipPlace, setTooltipPlace] = useState(place);
|
|
2896
|
+
const [tooltipVariant, setTooltipVariant] = useState(variant);
|
|
2897
|
+
const [tooltipOffset, setTooltipOffset] = useState(offset);
|
|
2898
|
+
const [tooltipDelayShow, setTooltipDelayShow] = useState(delayShow);
|
|
2899
|
+
const [tooltipDelayHide, setTooltipDelayHide] = useState(delayHide);
|
|
2900
|
+
const [tooltipFloat, setTooltipFloat] = useState(float);
|
|
2901
|
+
const [tooltipWrapper, setTooltipWrapper] = useState(wrapper);
|
|
2902
|
+
const [tooltipEvents, setTooltipEvents] = useState(events);
|
|
2903
|
+
const [tooltipPositionStrategy, setTooltipPositionStrategy] = useState(positionStrategy);
|
|
2904
|
+
const [activeAnchor, setActiveAnchor] = useState(null);
|
|
2905
|
+
/**
|
|
2906
|
+
* @todo Remove this in a future version (provider/wrapper method is deprecated)
|
|
2907
|
+
*/
|
|
2908
|
+
const { anchorRefs, activeAnchor: providerActiveAnchor } = useTooltip(id);
|
|
2909
|
+
const getDataAttributesFromAnchorElement = (elementReference) => {
|
|
2910
|
+
const dataAttributes = elementReference === null || elementReference === void 0 ? void 0 : elementReference.getAttributeNames().reduce((acc, name) => {
|
|
2911
|
+
var _a;
|
|
2912
|
+
if (name.startsWith('data-tooltip-')) {
|
|
2913
|
+
const parsedAttribute = name.replace(/^data-tooltip-/, '');
|
|
2914
|
+
acc[parsedAttribute] = (_a = elementReference === null || elementReference === void 0 ? void 0 : elementReference.getAttribute(name)) !== null && _a !== void 0 ? _a : null;
|
|
2915
|
+
}
|
|
2916
|
+
return acc;
|
|
2917
|
+
}, {});
|
|
2918
|
+
return dataAttributes;
|
|
1269
2919
|
};
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
2920
|
+
const applyAllDataAttributesFromAnchorElement = (dataAttributes) => {
|
|
2921
|
+
const handleDataAttributes = {
|
|
2922
|
+
place: (value) => {
|
|
2923
|
+
var _a;
|
|
2924
|
+
setTooltipPlace((_a = value) !== null && _a !== void 0 ? _a : place);
|
|
2925
|
+
},
|
|
2926
|
+
content: (value) => {
|
|
2927
|
+
setTooltipContent(value !== null && value !== void 0 ? value : content);
|
|
2928
|
+
},
|
|
2929
|
+
html: (value) => {
|
|
2930
|
+
setTooltipHtml(value !== null && value !== void 0 ? value : html);
|
|
2931
|
+
},
|
|
2932
|
+
variant: (value) => {
|
|
2933
|
+
var _a;
|
|
2934
|
+
setTooltipVariant((_a = value) !== null && _a !== void 0 ? _a : variant);
|
|
2935
|
+
},
|
|
2936
|
+
offset: (value) => {
|
|
2937
|
+
setTooltipOffset(value === null ? offset : Number(value));
|
|
2938
|
+
},
|
|
2939
|
+
wrapper: (value) => {
|
|
2940
|
+
var _a;
|
|
2941
|
+
setTooltipWrapper((_a = value) !== null && _a !== void 0 ? _a : wrapper);
|
|
2942
|
+
},
|
|
2943
|
+
events: (value) => {
|
|
2944
|
+
const parsed = value === null || value === void 0 ? void 0 : value.split(' ');
|
|
2945
|
+
setTooltipEvents(parsed !== null && parsed !== void 0 ? parsed : events);
|
|
2946
|
+
},
|
|
2947
|
+
'position-strategy': (value) => {
|
|
2948
|
+
var _a;
|
|
2949
|
+
setTooltipPositionStrategy((_a = value) !== null && _a !== void 0 ? _a : positionStrategy);
|
|
2950
|
+
},
|
|
2951
|
+
'delay-show': (value) => {
|
|
2952
|
+
setTooltipDelayShow(value === null ? delayShow : Number(value));
|
|
2953
|
+
},
|
|
2954
|
+
'delay-hide': (value) => {
|
|
2955
|
+
setTooltipDelayHide(value === null ? delayHide : Number(value));
|
|
2956
|
+
},
|
|
2957
|
+
float: (value) => {
|
|
2958
|
+
setTooltipFloat(value === null ? float : value === 'true');
|
|
2959
|
+
},
|
|
2960
|
+
};
|
|
2961
|
+
// reset unset data attributes to default values
|
|
2962
|
+
// without this, data attributes from the last active anchor will still be used
|
|
2963
|
+
Object.values(handleDataAttributes).forEach((handler) => handler(null));
|
|
2964
|
+
Object.entries(dataAttributes).forEach(([key, value]) => {
|
|
2965
|
+
var _a;
|
|
2966
|
+
(_a = handleDataAttributes[key]) === null || _a === void 0 ? void 0 : _a.call(handleDataAttributes, value);
|
|
1297
2967
|
});
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
2968
|
+
};
|
|
2969
|
+
useEffect(() => {
|
|
2970
|
+
setTooltipContent(content);
|
|
2971
|
+
}, [content]);
|
|
2972
|
+
useEffect(() => {
|
|
2973
|
+
setTooltipHtml(html);
|
|
2974
|
+
}, [html]);
|
|
2975
|
+
useEffect(() => {
|
|
2976
|
+
setTooltipPlace(place);
|
|
2977
|
+
}, [place]);
|
|
2978
|
+
useEffect(() => {
|
|
2979
|
+
var _a;
|
|
2980
|
+
const elementRefs = new Set(anchorRefs);
|
|
2981
|
+
let selector = anchorSelect;
|
|
2982
|
+
if (!selector && id) {
|
|
2983
|
+
selector = `[data-tooltip-id='${id}']`;
|
|
1301
2984
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
2985
|
+
if (selector) {
|
|
2986
|
+
try {
|
|
2987
|
+
const anchorsBySelect = document.querySelectorAll(selector);
|
|
2988
|
+
anchorsBySelect.forEach((anchor) => {
|
|
2989
|
+
elementRefs.add({ current: anchor });
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2992
|
+
catch (_b) {
|
|
2993
|
+
{
|
|
2994
|
+
// eslint-disable-next-line no-console
|
|
2995
|
+
console.warn(`[react-tooltip] "${anchorSelect}" is not a valid CSS selector`);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
const anchorById = document.querySelector(`[id='${anchorId}']`);
|
|
3000
|
+
if (anchorById) {
|
|
3001
|
+
elementRefs.add({ current: anchorById });
|
|
3002
|
+
}
|
|
3003
|
+
if (!elementRefs.size) {
|
|
3004
|
+
return () => null;
|
|
3005
|
+
}
|
|
3006
|
+
const anchorElement = (_a = activeAnchor !== null && activeAnchor !== void 0 ? activeAnchor : anchorById) !== null && _a !== void 0 ? _a : providerActiveAnchor.current;
|
|
3007
|
+
const observerCallback = (mutationList) => {
|
|
3008
|
+
mutationList.forEach((mutation) => {
|
|
3009
|
+
var _a;
|
|
3010
|
+
if (!anchorElement ||
|
|
3011
|
+
mutation.type !== 'attributes' ||
|
|
3012
|
+
!((_a = mutation.attributeName) === null || _a === void 0 ? void 0 : _a.startsWith('data-tooltip-'))) {
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
// make sure to get all set attributes, since all unset attributes are reset
|
|
3016
|
+
const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
|
|
3017
|
+
applyAllDataAttributesFromAnchorElement(dataAttributes);
|
|
3018
|
+
});
|
|
3019
|
+
};
|
|
3020
|
+
// Create an observer instance linked to the callback function
|
|
3021
|
+
const observer = new MutationObserver(observerCallback);
|
|
3022
|
+
// do not check for subtree and childrens, we only want to know attribute changes
|
|
3023
|
+
// to stay watching `data-attributes-*` from anchor element
|
|
3024
|
+
const observerConfig = { attributes: true, childList: false, subtree: false };
|
|
3025
|
+
if (anchorElement) {
|
|
3026
|
+
const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
|
|
3027
|
+
applyAllDataAttributesFromAnchorElement(dataAttributes);
|
|
3028
|
+
// Start observing the target node for configured mutations
|
|
3029
|
+
observer.observe(anchorElement, observerConfig);
|
|
3030
|
+
}
|
|
3031
|
+
return () => {
|
|
3032
|
+
// Remove the observer when the tooltip is destroyed
|
|
3033
|
+
observer.disconnect();
|
|
3034
|
+
};
|
|
3035
|
+
}, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]);
|
|
3036
|
+
/**
|
|
3037
|
+
* content priority: children < renderContent or content < html
|
|
3038
|
+
* children should be lower priority so that it can be used as the "default" content
|
|
3039
|
+
*/
|
|
3040
|
+
let renderedContent = children;
|
|
3041
|
+
if (render) {
|
|
3042
|
+
renderedContent = render({ content: tooltipContent !== null && tooltipContent !== void 0 ? tooltipContent : null, activeAnchor });
|
|
1307
3043
|
}
|
|
1308
|
-
if (
|
|
1309
|
-
|
|
3044
|
+
else if (tooltipContent) {
|
|
3045
|
+
renderedContent = tooltipContent;
|
|
1310
3046
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
mutationList.forEach((mutation) => {
|
|
1314
|
-
var _a2;
|
|
1315
|
-
if (!anchorElement || mutation.type !== "attributes" || !((_a2 = mutation.attributeName) == null ? void 0 : _a2.startsWith("data-tooltip-"))) {
|
|
1316
|
-
return;
|
|
1317
|
-
}
|
|
1318
|
-
const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
|
|
1319
|
-
applyAllDataAttributesFromAnchorElement(dataAttributes);
|
|
1320
|
-
});
|
|
1321
|
-
};
|
|
1322
|
-
const observer = new MutationObserver(observerCallback);
|
|
1323
|
-
const observerConfig = { attributes: true, childList: false, subtree: false };
|
|
1324
|
-
if (anchorElement) {
|
|
1325
|
-
const dataAttributes = getDataAttributesFromAnchorElement(anchorElement);
|
|
1326
|
-
applyAllDataAttributesFromAnchorElement(dataAttributes);
|
|
1327
|
-
observer.observe(anchorElement, observerConfig);
|
|
3047
|
+
if (tooltipHtml) {
|
|
3048
|
+
renderedContent = jsxRuntime.exports.jsx(TooltipContent, { content: tooltipHtml });
|
|
1328
3049
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
3050
|
+
const props = {
|
|
3051
|
+
id,
|
|
3052
|
+
anchorId,
|
|
3053
|
+
anchorSelect,
|
|
3054
|
+
className,
|
|
3055
|
+
classNameArrow,
|
|
3056
|
+
content: renderedContent,
|
|
3057
|
+
place: tooltipPlace,
|
|
3058
|
+
variant: tooltipVariant,
|
|
3059
|
+
offset: tooltipOffset,
|
|
3060
|
+
wrapper: tooltipWrapper,
|
|
3061
|
+
events: tooltipEvents,
|
|
3062
|
+
openOnClick,
|
|
3063
|
+
positionStrategy: tooltipPositionStrategy,
|
|
3064
|
+
middlewares,
|
|
3065
|
+
delayShow: tooltipDelayShow,
|
|
3066
|
+
delayHide: tooltipDelayHide,
|
|
3067
|
+
float: tooltipFloat,
|
|
3068
|
+
noArrow,
|
|
3069
|
+
clickable,
|
|
3070
|
+
closeOnEsc,
|
|
3071
|
+
style,
|
|
3072
|
+
position,
|
|
3073
|
+
isOpen,
|
|
3074
|
+
setIsOpen,
|
|
3075
|
+
afterShow,
|
|
3076
|
+
afterHide,
|
|
3077
|
+
activeAnchor,
|
|
3078
|
+
setActiveAnchor: (anchor) => setActiveAnchor(anchor),
|
|
1331
3079
|
};
|
|
1332
|
-
|
|
1333
|
-
let renderedContent = children;
|
|
1334
|
-
if (render) {
|
|
1335
|
-
renderedContent = render({ content: tooltipContent != null ? tooltipContent : null, activeAnchor });
|
|
1336
|
-
} else if (tooltipContent) {
|
|
1337
|
-
renderedContent = tooltipContent;
|
|
1338
|
-
}
|
|
1339
|
-
if (tooltipHtml) {
|
|
1340
|
-
renderedContent = /* @__PURE__ */ jsx5(TooltipContent_default, { content: tooltipHtml });
|
|
1341
|
-
}
|
|
1342
|
-
const props = {
|
|
1343
|
-
id,
|
|
1344
|
-
anchorId,
|
|
1345
|
-
anchorSelect,
|
|
1346
|
-
className,
|
|
1347
|
-
classNameArrow,
|
|
1348
|
-
content: renderedContent,
|
|
1349
|
-
place: tooltipPlace,
|
|
1350
|
-
variant: tooltipVariant,
|
|
1351
|
-
offset: tooltipOffset,
|
|
1352
|
-
wrapper: tooltipWrapper,
|
|
1353
|
-
events: tooltipEvents,
|
|
1354
|
-
openOnClick,
|
|
1355
|
-
positionStrategy: tooltipPositionStrategy,
|
|
1356
|
-
middlewares,
|
|
1357
|
-
delayShow: tooltipDelayShow,
|
|
1358
|
-
delayHide: tooltipDelayHide,
|
|
1359
|
-
float: tooltipFloat,
|
|
1360
|
-
noArrow,
|
|
1361
|
-
clickable,
|
|
1362
|
-
closeOnEsc,
|
|
1363
|
-
style,
|
|
1364
|
-
position,
|
|
1365
|
-
isOpen,
|
|
1366
|
-
setIsOpen,
|
|
1367
|
-
afterShow,
|
|
1368
|
-
afterHide,
|
|
1369
|
-
activeAnchor,
|
|
1370
|
-
setActiveAnchor: (anchor) => setActiveAnchor(anchor)
|
|
1371
|
-
};
|
|
1372
|
-
return /* @__PURE__ */ jsx5(Tooltip_default, { ...props });
|
|
1373
|
-
};
|
|
1374
|
-
var TooltipController_default = TooltipController;
|
|
1375
|
-
export {
|
|
1376
|
-
TooltipController_default as Tooltip,
|
|
1377
|
-
TooltipProvider_default as TooltipProvider,
|
|
1378
|
-
TooltipWrapper_default as TooltipWrapper
|
|
3080
|
+
return jsxRuntime.exports.jsx(Tooltip, { ...props });
|
|
1379
3081
|
};
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
classnames/index.js:
|
|
1383
|
-
(*!
|
|
1384
|
-
Copyright (c) 2018 Jed Watson.
|
|
1385
|
-
Licensed under the MIT License (MIT), see
|
|
1386
|
-
http://jedwatson.github.io/classnames
|
|
1387
|
-
*)
|
|
1388
|
-
*/
|
|
1389
|
-
//# sourceMappingURL=react-tooltip.mjs.map
|
|
3082
|
+
|
|
3083
|
+
export { TooltipController as Tooltip, TooltipProvider, TooltipWrapper };
|