vue-tippy 6.0.0-alpha.35 → 6.0.0-alpha.39
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{vue-tippy.cjs.js → vue-tippy.cjs} +328 -10
- package/dist/vue-tippy.d.ts +1 -0
- package/dist/{vue-tippy.esm-bundler.js → vue-tippy.esm-browser.js} +329 -11
- package/dist/vue-tippy.iife.js +328 -10
- package/dist/vue-tippy.iife.prod.js +6 -0
- package/dist/vue-tippy.mjs +4582 -0
- package/dist/{vue-tippy.cjs.prod.js → vue-tippy.prod.cjs} +328 -10
- package/index.cjs +7 -0
- package/index.js +2 -2
- package/package.json +18 -9
- package/dist/vue-tippy.global.prod.js +0 -6
- package/index.mjs +0 -1
@@ -0,0 +1,4582 @@
|
|
1
|
+
/*!
|
2
|
+
* vue-tippy v6.0.0-alpha.39
|
3
|
+
* (c) 2021
|
4
|
+
* @license MIT
|
5
|
+
*/
|
6
|
+
import { getCurrentInstance, ref, onMounted, onUnmounted, isRef, isReactive, watch, isVNode, render as render$1, h, defineComponent, nextTick } from 'vue';
|
7
|
+
|
8
|
+
var top = 'top';
|
9
|
+
var bottom = 'bottom';
|
10
|
+
var right = 'right';
|
11
|
+
var left = 'left';
|
12
|
+
var auto = 'auto';
|
13
|
+
var basePlacements = [top, bottom, right, left];
|
14
|
+
var start = 'start';
|
15
|
+
var end = 'end';
|
16
|
+
var clippingParents = 'clippingParents';
|
17
|
+
var viewport = 'viewport';
|
18
|
+
var popper = 'popper';
|
19
|
+
var reference = 'reference';
|
20
|
+
var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
|
21
|
+
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
22
|
+
}, []);
|
23
|
+
var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
24
|
+
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
25
|
+
}, []); // modifiers that need to read the DOM
|
26
|
+
|
27
|
+
var beforeRead = 'beforeRead';
|
28
|
+
var read = 'read';
|
29
|
+
var afterRead = 'afterRead'; // pure-logic modifiers
|
30
|
+
|
31
|
+
var beforeMain = 'beforeMain';
|
32
|
+
var main = 'main';
|
33
|
+
var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
|
34
|
+
|
35
|
+
var beforeWrite = 'beforeWrite';
|
36
|
+
var write = 'write';
|
37
|
+
var afterWrite = 'afterWrite';
|
38
|
+
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
39
|
+
|
40
|
+
function getNodeName(element) {
|
41
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
42
|
+
}
|
43
|
+
|
44
|
+
function getWindow(node) {
|
45
|
+
if (node == null) {
|
46
|
+
return window;
|
47
|
+
}
|
48
|
+
|
49
|
+
if (node.toString() !== '[object Window]') {
|
50
|
+
var ownerDocument = node.ownerDocument;
|
51
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
52
|
+
}
|
53
|
+
|
54
|
+
return node;
|
55
|
+
}
|
56
|
+
|
57
|
+
function isElement(node) {
|
58
|
+
var OwnElement = getWindow(node).Element;
|
59
|
+
return node instanceof OwnElement || node instanceof Element;
|
60
|
+
}
|
61
|
+
|
62
|
+
function isHTMLElement(node) {
|
63
|
+
var OwnElement = getWindow(node).HTMLElement;
|
64
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
65
|
+
}
|
66
|
+
|
67
|
+
function isShadowRoot(node) {
|
68
|
+
// IE 11 has no ShadowRoot
|
69
|
+
if (typeof ShadowRoot === 'undefined') {
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
|
73
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
74
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
75
|
+
}
|
76
|
+
|
77
|
+
// and applies them to the HTMLElements such as popper and arrow
|
78
|
+
|
79
|
+
function applyStyles(_ref) {
|
80
|
+
var state = _ref.state;
|
81
|
+
Object.keys(state.elements).forEach(function (name) {
|
82
|
+
var style = state.styles[name] || {};
|
83
|
+
var attributes = state.attributes[name] || {};
|
84
|
+
var element = state.elements[name]; // arrow is optional + virtual elements
|
85
|
+
|
86
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
87
|
+
return;
|
88
|
+
} // Flow doesn't support to extend this property, but it's the most
|
89
|
+
// effective way to apply styles to an HTMLElement
|
90
|
+
// $FlowFixMe[cannot-write]
|
91
|
+
|
92
|
+
|
93
|
+
Object.assign(element.style, style);
|
94
|
+
Object.keys(attributes).forEach(function (name) {
|
95
|
+
var value = attributes[name];
|
96
|
+
|
97
|
+
if (value === false) {
|
98
|
+
element.removeAttribute(name);
|
99
|
+
} else {
|
100
|
+
element.setAttribute(name, value === true ? '' : value);
|
101
|
+
}
|
102
|
+
});
|
103
|
+
});
|
104
|
+
}
|
105
|
+
|
106
|
+
function effect(_ref2) {
|
107
|
+
var state = _ref2.state;
|
108
|
+
var initialStyles = {
|
109
|
+
popper: {
|
110
|
+
position: state.options.strategy,
|
111
|
+
left: '0',
|
112
|
+
top: '0',
|
113
|
+
margin: '0'
|
114
|
+
},
|
115
|
+
arrow: {
|
116
|
+
position: 'absolute'
|
117
|
+
},
|
118
|
+
reference: {}
|
119
|
+
};
|
120
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
121
|
+
state.styles = initialStyles;
|
122
|
+
|
123
|
+
if (state.elements.arrow) {
|
124
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
125
|
+
}
|
126
|
+
|
127
|
+
return function () {
|
128
|
+
Object.keys(state.elements).forEach(function (name) {
|
129
|
+
var element = state.elements[name];
|
130
|
+
var attributes = state.attributes[name] || {};
|
131
|
+
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
|
132
|
+
|
133
|
+
var style = styleProperties.reduce(function (style, property) {
|
134
|
+
style[property] = '';
|
135
|
+
return style;
|
136
|
+
}, {}); // arrow is optional + virtual elements
|
137
|
+
|
138
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
|
142
|
+
Object.assign(element.style, style);
|
143
|
+
Object.keys(attributes).forEach(function (attribute) {
|
144
|
+
element.removeAttribute(attribute);
|
145
|
+
});
|
146
|
+
});
|
147
|
+
};
|
148
|
+
} // eslint-disable-next-line import/no-unused-modules
|
149
|
+
|
150
|
+
|
151
|
+
var applyStyles$1 = {
|
152
|
+
name: 'applyStyles',
|
153
|
+
enabled: true,
|
154
|
+
phase: 'write',
|
155
|
+
fn: applyStyles,
|
156
|
+
effect: effect,
|
157
|
+
requires: ['computeStyles']
|
158
|
+
};
|
159
|
+
|
160
|
+
function getBasePlacement(placement) {
|
161
|
+
return placement.split('-')[0];
|
162
|
+
}
|
163
|
+
|
164
|
+
function getBoundingClientRect(element) {
|
165
|
+
var rect = element.getBoundingClientRect();
|
166
|
+
return {
|
167
|
+
width: rect.width,
|
168
|
+
height: rect.height,
|
169
|
+
top: rect.top,
|
170
|
+
right: rect.right,
|
171
|
+
bottom: rect.bottom,
|
172
|
+
left: rect.left,
|
173
|
+
x: rect.left,
|
174
|
+
y: rect.top
|
175
|
+
};
|
176
|
+
}
|
177
|
+
|
178
|
+
// means it doesn't take into account transforms.
|
179
|
+
|
180
|
+
function getLayoutRect(element) {
|
181
|
+
var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
|
182
|
+
// Fixes https://github.com/popperjs/popper-core/issues/1223
|
183
|
+
|
184
|
+
var width = element.offsetWidth;
|
185
|
+
var height = element.offsetHeight;
|
186
|
+
|
187
|
+
if (Math.abs(clientRect.width - width) <= 1) {
|
188
|
+
width = clientRect.width;
|
189
|
+
}
|
190
|
+
|
191
|
+
if (Math.abs(clientRect.height - height) <= 1) {
|
192
|
+
height = clientRect.height;
|
193
|
+
}
|
194
|
+
|
195
|
+
return {
|
196
|
+
x: element.offsetLeft,
|
197
|
+
y: element.offsetTop,
|
198
|
+
width: width,
|
199
|
+
height: height
|
200
|
+
};
|
201
|
+
}
|
202
|
+
|
203
|
+
function contains(parent, child) {
|
204
|
+
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
205
|
+
|
206
|
+
if (parent.contains(child)) {
|
207
|
+
return true;
|
208
|
+
} // then fallback to custom implementation with Shadow DOM support
|
209
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
210
|
+
var next = child;
|
211
|
+
|
212
|
+
do {
|
213
|
+
if (next && parent.isSameNode(next)) {
|
214
|
+
return true;
|
215
|
+
} // $FlowFixMe[prop-missing]: need a better way to handle this...
|
216
|
+
|
217
|
+
|
218
|
+
next = next.parentNode || next.host;
|
219
|
+
} while (next);
|
220
|
+
} // Give up, the result is false
|
221
|
+
|
222
|
+
|
223
|
+
return false;
|
224
|
+
}
|
225
|
+
|
226
|
+
function getComputedStyle(element) {
|
227
|
+
return getWindow(element).getComputedStyle(element);
|
228
|
+
}
|
229
|
+
|
230
|
+
function isTableElement(element) {
|
231
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
232
|
+
}
|
233
|
+
|
234
|
+
function getDocumentElement(element) {
|
235
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
236
|
+
return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
|
237
|
+
element.document) || window.document).documentElement;
|
238
|
+
}
|
239
|
+
|
240
|
+
function getParentNode(element) {
|
241
|
+
if (getNodeName(element) === 'html') {
|
242
|
+
return element;
|
243
|
+
}
|
244
|
+
|
245
|
+
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
246
|
+
// $FlowFixMe[incompatible-return]
|
247
|
+
// $FlowFixMe[prop-missing]
|
248
|
+
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
249
|
+
element.parentNode || ( // DOM Element detected
|
250
|
+
isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
251
|
+
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
252
|
+
getDocumentElement(element) // fallback
|
253
|
+
|
254
|
+
);
|
255
|
+
}
|
256
|
+
|
257
|
+
function getTrueOffsetParent(element) {
|
258
|
+
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
259
|
+
getComputedStyle(element).position === 'fixed') {
|
260
|
+
return null;
|
261
|
+
}
|
262
|
+
|
263
|
+
return element.offsetParent;
|
264
|
+
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
|
265
|
+
// return the containing block
|
266
|
+
|
267
|
+
|
268
|
+
function getContainingBlock(element) {
|
269
|
+
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
|
270
|
+
var isIE = navigator.userAgent.indexOf('Trident') !== -1;
|
271
|
+
|
272
|
+
if (isIE && isHTMLElement(element)) {
|
273
|
+
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
274
|
+
var elementCss = getComputedStyle(element);
|
275
|
+
|
276
|
+
if (elementCss.position === 'fixed') {
|
277
|
+
return null;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
281
|
+
var currentNode = getParentNode(element);
|
282
|
+
|
283
|
+
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
284
|
+
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
285
|
+
// create a containing block.
|
286
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
287
|
+
|
288
|
+
if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
|
289
|
+
return currentNode;
|
290
|
+
} else {
|
291
|
+
currentNode = currentNode.parentNode;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
return null;
|
296
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
297
|
+
// such as table ancestors and cross browser bugs.
|
298
|
+
|
299
|
+
|
300
|
+
function getOffsetParent(element) {
|
301
|
+
var window = getWindow(element);
|
302
|
+
var offsetParent = getTrueOffsetParent(element);
|
303
|
+
|
304
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
305
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
306
|
+
}
|
307
|
+
|
308
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
|
309
|
+
return window;
|
310
|
+
}
|
311
|
+
|
312
|
+
return offsetParent || getContainingBlock(element) || window;
|
313
|
+
}
|
314
|
+
|
315
|
+
function getMainAxisFromPlacement(placement) {
|
316
|
+
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
317
|
+
}
|
318
|
+
|
319
|
+
var max = Math.max;
|
320
|
+
var min = Math.min;
|
321
|
+
var round = Math.round;
|
322
|
+
|
323
|
+
function within(min$1, value, max$1) {
|
324
|
+
return max(min$1, min(value, max$1));
|
325
|
+
}
|
326
|
+
|
327
|
+
function getFreshSideObject() {
|
328
|
+
return {
|
329
|
+
top: 0,
|
330
|
+
right: 0,
|
331
|
+
bottom: 0,
|
332
|
+
left: 0
|
333
|
+
};
|
334
|
+
}
|
335
|
+
|
336
|
+
function mergePaddingObject(paddingObject) {
|
337
|
+
return Object.assign({}, getFreshSideObject(), paddingObject);
|
338
|
+
}
|
339
|
+
|
340
|
+
function expandToHashMap(value, keys) {
|
341
|
+
return keys.reduce(function (hashMap, key) {
|
342
|
+
hashMap[key] = value;
|
343
|
+
return hashMap;
|
344
|
+
}, {});
|
345
|
+
}
|
346
|
+
|
347
|
+
var toPaddingObject = function toPaddingObject(padding, state) {
|
348
|
+
padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
349
|
+
placement: state.placement
|
350
|
+
})) : padding;
|
351
|
+
return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
352
|
+
};
|
353
|
+
|
354
|
+
function arrow(_ref) {
|
355
|
+
var _state$modifiersData$;
|
356
|
+
|
357
|
+
var state = _ref.state,
|
358
|
+
name = _ref.name,
|
359
|
+
options = _ref.options;
|
360
|
+
var arrowElement = state.elements.arrow;
|
361
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
362
|
+
var basePlacement = getBasePlacement(state.placement);
|
363
|
+
var axis = getMainAxisFromPlacement(basePlacement);
|
364
|
+
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
365
|
+
var len = isVertical ? 'height' : 'width';
|
366
|
+
|
367
|
+
if (!arrowElement || !popperOffsets) {
|
368
|
+
return;
|
369
|
+
}
|
370
|
+
|
371
|
+
var paddingObject = toPaddingObject(options.padding, state);
|
372
|
+
var arrowRect = getLayoutRect(arrowElement);
|
373
|
+
var minProp = axis === 'y' ? top : left;
|
374
|
+
var maxProp = axis === 'y' ? bottom : right;
|
375
|
+
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
376
|
+
var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
377
|
+
var arrowOffsetParent = getOffsetParent(arrowElement);
|
378
|
+
var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
379
|
+
var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
|
380
|
+
// outside of the popper bounds
|
381
|
+
|
382
|
+
var min = paddingObject[minProp];
|
383
|
+
var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
384
|
+
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
385
|
+
var offset = within(min, center, max); // Prevents breaking syntax highlighting...
|
386
|
+
|
387
|
+
var axisProp = axis;
|
388
|
+
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
389
|
+
}
|
390
|
+
|
391
|
+
function effect$1(_ref2) {
|
392
|
+
var state = _ref2.state,
|
393
|
+
options = _ref2.options;
|
394
|
+
var _options$element = options.element,
|
395
|
+
arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
396
|
+
|
397
|
+
if (arrowElement == null) {
|
398
|
+
return;
|
399
|
+
} // CSS selector
|
400
|
+
|
401
|
+
|
402
|
+
if (typeof arrowElement === 'string') {
|
403
|
+
arrowElement = state.elements.popper.querySelector(arrowElement);
|
404
|
+
|
405
|
+
if (!arrowElement) {
|
406
|
+
return;
|
407
|
+
}
|
408
|
+
}
|
409
|
+
|
410
|
+
if (process.env.NODE_ENV !== "production") {
|
411
|
+
if (!isHTMLElement(arrowElement)) {
|
412
|
+
console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
if (!contains(state.elements.popper, arrowElement)) {
|
417
|
+
if (process.env.NODE_ENV !== "production") {
|
418
|
+
console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
|
419
|
+
}
|
420
|
+
|
421
|
+
return;
|
422
|
+
}
|
423
|
+
|
424
|
+
state.elements.arrow = arrowElement;
|
425
|
+
} // eslint-disable-next-line import/no-unused-modules
|
426
|
+
|
427
|
+
|
428
|
+
var arrow$1 = {
|
429
|
+
name: 'arrow',
|
430
|
+
enabled: true,
|
431
|
+
phase: 'main',
|
432
|
+
fn: arrow,
|
433
|
+
effect: effect$1,
|
434
|
+
requires: ['popperOffsets'],
|
435
|
+
requiresIfExists: ['preventOverflow']
|
436
|
+
};
|
437
|
+
|
438
|
+
var unsetSides = {
|
439
|
+
top: 'auto',
|
440
|
+
right: 'auto',
|
441
|
+
bottom: 'auto',
|
442
|
+
left: 'auto'
|
443
|
+
}; // Round the offsets to the nearest suitable subpixel based on the DPR.
|
444
|
+
// Zooming can change the DPR, but it seems to report a value that will
|
445
|
+
// cleanly divide the values into the appropriate subpixels.
|
446
|
+
|
447
|
+
function roundOffsetsByDPR(_ref) {
|
448
|
+
var x = _ref.x,
|
449
|
+
y = _ref.y;
|
450
|
+
var win = window;
|
451
|
+
var dpr = win.devicePixelRatio || 1;
|
452
|
+
return {
|
453
|
+
x: round(round(x * dpr) / dpr) || 0,
|
454
|
+
y: round(round(y * dpr) / dpr) || 0
|
455
|
+
};
|
456
|
+
}
|
457
|
+
|
458
|
+
function mapToStyles(_ref2) {
|
459
|
+
var _Object$assign2;
|
460
|
+
|
461
|
+
var popper = _ref2.popper,
|
462
|
+
popperRect = _ref2.popperRect,
|
463
|
+
placement = _ref2.placement,
|
464
|
+
offsets = _ref2.offsets,
|
465
|
+
position = _ref2.position,
|
466
|
+
gpuAcceleration = _ref2.gpuAcceleration,
|
467
|
+
adaptive = _ref2.adaptive,
|
468
|
+
roundOffsets = _ref2.roundOffsets;
|
469
|
+
|
470
|
+
var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
|
471
|
+
_ref3$x = _ref3.x,
|
472
|
+
x = _ref3$x === void 0 ? 0 : _ref3$x,
|
473
|
+
_ref3$y = _ref3.y,
|
474
|
+
y = _ref3$y === void 0 ? 0 : _ref3$y;
|
475
|
+
|
476
|
+
var hasX = offsets.hasOwnProperty('x');
|
477
|
+
var hasY = offsets.hasOwnProperty('y');
|
478
|
+
var sideX = left;
|
479
|
+
var sideY = top;
|
480
|
+
var win = window;
|
481
|
+
|
482
|
+
if (adaptive) {
|
483
|
+
var offsetParent = getOffsetParent(popper);
|
484
|
+
var heightProp = 'clientHeight';
|
485
|
+
var widthProp = 'clientWidth';
|
486
|
+
|
487
|
+
if (offsetParent === getWindow(popper)) {
|
488
|
+
offsetParent = getDocumentElement(popper);
|
489
|
+
|
490
|
+
if (getComputedStyle(offsetParent).position !== 'static') {
|
491
|
+
heightProp = 'scrollHeight';
|
492
|
+
widthProp = 'scrollWidth';
|
493
|
+
}
|
494
|
+
} // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
|
495
|
+
|
496
|
+
|
497
|
+
offsetParent = offsetParent;
|
498
|
+
|
499
|
+
if (placement === top) {
|
500
|
+
sideY = bottom; // $FlowFixMe[prop-missing]
|
501
|
+
|
502
|
+
y -= offsetParent[heightProp] - popperRect.height;
|
503
|
+
y *= gpuAcceleration ? 1 : -1;
|
504
|
+
}
|
505
|
+
|
506
|
+
if (placement === left) {
|
507
|
+
sideX = right; // $FlowFixMe[prop-missing]
|
508
|
+
|
509
|
+
x -= offsetParent[widthProp] - popperRect.width;
|
510
|
+
x *= gpuAcceleration ? 1 : -1;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
var commonStyles = Object.assign({
|
515
|
+
position: position
|
516
|
+
}, adaptive && unsetSides);
|
517
|
+
|
518
|
+
if (gpuAcceleration) {
|
519
|
+
var _Object$assign;
|
520
|
+
|
521
|
+
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
522
|
+
}
|
523
|
+
|
524
|
+
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
525
|
+
}
|
526
|
+
|
527
|
+
function computeStyles(_ref4) {
|
528
|
+
var state = _ref4.state,
|
529
|
+
options = _ref4.options;
|
530
|
+
var _options$gpuAccelerat = options.gpuAcceleration,
|
531
|
+
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
532
|
+
_options$adaptive = options.adaptive,
|
533
|
+
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
534
|
+
_options$roundOffsets = options.roundOffsets,
|
535
|
+
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
536
|
+
|
537
|
+
if (process.env.NODE_ENV !== "production") {
|
538
|
+
var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
|
539
|
+
|
540
|
+
if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
|
541
|
+
return transitionProperty.indexOf(property) >= 0;
|
542
|
+
})) {
|
543
|
+
console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
|
544
|
+
}
|
545
|
+
}
|
546
|
+
|
547
|
+
var commonStyles = {
|
548
|
+
placement: getBasePlacement(state.placement),
|
549
|
+
popper: state.elements.popper,
|
550
|
+
popperRect: state.rects.popper,
|
551
|
+
gpuAcceleration: gpuAcceleration
|
552
|
+
};
|
553
|
+
|
554
|
+
if (state.modifiersData.popperOffsets != null) {
|
555
|
+
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
556
|
+
offsets: state.modifiersData.popperOffsets,
|
557
|
+
position: state.options.strategy,
|
558
|
+
adaptive: adaptive,
|
559
|
+
roundOffsets: roundOffsets
|
560
|
+
})));
|
561
|
+
}
|
562
|
+
|
563
|
+
if (state.modifiersData.arrow != null) {
|
564
|
+
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
565
|
+
offsets: state.modifiersData.arrow,
|
566
|
+
position: 'absolute',
|
567
|
+
adaptive: false,
|
568
|
+
roundOffsets: roundOffsets
|
569
|
+
})));
|
570
|
+
}
|
571
|
+
|
572
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
573
|
+
'data-popper-placement': state.placement
|
574
|
+
});
|
575
|
+
} // eslint-disable-next-line import/no-unused-modules
|
576
|
+
|
577
|
+
|
578
|
+
var computeStyles$1 = {
|
579
|
+
name: 'computeStyles',
|
580
|
+
enabled: true,
|
581
|
+
phase: 'beforeWrite',
|
582
|
+
fn: computeStyles,
|
583
|
+
data: {}
|
584
|
+
};
|
585
|
+
|
586
|
+
var passive = {
|
587
|
+
passive: true
|
588
|
+
};
|
589
|
+
|
590
|
+
function effect$2(_ref) {
|
591
|
+
var state = _ref.state,
|
592
|
+
instance = _ref.instance,
|
593
|
+
options = _ref.options;
|
594
|
+
var _options$scroll = options.scroll,
|
595
|
+
scroll = _options$scroll === void 0 ? true : _options$scroll,
|
596
|
+
_options$resize = options.resize,
|
597
|
+
resize = _options$resize === void 0 ? true : _options$resize;
|
598
|
+
var window = getWindow(state.elements.popper);
|
599
|
+
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
600
|
+
|
601
|
+
if (scroll) {
|
602
|
+
scrollParents.forEach(function (scrollParent) {
|
603
|
+
scrollParent.addEventListener('scroll', instance.update, passive);
|
604
|
+
});
|
605
|
+
}
|
606
|
+
|
607
|
+
if (resize) {
|
608
|
+
window.addEventListener('resize', instance.update, passive);
|
609
|
+
}
|
610
|
+
|
611
|
+
return function () {
|
612
|
+
if (scroll) {
|
613
|
+
scrollParents.forEach(function (scrollParent) {
|
614
|
+
scrollParent.removeEventListener('scroll', instance.update, passive);
|
615
|
+
});
|
616
|
+
}
|
617
|
+
|
618
|
+
if (resize) {
|
619
|
+
window.removeEventListener('resize', instance.update, passive);
|
620
|
+
}
|
621
|
+
};
|
622
|
+
} // eslint-disable-next-line import/no-unused-modules
|
623
|
+
|
624
|
+
|
625
|
+
var eventListeners = {
|
626
|
+
name: 'eventListeners',
|
627
|
+
enabled: true,
|
628
|
+
phase: 'write',
|
629
|
+
fn: function fn() {},
|
630
|
+
effect: effect$2,
|
631
|
+
data: {}
|
632
|
+
};
|
633
|
+
|
634
|
+
var hash = {
|
635
|
+
left: 'right',
|
636
|
+
right: 'left',
|
637
|
+
bottom: 'top',
|
638
|
+
top: 'bottom'
|
639
|
+
};
|
640
|
+
function getOppositePlacement(placement) {
|
641
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
642
|
+
return hash[matched];
|
643
|
+
});
|
644
|
+
}
|
645
|
+
|
646
|
+
var hash$1 = {
|
647
|
+
start: 'end',
|
648
|
+
end: 'start'
|
649
|
+
};
|
650
|
+
function getOppositeVariationPlacement(placement) {
|
651
|
+
return placement.replace(/start|end/g, function (matched) {
|
652
|
+
return hash$1[matched];
|
653
|
+
});
|
654
|
+
}
|
655
|
+
|
656
|
+
function getWindowScroll(node) {
|
657
|
+
var win = getWindow(node);
|
658
|
+
var scrollLeft = win.pageXOffset;
|
659
|
+
var scrollTop = win.pageYOffset;
|
660
|
+
return {
|
661
|
+
scrollLeft: scrollLeft,
|
662
|
+
scrollTop: scrollTop
|
663
|
+
};
|
664
|
+
}
|
665
|
+
|
666
|
+
function getWindowScrollBarX(element) {
|
667
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
668
|
+
// incorrect for RTL.
|
669
|
+
// Popper 1 is broken in this case and never had a bug report so let's assume
|
670
|
+
// it's not an issue. I don't think anyone ever specifies width on <html>
|
671
|
+
// anyway.
|
672
|
+
// Browsers where the left scrollbar doesn't cause an issue report `0` for
|
673
|
+
// this (e.g. Edge 2019, IE11, Safari)
|
674
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
675
|
+
}
|
676
|
+
|
677
|
+
function getViewportRect(element) {
|
678
|
+
var win = getWindow(element);
|
679
|
+
var html = getDocumentElement(element);
|
680
|
+
var visualViewport = win.visualViewport;
|
681
|
+
var width = html.clientWidth;
|
682
|
+
var height = html.clientHeight;
|
683
|
+
var x = 0;
|
684
|
+
var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
|
685
|
+
// can be obscured underneath it.
|
686
|
+
// Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
|
687
|
+
// if it isn't open, so if this isn't available, the popper will be detected
|
688
|
+
// to overflow the bottom of the screen too early.
|
689
|
+
|
690
|
+
if (visualViewport) {
|
691
|
+
width = visualViewport.width;
|
692
|
+
height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
|
693
|
+
// In Chrome, it returns a value very close to 0 (+/-) but contains rounding
|
694
|
+
// errors due to floating point numbers, so we need to check precision.
|
695
|
+
// Safari returns a number <= 0, usually < -1 when pinch-zoomed
|
696
|
+
// Feature detection fails in mobile emulation mode in Chrome.
|
697
|
+
// Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
|
698
|
+
// 0.001
|
699
|
+
// Fallback here: "Not Safari" userAgent
|
700
|
+
|
701
|
+
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
702
|
+
x = visualViewport.offsetLeft;
|
703
|
+
y = visualViewport.offsetTop;
|
704
|
+
}
|
705
|
+
}
|
706
|
+
|
707
|
+
return {
|
708
|
+
width: width,
|
709
|
+
height: height,
|
710
|
+
x: x + getWindowScrollBarX(element),
|
711
|
+
y: y
|
712
|
+
};
|
713
|
+
}
|
714
|
+
|
715
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
716
|
+
|
717
|
+
function getDocumentRect(element) {
|
718
|
+
var _element$ownerDocumen;
|
719
|
+
|
720
|
+
var html = getDocumentElement(element);
|
721
|
+
var winScroll = getWindowScroll(element);
|
722
|
+
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
723
|
+
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
724
|
+
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
725
|
+
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
726
|
+
var y = -winScroll.scrollTop;
|
727
|
+
|
728
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
729
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
730
|
+
}
|
731
|
+
|
732
|
+
return {
|
733
|
+
width: width,
|
734
|
+
height: height,
|
735
|
+
x: x,
|
736
|
+
y: y
|
737
|
+
};
|
738
|
+
}
|
739
|
+
|
740
|
+
function isScrollParent(element) {
|
741
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
742
|
+
var _getComputedStyle = getComputedStyle(element),
|
743
|
+
overflow = _getComputedStyle.overflow,
|
744
|
+
overflowX = _getComputedStyle.overflowX,
|
745
|
+
overflowY = _getComputedStyle.overflowY;
|
746
|
+
|
747
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
748
|
+
}
|
749
|
+
|
750
|
+
function getScrollParent(node) {
|
751
|
+
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
752
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
753
|
+
return node.ownerDocument.body;
|
754
|
+
}
|
755
|
+
|
756
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
757
|
+
return node;
|
758
|
+
}
|
759
|
+
|
760
|
+
return getScrollParent(getParentNode(node));
|
761
|
+
}
|
762
|
+
|
763
|
+
/*
|
764
|
+
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
765
|
+
until we get to the top window object. This list is what we attach scroll listeners
|
766
|
+
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
767
|
+
reference element's position.
|
768
|
+
*/
|
769
|
+
|
770
|
+
function listScrollParents(element, list) {
|
771
|
+
var _element$ownerDocumen;
|
772
|
+
|
773
|
+
if (list === void 0) {
|
774
|
+
list = [];
|
775
|
+
}
|
776
|
+
|
777
|
+
var scrollParent = getScrollParent(element);
|
778
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
779
|
+
var win = getWindow(scrollParent);
|
780
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
781
|
+
var updatedList = list.concat(target);
|
782
|
+
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
783
|
+
updatedList.concat(listScrollParents(getParentNode(target)));
|
784
|
+
}
|
785
|
+
|
786
|
+
function rectToClientRect(rect) {
|
787
|
+
return Object.assign({}, rect, {
|
788
|
+
left: rect.x,
|
789
|
+
top: rect.y,
|
790
|
+
right: rect.x + rect.width,
|
791
|
+
bottom: rect.y + rect.height
|
792
|
+
});
|
793
|
+
}
|
794
|
+
|
795
|
+
function getInnerBoundingClientRect(element) {
|
796
|
+
var rect = getBoundingClientRect(element);
|
797
|
+
rect.top = rect.top + element.clientTop;
|
798
|
+
rect.left = rect.left + element.clientLeft;
|
799
|
+
rect.bottom = rect.top + element.clientHeight;
|
800
|
+
rect.right = rect.left + element.clientWidth;
|
801
|
+
rect.width = element.clientWidth;
|
802
|
+
rect.height = element.clientHeight;
|
803
|
+
rect.x = rect.left;
|
804
|
+
rect.y = rect.top;
|
805
|
+
return rect;
|
806
|
+
}
|
807
|
+
|
808
|
+
function getClientRectFromMixedType(element, clippingParent) {
|
809
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
810
|
+
} // A "clipping parent" is an overflowable container with the characteristic of
|
811
|
+
// clipping (or hiding) overflowing elements with a position different from
|
812
|
+
// `initial`
|
813
|
+
|
814
|
+
|
815
|
+
function getClippingParents(element) {
|
816
|
+
var clippingParents = listScrollParents(getParentNode(element));
|
817
|
+
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
818
|
+
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
819
|
+
|
820
|
+
if (!isElement(clipperElement)) {
|
821
|
+
return [];
|
822
|
+
} // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
|
823
|
+
|
824
|
+
|
825
|
+
return clippingParents.filter(function (clippingParent) {
|
826
|
+
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
827
|
+
});
|
828
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
829
|
+
// clipping parents
|
830
|
+
|
831
|
+
|
832
|
+
function getClippingRect(element, boundary, rootBoundary) {
|
833
|
+
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
834
|
+
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
835
|
+
var firstClippingParent = clippingParents[0];
|
836
|
+
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
837
|
+
var rect = getClientRectFromMixedType(element, clippingParent);
|
838
|
+
accRect.top = max(rect.top, accRect.top);
|
839
|
+
accRect.right = min(rect.right, accRect.right);
|
840
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
841
|
+
accRect.left = max(rect.left, accRect.left);
|
842
|
+
return accRect;
|
843
|
+
}, getClientRectFromMixedType(element, firstClippingParent));
|
844
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
845
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
846
|
+
clippingRect.x = clippingRect.left;
|
847
|
+
clippingRect.y = clippingRect.top;
|
848
|
+
return clippingRect;
|
849
|
+
}
|
850
|
+
|
851
|
+
function getVariation(placement) {
|
852
|
+
return placement.split('-')[1];
|
853
|
+
}
|
854
|
+
|
855
|
+
function computeOffsets(_ref) {
|
856
|
+
var reference = _ref.reference,
|
857
|
+
element = _ref.element,
|
858
|
+
placement = _ref.placement;
|
859
|
+
var basePlacement = placement ? getBasePlacement(placement) : null;
|
860
|
+
var variation = placement ? getVariation(placement) : null;
|
861
|
+
var commonX = reference.x + reference.width / 2 - element.width / 2;
|
862
|
+
var commonY = reference.y + reference.height / 2 - element.height / 2;
|
863
|
+
var offsets;
|
864
|
+
|
865
|
+
switch (basePlacement) {
|
866
|
+
case top:
|
867
|
+
offsets = {
|
868
|
+
x: commonX,
|
869
|
+
y: reference.y - element.height
|
870
|
+
};
|
871
|
+
break;
|
872
|
+
|
873
|
+
case bottom:
|
874
|
+
offsets = {
|
875
|
+
x: commonX,
|
876
|
+
y: reference.y + reference.height
|
877
|
+
};
|
878
|
+
break;
|
879
|
+
|
880
|
+
case right:
|
881
|
+
offsets = {
|
882
|
+
x: reference.x + reference.width,
|
883
|
+
y: commonY
|
884
|
+
};
|
885
|
+
break;
|
886
|
+
|
887
|
+
case left:
|
888
|
+
offsets = {
|
889
|
+
x: reference.x - element.width,
|
890
|
+
y: commonY
|
891
|
+
};
|
892
|
+
break;
|
893
|
+
|
894
|
+
default:
|
895
|
+
offsets = {
|
896
|
+
x: reference.x,
|
897
|
+
y: reference.y
|
898
|
+
};
|
899
|
+
}
|
900
|
+
|
901
|
+
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
902
|
+
|
903
|
+
if (mainAxis != null) {
|
904
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
905
|
+
|
906
|
+
switch (variation) {
|
907
|
+
case start:
|
908
|
+
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
909
|
+
break;
|
910
|
+
|
911
|
+
case end:
|
912
|
+
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
913
|
+
break;
|
914
|
+
}
|
915
|
+
}
|
916
|
+
|
917
|
+
return offsets;
|
918
|
+
}
|
919
|
+
|
920
|
+
function detectOverflow(state, options) {
|
921
|
+
if (options === void 0) {
|
922
|
+
options = {};
|
923
|
+
}
|
924
|
+
|
925
|
+
var _options = options,
|
926
|
+
_options$placement = _options.placement,
|
927
|
+
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
928
|
+
_options$boundary = _options.boundary,
|
929
|
+
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
930
|
+
_options$rootBoundary = _options.rootBoundary,
|
931
|
+
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
932
|
+
_options$elementConte = _options.elementContext,
|
933
|
+
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
934
|
+
_options$altBoundary = _options.altBoundary,
|
935
|
+
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
936
|
+
_options$padding = _options.padding,
|
937
|
+
padding = _options$padding === void 0 ? 0 : _options$padding;
|
938
|
+
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
939
|
+
var altContext = elementContext === popper ? reference : popper;
|
940
|
+
var referenceElement = state.elements.reference;
|
941
|
+
var popperRect = state.rects.popper;
|
942
|
+
var element = state.elements[altBoundary ? altContext : elementContext];
|
943
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
944
|
+
var referenceClientRect = getBoundingClientRect(referenceElement);
|
945
|
+
var popperOffsets = computeOffsets({
|
946
|
+
reference: referenceClientRect,
|
947
|
+
element: popperRect,
|
948
|
+
strategy: 'absolute',
|
949
|
+
placement: placement
|
950
|
+
});
|
951
|
+
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
952
|
+
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
|
953
|
+
// 0 or negative = within the clipping rect
|
954
|
+
|
955
|
+
var overflowOffsets = {
|
956
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
957
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
958
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
959
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
960
|
+
};
|
961
|
+
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
|
962
|
+
|
963
|
+
if (elementContext === popper && offsetData) {
|
964
|
+
var offset = offsetData[placement];
|
965
|
+
Object.keys(overflowOffsets).forEach(function (key) {
|
966
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
967
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
968
|
+
overflowOffsets[key] += offset[axis] * multiply;
|
969
|
+
});
|
970
|
+
}
|
971
|
+
|
972
|
+
return overflowOffsets;
|
973
|
+
}
|
974
|
+
|
975
|
+
function computeAutoPlacement(state, options) {
|
976
|
+
if (options === void 0) {
|
977
|
+
options = {};
|
978
|
+
}
|
979
|
+
|
980
|
+
var _options = options,
|
981
|
+
placement = _options.placement,
|
982
|
+
boundary = _options.boundary,
|
983
|
+
rootBoundary = _options.rootBoundary,
|
984
|
+
padding = _options.padding,
|
985
|
+
flipVariations = _options.flipVariations,
|
986
|
+
_options$allowedAutoP = _options.allowedAutoPlacements,
|
987
|
+
allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
988
|
+
var variation = getVariation(placement);
|
989
|
+
var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
|
990
|
+
return getVariation(placement) === variation;
|
991
|
+
}) : basePlacements;
|
992
|
+
var allowedPlacements = placements$1.filter(function (placement) {
|
993
|
+
return allowedAutoPlacements.indexOf(placement) >= 0;
|
994
|
+
});
|
995
|
+
|
996
|
+
if (allowedPlacements.length === 0) {
|
997
|
+
allowedPlacements = placements$1;
|
998
|
+
|
999
|
+
if (process.env.NODE_ENV !== "production") {
|
1000
|
+
console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
|
1001
|
+
}
|
1002
|
+
} // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
|
1003
|
+
|
1004
|
+
|
1005
|
+
var overflows = allowedPlacements.reduce(function (acc, placement) {
|
1006
|
+
acc[placement] = detectOverflow(state, {
|
1007
|
+
placement: placement,
|
1008
|
+
boundary: boundary,
|
1009
|
+
rootBoundary: rootBoundary,
|
1010
|
+
padding: padding
|
1011
|
+
})[getBasePlacement(placement)];
|
1012
|
+
return acc;
|
1013
|
+
}, {});
|
1014
|
+
return Object.keys(overflows).sort(function (a, b) {
|
1015
|
+
return overflows[a] - overflows[b];
|
1016
|
+
});
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
function getExpandedFallbackPlacements(placement) {
|
1020
|
+
if (getBasePlacement(placement) === auto) {
|
1021
|
+
return [];
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
var oppositePlacement = getOppositePlacement(placement);
|
1025
|
+
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
function flip(_ref) {
|
1029
|
+
var state = _ref.state,
|
1030
|
+
options = _ref.options,
|
1031
|
+
name = _ref.name;
|
1032
|
+
|
1033
|
+
if (state.modifiersData[name]._skip) {
|
1034
|
+
return;
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
var _options$mainAxis = options.mainAxis,
|
1038
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
1039
|
+
_options$altAxis = options.altAxis,
|
1040
|
+
checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
1041
|
+
specifiedFallbackPlacements = options.fallbackPlacements,
|
1042
|
+
padding = options.padding,
|
1043
|
+
boundary = options.boundary,
|
1044
|
+
rootBoundary = options.rootBoundary,
|
1045
|
+
altBoundary = options.altBoundary,
|
1046
|
+
_options$flipVariatio = options.flipVariations,
|
1047
|
+
flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
1048
|
+
allowedAutoPlacements = options.allowedAutoPlacements;
|
1049
|
+
var preferredPlacement = state.options.placement;
|
1050
|
+
var basePlacement = getBasePlacement(preferredPlacement);
|
1051
|
+
var isBasePlacement = basePlacement === preferredPlacement;
|
1052
|
+
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
1053
|
+
var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
1054
|
+
return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
1055
|
+
placement: placement,
|
1056
|
+
boundary: boundary,
|
1057
|
+
rootBoundary: rootBoundary,
|
1058
|
+
padding: padding,
|
1059
|
+
flipVariations: flipVariations,
|
1060
|
+
allowedAutoPlacements: allowedAutoPlacements
|
1061
|
+
}) : placement);
|
1062
|
+
}, []);
|
1063
|
+
var referenceRect = state.rects.reference;
|
1064
|
+
var popperRect = state.rects.popper;
|
1065
|
+
var checksMap = new Map();
|
1066
|
+
var makeFallbackChecks = true;
|
1067
|
+
var firstFittingPlacement = placements[0];
|
1068
|
+
|
1069
|
+
for (var i = 0; i < placements.length; i++) {
|
1070
|
+
var placement = placements[i];
|
1071
|
+
|
1072
|
+
var _basePlacement = getBasePlacement(placement);
|
1073
|
+
|
1074
|
+
var isStartVariation = getVariation(placement) === start;
|
1075
|
+
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
1076
|
+
var len = isVertical ? 'width' : 'height';
|
1077
|
+
var overflow = detectOverflow(state, {
|
1078
|
+
placement: placement,
|
1079
|
+
boundary: boundary,
|
1080
|
+
rootBoundary: rootBoundary,
|
1081
|
+
altBoundary: altBoundary,
|
1082
|
+
padding: padding
|
1083
|
+
});
|
1084
|
+
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
1085
|
+
|
1086
|
+
if (referenceRect[len] > popperRect[len]) {
|
1087
|
+
mainVariationSide = getOppositePlacement(mainVariationSide);
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
var altVariationSide = getOppositePlacement(mainVariationSide);
|
1091
|
+
var checks = [];
|
1092
|
+
|
1093
|
+
if (checkMainAxis) {
|
1094
|
+
checks.push(overflow[_basePlacement] <= 0);
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
if (checkAltAxis) {
|
1098
|
+
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
if (checks.every(function (check) {
|
1102
|
+
return check;
|
1103
|
+
})) {
|
1104
|
+
firstFittingPlacement = placement;
|
1105
|
+
makeFallbackChecks = false;
|
1106
|
+
break;
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
checksMap.set(placement, checks);
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
if (makeFallbackChecks) {
|
1113
|
+
// `2` may be desired in some cases – research later
|
1114
|
+
var numberOfChecks = flipVariations ? 3 : 1;
|
1115
|
+
|
1116
|
+
var _loop = function _loop(_i) {
|
1117
|
+
var fittingPlacement = placements.find(function (placement) {
|
1118
|
+
var checks = checksMap.get(placement);
|
1119
|
+
|
1120
|
+
if (checks) {
|
1121
|
+
return checks.slice(0, _i).every(function (check) {
|
1122
|
+
return check;
|
1123
|
+
});
|
1124
|
+
}
|
1125
|
+
});
|
1126
|
+
|
1127
|
+
if (fittingPlacement) {
|
1128
|
+
firstFittingPlacement = fittingPlacement;
|
1129
|
+
return "break";
|
1130
|
+
}
|
1131
|
+
};
|
1132
|
+
|
1133
|
+
for (var _i = numberOfChecks; _i > 0; _i--) {
|
1134
|
+
var _ret = _loop(_i);
|
1135
|
+
|
1136
|
+
if (_ret === "break") break;
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
if (state.placement !== firstFittingPlacement) {
|
1141
|
+
state.modifiersData[name]._skip = true;
|
1142
|
+
state.placement = firstFittingPlacement;
|
1143
|
+
state.reset = true;
|
1144
|
+
}
|
1145
|
+
} // eslint-disable-next-line import/no-unused-modules
|
1146
|
+
|
1147
|
+
|
1148
|
+
var flip$1 = {
|
1149
|
+
name: 'flip',
|
1150
|
+
enabled: true,
|
1151
|
+
phase: 'main',
|
1152
|
+
fn: flip,
|
1153
|
+
requiresIfExists: ['offset'],
|
1154
|
+
data: {
|
1155
|
+
_skip: false
|
1156
|
+
}
|
1157
|
+
};
|
1158
|
+
|
1159
|
+
function getSideOffsets(overflow, rect, preventedOffsets) {
|
1160
|
+
if (preventedOffsets === void 0) {
|
1161
|
+
preventedOffsets = {
|
1162
|
+
x: 0,
|
1163
|
+
y: 0
|
1164
|
+
};
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
return {
|
1168
|
+
top: overflow.top - rect.height - preventedOffsets.y,
|
1169
|
+
right: overflow.right - rect.width + preventedOffsets.x,
|
1170
|
+
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
1171
|
+
left: overflow.left - rect.width - preventedOffsets.x
|
1172
|
+
};
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
function isAnySideFullyClipped(overflow) {
|
1176
|
+
return [top, right, bottom, left].some(function (side) {
|
1177
|
+
return overflow[side] >= 0;
|
1178
|
+
});
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
function hide(_ref) {
|
1182
|
+
var state = _ref.state,
|
1183
|
+
name = _ref.name;
|
1184
|
+
var referenceRect = state.rects.reference;
|
1185
|
+
var popperRect = state.rects.popper;
|
1186
|
+
var preventedOffsets = state.modifiersData.preventOverflow;
|
1187
|
+
var referenceOverflow = detectOverflow(state, {
|
1188
|
+
elementContext: 'reference'
|
1189
|
+
});
|
1190
|
+
var popperAltOverflow = detectOverflow(state, {
|
1191
|
+
altBoundary: true
|
1192
|
+
});
|
1193
|
+
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
1194
|
+
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
1195
|
+
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
1196
|
+
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
1197
|
+
state.modifiersData[name] = {
|
1198
|
+
referenceClippingOffsets: referenceClippingOffsets,
|
1199
|
+
popperEscapeOffsets: popperEscapeOffsets,
|
1200
|
+
isReferenceHidden: isReferenceHidden,
|
1201
|
+
hasPopperEscaped: hasPopperEscaped
|
1202
|
+
};
|
1203
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
1204
|
+
'data-popper-reference-hidden': isReferenceHidden,
|
1205
|
+
'data-popper-escaped': hasPopperEscaped
|
1206
|
+
});
|
1207
|
+
} // eslint-disable-next-line import/no-unused-modules
|
1208
|
+
|
1209
|
+
|
1210
|
+
var hide$1 = {
|
1211
|
+
name: 'hide',
|
1212
|
+
enabled: true,
|
1213
|
+
phase: 'main',
|
1214
|
+
requiresIfExists: ['preventOverflow'],
|
1215
|
+
fn: hide
|
1216
|
+
};
|
1217
|
+
|
1218
|
+
function distanceAndSkiddingToXY(placement, rects, offset) {
|
1219
|
+
var basePlacement = getBasePlacement(placement);
|
1220
|
+
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
1221
|
+
|
1222
|
+
var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
|
1223
|
+
placement: placement
|
1224
|
+
})) : offset,
|
1225
|
+
skidding = _ref[0],
|
1226
|
+
distance = _ref[1];
|
1227
|
+
|
1228
|
+
skidding = skidding || 0;
|
1229
|
+
distance = (distance || 0) * invertDistance;
|
1230
|
+
return [left, right].indexOf(basePlacement) >= 0 ? {
|
1231
|
+
x: distance,
|
1232
|
+
y: skidding
|
1233
|
+
} : {
|
1234
|
+
x: skidding,
|
1235
|
+
y: distance
|
1236
|
+
};
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
function offset(_ref2) {
|
1240
|
+
var state = _ref2.state,
|
1241
|
+
options = _ref2.options,
|
1242
|
+
name = _ref2.name;
|
1243
|
+
var _options$offset = options.offset,
|
1244
|
+
offset = _options$offset === void 0 ? [0, 0] : _options$offset;
|
1245
|
+
var data = placements.reduce(function (acc, placement) {
|
1246
|
+
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
1247
|
+
return acc;
|
1248
|
+
}, {});
|
1249
|
+
var _data$state$placement = data[state.placement],
|
1250
|
+
x = _data$state$placement.x,
|
1251
|
+
y = _data$state$placement.y;
|
1252
|
+
|
1253
|
+
if (state.modifiersData.popperOffsets != null) {
|
1254
|
+
state.modifiersData.popperOffsets.x += x;
|
1255
|
+
state.modifiersData.popperOffsets.y += y;
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
state.modifiersData[name] = data;
|
1259
|
+
} // eslint-disable-next-line import/no-unused-modules
|
1260
|
+
|
1261
|
+
|
1262
|
+
var offset$1 = {
|
1263
|
+
name: 'offset',
|
1264
|
+
enabled: true,
|
1265
|
+
phase: 'main',
|
1266
|
+
requires: ['popperOffsets'],
|
1267
|
+
fn: offset
|
1268
|
+
};
|
1269
|
+
|
1270
|
+
function popperOffsets(_ref) {
|
1271
|
+
var state = _ref.state,
|
1272
|
+
name = _ref.name;
|
1273
|
+
// Offsets are the actual position the popper needs to have to be
|
1274
|
+
// properly positioned near its reference element
|
1275
|
+
// This is the most basic placement, and will be adjusted by
|
1276
|
+
// the modifiers in the next step
|
1277
|
+
state.modifiersData[name] = computeOffsets({
|
1278
|
+
reference: state.rects.reference,
|
1279
|
+
element: state.rects.popper,
|
1280
|
+
strategy: 'absolute',
|
1281
|
+
placement: state.placement
|
1282
|
+
});
|
1283
|
+
} // eslint-disable-next-line import/no-unused-modules
|
1284
|
+
|
1285
|
+
|
1286
|
+
var popperOffsets$1 = {
|
1287
|
+
name: 'popperOffsets',
|
1288
|
+
enabled: true,
|
1289
|
+
phase: 'read',
|
1290
|
+
fn: popperOffsets,
|
1291
|
+
data: {}
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
function getAltAxis(axis) {
|
1295
|
+
return axis === 'x' ? 'y' : 'x';
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
function preventOverflow(_ref) {
|
1299
|
+
var state = _ref.state,
|
1300
|
+
options = _ref.options,
|
1301
|
+
name = _ref.name;
|
1302
|
+
var _options$mainAxis = options.mainAxis,
|
1303
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
1304
|
+
_options$altAxis = options.altAxis,
|
1305
|
+
checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
|
1306
|
+
boundary = options.boundary,
|
1307
|
+
rootBoundary = options.rootBoundary,
|
1308
|
+
altBoundary = options.altBoundary,
|
1309
|
+
padding = options.padding,
|
1310
|
+
_options$tether = options.tether,
|
1311
|
+
tether = _options$tether === void 0 ? true : _options$tether,
|
1312
|
+
_options$tetherOffset = options.tetherOffset,
|
1313
|
+
tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
1314
|
+
var overflow = detectOverflow(state, {
|
1315
|
+
boundary: boundary,
|
1316
|
+
rootBoundary: rootBoundary,
|
1317
|
+
padding: padding,
|
1318
|
+
altBoundary: altBoundary
|
1319
|
+
});
|
1320
|
+
var basePlacement = getBasePlacement(state.placement);
|
1321
|
+
var variation = getVariation(state.placement);
|
1322
|
+
var isBasePlacement = !variation;
|
1323
|
+
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
1324
|
+
var altAxis = getAltAxis(mainAxis);
|
1325
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
1326
|
+
var referenceRect = state.rects.reference;
|
1327
|
+
var popperRect = state.rects.popper;
|
1328
|
+
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
1329
|
+
placement: state.placement
|
1330
|
+
})) : tetherOffset;
|
1331
|
+
var data = {
|
1332
|
+
x: 0,
|
1333
|
+
y: 0
|
1334
|
+
};
|
1335
|
+
|
1336
|
+
if (!popperOffsets) {
|
1337
|
+
return;
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
if (checkMainAxis || checkAltAxis) {
|
1341
|
+
var mainSide = mainAxis === 'y' ? top : left;
|
1342
|
+
var altSide = mainAxis === 'y' ? bottom : right;
|
1343
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
1344
|
+
var offset = popperOffsets[mainAxis];
|
1345
|
+
var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
|
1346
|
+
var max$1 = popperOffsets[mainAxis] - overflow[altSide];
|
1347
|
+
var additive = tether ? -popperRect[len] / 2 : 0;
|
1348
|
+
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
1349
|
+
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
|
1350
|
+
// outside the reference bounds
|
1351
|
+
|
1352
|
+
var arrowElement = state.elements.arrow;
|
1353
|
+
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
1354
|
+
width: 0,
|
1355
|
+
height: 0
|
1356
|
+
};
|
1357
|
+
var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
1358
|
+
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
1359
|
+
var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
|
1360
|
+
// to include its full size in the calculation. If the reference is small
|
1361
|
+
// and near the edge of a boundary, the popper can overflow even if the
|
1362
|
+
// reference is not overflowing as well (e.g. virtual elements with no
|
1363
|
+
// width or height)
|
1364
|
+
|
1365
|
+
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
1366
|
+
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
|
1367
|
+
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
|
1368
|
+
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
1369
|
+
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
1370
|
+
var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
|
1371
|
+
var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
|
1372
|
+
var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
|
1373
|
+
|
1374
|
+
if (checkMainAxis) {
|
1375
|
+
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
1376
|
+
popperOffsets[mainAxis] = preventedOffset;
|
1377
|
+
data[mainAxis] = preventedOffset - offset;
|
1378
|
+
}
|
1379
|
+
|
1380
|
+
if (checkAltAxis) {
|
1381
|
+
var _mainSide = mainAxis === 'x' ? top : left;
|
1382
|
+
|
1383
|
+
var _altSide = mainAxis === 'x' ? bottom : right;
|
1384
|
+
|
1385
|
+
var _offset = popperOffsets[altAxis];
|
1386
|
+
|
1387
|
+
var _min = _offset + overflow[_mainSide];
|
1388
|
+
|
1389
|
+
var _max = _offset - overflow[_altSide];
|
1390
|
+
|
1391
|
+
var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
|
1392
|
+
|
1393
|
+
popperOffsets[altAxis] = _preventedOffset;
|
1394
|
+
data[altAxis] = _preventedOffset - _offset;
|
1395
|
+
}
|
1396
|
+
}
|
1397
|
+
|
1398
|
+
state.modifiersData[name] = data;
|
1399
|
+
} // eslint-disable-next-line import/no-unused-modules
|
1400
|
+
|
1401
|
+
|
1402
|
+
var preventOverflow$1 = {
|
1403
|
+
name: 'preventOverflow',
|
1404
|
+
enabled: true,
|
1405
|
+
phase: 'main',
|
1406
|
+
fn: preventOverflow,
|
1407
|
+
requiresIfExists: ['offset']
|
1408
|
+
};
|
1409
|
+
|
1410
|
+
function getHTMLElementScroll(element) {
|
1411
|
+
return {
|
1412
|
+
scrollLeft: element.scrollLeft,
|
1413
|
+
scrollTop: element.scrollTop
|
1414
|
+
};
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
function getNodeScroll(node) {
|
1418
|
+
if (node === getWindow(node) || !isHTMLElement(node)) {
|
1419
|
+
return getWindowScroll(node);
|
1420
|
+
} else {
|
1421
|
+
return getHTMLElementScroll(node);
|
1422
|
+
}
|
1423
|
+
}
|
1424
|
+
|
1425
|
+
// Composite means it takes into account transforms as well as layout.
|
1426
|
+
|
1427
|
+
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
1428
|
+
if (isFixed === void 0) {
|
1429
|
+
isFixed = false;
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
var documentElement = getDocumentElement(offsetParent);
|
1433
|
+
var rect = getBoundingClientRect(elementOrVirtualElement);
|
1434
|
+
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
1435
|
+
var scroll = {
|
1436
|
+
scrollLeft: 0,
|
1437
|
+
scrollTop: 0
|
1438
|
+
};
|
1439
|
+
var offsets = {
|
1440
|
+
x: 0,
|
1441
|
+
y: 0
|
1442
|
+
};
|
1443
|
+
|
1444
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
1445
|
+
if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
|
1446
|
+
isScrollParent(documentElement)) {
|
1447
|
+
scroll = getNodeScroll(offsetParent);
|
1448
|
+
}
|
1449
|
+
|
1450
|
+
if (isHTMLElement(offsetParent)) {
|
1451
|
+
offsets = getBoundingClientRect(offsetParent);
|
1452
|
+
offsets.x += offsetParent.clientLeft;
|
1453
|
+
offsets.y += offsetParent.clientTop;
|
1454
|
+
} else if (documentElement) {
|
1455
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
1456
|
+
}
|
1457
|
+
}
|
1458
|
+
|
1459
|
+
return {
|
1460
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
1461
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
1462
|
+
width: rect.width,
|
1463
|
+
height: rect.height
|
1464
|
+
};
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
function order(modifiers) {
|
1468
|
+
var map = new Map();
|
1469
|
+
var visited = new Set();
|
1470
|
+
var result = [];
|
1471
|
+
modifiers.forEach(function (modifier) {
|
1472
|
+
map.set(modifier.name, modifier);
|
1473
|
+
}); // On visiting object, check for its dependencies and visit them recursively
|
1474
|
+
|
1475
|
+
function sort(modifier) {
|
1476
|
+
visited.add(modifier.name);
|
1477
|
+
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
1478
|
+
requires.forEach(function (dep) {
|
1479
|
+
if (!visited.has(dep)) {
|
1480
|
+
var depModifier = map.get(dep);
|
1481
|
+
|
1482
|
+
if (depModifier) {
|
1483
|
+
sort(depModifier);
|
1484
|
+
}
|
1485
|
+
}
|
1486
|
+
});
|
1487
|
+
result.push(modifier);
|
1488
|
+
}
|
1489
|
+
|
1490
|
+
modifiers.forEach(function (modifier) {
|
1491
|
+
if (!visited.has(modifier.name)) {
|
1492
|
+
// check for visited object
|
1493
|
+
sort(modifier);
|
1494
|
+
}
|
1495
|
+
});
|
1496
|
+
return result;
|
1497
|
+
}
|
1498
|
+
|
1499
|
+
function orderModifiers(modifiers) {
|
1500
|
+
// order based on dependencies
|
1501
|
+
var orderedModifiers = order(modifiers); // order based on phase
|
1502
|
+
|
1503
|
+
return modifierPhases.reduce(function (acc, phase) {
|
1504
|
+
return acc.concat(orderedModifiers.filter(function (modifier) {
|
1505
|
+
return modifier.phase === phase;
|
1506
|
+
}));
|
1507
|
+
}, []);
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
function debounce(fn) {
|
1511
|
+
var pending;
|
1512
|
+
return function () {
|
1513
|
+
if (!pending) {
|
1514
|
+
pending = new Promise(function (resolve) {
|
1515
|
+
Promise.resolve().then(function () {
|
1516
|
+
pending = undefined;
|
1517
|
+
resolve(fn());
|
1518
|
+
});
|
1519
|
+
});
|
1520
|
+
}
|
1521
|
+
|
1522
|
+
return pending;
|
1523
|
+
};
|
1524
|
+
}
|
1525
|
+
|
1526
|
+
function format(str) {
|
1527
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1528
|
+
args[_key - 1] = arguments[_key];
|
1529
|
+
}
|
1530
|
+
|
1531
|
+
return [].concat(args).reduce(function (p, c) {
|
1532
|
+
return p.replace(/%s/, c);
|
1533
|
+
}, str);
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
|
1537
|
+
var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
|
1538
|
+
var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
|
1539
|
+
function validateModifiers(modifiers) {
|
1540
|
+
modifiers.forEach(function (modifier) {
|
1541
|
+
Object.keys(modifier).forEach(function (key) {
|
1542
|
+
switch (key) {
|
1543
|
+
case 'name':
|
1544
|
+
if (typeof modifier.name !== 'string') {
|
1545
|
+
console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
break;
|
1549
|
+
|
1550
|
+
case 'enabled':
|
1551
|
+
if (typeof modifier.enabled !== 'boolean') {
|
1552
|
+
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
|
1553
|
+
}
|
1554
|
+
|
1555
|
+
case 'phase':
|
1556
|
+
if (modifierPhases.indexOf(modifier.phase) < 0) {
|
1557
|
+
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
break;
|
1561
|
+
|
1562
|
+
case 'fn':
|
1563
|
+
if (typeof modifier.fn !== 'function') {
|
1564
|
+
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
break;
|
1568
|
+
|
1569
|
+
case 'effect':
|
1570
|
+
if (typeof modifier.effect !== 'function') {
|
1571
|
+
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
break;
|
1575
|
+
|
1576
|
+
case 'requires':
|
1577
|
+
if (!Array.isArray(modifier.requires)) {
|
1578
|
+
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
break;
|
1582
|
+
|
1583
|
+
case 'requiresIfExists':
|
1584
|
+
if (!Array.isArray(modifier.requiresIfExists)) {
|
1585
|
+
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
break;
|
1589
|
+
|
1590
|
+
case 'options':
|
1591
|
+
case 'data':
|
1592
|
+
break;
|
1593
|
+
|
1594
|
+
default:
|
1595
|
+
console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
|
1596
|
+
return "\"" + s + "\"";
|
1597
|
+
}).join(', ') + "; but \"" + key + "\" was provided.");
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
modifier.requires && modifier.requires.forEach(function (requirement) {
|
1601
|
+
if (modifiers.find(function (mod) {
|
1602
|
+
return mod.name === requirement;
|
1603
|
+
}) == null) {
|
1604
|
+
console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
|
1605
|
+
}
|
1606
|
+
});
|
1607
|
+
});
|
1608
|
+
});
|
1609
|
+
}
|
1610
|
+
|
1611
|
+
function uniqueBy(arr, fn) {
|
1612
|
+
var identifiers = new Set();
|
1613
|
+
return arr.filter(function (item) {
|
1614
|
+
var identifier = fn(item);
|
1615
|
+
|
1616
|
+
if (!identifiers.has(identifier)) {
|
1617
|
+
identifiers.add(identifier);
|
1618
|
+
return true;
|
1619
|
+
}
|
1620
|
+
});
|
1621
|
+
}
|
1622
|
+
|
1623
|
+
function mergeByName(modifiers) {
|
1624
|
+
var merged = modifiers.reduce(function (merged, current) {
|
1625
|
+
var existing = merged[current.name];
|
1626
|
+
merged[current.name] = existing ? Object.assign({}, existing, current, {
|
1627
|
+
options: Object.assign({}, existing.options, current.options),
|
1628
|
+
data: Object.assign({}, existing.data, current.data)
|
1629
|
+
}) : current;
|
1630
|
+
return merged;
|
1631
|
+
}, {}); // IE11 does not support Object.values
|
1632
|
+
|
1633
|
+
return Object.keys(merged).map(function (key) {
|
1634
|
+
return merged[key];
|
1635
|
+
});
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
|
1639
|
+
var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
|
1640
|
+
var DEFAULT_OPTIONS = {
|
1641
|
+
placement: 'bottom',
|
1642
|
+
modifiers: [],
|
1643
|
+
strategy: 'absolute'
|
1644
|
+
};
|
1645
|
+
|
1646
|
+
function areValidElements() {
|
1647
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1648
|
+
args[_key] = arguments[_key];
|
1649
|
+
}
|
1650
|
+
|
1651
|
+
return !args.some(function (element) {
|
1652
|
+
return !(element && typeof element.getBoundingClientRect === 'function');
|
1653
|
+
});
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
function popperGenerator(generatorOptions) {
|
1657
|
+
if (generatorOptions === void 0) {
|
1658
|
+
generatorOptions = {};
|
1659
|
+
}
|
1660
|
+
|
1661
|
+
var _generatorOptions = generatorOptions,
|
1662
|
+
_generatorOptions$def = _generatorOptions.defaultModifiers,
|
1663
|
+
defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
|
1664
|
+
_generatorOptions$def2 = _generatorOptions.defaultOptions,
|
1665
|
+
defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
1666
|
+
return function createPopper(reference, popper, options) {
|
1667
|
+
if (options === void 0) {
|
1668
|
+
options = defaultOptions;
|
1669
|
+
}
|
1670
|
+
|
1671
|
+
var state = {
|
1672
|
+
placement: 'bottom',
|
1673
|
+
orderedModifiers: [],
|
1674
|
+
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
1675
|
+
modifiersData: {},
|
1676
|
+
elements: {
|
1677
|
+
reference: reference,
|
1678
|
+
popper: popper
|
1679
|
+
},
|
1680
|
+
attributes: {},
|
1681
|
+
styles: {}
|
1682
|
+
};
|
1683
|
+
var effectCleanupFns = [];
|
1684
|
+
var isDestroyed = false;
|
1685
|
+
var instance = {
|
1686
|
+
state: state,
|
1687
|
+
setOptions: function setOptions(options) {
|
1688
|
+
cleanupModifierEffects();
|
1689
|
+
state.options = Object.assign({}, defaultOptions, state.options, options);
|
1690
|
+
state.scrollParents = {
|
1691
|
+
reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
1692
|
+
popper: listScrollParents(popper)
|
1693
|
+
}; // Orders the modifiers based on their dependencies and `phase`
|
1694
|
+
// properties
|
1695
|
+
|
1696
|
+
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
|
1697
|
+
|
1698
|
+
state.orderedModifiers = orderedModifiers.filter(function (m) {
|
1699
|
+
return m.enabled;
|
1700
|
+
}); // Validate the provided modifiers so that the consumer will get warned
|
1701
|
+
// if one of the modifiers is invalid for any reason
|
1702
|
+
|
1703
|
+
if (process.env.NODE_ENV !== "production") {
|
1704
|
+
var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
|
1705
|
+
var name = _ref.name;
|
1706
|
+
return name;
|
1707
|
+
});
|
1708
|
+
validateModifiers(modifiers);
|
1709
|
+
|
1710
|
+
if (getBasePlacement(state.options.placement) === auto) {
|
1711
|
+
var flipModifier = state.orderedModifiers.find(function (_ref2) {
|
1712
|
+
var name = _ref2.name;
|
1713
|
+
return name === 'flip';
|
1714
|
+
});
|
1715
|
+
|
1716
|
+
if (!flipModifier) {
|
1717
|
+
console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
|
1718
|
+
}
|
1719
|
+
}
|
1720
|
+
|
1721
|
+
var _getComputedStyle = getComputedStyle(popper),
|
1722
|
+
marginTop = _getComputedStyle.marginTop,
|
1723
|
+
marginRight = _getComputedStyle.marginRight,
|
1724
|
+
marginBottom = _getComputedStyle.marginBottom,
|
1725
|
+
marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
|
1726
|
+
// cause bugs with positioning, so we'll warn the consumer
|
1727
|
+
|
1728
|
+
|
1729
|
+
if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
|
1730
|
+
return parseFloat(margin);
|
1731
|
+
})) {
|
1732
|
+
console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
|
1733
|
+
}
|
1734
|
+
}
|
1735
|
+
|
1736
|
+
runModifierEffects();
|
1737
|
+
return instance.update();
|
1738
|
+
},
|
1739
|
+
// Sync update – it will always be executed, even if not necessary. This
|
1740
|
+
// is useful for low frequency updates where sync behavior simplifies the
|
1741
|
+
// logic.
|
1742
|
+
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
1743
|
+
// prefer the async Popper#update method
|
1744
|
+
forceUpdate: function forceUpdate() {
|
1745
|
+
if (isDestroyed) {
|
1746
|
+
return;
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
var _state$elements = state.elements,
|
1750
|
+
reference = _state$elements.reference,
|
1751
|
+
popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
|
1752
|
+
// anymore
|
1753
|
+
|
1754
|
+
if (!areValidElements(reference, popper)) {
|
1755
|
+
if (process.env.NODE_ENV !== "production") {
|
1756
|
+
console.error(INVALID_ELEMENT_ERROR);
|
1757
|
+
}
|
1758
|
+
|
1759
|
+
return;
|
1760
|
+
} // Store the reference and popper rects to be read by modifiers
|
1761
|
+
|
1762
|
+
|
1763
|
+
state.rects = {
|
1764
|
+
reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
1765
|
+
popper: getLayoutRect(popper)
|
1766
|
+
}; // Modifiers have the ability to reset the current update cycle. The
|
1767
|
+
// most common use case for this is the `flip` modifier changing the
|
1768
|
+
// placement, which then needs to re-run all the modifiers, because the
|
1769
|
+
// logic was previously ran for the previous placement and is therefore
|
1770
|
+
// stale/incorrect
|
1771
|
+
|
1772
|
+
state.reset = false;
|
1773
|
+
state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
|
1774
|
+
// is filled with the initial data specified by the modifier. This means
|
1775
|
+
// it doesn't persist and is fresh on each update.
|
1776
|
+
// To ensure persistent data, use `${name}#persistent`
|
1777
|
+
|
1778
|
+
state.orderedModifiers.forEach(function (modifier) {
|
1779
|
+
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
1780
|
+
});
|
1781
|
+
var __debug_loops__ = 0;
|
1782
|
+
|
1783
|
+
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
1784
|
+
if (process.env.NODE_ENV !== "production") {
|
1785
|
+
__debug_loops__ += 1;
|
1786
|
+
|
1787
|
+
if (__debug_loops__ > 100) {
|
1788
|
+
console.error(INFINITE_LOOP_ERROR);
|
1789
|
+
break;
|
1790
|
+
}
|
1791
|
+
}
|
1792
|
+
|
1793
|
+
if (state.reset === true) {
|
1794
|
+
state.reset = false;
|
1795
|
+
index = -1;
|
1796
|
+
continue;
|
1797
|
+
}
|
1798
|
+
|
1799
|
+
var _state$orderedModifie = state.orderedModifiers[index],
|
1800
|
+
fn = _state$orderedModifie.fn,
|
1801
|
+
_state$orderedModifie2 = _state$orderedModifie.options,
|
1802
|
+
_options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
|
1803
|
+
name = _state$orderedModifie.name;
|
1804
|
+
|
1805
|
+
if (typeof fn === 'function') {
|
1806
|
+
state = fn({
|
1807
|
+
state: state,
|
1808
|
+
options: _options,
|
1809
|
+
name: name,
|
1810
|
+
instance: instance
|
1811
|
+
}) || state;
|
1812
|
+
}
|
1813
|
+
}
|
1814
|
+
},
|
1815
|
+
// Async and optimistically optimized update – it will not be executed if
|
1816
|
+
// not necessary (debounced to run at most once-per-tick)
|
1817
|
+
update: debounce(function () {
|
1818
|
+
return new Promise(function (resolve) {
|
1819
|
+
instance.forceUpdate();
|
1820
|
+
resolve(state);
|
1821
|
+
});
|
1822
|
+
}),
|
1823
|
+
destroy: function destroy() {
|
1824
|
+
cleanupModifierEffects();
|
1825
|
+
isDestroyed = true;
|
1826
|
+
}
|
1827
|
+
};
|
1828
|
+
|
1829
|
+
if (!areValidElements(reference, popper)) {
|
1830
|
+
if (process.env.NODE_ENV !== "production") {
|
1831
|
+
console.error(INVALID_ELEMENT_ERROR);
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
return instance;
|
1835
|
+
}
|
1836
|
+
|
1837
|
+
instance.setOptions(options).then(function (state) {
|
1838
|
+
if (!isDestroyed && options.onFirstUpdate) {
|
1839
|
+
options.onFirstUpdate(state);
|
1840
|
+
}
|
1841
|
+
}); // Modifiers have the ability to execute arbitrary code before the first
|
1842
|
+
// update cycle runs. They will be executed in the same order as the update
|
1843
|
+
// cycle. This is useful when a modifier adds some persistent data that
|
1844
|
+
// other modifiers need to use, but the modifier is run after the dependent
|
1845
|
+
// one.
|
1846
|
+
|
1847
|
+
function runModifierEffects() {
|
1848
|
+
state.orderedModifiers.forEach(function (_ref3) {
|
1849
|
+
var name = _ref3.name,
|
1850
|
+
_ref3$options = _ref3.options,
|
1851
|
+
options = _ref3$options === void 0 ? {} : _ref3$options,
|
1852
|
+
effect = _ref3.effect;
|
1853
|
+
|
1854
|
+
if (typeof effect === 'function') {
|
1855
|
+
var cleanupFn = effect({
|
1856
|
+
state: state,
|
1857
|
+
name: name,
|
1858
|
+
instance: instance,
|
1859
|
+
options: options
|
1860
|
+
});
|
1861
|
+
|
1862
|
+
var noopFn = function noopFn() {};
|
1863
|
+
|
1864
|
+
effectCleanupFns.push(cleanupFn || noopFn);
|
1865
|
+
}
|
1866
|
+
});
|
1867
|
+
}
|
1868
|
+
|
1869
|
+
function cleanupModifierEffects() {
|
1870
|
+
effectCleanupFns.forEach(function (fn) {
|
1871
|
+
return fn();
|
1872
|
+
});
|
1873
|
+
effectCleanupFns = [];
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
return instance;
|
1877
|
+
};
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
1881
|
+
var createPopper = /*#__PURE__*/popperGenerator({
|
1882
|
+
defaultModifiers: defaultModifiers
|
1883
|
+
}); // eslint-disable-next-line import/no-unused-modules
|
1884
|
+
|
1885
|
+
/**!
|
1886
|
+
* tippy.js v6.3.1
|
1887
|
+
* (c) 2017-2021 atomiks
|
1888
|
+
* MIT License
|
1889
|
+
*/
|
1890
|
+
|
1891
|
+
var ROUND_ARROW = '<svg width="16" height="6" xmlns="http://www.w3.org/2000/svg"><path d="M0 6s1.796-.013 4.67-3.615C5.851.9 6.93.006 8 0c1.07-.006 2.148.887 3.343 2.385C14.233 6.005 16 6 16 6H0z"></svg>';
|
1892
|
+
var BOX_CLASS = "tippy-box";
|
1893
|
+
var CONTENT_CLASS = "tippy-content";
|
1894
|
+
var BACKDROP_CLASS = "tippy-backdrop";
|
1895
|
+
var ARROW_CLASS = "tippy-arrow";
|
1896
|
+
var SVG_ARROW_CLASS = "tippy-svg-arrow";
|
1897
|
+
var TOUCH_OPTIONS = {
|
1898
|
+
passive: true,
|
1899
|
+
capture: true
|
1900
|
+
};
|
1901
|
+
|
1902
|
+
function hasOwnProperty(obj, key) {
|
1903
|
+
return {}.hasOwnProperty.call(obj, key);
|
1904
|
+
}
|
1905
|
+
function getValueAtIndexOrReturn(value, index, defaultValue) {
|
1906
|
+
if (Array.isArray(value)) {
|
1907
|
+
var v = value[index];
|
1908
|
+
return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
|
1909
|
+
}
|
1910
|
+
|
1911
|
+
return value;
|
1912
|
+
}
|
1913
|
+
function isType(value, type) {
|
1914
|
+
var str = {}.toString.call(value);
|
1915
|
+
return str.indexOf('[object') === 0 && str.indexOf(type + "]") > -1;
|
1916
|
+
}
|
1917
|
+
function invokeWithArgsOrReturn(value, args) {
|
1918
|
+
return typeof value === 'function' ? value.apply(void 0, args) : value;
|
1919
|
+
}
|
1920
|
+
function debounce$1(fn, ms) {
|
1921
|
+
// Avoid wrapping in `setTimeout` if ms is 0 anyway
|
1922
|
+
if (ms === 0) {
|
1923
|
+
return fn;
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
var timeout;
|
1927
|
+
return function (arg) {
|
1928
|
+
clearTimeout(timeout);
|
1929
|
+
timeout = setTimeout(function () {
|
1930
|
+
fn(arg);
|
1931
|
+
}, ms);
|
1932
|
+
};
|
1933
|
+
}
|
1934
|
+
function removeProperties(obj, keys) {
|
1935
|
+
var clone = Object.assign({}, obj);
|
1936
|
+
keys.forEach(function (key) {
|
1937
|
+
delete clone[key];
|
1938
|
+
});
|
1939
|
+
return clone;
|
1940
|
+
}
|
1941
|
+
function splitBySpaces(value) {
|
1942
|
+
return value.split(/\s+/).filter(Boolean);
|
1943
|
+
}
|
1944
|
+
function normalizeToArray(value) {
|
1945
|
+
return [].concat(value);
|
1946
|
+
}
|
1947
|
+
function pushIfUnique(arr, value) {
|
1948
|
+
if (arr.indexOf(value) === -1) {
|
1949
|
+
arr.push(value);
|
1950
|
+
}
|
1951
|
+
}
|
1952
|
+
function unique(arr) {
|
1953
|
+
return arr.filter(function (item, index) {
|
1954
|
+
return arr.indexOf(item) === index;
|
1955
|
+
});
|
1956
|
+
}
|
1957
|
+
function getBasePlacement$1(placement) {
|
1958
|
+
return placement.split('-')[0];
|
1959
|
+
}
|
1960
|
+
function arrayFrom(value) {
|
1961
|
+
return [].slice.call(value);
|
1962
|
+
}
|
1963
|
+
function removeUndefinedProps(obj) {
|
1964
|
+
return Object.keys(obj).reduce(function (acc, key) {
|
1965
|
+
if (obj[key] !== undefined) {
|
1966
|
+
acc[key] = obj[key];
|
1967
|
+
}
|
1968
|
+
|
1969
|
+
return acc;
|
1970
|
+
}, {});
|
1971
|
+
}
|
1972
|
+
|
1973
|
+
function div() {
|
1974
|
+
return document.createElement('div');
|
1975
|
+
}
|
1976
|
+
function isElement$1(value) {
|
1977
|
+
return ['Element', 'Fragment'].some(function (type) {
|
1978
|
+
return isType(value, type);
|
1979
|
+
});
|
1980
|
+
}
|
1981
|
+
function isNodeList(value) {
|
1982
|
+
return isType(value, 'NodeList');
|
1983
|
+
}
|
1984
|
+
function isMouseEvent(value) {
|
1985
|
+
return isType(value, 'MouseEvent');
|
1986
|
+
}
|
1987
|
+
function isReferenceElement(value) {
|
1988
|
+
return !!(value && value._tippy && value._tippy.reference === value);
|
1989
|
+
}
|
1990
|
+
function getArrayOfElements(value) {
|
1991
|
+
if (isElement$1(value)) {
|
1992
|
+
return [value];
|
1993
|
+
}
|
1994
|
+
|
1995
|
+
if (isNodeList(value)) {
|
1996
|
+
return arrayFrom(value);
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
if (Array.isArray(value)) {
|
2000
|
+
return value;
|
2001
|
+
}
|
2002
|
+
|
2003
|
+
return arrayFrom(document.querySelectorAll(value));
|
2004
|
+
}
|
2005
|
+
function setTransitionDuration(els, value) {
|
2006
|
+
els.forEach(function (el) {
|
2007
|
+
if (el) {
|
2008
|
+
el.style.transitionDuration = value + "ms";
|
2009
|
+
}
|
2010
|
+
});
|
2011
|
+
}
|
2012
|
+
function setVisibilityState(els, state) {
|
2013
|
+
els.forEach(function (el) {
|
2014
|
+
if (el) {
|
2015
|
+
el.setAttribute('data-state', state);
|
2016
|
+
}
|
2017
|
+
});
|
2018
|
+
}
|
2019
|
+
function getOwnerDocument(elementOrElements) {
|
2020
|
+
var _element$ownerDocumen;
|
2021
|
+
|
2022
|
+
var _normalizeToArray = normalizeToArray(elementOrElements),
|
2023
|
+
element = _normalizeToArray[0]; // Elements created via a <template> have an ownerDocument with no reference to the body
|
2024
|
+
|
2025
|
+
|
2026
|
+
return (element == null ? void 0 : (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body) ? element.ownerDocument : document;
|
2027
|
+
}
|
2028
|
+
function isCursorOutsideInteractiveBorder(popperTreeData, event) {
|
2029
|
+
var clientX = event.clientX,
|
2030
|
+
clientY = event.clientY;
|
2031
|
+
return popperTreeData.every(function (_ref) {
|
2032
|
+
var popperRect = _ref.popperRect,
|
2033
|
+
popperState = _ref.popperState,
|
2034
|
+
props = _ref.props;
|
2035
|
+
var interactiveBorder = props.interactiveBorder;
|
2036
|
+
var basePlacement = getBasePlacement$1(popperState.placement);
|
2037
|
+
var offsetData = popperState.modifiersData.offset;
|
2038
|
+
|
2039
|
+
if (!offsetData) {
|
2040
|
+
return true;
|
2041
|
+
}
|
2042
|
+
|
2043
|
+
var topDistance = basePlacement === 'bottom' ? offsetData.top.y : 0;
|
2044
|
+
var bottomDistance = basePlacement === 'top' ? offsetData.bottom.y : 0;
|
2045
|
+
var leftDistance = basePlacement === 'right' ? offsetData.left.x : 0;
|
2046
|
+
var rightDistance = basePlacement === 'left' ? offsetData.right.x : 0;
|
2047
|
+
var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;
|
2048
|
+
var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;
|
2049
|
+
var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;
|
2050
|
+
var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;
|
2051
|
+
return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
|
2052
|
+
});
|
2053
|
+
}
|
2054
|
+
function updateTransitionEndListener(box, action, listener) {
|
2055
|
+
var method = action + "EventListener"; // some browsers apparently support `transition` (unprefixed) but only fire
|
2056
|
+
// `webkitTransitionEnd`...
|
2057
|
+
|
2058
|
+
['transitionend', 'webkitTransitionEnd'].forEach(function (event) {
|
2059
|
+
box[method](event, listener);
|
2060
|
+
});
|
2061
|
+
}
|
2062
|
+
|
2063
|
+
var currentInput = {
|
2064
|
+
isTouch: false
|
2065
|
+
};
|
2066
|
+
var lastMouseMoveTime = 0;
|
2067
|
+
/**
|
2068
|
+
* When a `touchstart` event is fired, it's assumed the user is using touch
|
2069
|
+
* input. We'll bind a `mousemove` event listener to listen for mouse input in
|
2070
|
+
* the future. This way, the `isTouch` property is fully dynamic and will handle
|
2071
|
+
* hybrid devices that use a mix of touch + mouse input.
|
2072
|
+
*/
|
2073
|
+
|
2074
|
+
function onDocumentTouchStart() {
|
2075
|
+
if (currentInput.isTouch) {
|
2076
|
+
return;
|
2077
|
+
}
|
2078
|
+
|
2079
|
+
currentInput.isTouch = true;
|
2080
|
+
|
2081
|
+
if (window.performance) {
|
2082
|
+
document.addEventListener('mousemove', onDocumentMouseMove);
|
2083
|
+
}
|
2084
|
+
}
|
2085
|
+
/**
|
2086
|
+
* When two `mousemove` event are fired consecutively within 20ms, it's assumed
|
2087
|
+
* the user is using mouse input again. `mousemove` can fire on touch devices as
|
2088
|
+
* well, but very rarely that quickly.
|
2089
|
+
*/
|
2090
|
+
|
2091
|
+
function onDocumentMouseMove() {
|
2092
|
+
var now = performance.now();
|
2093
|
+
|
2094
|
+
if (now - lastMouseMoveTime < 20) {
|
2095
|
+
currentInput.isTouch = false;
|
2096
|
+
document.removeEventListener('mousemove', onDocumentMouseMove);
|
2097
|
+
}
|
2098
|
+
|
2099
|
+
lastMouseMoveTime = now;
|
2100
|
+
}
|
2101
|
+
/**
|
2102
|
+
* When an element is in focus and has a tippy, leaving the tab/window and
|
2103
|
+
* returning causes it to show again. For mouse users this is unexpected, but
|
2104
|
+
* for keyboard use it makes sense.
|
2105
|
+
* TODO: find a better technique to solve this problem
|
2106
|
+
*/
|
2107
|
+
|
2108
|
+
function onWindowBlur() {
|
2109
|
+
var activeElement = document.activeElement;
|
2110
|
+
|
2111
|
+
if (isReferenceElement(activeElement)) {
|
2112
|
+
var instance = activeElement._tippy;
|
2113
|
+
|
2114
|
+
if (activeElement.blur && !instance.state.isVisible) {
|
2115
|
+
activeElement.blur();
|
2116
|
+
}
|
2117
|
+
}
|
2118
|
+
}
|
2119
|
+
function bindGlobalEventListeners() {
|
2120
|
+
document.addEventListener('touchstart', onDocumentTouchStart, TOUCH_OPTIONS);
|
2121
|
+
window.addEventListener('blur', onWindowBlur);
|
2122
|
+
}
|
2123
|
+
|
2124
|
+
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
2125
|
+
var ua = isBrowser ? navigator.userAgent : '';
|
2126
|
+
var isIE = /MSIE |Trident\//.test(ua);
|
2127
|
+
|
2128
|
+
function createMemoryLeakWarning(method) {
|
2129
|
+
var txt = method === 'destroy' ? 'n already-' : ' ';
|
2130
|
+
return [method + "() was called on a" + txt + "destroyed instance. This is a no-op but", 'indicates a potential memory leak.'].join(' ');
|
2131
|
+
}
|
2132
|
+
function clean(value) {
|
2133
|
+
var spacesAndTabs = /[ \t]{2,}/g;
|
2134
|
+
var lineStartWithSpaces = /^[ \t]*/gm;
|
2135
|
+
return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
|
2136
|
+
}
|
2137
|
+
|
2138
|
+
function getDevMessage(message) {
|
2139
|
+
return clean("\n %ctippy.js\n\n %c" + clean(message) + "\n\n %c\uD83D\uDC77\u200D This is a development-only message. It will be removed in production.\n ");
|
2140
|
+
}
|
2141
|
+
|
2142
|
+
function getFormattedMessage(message) {
|
2143
|
+
return [getDevMessage(message), // title
|
2144
|
+
'color: #00C584; font-size: 1.3em; font-weight: bold;', // message
|
2145
|
+
'line-height: 1.5', // footer
|
2146
|
+
'color: #a6a095;'];
|
2147
|
+
} // Assume warnings and errors never have the same message
|
2148
|
+
|
2149
|
+
var visitedMessages;
|
2150
|
+
|
2151
|
+
if (process.env.NODE_ENV !== "production") {
|
2152
|
+
resetVisitedMessages();
|
2153
|
+
}
|
2154
|
+
|
2155
|
+
function resetVisitedMessages() {
|
2156
|
+
visitedMessages = new Set();
|
2157
|
+
}
|
2158
|
+
function warnWhen(condition, message) {
|
2159
|
+
if (condition && !visitedMessages.has(message)) {
|
2160
|
+
var _console;
|
2161
|
+
|
2162
|
+
visitedMessages.add(message);
|
2163
|
+
|
2164
|
+
(_console = console).warn.apply(_console, getFormattedMessage(message));
|
2165
|
+
}
|
2166
|
+
}
|
2167
|
+
function errorWhen(condition, message) {
|
2168
|
+
if (condition && !visitedMessages.has(message)) {
|
2169
|
+
var _console2;
|
2170
|
+
|
2171
|
+
visitedMessages.add(message);
|
2172
|
+
|
2173
|
+
(_console2 = console).error.apply(_console2, getFormattedMessage(message));
|
2174
|
+
}
|
2175
|
+
}
|
2176
|
+
function validateTargets(targets) {
|
2177
|
+
var didPassFalsyValue = !targets;
|
2178
|
+
var didPassPlainObject = Object.prototype.toString.call(targets) === '[object Object]' && !targets.addEventListener;
|
2179
|
+
errorWhen(didPassFalsyValue, ['tippy() was passed', '`' + String(targets) + '`', 'as its targets (first) argument. Valid types are: String, Element,', 'Element[], or NodeList.'].join(' '));
|
2180
|
+
errorWhen(didPassPlainObject, ['tippy() was passed a plain object which is not supported as an argument', 'for virtual positioning. Use props.getReferenceClientRect instead.'].join(' '));
|
2181
|
+
}
|
2182
|
+
|
2183
|
+
var pluginProps = {
|
2184
|
+
animateFill: false,
|
2185
|
+
followCursor: false,
|
2186
|
+
inlinePositioning: false,
|
2187
|
+
sticky: false
|
2188
|
+
};
|
2189
|
+
var renderProps = {
|
2190
|
+
allowHTML: false,
|
2191
|
+
animation: 'fade',
|
2192
|
+
arrow: true,
|
2193
|
+
content: '',
|
2194
|
+
inertia: false,
|
2195
|
+
maxWidth: 350,
|
2196
|
+
role: 'tooltip',
|
2197
|
+
theme: '',
|
2198
|
+
zIndex: 9999
|
2199
|
+
};
|
2200
|
+
var defaultProps = Object.assign({
|
2201
|
+
appendTo: function appendTo() {
|
2202
|
+
return document.body;
|
2203
|
+
},
|
2204
|
+
aria: {
|
2205
|
+
content: 'auto',
|
2206
|
+
expanded: 'auto'
|
2207
|
+
},
|
2208
|
+
delay: 0,
|
2209
|
+
duration: [300, 250],
|
2210
|
+
getReferenceClientRect: null,
|
2211
|
+
hideOnClick: true,
|
2212
|
+
ignoreAttributes: false,
|
2213
|
+
interactive: false,
|
2214
|
+
interactiveBorder: 2,
|
2215
|
+
interactiveDebounce: 0,
|
2216
|
+
moveTransition: '',
|
2217
|
+
offset: [0, 10],
|
2218
|
+
onAfterUpdate: function onAfterUpdate() {},
|
2219
|
+
onBeforeUpdate: function onBeforeUpdate() {},
|
2220
|
+
onCreate: function onCreate() {},
|
2221
|
+
onDestroy: function onDestroy() {},
|
2222
|
+
onHidden: function onHidden() {},
|
2223
|
+
onHide: function onHide() {},
|
2224
|
+
onMount: function onMount() {},
|
2225
|
+
onShow: function onShow() {},
|
2226
|
+
onShown: function onShown() {},
|
2227
|
+
onTrigger: function onTrigger() {},
|
2228
|
+
onUntrigger: function onUntrigger() {},
|
2229
|
+
onClickOutside: function onClickOutside() {},
|
2230
|
+
placement: 'top',
|
2231
|
+
plugins: [],
|
2232
|
+
popperOptions: {},
|
2233
|
+
render: null,
|
2234
|
+
showOnCreate: false,
|
2235
|
+
touch: true,
|
2236
|
+
trigger: 'mouseenter focus',
|
2237
|
+
triggerTarget: null
|
2238
|
+
}, pluginProps, {}, renderProps);
|
2239
|
+
var defaultKeys = Object.keys(defaultProps);
|
2240
|
+
var setDefaultProps = function setDefaultProps(partialProps) {
|
2241
|
+
/* istanbul ignore else */
|
2242
|
+
if (process.env.NODE_ENV !== "production") {
|
2243
|
+
validateProps(partialProps, []);
|
2244
|
+
}
|
2245
|
+
|
2246
|
+
var keys = Object.keys(partialProps);
|
2247
|
+
keys.forEach(function (key) {
|
2248
|
+
defaultProps[key] = partialProps[key];
|
2249
|
+
});
|
2250
|
+
};
|
2251
|
+
function getExtendedPassedProps(passedProps) {
|
2252
|
+
var plugins = passedProps.plugins || [];
|
2253
|
+
var pluginProps = plugins.reduce(function (acc, plugin) {
|
2254
|
+
var name = plugin.name,
|
2255
|
+
defaultValue = plugin.defaultValue;
|
2256
|
+
|
2257
|
+
if (name) {
|
2258
|
+
acc[name] = passedProps[name] !== undefined ? passedProps[name] : defaultValue;
|
2259
|
+
}
|
2260
|
+
|
2261
|
+
return acc;
|
2262
|
+
}, {});
|
2263
|
+
return Object.assign({}, passedProps, {}, pluginProps);
|
2264
|
+
}
|
2265
|
+
function getDataAttributeProps(reference, plugins) {
|
2266
|
+
var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
|
2267
|
+
plugins: plugins
|
2268
|
+
}))) : defaultKeys;
|
2269
|
+
var props = propKeys.reduce(function (acc, key) {
|
2270
|
+
var valueAsString = (reference.getAttribute("data-tippy-" + key) || '').trim();
|
2271
|
+
|
2272
|
+
if (!valueAsString) {
|
2273
|
+
return acc;
|
2274
|
+
}
|
2275
|
+
|
2276
|
+
if (key === 'content') {
|
2277
|
+
acc[key] = valueAsString;
|
2278
|
+
} else {
|
2279
|
+
try {
|
2280
|
+
acc[key] = JSON.parse(valueAsString);
|
2281
|
+
} catch (e) {
|
2282
|
+
acc[key] = valueAsString;
|
2283
|
+
}
|
2284
|
+
}
|
2285
|
+
|
2286
|
+
return acc;
|
2287
|
+
}, {});
|
2288
|
+
return props;
|
2289
|
+
}
|
2290
|
+
function evaluateProps(reference, props) {
|
2291
|
+
var out = Object.assign({}, props, {
|
2292
|
+
content: invokeWithArgsOrReturn(props.content, [reference])
|
2293
|
+
}, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins));
|
2294
|
+
out.aria = Object.assign({}, defaultProps.aria, {}, out.aria);
|
2295
|
+
out.aria = {
|
2296
|
+
expanded: out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,
|
2297
|
+
content: out.aria.content === 'auto' ? props.interactive ? null : 'describedby' : out.aria.content
|
2298
|
+
};
|
2299
|
+
return out;
|
2300
|
+
}
|
2301
|
+
function validateProps(partialProps, plugins) {
|
2302
|
+
if (partialProps === void 0) {
|
2303
|
+
partialProps = {};
|
2304
|
+
}
|
2305
|
+
|
2306
|
+
if (plugins === void 0) {
|
2307
|
+
plugins = [];
|
2308
|
+
}
|
2309
|
+
|
2310
|
+
var keys = Object.keys(partialProps);
|
2311
|
+
keys.forEach(function (prop) {
|
2312
|
+
var nonPluginProps = removeProperties(defaultProps, Object.keys(pluginProps));
|
2313
|
+
var didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop); // Check if the prop exists in `plugins`
|
2314
|
+
|
2315
|
+
if (didPassUnknownProp) {
|
2316
|
+
didPassUnknownProp = plugins.filter(function (plugin) {
|
2317
|
+
return plugin.name === prop;
|
2318
|
+
}).length === 0;
|
2319
|
+
}
|
2320
|
+
|
2321
|
+
warnWhen(didPassUnknownProp, ["`" + prop + "`", "is not a valid prop. You may have spelled it incorrectly, or if it's", 'a plugin, forgot to pass it in an array as props.plugins.', '\n\n', 'All props: https://atomiks.github.io/tippyjs/v6/all-props/\n', 'Plugins: https://atomiks.github.io/tippyjs/v6/plugins/'].join(' '));
|
2322
|
+
});
|
2323
|
+
}
|
2324
|
+
|
2325
|
+
var innerHTML = function innerHTML() {
|
2326
|
+
return 'innerHTML';
|
2327
|
+
};
|
2328
|
+
|
2329
|
+
function dangerouslySetInnerHTML(element, html) {
|
2330
|
+
element[innerHTML()] = html;
|
2331
|
+
}
|
2332
|
+
|
2333
|
+
function createArrowElement(value) {
|
2334
|
+
var arrow = div();
|
2335
|
+
|
2336
|
+
if (value === true) {
|
2337
|
+
arrow.className = ARROW_CLASS;
|
2338
|
+
} else {
|
2339
|
+
arrow.className = SVG_ARROW_CLASS;
|
2340
|
+
|
2341
|
+
if (isElement$1(value)) {
|
2342
|
+
arrow.appendChild(value);
|
2343
|
+
} else {
|
2344
|
+
dangerouslySetInnerHTML(arrow, value);
|
2345
|
+
}
|
2346
|
+
}
|
2347
|
+
|
2348
|
+
return arrow;
|
2349
|
+
}
|
2350
|
+
|
2351
|
+
function setContent(content, props) {
|
2352
|
+
if (isElement$1(props.content)) {
|
2353
|
+
dangerouslySetInnerHTML(content, '');
|
2354
|
+
content.appendChild(props.content);
|
2355
|
+
} else if (typeof props.content !== 'function') {
|
2356
|
+
if (props.allowHTML) {
|
2357
|
+
dangerouslySetInnerHTML(content, props.content);
|
2358
|
+
} else {
|
2359
|
+
content.textContent = props.content;
|
2360
|
+
}
|
2361
|
+
}
|
2362
|
+
}
|
2363
|
+
function getChildren(popper) {
|
2364
|
+
var box = popper.firstElementChild;
|
2365
|
+
var boxChildren = arrayFrom(box.children);
|
2366
|
+
return {
|
2367
|
+
box: box,
|
2368
|
+
content: boxChildren.find(function (node) {
|
2369
|
+
return node.classList.contains(CONTENT_CLASS);
|
2370
|
+
}),
|
2371
|
+
arrow: boxChildren.find(function (node) {
|
2372
|
+
return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);
|
2373
|
+
}),
|
2374
|
+
backdrop: boxChildren.find(function (node) {
|
2375
|
+
return node.classList.contains(BACKDROP_CLASS);
|
2376
|
+
})
|
2377
|
+
};
|
2378
|
+
}
|
2379
|
+
function render(instance) {
|
2380
|
+
var popper = div();
|
2381
|
+
var box = div();
|
2382
|
+
box.className = BOX_CLASS;
|
2383
|
+
box.setAttribute('data-state', 'hidden');
|
2384
|
+
box.setAttribute('tabindex', '-1');
|
2385
|
+
var content = div();
|
2386
|
+
content.className = CONTENT_CLASS;
|
2387
|
+
content.setAttribute('data-state', 'hidden');
|
2388
|
+
setContent(content, instance.props);
|
2389
|
+
popper.appendChild(box);
|
2390
|
+
box.appendChild(content);
|
2391
|
+
onUpdate(instance.props, instance.props);
|
2392
|
+
|
2393
|
+
function onUpdate(prevProps, nextProps) {
|
2394
|
+
var _getChildren = getChildren(popper),
|
2395
|
+
box = _getChildren.box,
|
2396
|
+
content = _getChildren.content,
|
2397
|
+
arrow = _getChildren.arrow;
|
2398
|
+
|
2399
|
+
if (nextProps.theme) {
|
2400
|
+
box.setAttribute('data-theme', nextProps.theme);
|
2401
|
+
} else {
|
2402
|
+
box.removeAttribute('data-theme');
|
2403
|
+
}
|
2404
|
+
|
2405
|
+
if (typeof nextProps.animation === 'string') {
|
2406
|
+
box.setAttribute('data-animation', nextProps.animation);
|
2407
|
+
} else {
|
2408
|
+
box.removeAttribute('data-animation');
|
2409
|
+
}
|
2410
|
+
|
2411
|
+
if (nextProps.inertia) {
|
2412
|
+
box.setAttribute('data-inertia', '');
|
2413
|
+
} else {
|
2414
|
+
box.removeAttribute('data-inertia');
|
2415
|
+
}
|
2416
|
+
|
2417
|
+
box.style.maxWidth = typeof nextProps.maxWidth === 'number' ? nextProps.maxWidth + "px" : nextProps.maxWidth;
|
2418
|
+
|
2419
|
+
if (nextProps.role) {
|
2420
|
+
box.setAttribute('role', nextProps.role);
|
2421
|
+
} else {
|
2422
|
+
box.removeAttribute('role');
|
2423
|
+
}
|
2424
|
+
|
2425
|
+
if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {
|
2426
|
+
setContent(content, instance.props);
|
2427
|
+
}
|
2428
|
+
|
2429
|
+
if (nextProps.arrow) {
|
2430
|
+
if (!arrow) {
|
2431
|
+
box.appendChild(createArrowElement(nextProps.arrow));
|
2432
|
+
} else if (prevProps.arrow !== nextProps.arrow) {
|
2433
|
+
box.removeChild(arrow);
|
2434
|
+
box.appendChild(createArrowElement(nextProps.arrow));
|
2435
|
+
}
|
2436
|
+
} else if (arrow) {
|
2437
|
+
box.removeChild(arrow);
|
2438
|
+
}
|
2439
|
+
}
|
2440
|
+
|
2441
|
+
return {
|
2442
|
+
popper: popper,
|
2443
|
+
onUpdate: onUpdate
|
2444
|
+
};
|
2445
|
+
} // Runtime check to identify if the render function is the default one; this
|
2446
|
+
// way we can apply default CSS transitions logic and it can be tree-shaken away
|
2447
|
+
|
2448
|
+
render.$$tippy = true;
|
2449
|
+
|
2450
|
+
var idCounter = 1;
|
2451
|
+
var mouseMoveListeners = []; // Used by `hideAll()`
|
2452
|
+
|
2453
|
+
var mountedInstances = [];
|
2454
|
+
function createTippy(reference, passedProps) {
|
2455
|
+
var props = evaluateProps(reference, Object.assign({}, defaultProps, {}, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================
|
2456
|
+
// 🔒 Private members
|
2457
|
+
// ===========================================================================
|
2458
|
+
|
2459
|
+
var showTimeout;
|
2460
|
+
var hideTimeout;
|
2461
|
+
var scheduleHideAnimationFrame;
|
2462
|
+
var isVisibleFromClick = false;
|
2463
|
+
var didHideDueToDocumentMouseDown = false;
|
2464
|
+
var didTouchMove = false;
|
2465
|
+
var ignoreOnFirstUpdate = false;
|
2466
|
+
var lastTriggerEvent;
|
2467
|
+
var currentTransitionEndListener;
|
2468
|
+
var onFirstUpdate;
|
2469
|
+
var listeners = [];
|
2470
|
+
var debouncedOnMouseMove = debounce$1(onMouseMove, props.interactiveDebounce);
|
2471
|
+
var currentTarget; // ===========================================================================
|
2472
|
+
// 🔑 Public members
|
2473
|
+
// ===========================================================================
|
2474
|
+
|
2475
|
+
var id = idCounter++;
|
2476
|
+
var popperInstance = null;
|
2477
|
+
var plugins = unique(props.plugins);
|
2478
|
+
var state = {
|
2479
|
+
// Is the instance currently enabled?
|
2480
|
+
isEnabled: true,
|
2481
|
+
// Is the tippy currently showing and not transitioning out?
|
2482
|
+
isVisible: false,
|
2483
|
+
// Has the instance been destroyed?
|
2484
|
+
isDestroyed: false,
|
2485
|
+
// Is the tippy currently mounted to the DOM?
|
2486
|
+
isMounted: false,
|
2487
|
+
// Has the tippy finished transitioning in?
|
2488
|
+
isShown: false
|
2489
|
+
};
|
2490
|
+
var instance = {
|
2491
|
+
// properties
|
2492
|
+
id: id,
|
2493
|
+
reference: reference,
|
2494
|
+
popper: div(),
|
2495
|
+
popperInstance: popperInstance,
|
2496
|
+
props: props,
|
2497
|
+
state: state,
|
2498
|
+
plugins: plugins,
|
2499
|
+
// methods
|
2500
|
+
clearDelayTimeouts: clearDelayTimeouts,
|
2501
|
+
setProps: setProps,
|
2502
|
+
setContent: setContent,
|
2503
|
+
show: show,
|
2504
|
+
hide: hide,
|
2505
|
+
hideWithInteractivity: hideWithInteractivity,
|
2506
|
+
enable: enable,
|
2507
|
+
disable: disable,
|
2508
|
+
unmount: unmount,
|
2509
|
+
destroy: destroy
|
2510
|
+
}; // TODO: Investigate why this early return causes a TDZ error in the tests —
|
2511
|
+
// it doesn't seem to happen in the browser
|
2512
|
+
|
2513
|
+
/* istanbul ignore if */
|
2514
|
+
|
2515
|
+
if (!props.render) {
|
2516
|
+
if (process.env.NODE_ENV !== "production") {
|
2517
|
+
errorWhen(true, 'render() function has not been supplied.');
|
2518
|
+
}
|
2519
|
+
|
2520
|
+
return instance;
|
2521
|
+
} // ===========================================================================
|
2522
|
+
// Initial mutations
|
2523
|
+
// ===========================================================================
|
2524
|
+
|
2525
|
+
|
2526
|
+
var _props$render = props.render(instance),
|
2527
|
+
popper = _props$render.popper,
|
2528
|
+
onUpdate = _props$render.onUpdate;
|
2529
|
+
|
2530
|
+
popper.setAttribute('data-tippy-root', '');
|
2531
|
+
popper.id = "tippy-" + instance.id;
|
2532
|
+
instance.popper = popper;
|
2533
|
+
reference._tippy = instance;
|
2534
|
+
popper._tippy = instance;
|
2535
|
+
var pluginsHooks = plugins.map(function (plugin) {
|
2536
|
+
return plugin.fn(instance);
|
2537
|
+
});
|
2538
|
+
var hasAriaExpanded = reference.hasAttribute('aria-expanded');
|
2539
|
+
addListeners();
|
2540
|
+
handleAriaExpandedAttribute();
|
2541
|
+
handleStyles();
|
2542
|
+
invokeHook('onCreate', [instance]);
|
2543
|
+
|
2544
|
+
if (props.showOnCreate) {
|
2545
|
+
scheduleShow();
|
2546
|
+
} // Prevent a tippy with a delay from hiding if the cursor left then returned
|
2547
|
+
// before it started hiding
|
2548
|
+
|
2549
|
+
|
2550
|
+
popper.addEventListener('mouseenter', function () {
|
2551
|
+
if (instance.props.interactive && instance.state.isVisible) {
|
2552
|
+
instance.clearDelayTimeouts();
|
2553
|
+
}
|
2554
|
+
});
|
2555
|
+
popper.addEventListener('mouseleave', function (event) {
|
2556
|
+
if (instance.props.interactive && instance.props.trigger.indexOf('mouseenter') >= 0) {
|
2557
|
+
getDocument().addEventListener('mousemove', debouncedOnMouseMove);
|
2558
|
+
debouncedOnMouseMove(event);
|
2559
|
+
}
|
2560
|
+
});
|
2561
|
+
return instance; // ===========================================================================
|
2562
|
+
// 🔒 Private methods
|
2563
|
+
// ===========================================================================
|
2564
|
+
|
2565
|
+
function getNormalizedTouchSettings() {
|
2566
|
+
var touch = instance.props.touch;
|
2567
|
+
return Array.isArray(touch) ? touch : [touch, 0];
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
function getIsCustomTouchBehavior() {
|
2571
|
+
return getNormalizedTouchSettings()[0] === 'hold';
|
2572
|
+
}
|
2573
|
+
|
2574
|
+
function getIsDefaultRenderFn() {
|
2575
|
+
var _instance$props$rende;
|
2576
|
+
|
2577
|
+
// @ts-ignore
|
2578
|
+
return !!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy);
|
2579
|
+
}
|
2580
|
+
|
2581
|
+
function getCurrentTarget() {
|
2582
|
+
return currentTarget || reference;
|
2583
|
+
}
|
2584
|
+
|
2585
|
+
function getDocument() {
|
2586
|
+
var parent = getCurrentTarget().parentNode;
|
2587
|
+
return parent ? getOwnerDocument(parent) : document;
|
2588
|
+
}
|
2589
|
+
|
2590
|
+
function getDefaultTemplateChildren() {
|
2591
|
+
return getChildren(popper);
|
2592
|
+
}
|
2593
|
+
|
2594
|
+
function getDelay(isShow) {
|
2595
|
+
// For touch or keyboard input, force `0` delay for UX reasons
|
2596
|
+
// Also if the instance is mounted but not visible (transitioning out),
|
2597
|
+
// ignore delay
|
2598
|
+
if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === 'focus') {
|
2599
|
+
return 0;
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
|
2603
|
+
}
|
2604
|
+
|
2605
|
+
function handleStyles() {
|
2606
|
+
popper.style.pointerEvents = instance.props.interactive && instance.state.isVisible ? '' : 'none';
|
2607
|
+
popper.style.zIndex = "" + instance.props.zIndex;
|
2608
|
+
}
|
2609
|
+
|
2610
|
+
function invokeHook(hook, args, shouldInvokePropsHook) {
|
2611
|
+
if (shouldInvokePropsHook === void 0) {
|
2612
|
+
shouldInvokePropsHook = true;
|
2613
|
+
}
|
2614
|
+
|
2615
|
+
pluginsHooks.forEach(function (pluginHooks) {
|
2616
|
+
if (pluginHooks[hook]) {
|
2617
|
+
pluginHooks[hook].apply(void 0, args);
|
2618
|
+
}
|
2619
|
+
});
|
2620
|
+
|
2621
|
+
if (shouldInvokePropsHook) {
|
2622
|
+
var _instance$props;
|
2623
|
+
|
2624
|
+
(_instance$props = instance.props)[hook].apply(_instance$props, args);
|
2625
|
+
}
|
2626
|
+
}
|
2627
|
+
|
2628
|
+
function handleAriaContentAttribute() {
|
2629
|
+
var aria = instance.props.aria;
|
2630
|
+
|
2631
|
+
if (!aria.content) {
|
2632
|
+
return;
|
2633
|
+
}
|
2634
|
+
|
2635
|
+
var attr = "aria-" + aria.content;
|
2636
|
+
var id = popper.id;
|
2637
|
+
var nodes = normalizeToArray(instance.props.triggerTarget || reference);
|
2638
|
+
nodes.forEach(function (node) {
|
2639
|
+
var currentValue = node.getAttribute(attr);
|
2640
|
+
|
2641
|
+
if (instance.state.isVisible) {
|
2642
|
+
node.setAttribute(attr, currentValue ? currentValue + " " + id : id);
|
2643
|
+
} else {
|
2644
|
+
var nextValue = currentValue && currentValue.replace(id, '').trim();
|
2645
|
+
|
2646
|
+
if (nextValue) {
|
2647
|
+
node.setAttribute(attr, nextValue);
|
2648
|
+
} else {
|
2649
|
+
node.removeAttribute(attr);
|
2650
|
+
}
|
2651
|
+
}
|
2652
|
+
});
|
2653
|
+
}
|
2654
|
+
|
2655
|
+
function handleAriaExpandedAttribute() {
|
2656
|
+
if (hasAriaExpanded || !instance.props.aria.expanded) {
|
2657
|
+
return;
|
2658
|
+
}
|
2659
|
+
|
2660
|
+
var nodes = normalizeToArray(instance.props.triggerTarget || reference);
|
2661
|
+
nodes.forEach(function (node) {
|
2662
|
+
if (instance.props.interactive) {
|
2663
|
+
node.setAttribute('aria-expanded', instance.state.isVisible && node === getCurrentTarget() ? 'true' : 'false');
|
2664
|
+
} else {
|
2665
|
+
node.removeAttribute('aria-expanded');
|
2666
|
+
}
|
2667
|
+
});
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
function cleanupInteractiveMouseListeners() {
|
2671
|
+
getDocument().removeEventListener('mousemove', debouncedOnMouseMove);
|
2672
|
+
mouseMoveListeners = mouseMoveListeners.filter(function (listener) {
|
2673
|
+
return listener !== debouncedOnMouseMove;
|
2674
|
+
});
|
2675
|
+
}
|
2676
|
+
|
2677
|
+
function onDocumentPress(event) {
|
2678
|
+
// Moved finger to scroll instead of an intentional tap outside
|
2679
|
+
if (currentInput.isTouch) {
|
2680
|
+
if (didTouchMove || event.type === 'mousedown') {
|
2681
|
+
return;
|
2682
|
+
}
|
2683
|
+
} // Clicked on interactive popper
|
2684
|
+
|
2685
|
+
|
2686
|
+
if (instance.props.interactive && popper.contains(event.target)) {
|
2687
|
+
return;
|
2688
|
+
} // Clicked on the event listeners target
|
2689
|
+
|
2690
|
+
|
2691
|
+
if (getCurrentTarget().contains(event.target)) {
|
2692
|
+
if (currentInput.isTouch) {
|
2693
|
+
return;
|
2694
|
+
}
|
2695
|
+
|
2696
|
+
if (instance.state.isVisible && instance.props.trigger.indexOf('click') >= 0) {
|
2697
|
+
return;
|
2698
|
+
}
|
2699
|
+
} else {
|
2700
|
+
invokeHook('onClickOutside', [instance, event]);
|
2701
|
+
}
|
2702
|
+
|
2703
|
+
if (instance.props.hideOnClick === true) {
|
2704
|
+
instance.clearDelayTimeouts();
|
2705
|
+
instance.hide(); // `mousedown` event is fired right before `focus` if pressing the
|
2706
|
+
// currentTarget. This lets a tippy with `focus` trigger know that it
|
2707
|
+
// should not show
|
2708
|
+
|
2709
|
+
didHideDueToDocumentMouseDown = true;
|
2710
|
+
setTimeout(function () {
|
2711
|
+
didHideDueToDocumentMouseDown = false;
|
2712
|
+
}); // The listener gets added in `scheduleShow()`, but this may be hiding it
|
2713
|
+
// before it shows, and hide()'s early bail-out behavior can prevent it
|
2714
|
+
// from being cleaned up
|
2715
|
+
|
2716
|
+
if (!instance.state.isMounted) {
|
2717
|
+
removeDocumentPress();
|
2718
|
+
}
|
2719
|
+
}
|
2720
|
+
}
|
2721
|
+
|
2722
|
+
function onTouchMove() {
|
2723
|
+
didTouchMove = true;
|
2724
|
+
}
|
2725
|
+
|
2726
|
+
function onTouchStart() {
|
2727
|
+
didTouchMove = false;
|
2728
|
+
}
|
2729
|
+
|
2730
|
+
function addDocumentPress() {
|
2731
|
+
var doc = getDocument();
|
2732
|
+
doc.addEventListener('mousedown', onDocumentPress, true);
|
2733
|
+
doc.addEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
|
2734
|
+
doc.addEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
|
2735
|
+
doc.addEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
|
2736
|
+
}
|
2737
|
+
|
2738
|
+
function removeDocumentPress() {
|
2739
|
+
var doc = getDocument();
|
2740
|
+
doc.removeEventListener('mousedown', onDocumentPress, true);
|
2741
|
+
doc.removeEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
|
2742
|
+
doc.removeEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
|
2743
|
+
doc.removeEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
|
2744
|
+
}
|
2745
|
+
|
2746
|
+
function onTransitionedOut(duration, callback) {
|
2747
|
+
onTransitionEnd(duration, function () {
|
2748
|
+
if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) {
|
2749
|
+
callback();
|
2750
|
+
}
|
2751
|
+
});
|
2752
|
+
}
|
2753
|
+
|
2754
|
+
function onTransitionedIn(duration, callback) {
|
2755
|
+
onTransitionEnd(duration, callback);
|
2756
|
+
}
|
2757
|
+
|
2758
|
+
function onTransitionEnd(duration, callback) {
|
2759
|
+
var box = getDefaultTemplateChildren().box;
|
2760
|
+
|
2761
|
+
function listener(event) {
|
2762
|
+
if (event.target === box) {
|
2763
|
+
updateTransitionEndListener(box, 'remove', listener);
|
2764
|
+
callback();
|
2765
|
+
}
|
2766
|
+
} // Make callback synchronous if duration is 0
|
2767
|
+
// `transitionend` won't fire otherwise
|
2768
|
+
|
2769
|
+
|
2770
|
+
if (duration === 0) {
|
2771
|
+
return callback();
|
2772
|
+
}
|
2773
|
+
|
2774
|
+
updateTransitionEndListener(box, 'remove', currentTransitionEndListener);
|
2775
|
+
updateTransitionEndListener(box, 'add', listener);
|
2776
|
+
currentTransitionEndListener = listener;
|
2777
|
+
}
|
2778
|
+
|
2779
|
+
function on(eventType, handler, options) {
|
2780
|
+
if (options === void 0) {
|
2781
|
+
options = false;
|
2782
|
+
}
|
2783
|
+
|
2784
|
+
var nodes = normalizeToArray(instance.props.triggerTarget || reference);
|
2785
|
+
nodes.forEach(function (node) {
|
2786
|
+
node.addEventListener(eventType, handler, options);
|
2787
|
+
listeners.push({
|
2788
|
+
node: node,
|
2789
|
+
eventType: eventType,
|
2790
|
+
handler: handler,
|
2791
|
+
options: options
|
2792
|
+
});
|
2793
|
+
});
|
2794
|
+
}
|
2795
|
+
|
2796
|
+
function addListeners() {
|
2797
|
+
if (getIsCustomTouchBehavior()) {
|
2798
|
+
on('touchstart', onTrigger, {
|
2799
|
+
passive: true
|
2800
|
+
});
|
2801
|
+
on('touchend', onMouseLeave, {
|
2802
|
+
passive: true
|
2803
|
+
});
|
2804
|
+
}
|
2805
|
+
|
2806
|
+
splitBySpaces(instance.props.trigger).forEach(function (eventType) {
|
2807
|
+
if (eventType === 'manual') {
|
2808
|
+
return;
|
2809
|
+
}
|
2810
|
+
|
2811
|
+
on(eventType, onTrigger);
|
2812
|
+
|
2813
|
+
switch (eventType) {
|
2814
|
+
case 'mouseenter':
|
2815
|
+
on('mouseleave', onMouseLeave);
|
2816
|
+
break;
|
2817
|
+
|
2818
|
+
case 'focus':
|
2819
|
+
on(isIE ? 'focusout' : 'blur', onBlurOrFocusOut);
|
2820
|
+
break;
|
2821
|
+
|
2822
|
+
case 'focusin':
|
2823
|
+
on('focusout', onBlurOrFocusOut);
|
2824
|
+
break;
|
2825
|
+
}
|
2826
|
+
});
|
2827
|
+
}
|
2828
|
+
|
2829
|
+
function removeListeners() {
|
2830
|
+
listeners.forEach(function (_ref) {
|
2831
|
+
var node = _ref.node,
|
2832
|
+
eventType = _ref.eventType,
|
2833
|
+
handler = _ref.handler,
|
2834
|
+
options = _ref.options;
|
2835
|
+
node.removeEventListener(eventType, handler, options);
|
2836
|
+
});
|
2837
|
+
listeners = [];
|
2838
|
+
}
|
2839
|
+
|
2840
|
+
function onTrigger(event) {
|
2841
|
+
var _lastTriggerEvent;
|
2842
|
+
|
2843
|
+
var shouldScheduleClickHide = false;
|
2844
|
+
|
2845
|
+
if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {
|
2846
|
+
return;
|
2847
|
+
}
|
2848
|
+
|
2849
|
+
var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === 'focus';
|
2850
|
+
lastTriggerEvent = event;
|
2851
|
+
currentTarget = event.currentTarget;
|
2852
|
+
handleAriaExpandedAttribute();
|
2853
|
+
|
2854
|
+
if (!instance.state.isVisible && isMouseEvent(event)) {
|
2855
|
+
// If scrolling, `mouseenter` events can be fired if the cursor lands
|
2856
|
+
// over a new target, but `mousemove` events don't get fired. This
|
2857
|
+
// causes interactive tooltips to get stuck open until the cursor is
|
2858
|
+
// moved
|
2859
|
+
mouseMoveListeners.forEach(function (listener) {
|
2860
|
+
return listener(event);
|
2861
|
+
});
|
2862
|
+
} // Toggle show/hide when clicking click-triggered tooltips
|
2863
|
+
|
2864
|
+
|
2865
|
+
if (event.type === 'click' && (instance.props.trigger.indexOf('mouseenter') < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {
|
2866
|
+
shouldScheduleClickHide = true;
|
2867
|
+
} else {
|
2868
|
+
scheduleShow(event);
|
2869
|
+
}
|
2870
|
+
|
2871
|
+
if (event.type === 'click') {
|
2872
|
+
isVisibleFromClick = !shouldScheduleClickHide;
|
2873
|
+
}
|
2874
|
+
|
2875
|
+
if (shouldScheduleClickHide && !wasFocused) {
|
2876
|
+
scheduleHide(event);
|
2877
|
+
}
|
2878
|
+
}
|
2879
|
+
|
2880
|
+
function onMouseMove(event) {
|
2881
|
+
var target = event.target;
|
2882
|
+
var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper.contains(target);
|
2883
|
+
|
2884
|
+
if (event.type === 'mousemove' && isCursorOverReferenceOrPopper) {
|
2885
|
+
return;
|
2886
|
+
}
|
2887
|
+
|
2888
|
+
var popperTreeData = getNestedPopperTree().concat(popper).map(function (popper) {
|
2889
|
+
var _instance$popperInsta;
|
2890
|
+
|
2891
|
+
var instance = popper._tippy;
|
2892
|
+
var state = (_instance$popperInsta = instance.popperInstance) == null ? void 0 : _instance$popperInsta.state;
|
2893
|
+
|
2894
|
+
if (state) {
|
2895
|
+
return {
|
2896
|
+
popperRect: popper.getBoundingClientRect(),
|
2897
|
+
popperState: state,
|
2898
|
+
props: props
|
2899
|
+
};
|
2900
|
+
}
|
2901
|
+
|
2902
|
+
return null;
|
2903
|
+
}).filter(Boolean);
|
2904
|
+
|
2905
|
+
if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {
|
2906
|
+
cleanupInteractiveMouseListeners();
|
2907
|
+
scheduleHide(event);
|
2908
|
+
}
|
2909
|
+
}
|
2910
|
+
|
2911
|
+
function onMouseLeave(event) {
|
2912
|
+
var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf('click') >= 0 && isVisibleFromClick;
|
2913
|
+
|
2914
|
+
if (shouldBail) {
|
2915
|
+
return;
|
2916
|
+
}
|
2917
|
+
|
2918
|
+
if (instance.props.interactive) {
|
2919
|
+
instance.hideWithInteractivity(event);
|
2920
|
+
return;
|
2921
|
+
}
|
2922
|
+
|
2923
|
+
scheduleHide(event);
|
2924
|
+
}
|
2925
|
+
|
2926
|
+
function onBlurOrFocusOut(event) {
|
2927
|
+
if (instance.props.trigger.indexOf('focusin') < 0 && event.target !== getCurrentTarget()) {
|
2928
|
+
return;
|
2929
|
+
} // If focus was moved to within the popper
|
2930
|
+
|
2931
|
+
|
2932
|
+
if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) {
|
2933
|
+
return;
|
2934
|
+
}
|
2935
|
+
|
2936
|
+
scheduleHide(event);
|
2937
|
+
}
|
2938
|
+
|
2939
|
+
function isEventListenerStopped(event) {
|
2940
|
+
return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf('touch') >= 0 : false;
|
2941
|
+
}
|
2942
|
+
|
2943
|
+
function createPopperInstance() {
|
2944
|
+
destroyPopperInstance();
|
2945
|
+
var _instance$props2 = instance.props,
|
2946
|
+
popperOptions = _instance$props2.popperOptions,
|
2947
|
+
placement = _instance$props2.placement,
|
2948
|
+
offset = _instance$props2.offset,
|
2949
|
+
getReferenceClientRect = _instance$props2.getReferenceClientRect,
|
2950
|
+
moveTransition = _instance$props2.moveTransition;
|
2951
|
+
var arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null;
|
2952
|
+
var computedReference = getReferenceClientRect ? {
|
2953
|
+
getBoundingClientRect: getReferenceClientRect,
|
2954
|
+
contextElement: getReferenceClientRect.contextElement || getCurrentTarget()
|
2955
|
+
} : reference;
|
2956
|
+
var tippyModifier = {
|
2957
|
+
name: '$$tippy',
|
2958
|
+
enabled: true,
|
2959
|
+
phase: 'beforeWrite',
|
2960
|
+
requires: ['computeStyles'],
|
2961
|
+
fn: function fn(_ref2) {
|
2962
|
+
var state = _ref2.state;
|
2963
|
+
|
2964
|
+
if (getIsDefaultRenderFn()) {
|
2965
|
+
var _getDefaultTemplateCh = getDefaultTemplateChildren(),
|
2966
|
+
box = _getDefaultTemplateCh.box;
|
2967
|
+
|
2968
|
+
['placement', 'reference-hidden', 'escaped'].forEach(function (attr) {
|
2969
|
+
if (attr === 'placement') {
|
2970
|
+
box.setAttribute('data-placement', state.placement);
|
2971
|
+
} else {
|
2972
|
+
if (state.attributes.popper["data-popper-" + attr]) {
|
2973
|
+
box.setAttribute("data-" + attr, '');
|
2974
|
+
} else {
|
2975
|
+
box.removeAttribute("data-" + attr);
|
2976
|
+
}
|
2977
|
+
}
|
2978
|
+
});
|
2979
|
+
state.attributes.popper = {};
|
2980
|
+
}
|
2981
|
+
}
|
2982
|
+
};
|
2983
|
+
var modifiers = [{
|
2984
|
+
name: 'offset',
|
2985
|
+
options: {
|
2986
|
+
offset: offset
|
2987
|
+
}
|
2988
|
+
}, {
|
2989
|
+
name: 'preventOverflow',
|
2990
|
+
options: {
|
2991
|
+
padding: {
|
2992
|
+
top: 2,
|
2993
|
+
bottom: 2,
|
2994
|
+
left: 5,
|
2995
|
+
right: 5
|
2996
|
+
}
|
2997
|
+
}
|
2998
|
+
}, {
|
2999
|
+
name: 'flip',
|
3000
|
+
options: {
|
3001
|
+
padding: 5
|
3002
|
+
}
|
3003
|
+
}, {
|
3004
|
+
name: 'computeStyles',
|
3005
|
+
options: {
|
3006
|
+
adaptive: !moveTransition
|
3007
|
+
}
|
3008
|
+
}, tippyModifier];
|
3009
|
+
|
3010
|
+
if (getIsDefaultRenderFn() && arrow) {
|
3011
|
+
modifiers.push({
|
3012
|
+
name: 'arrow',
|
3013
|
+
options: {
|
3014
|
+
element: arrow,
|
3015
|
+
padding: 3
|
3016
|
+
}
|
3017
|
+
});
|
3018
|
+
}
|
3019
|
+
|
3020
|
+
modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);
|
3021
|
+
instance.popperInstance = createPopper(computedReference, popper, Object.assign({}, popperOptions, {
|
3022
|
+
placement: placement,
|
3023
|
+
onFirstUpdate: onFirstUpdate,
|
3024
|
+
modifiers: modifiers
|
3025
|
+
}));
|
3026
|
+
}
|
3027
|
+
|
3028
|
+
function destroyPopperInstance() {
|
3029
|
+
if (instance.popperInstance) {
|
3030
|
+
instance.popperInstance.destroy();
|
3031
|
+
instance.popperInstance = null;
|
3032
|
+
}
|
3033
|
+
}
|
3034
|
+
|
3035
|
+
function mount() {
|
3036
|
+
var appendTo = instance.props.appendTo;
|
3037
|
+
var parentNode; // By default, we'll append the popper to the triggerTargets's parentNode so
|
3038
|
+
// it's directly after the reference element so the elements inside the
|
3039
|
+
// tippy can be tabbed to
|
3040
|
+
// If there are clipping issues, the user can specify a different appendTo
|
3041
|
+
// and ensure focus management is handled correctly manually
|
3042
|
+
|
3043
|
+
var node = getCurrentTarget();
|
3044
|
+
|
3045
|
+
if (instance.props.interactive && appendTo === defaultProps.appendTo || appendTo === 'parent') {
|
3046
|
+
parentNode = node.parentNode;
|
3047
|
+
} else {
|
3048
|
+
parentNode = invokeWithArgsOrReturn(appendTo, [node]);
|
3049
|
+
} // The popper element needs to exist on the DOM before its position can be
|
3050
|
+
// updated as Popper needs to read its dimensions
|
3051
|
+
|
3052
|
+
|
3053
|
+
if (!parentNode.contains(popper)) {
|
3054
|
+
parentNode.appendChild(popper);
|
3055
|
+
}
|
3056
|
+
|
3057
|
+
createPopperInstance();
|
3058
|
+
/* istanbul ignore else */
|
3059
|
+
|
3060
|
+
if (process.env.NODE_ENV !== "production") {
|
3061
|
+
// Accessibility check
|
3062
|
+
warnWhen(instance.props.interactive && appendTo === defaultProps.appendTo && node.nextElementSibling !== popper, ['Interactive tippy element may not be accessible via keyboard', 'navigation because it is not directly after the reference element', 'in the DOM source order.', '\n\n', 'Using a wrapper <div> or <span> tag around the reference element', 'solves this by creating a new parentNode context.', '\n\n', 'Specifying `appendTo: document.body` silences this warning, but it', 'assumes you are using a focus management solution to handle', 'keyboard navigation.', '\n\n', 'See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity'].join(' '));
|
3063
|
+
}
|
3064
|
+
}
|
3065
|
+
|
3066
|
+
function getNestedPopperTree() {
|
3067
|
+
return arrayFrom(popper.querySelectorAll('[data-tippy-root]'));
|
3068
|
+
}
|
3069
|
+
|
3070
|
+
function scheduleShow(event) {
|
3071
|
+
instance.clearDelayTimeouts();
|
3072
|
+
|
3073
|
+
if (event) {
|
3074
|
+
invokeHook('onTrigger', [instance, event]);
|
3075
|
+
}
|
3076
|
+
|
3077
|
+
addDocumentPress();
|
3078
|
+
var delay = getDelay(true);
|
3079
|
+
|
3080
|
+
var _getNormalizedTouchSe = getNormalizedTouchSettings(),
|
3081
|
+
touchValue = _getNormalizedTouchSe[0],
|
3082
|
+
touchDelay = _getNormalizedTouchSe[1];
|
3083
|
+
|
3084
|
+
if (currentInput.isTouch && touchValue === 'hold' && touchDelay) {
|
3085
|
+
delay = touchDelay;
|
3086
|
+
}
|
3087
|
+
|
3088
|
+
if (delay) {
|
3089
|
+
showTimeout = setTimeout(function () {
|
3090
|
+
instance.show();
|
3091
|
+
}, delay);
|
3092
|
+
} else {
|
3093
|
+
instance.show();
|
3094
|
+
}
|
3095
|
+
}
|
3096
|
+
|
3097
|
+
function scheduleHide(event) {
|
3098
|
+
instance.clearDelayTimeouts();
|
3099
|
+
invokeHook('onUntrigger', [instance, event]);
|
3100
|
+
|
3101
|
+
if (!instance.state.isVisible) {
|
3102
|
+
removeDocumentPress();
|
3103
|
+
return;
|
3104
|
+
} // For interactive tippies, scheduleHide is added to a document.body handler
|
3105
|
+
// from onMouseLeave so must intercept scheduled hides from mousemove/leave
|
3106
|
+
// events when trigger contains mouseenter and click, and the tip is
|
3107
|
+
// currently shown as a result of a click.
|
3108
|
+
|
3109
|
+
|
3110
|
+
if (instance.props.trigger.indexOf('mouseenter') >= 0 && instance.props.trigger.indexOf('click') >= 0 && ['mouseleave', 'mousemove'].indexOf(event.type) >= 0 && isVisibleFromClick) {
|
3111
|
+
return;
|
3112
|
+
}
|
3113
|
+
|
3114
|
+
var delay = getDelay(false);
|
3115
|
+
|
3116
|
+
if (delay) {
|
3117
|
+
hideTimeout = setTimeout(function () {
|
3118
|
+
if (instance.state.isVisible) {
|
3119
|
+
instance.hide();
|
3120
|
+
}
|
3121
|
+
}, delay);
|
3122
|
+
} else {
|
3123
|
+
// Fixes a `transitionend` problem when it fires 1 frame too
|
3124
|
+
// late sometimes, we don't want hide() to be called.
|
3125
|
+
scheduleHideAnimationFrame = requestAnimationFrame(function () {
|
3126
|
+
instance.hide();
|
3127
|
+
});
|
3128
|
+
}
|
3129
|
+
} // ===========================================================================
|
3130
|
+
// 🔑 Public methods
|
3131
|
+
// ===========================================================================
|
3132
|
+
|
3133
|
+
|
3134
|
+
function enable() {
|
3135
|
+
instance.state.isEnabled = true;
|
3136
|
+
}
|
3137
|
+
|
3138
|
+
function disable() {
|
3139
|
+
// Disabling the instance should also hide it
|
3140
|
+
// https://github.com/atomiks/tippy.js-react/issues/106
|
3141
|
+
instance.hide();
|
3142
|
+
instance.state.isEnabled = false;
|
3143
|
+
}
|
3144
|
+
|
3145
|
+
function clearDelayTimeouts() {
|
3146
|
+
clearTimeout(showTimeout);
|
3147
|
+
clearTimeout(hideTimeout);
|
3148
|
+
cancelAnimationFrame(scheduleHideAnimationFrame);
|
3149
|
+
}
|
3150
|
+
|
3151
|
+
function setProps(partialProps) {
|
3152
|
+
/* istanbul ignore else */
|
3153
|
+
if (process.env.NODE_ENV !== "production") {
|
3154
|
+
warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('setProps'));
|
3155
|
+
}
|
3156
|
+
|
3157
|
+
if (instance.state.isDestroyed) {
|
3158
|
+
return;
|
3159
|
+
}
|
3160
|
+
|
3161
|
+
invokeHook('onBeforeUpdate', [instance, partialProps]);
|
3162
|
+
removeListeners();
|
3163
|
+
var prevProps = instance.props;
|
3164
|
+
var nextProps = evaluateProps(reference, Object.assign({}, instance.props, {}, partialProps, {
|
3165
|
+
ignoreAttributes: true
|
3166
|
+
}));
|
3167
|
+
instance.props = nextProps;
|
3168
|
+
addListeners();
|
3169
|
+
|
3170
|
+
if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {
|
3171
|
+
cleanupInteractiveMouseListeners();
|
3172
|
+
debouncedOnMouseMove = debounce$1(onMouseMove, nextProps.interactiveDebounce);
|
3173
|
+
} // Ensure stale aria-expanded attributes are removed
|
3174
|
+
|
3175
|
+
|
3176
|
+
if (prevProps.triggerTarget && !nextProps.triggerTarget) {
|
3177
|
+
normalizeToArray(prevProps.triggerTarget).forEach(function (node) {
|
3178
|
+
node.removeAttribute('aria-expanded');
|
3179
|
+
});
|
3180
|
+
} else if (nextProps.triggerTarget) {
|
3181
|
+
reference.removeAttribute('aria-expanded');
|
3182
|
+
}
|
3183
|
+
|
3184
|
+
handleAriaExpandedAttribute();
|
3185
|
+
handleStyles();
|
3186
|
+
|
3187
|
+
if (onUpdate) {
|
3188
|
+
onUpdate(prevProps, nextProps);
|
3189
|
+
}
|
3190
|
+
|
3191
|
+
if (instance.popperInstance) {
|
3192
|
+
createPopperInstance(); // Fixes an issue with nested tippies if they are all getting re-rendered,
|
3193
|
+
// and the nested ones get re-rendered first.
|
3194
|
+
// https://github.com/atomiks/tippyjs-react/issues/177
|
3195
|
+
// TODO: find a cleaner / more efficient solution(!)
|
3196
|
+
|
3197
|
+
getNestedPopperTree().forEach(function (nestedPopper) {
|
3198
|
+
// React (and other UI libs likely) requires a rAF wrapper as it flushes
|
3199
|
+
// its work in one
|
3200
|
+
requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);
|
3201
|
+
});
|
3202
|
+
}
|
3203
|
+
|
3204
|
+
invokeHook('onAfterUpdate', [instance, partialProps]);
|
3205
|
+
}
|
3206
|
+
|
3207
|
+
function setContent(content) {
|
3208
|
+
instance.setProps({
|
3209
|
+
content: content
|
3210
|
+
});
|
3211
|
+
}
|
3212
|
+
|
3213
|
+
function show() {
|
3214
|
+
/* istanbul ignore else */
|
3215
|
+
if (process.env.NODE_ENV !== "production") {
|
3216
|
+
warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('show'));
|
3217
|
+
} // Early bail-out
|
3218
|
+
|
3219
|
+
|
3220
|
+
var isAlreadyVisible = instance.state.isVisible;
|
3221
|
+
var isDestroyed = instance.state.isDestroyed;
|
3222
|
+
var isDisabled = !instance.state.isEnabled;
|
3223
|
+
var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
|
3224
|
+
var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
|
3225
|
+
|
3226
|
+
if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
|
3227
|
+
return;
|
3228
|
+
} // Normalize `disabled` behavior across browsers.
|
3229
|
+
// Firefox allows events on disabled elements, but Chrome doesn't.
|
3230
|
+
// Using a wrapper element (i.e. <span>) is recommended.
|
3231
|
+
|
3232
|
+
|
3233
|
+
if (getCurrentTarget().hasAttribute('disabled')) {
|
3234
|
+
return;
|
3235
|
+
}
|
3236
|
+
|
3237
|
+
invokeHook('onShow', [instance], false);
|
3238
|
+
|
3239
|
+
if (instance.props.onShow(instance) === false) {
|
3240
|
+
return;
|
3241
|
+
}
|
3242
|
+
|
3243
|
+
instance.state.isVisible = true;
|
3244
|
+
|
3245
|
+
if (getIsDefaultRenderFn()) {
|
3246
|
+
popper.style.visibility = 'visible';
|
3247
|
+
}
|
3248
|
+
|
3249
|
+
handleStyles();
|
3250
|
+
addDocumentPress();
|
3251
|
+
|
3252
|
+
if (!instance.state.isMounted) {
|
3253
|
+
popper.style.transition = 'none';
|
3254
|
+
} // If flipping to the opposite side after hiding at least once, the
|
3255
|
+
// animation will use the wrong placement without resetting the duration
|
3256
|
+
|
3257
|
+
|
3258
|
+
if (getIsDefaultRenderFn()) {
|
3259
|
+
var _getDefaultTemplateCh2 = getDefaultTemplateChildren(),
|
3260
|
+
box = _getDefaultTemplateCh2.box,
|
3261
|
+
content = _getDefaultTemplateCh2.content;
|
3262
|
+
|
3263
|
+
setTransitionDuration([box, content], 0);
|
3264
|
+
}
|
3265
|
+
|
3266
|
+
onFirstUpdate = function onFirstUpdate() {
|
3267
|
+
var _instance$popperInsta2;
|
3268
|
+
|
3269
|
+
if (!instance.state.isVisible || ignoreOnFirstUpdate) {
|
3270
|
+
return;
|
3271
|
+
}
|
3272
|
+
|
3273
|
+
ignoreOnFirstUpdate = true; // reflow
|
3274
|
+
|
3275
|
+
void popper.offsetHeight;
|
3276
|
+
popper.style.transition = instance.props.moveTransition;
|
3277
|
+
|
3278
|
+
if (getIsDefaultRenderFn() && instance.props.animation) {
|
3279
|
+
var _getDefaultTemplateCh3 = getDefaultTemplateChildren(),
|
3280
|
+
_box = _getDefaultTemplateCh3.box,
|
3281
|
+
_content = _getDefaultTemplateCh3.content;
|
3282
|
+
|
3283
|
+
setTransitionDuration([_box, _content], duration);
|
3284
|
+
setVisibilityState([_box, _content], 'visible');
|
3285
|
+
}
|
3286
|
+
|
3287
|
+
handleAriaContentAttribute();
|
3288
|
+
handleAriaExpandedAttribute();
|
3289
|
+
pushIfUnique(mountedInstances, instance); // certain modifiers (e.g. `maxSize`) require a second update after the
|
3290
|
+
// popper has been positioned for the first time
|
3291
|
+
|
3292
|
+
(_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
|
3293
|
+
instance.state.isMounted = true;
|
3294
|
+
invokeHook('onMount', [instance]);
|
3295
|
+
|
3296
|
+
if (instance.props.animation && getIsDefaultRenderFn()) {
|
3297
|
+
onTransitionedIn(duration, function () {
|
3298
|
+
instance.state.isShown = true;
|
3299
|
+
invokeHook('onShown', [instance]);
|
3300
|
+
});
|
3301
|
+
}
|
3302
|
+
};
|
3303
|
+
|
3304
|
+
mount();
|
3305
|
+
}
|
3306
|
+
|
3307
|
+
function hide() {
|
3308
|
+
/* istanbul ignore else */
|
3309
|
+
if (process.env.NODE_ENV !== "production") {
|
3310
|
+
warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hide'));
|
3311
|
+
} // Early bail-out
|
3312
|
+
|
3313
|
+
|
3314
|
+
var isAlreadyHidden = !instance.state.isVisible;
|
3315
|
+
var isDestroyed = instance.state.isDestroyed;
|
3316
|
+
var isDisabled = !instance.state.isEnabled;
|
3317
|
+
var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
|
3318
|
+
|
3319
|
+
if (isAlreadyHidden || isDestroyed || isDisabled) {
|
3320
|
+
return;
|
3321
|
+
}
|
3322
|
+
|
3323
|
+
invokeHook('onHide', [instance], false);
|
3324
|
+
|
3325
|
+
if (instance.props.onHide(instance) === false) {
|
3326
|
+
return;
|
3327
|
+
}
|
3328
|
+
|
3329
|
+
instance.state.isVisible = false;
|
3330
|
+
instance.state.isShown = false;
|
3331
|
+
ignoreOnFirstUpdate = false;
|
3332
|
+
isVisibleFromClick = false;
|
3333
|
+
|
3334
|
+
if (getIsDefaultRenderFn()) {
|
3335
|
+
popper.style.visibility = 'hidden';
|
3336
|
+
}
|
3337
|
+
|
3338
|
+
cleanupInteractiveMouseListeners();
|
3339
|
+
removeDocumentPress();
|
3340
|
+
handleStyles();
|
3341
|
+
|
3342
|
+
if (getIsDefaultRenderFn()) {
|
3343
|
+
var _getDefaultTemplateCh4 = getDefaultTemplateChildren(),
|
3344
|
+
box = _getDefaultTemplateCh4.box,
|
3345
|
+
content = _getDefaultTemplateCh4.content;
|
3346
|
+
|
3347
|
+
if (instance.props.animation) {
|
3348
|
+
setTransitionDuration([box, content], duration);
|
3349
|
+
setVisibilityState([box, content], 'hidden');
|
3350
|
+
}
|
3351
|
+
}
|
3352
|
+
|
3353
|
+
handleAriaContentAttribute();
|
3354
|
+
handleAriaExpandedAttribute();
|
3355
|
+
|
3356
|
+
if (instance.props.animation) {
|
3357
|
+
if (getIsDefaultRenderFn()) {
|
3358
|
+
onTransitionedOut(duration, instance.unmount);
|
3359
|
+
}
|
3360
|
+
} else {
|
3361
|
+
instance.unmount();
|
3362
|
+
}
|
3363
|
+
}
|
3364
|
+
|
3365
|
+
function hideWithInteractivity(event) {
|
3366
|
+
/* istanbul ignore else */
|
3367
|
+
if (process.env.NODE_ENV !== "production") {
|
3368
|
+
warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hideWithInteractivity'));
|
3369
|
+
}
|
3370
|
+
|
3371
|
+
getDocument().addEventListener('mousemove', debouncedOnMouseMove);
|
3372
|
+
pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
|
3373
|
+
debouncedOnMouseMove(event);
|
3374
|
+
}
|
3375
|
+
|
3376
|
+
function unmount() {
|
3377
|
+
/* istanbul ignore else */
|
3378
|
+
if (process.env.NODE_ENV !== "production") {
|
3379
|
+
warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('unmount'));
|
3380
|
+
}
|
3381
|
+
|
3382
|
+
if (instance.state.isVisible) {
|
3383
|
+
instance.hide();
|
3384
|
+
}
|
3385
|
+
|
3386
|
+
if (!instance.state.isMounted) {
|
3387
|
+
return;
|
3388
|
+
}
|
3389
|
+
|
3390
|
+
destroyPopperInstance(); // If a popper is not interactive, it will be appended outside the popper
|
3391
|
+
// tree by default. This seems mainly for interactive tippies, but we should
|
3392
|
+
// find a workaround if possible
|
3393
|
+
|
3394
|
+
getNestedPopperTree().forEach(function (nestedPopper) {
|
3395
|
+
nestedPopper._tippy.unmount();
|
3396
|
+
});
|
3397
|
+
|
3398
|
+
if (popper.parentNode) {
|
3399
|
+
popper.parentNode.removeChild(popper);
|
3400
|
+
}
|
3401
|
+
|
3402
|
+
mountedInstances = mountedInstances.filter(function (i) {
|
3403
|
+
return i !== instance;
|
3404
|
+
});
|
3405
|
+
instance.state.isMounted = false;
|
3406
|
+
invokeHook('onHidden', [instance]);
|
3407
|
+
}
|
3408
|
+
|
3409
|
+
function destroy() {
|
3410
|
+
/* istanbul ignore else */
|
3411
|
+
if (process.env.NODE_ENV !== "production") {
|
3412
|
+
warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('destroy'));
|
3413
|
+
}
|
3414
|
+
|
3415
|
+
if (instance.state.isDestroyed) {
|
3416
|
+
return;
|
3417
|
+
}
|
3418
|
+
|
3419
|
+
instance.clearDelayTimeouts();
|
3420
|
+
instance.unmount();
|
3421
|
+
removeListeners();
|
3422
|
+
delete reference._tippy;
|
3423
|
+
instance.state.isDestroyed = true;
|
3424
|
+
invokeHook('onDestroy', [instance]);
|
3425
|
+
}
|
3426
|
+
}
|
3427
|
+
|
3428
|
+
function tippy(targets, optionalProps) {
|
3429
|
+
if (optionalProps === void 0) {
|
3430
|
+
optionalProps = {};
|
3431
|
+
}
|
3432
|
+
|
3433
|
+
var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
|
3434
|
+
/* istanbul ignore else */
|
3435
|
+
|
3436
|
+
if (process.env.NODE_ENV !== "production") {
|
3437
|
+
validateTargets(targets);
|
3438
|
+
validateProps(optionalProps, plugins);
|
3439
|
+
}
|
3440
|
+
|
3441
|
+
bindGlobalEventListeners();
|
3442
|
+
var passedProps = Object.assign({}, optionalProps, {
|
3443
|
+
plugins: plugins
|
3444
|
+
});
|
3445
|
+
var elements = getArrayOfElements(targets);
|
3446
|
+
/* istanbul ignore else */
|
3447
|
+
|
3448
|
+
if (process.env.NODE_ENV !== "production") {
|
3449
|
+
var isSingleContentElement = isElement$1(passedProps.content);
|
3450
|
+
var isMoreThanOneReferenceElement = elements.length > 1;
|
3451
|
+
warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ['tippy() was passed an Element as the `content` prop, but more than', 'one tippy instance was created by this invocation. This means the', 'content element will only be appended to the last tippy instance.', '\n\n', 'Instead, pass the .innerHTML of the element, or use a function that', 'returns a cloned version of the element instead.', '\n\n', '1) content: element.innerHTML\n', '2) content: () => element.cloneNode(true)'].join(' '));
|
3452
|
+
}
|
3453
|
+
|
3454
|
+
var instances = elements.reduce(function (acc, reference) {
|
3455
|
+
var instance = reference && createTippy(reference, passedProps);
|
3456
|
+
|
3457
|
+
if (instance) {
|
3458
|
+
acc.push(instance);
|
3459
|
+
}
|
3460
|
+
|
3461
|
+
return acc;
|
3462
|
+
}, []);
|
3463
|
+
return isElement$1(targets) ? instances[0] : instances;
|
3464
|
+
}
|
3465
|
+
|
3466
|
+
tippy.defaultProps = defaultProps;
|
3467
|
+
tippy.setDefaultProps = setDefaultProps;
|
3468
|
+
tippy.currentInput = currentInput;
|
3469
|
+
|
3470
|
+
// every time the popper is destroyed (i.e. a new target), removing the styles
|
3471
|
+
// and causing transitions to break for singletons when the console is open, but
|
3472
|
+
// most notably for non-transform styles being used, `gpuAcceleration: false`.
|
3473
|
+
|
3474
|
+
var applyStylesModifier = Object.assign({}, applyStyles$1, {
|
3475
|
+
effect: function effect(_ref) {
|
3476
|
+
var state = _ref.state;
|
3477
|
+
var initialStyles = {
|
3478
|
+
popper: {
|
3479
|
+
position: state.options.strategy,
|
3480
|
+
left: '0',
|
3481
|
+
top: '0',
|
3482
|
+
margin: '0'
|
3483
|
+
},
|
3484
|
+
arrow: {
|
3485
|
+
position: 'absolute'
|
3486
|
+
},
|
3487
|
+
reference: {}
|
3488
|
+
};
|
3489
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
3490
|
+
state.styles = initialStyles;
|
3491
|
+
|
3492
|
+
if (state.elements.arrow) {
|
3493
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
3494
|
+
} // intentionally return no cleanup function
|
3495
|
+
// return () => { ... }
|
3496
|
+
|
3497
|
+
}
|
3498
|
+
});
|
3499
|
+
|
3500
|
+
var createSingleton = function createSingleton(tippyInstances, optionalProps) {
|
3501
|
+
var _optionalProps$popper;
|
3502
|
+
|
3503
|
+
if (optionalProps === void 0) {
|
3504
|
+
optionalProps = {};
|
3505
|
+
}
|
3506
|
+
|
3507
|
+
/* istanbul ignore else */
|
3508
|
+
if (process.env.NODE_ENV !== "production") {
|
3509
|
+
errorWhen(!Array.isArray(tippyInstances), ['The first argument passed to createSingleton() must be an array of', 'tippy instances. The passed value was', String(tippyInstances)].join(' '));
|
3510
|
+
}
|
3511
|
+
|
3512
|
+
var individualInstances = tippyInstances;
|
3513
|
+
var references = [];
|
3514
|
+
var currentTarget;
|
3515
|
+
var overrides = optionalProps.overrides;
|
3516
|
+
var interceptSetPropsCleanups = [];
|
3517
|
+
var shownOnCreate = false;
|
3518
|
+
|
3519
|
+
function setReferences() {
|
3520
|
+
references = individualInstances.map(function (instance) {
|
3521
|
+
return instance.reference;
|
3522
|
+
});
|
3523
|
+
}
|
3524
|
+
|
3525
|
+
function enableInstances(isEnabled) {
|
3526
|
+
individualInstances.forEach(function (instance) {
|
3527
|
+
if (isEnabled) {
|
3528
|
+
instance.enable();
|
3529
|
+
} else {
|
3530
|
+
instance.disable();
|
3531
|
+
}
|
3532
|
+
});
|
3533
|
+
}
|
3534
|
+
|
3535
|
+
function interceptSetProps(singleton) {
|
3536
|
+
return individualInstances.map(function (instance) {
|
3537
|
+
var originalSetProps = instance.setProps;
|
3538
|
+
|
3539
|
+
instance.setProps = function (props) {
|
3540
|
+
originalSetProps(props);
|
3541
|
+
|
3542
|
+
if (instance.reference === currentTarget) {
|
3543
|
+
singleton.setProps(props);
|
3544
|
+
}
|
3545
|
+
};
|
3546
|
+
|
3547
|
+
return function () {
|
3548
|
+
instance.setProps = originalSetProps;
|
3549
|
+
};
|
3550
|
+
});
|
3551
|
+
} // have to pass singleton, as it maybe undefined on first call
|
3552
|
+
|
3553
|
+
|
3554
|
+
function prepareInstance(singleton, target) {
|
3555
|
+
var index = references.indexOf(target); // bail-out
|
3556
|
+
|
3557
|
+
if (target === currentTarget) {
|
3558
|
+
return;
|
3559
|
+
}
|
3560
|
+
|
3561
|
+
currentTarget = target;
|
3562
|
+
var overrideProps = (overrides || []).concat('content').reduce(function (acc, prop) {
|
3563
|
+
acc[prop] = individualInstances[index].props[prop];
|
3564
|
+
return acc;
|
3565
|
+
}, {});
|
3566
|
+
singleton.setProps(Object.assign({}, overrideProps, {
|
3567
|
+
getReferenceClientRect: typeof overrideProps.getReferenceClientRect === 'function' ? overrideProps.getReferenceClientRect : function () {
|
3568
|
+
return target.getBoundingClientRect();
|
3569
|
+
}
|
3570
|
+
}));
|
3571
|
+
}
|
3572
|
+
|
3573
|
+
enableInstances(false);
|
3574
|
+
setReferences();
|
3575
|
+
var plugin = {
|
3576
|
+
fn: function fn() {
|
3577
|
+
return {
|
3578
|
+
onDestroy: function onDestroy() {
|
3579
|
+
enableInstances(true);
|
3580
|
+
},
|
3581
|
+
onHidden: function onHidden() {
|
3582
|
+
currentTarget = null;
|
3583
|
+
},
|
3584
|
+
onClickOutside: function onClickOutside(instance) {
|
3585
|
+
if (instance.props.showOnCreate && !shownOnCreate) {
|
3586
|
+
shownOnCreate = true;
|
3587
|
+
currentTarget = null;
|
3588
|
+
}
|
3589
|
+
},
|
3590
|
+
onShow: function onShow(instance) {
|
3591
|
+
if (instance.props.showOnCreate && !shownOnCreate) {
|
3592
|
+
shownOnCreate = true;
|
3593
|
+
prepareInstance(instance, references[0]);
|
3594
|
+
}
|
3595
|
+
},
|
3596
|
+
onTrigger: function onTrigger(instance, event) {
|
3597
|
+
prepareInstance(instance, event.currentTarget);
|
3598
|
+
}
|
3599
|
+
};
|
3600
|
+
}
|
3601
|
+
};
|
3602
|
+
var singleton = tippy(div(), Object.assign({}, removeProperties(optionalProps, ['overrides']), {
|
3603
|
+
plugins: [plugin].concat(optionalProps.plugins || []),
|
3604
|
+
triggerTarget: references,
|
3605
|
+
popperOptions: Object.assign({}, optionalProps.popperOptions, {
|
3606
|
+
modifiers: [].concat(((_optionalProps$popper = optionalProps.popperOptions) == null ? void 0 : _optionalProps$popper.modifiers) || [], [applyStylesModifier])
|
3607
|
+
})
|
3608
|
+
}));
|
3609
|
+
var originalShow = singleton.show;
|
3610
|
+
|
3611
|
+
singleton.show = function (target) {
|
3612
|
+
originalShow(); // first time, showOnCreate or programmatic call with no params
|
3613
|
+
// default to showing first instance
|
3614
|
+
|
3615
|
+
if (!currentTarget && target == null) {
|
3616
|
+
return prepareInstance(singleton, references[0]);
|
3617
|
+
} // triggered from event (do nothing as prepareInstance already called by onTrigger)
|
3618
|
+
// programmatic call with no params when already visible (do nothing again)
|
3619
|
+
|
3620
|
+
|
3621
|
+
if (currentTarget && target == null) {
|
3622
|
+
return;
|
3623
|
+
} // target is index of instance
|
3624
|
+
|
3625
|
+
|
3626
|
+
if (typeof target === 'number') {
|
3627
|
+
return references[target] && prepareInstance(singleton, references[target]);
|
3628
|
+
} // target is a child tippy instance
|
3629
|
+
|
3630
|
+
|
3631
|
+
if (individualInstances.includes(target)) {
|
3632
|
+
var ref = target.reference;
|
3633
|
+
return prepareInstance(singleton, ref);
|
3634
|
+
} // target is a ReferenceElement
|
3635
|
+
|
3636
|
+
|
3637
|
+
if (references.includes(target)) {
|
3638
|
+
return prepareInstance(singleton, target);
|
3639
|
+
}
|
3640
|
+
};
|
3641
|
+
|
3642
|
+
singleton.showNext = function () {
|
3643
|
+
var first = references[0];
|
3644
|
+
|
3645
|
+
if (!currentTarget) {
|
3646
|
+
return singleton.show(0);
|
3647
|
+
}
|
3648
|
+
|
3649
|
+
var index = references.indexOf(currentTarget);
|
3650
|
+
singleton.show(references[index + 1] || first);
|
3651
|
+
};
|
3652
|
+
|
3653
|
+
singleton.showPrevious = function () {
|
3654
|
+
var last = references[references.length - 1];
|
3655
|
+
|
3656
|
+
if (!currentTarget) {
|
3657
|
+
return singleton.show(last);
|
3658
|
+
}
|
3659
|
+
|
3660
|
+
var index = references.indexOf(currentTarget);
|
3661
|
+
var target = references[index - 1] || last;
|
3662
|
+
singleton.show(target);
|
3663
|
+
};
|
3664
|
+
|
3665
|
+
var originalSetProps = singleton.setProps;
|
3666
|
+
|
3667
|
+
singleton.setProps = function (props) {
|
3668
|
+
overrides = props.overrides || overrides;
|
3669
|
+
originalSetProps(props);
|
3670
|
+
};
|
3671
|
+
|
3672
|
+
singleton.setInstances = function (nextInstances) {
|
3673
|
+
enableInstances(true);
|
3674
|
+
interceptSetPropsCleanups.forEach(function (fn) {
|
3675
|
+
return fn();
|
3676
|
+
});
|
3677
|
+
individualInstances = nextInstances;
|
3678
|
+
enableInstances(false);
|
3679
|
+
setReferences();
|
3680
|
+
interceptSetProps(singleton);
|
3681
|
+
singleton.setProps({
|
3682
|
+
triggerTarget: references
|
3683
|
+
});
|
3684
|
+
};
|
3685
|
+
|
3686
|
+
interceptSetPropsCleanups = interceptSetProps(singleton);
|
3687
|
+
return singleton;
|
3688
|
+
};
|
3689
|
+
|
3690
|
+
var animateFill = {
|
3691
|
+
name: 'animateFill',
|
3692
|
+
defaultValue: false,
|
3693
|
+
fn: function fn(instance) {
|
3694
|
+
var _instance$props$rende;
|
3695
|
+
|
3696
|
+
// @ts-ignore
|
3697
|
+
if (!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy)) {
|
3698
|
+
if (process.env.NODE_ENV !== "production") {
|
3699
|
+
errorWhen(instance.props.animateFill, 'The `animateFill` plugin requires the default render function.');
|
3700
|
+
}
|
3701
|
+
|
3702
|
+
return {};
|
3703
|
+
}
|
3704
|
+
|
3705
|
+
var _getChildren = getChildren(instance.popper),
|
3706
|
+
box = _getChildren.box,
|
3707
|
+
content = _getChildren.content;
|
3708
|
+
|
3709
|
+
var backdrop = instance.props.animateFill ? createBackdropElement() : null;
|
3710
|
+
return {
|
3711
|
+
onCreate: function onCreate() {
|
3712
|
+
if (backdrop) {
|
3713
|
+
box.insertBefore(backdrop, box.firstElementChild);
|
3714
|
+
box.setAttribute('data-animatefill', '');
|
3715
|
+
box.style.overflow = 'hidden';
|
3716
|
+
instance.setProps({
|
3717
|
+
arrow: false,
|
3718
|
+
animation: 'shift-away'
|
3719
|
+
});
|
3720
|
+
}
|
3721
|
+
},
|
3722
|
+
onMount: function onMount() {
|
3723
|
+
if (backdrop) {
|
3724
|
+
var transitionDuration = box.style.transitionDuration;
|
3725
|
+
var duration = Number(transitionDuration.replace('ms', '')); // The content should fade in after the backdrop has mostly filled the
|
3726
|
+
// tooltip element. `clip-path` is the other alternative but is not
|
3727
|
+
// well-supported and is buggy on some devices.
|
3728
|
+
|
3729
|
+
content.style.transitionDelay = Math.round(duration / 10) + "ms";
|
3730
|
+
backdrop.style.transitionDuration = transitionDuration;
|
3731
|
+
setVisibilityState([backdrop], 'visible');
|
3732
|
+
}
|
3733
|
+
},
|
3734
|
+
onShow: function onShow() {
|
3735
|
+
if (backdrop) {
|
3736
|
+
backdrop.style.transitionDuration = '0ms';
|
3737
|
+
}
|
3738
|
+
},
|
3739
|
+
onHide: function onHide() {
|
3740
|
+
if (backdrop) {
|
3741
|
+
setVisibilityState([backdrop], 'hidden');
|
3742
|
+
}
|
3743
|
+
}
|
3744
|
+
};
|
3745
|
+
}
|
3746
|
+
};
|
3747
|
+
|
3748
|
+
function createBackdropElement() {
|
3749
|
+
var backdrop = div();
|
3750
|
+
backdrop.className = BACKDROP_CLASS;
|
3751
|
+
setVisibilityState([backdrop], 'hidden');
|
3752
|
+
return backdrop;
|
3753
|
+
}
|
3754
|
+
|
3755
|
+
var mouseCoords = {
|
3756
|
+
clientX: 0,
|
3757
|
+
clientY: 0
|
3758
|
+
};
|
3759
|
+
var activeInstances = [];
|
3760
|
+
|
3761
|
+
function storeMouseCoords(_ref) {
|
3762
|
+
var clientX = _ref.clientX,
|
3763
|
+
clientY = _ref.clientY;
|
3764
|
+
mouseCoords = {
|
3765
|
+
clientX: clientX,
|
3766
|
+
clientY: clientY
|
3767
|
+
};
|
3768
|
+
}
|
3769
|
+
|
3770
|
+
function addMouseCoordsListener(doc) {
|
3771
|
+
doc.addEventListener('mousemove', storeMouseCoords);
|
3772
|
+
}
|
3773
|
+
|
3774
|
+
function removeMouseCoordsListener(doc) {
|
3775
|
+
doc.removeEventListener('mousemove', storeMouseCoords);
|
3776
|
+
}
|
3777
|
+
|
3778
|
+
var followCursor = {
|
3779
|
+
name: 'followCursor',
|
3780
|
+
defaultValue: false,
|
3781
|
+
fn: function fn(instance) {
|
3782
|
+
var reference = instance.reference;
|
3783
|
+
var doc = getOwnerDocument(instance.props.triggerTarget || reference);
|
3784
|
+
var isInternalUpdate = false;
|
3785
|
+
var wasFocusEvent = false;
|
3786
|
+
var isUnmounted = true;
|
3787
|
+
var prevProps = instance.props;
|
3788
|
+
|
3789
|
+
function getIsInitialBehavior() {
|
3790
|
+
return instance.props.followCursor === 'initial' && instance.state.isVisible;
|
3791
|
+
}
|
3792
|
+
|
3793
|
+
function addListener() {
|
3794
|
+
doc.addEventListener('mousemove', onMouseMove);
|
3795
|
+
}
|
3796
|
+
|
3797
|
+
function removeListener() {
|
3798
|
+
doc.removeEventListener('mousemove', onMouseMove);
|
3799
|
+
}
|
3800
|
+
|
3801
|
+
function unsetGetReferenceClientRect() {
|
3802
|
+
isInternalUpdate = true;
|
3803
|
+
instance.setProps({
|
3804
|
+
getReferenceClientRect: null
|
3805
|
+
});
|
3806
|
+
isInternalUpdate = false;
|
3807
|
+
}
|
3808
|
+
|
3809
|
+
function onMouseMove(event) {
|
3810
|
+
// If the instance is interactive, avoid updating the position unless it's
|
3811
|
+
// over the reference element
|
3812
|
+
var isCursorOverReference = event.target ? reference.contains(event.target) : true;
|
3813
|
+
var followCursor = instance.props.followCursor;
|
3814
|
+
var clientX = event.clientX,
|
3815
|
+
clientY = event.clientY;
|
3816
|
+
var rect = reference.getBoundingClientRect();
|
3817
|
+
var relativeX = clientX - rect.left;
|
3818
|
+
var relativeY = clientY - rect.top;
|
3819
|
+
|
3820
|
+
if (isCursorOverReference || !instance.props.interactive) {
|
3821
|
+
instance.setProps({
|
3822
|
+
getReferenceClientRect: function getReferenceClientRect() {
|
3823
|
+
var rect = reference.getBoundingClientRect();
|
3824
|
+
var x = clientX;
|
3825
|
+
var y = clientY;
|
3826
|
+
|
3827
|
+
if (followCursor === 'initial') {
|
3828
|
+
x = rect.left + relativeX;
|
3829
|
+
y = rect.top + relativeY;
|
3830
|
+
}
|
3831
|
+
|
3832
|
+
var top = followCursor === 'horizontal' ? rect.top : y;
|
3833
|
+
var right = followCursor === 'vertical' ? rect.right : x;
|
3834
|
+
var bottom = followCursor === 'horizontal' ? rect.bottom : y;
|
3835
|
+
var left = followCursor === 'vertical' ? rect.left : x;
|
3836
|
+
return {
|
3837
|
+
width: right - left,
|
3838
|
+
height: bottom - top,
|
3839
|
+
top: top,
|
3840
|
+
right: right,
|
3841
|
+
bottom: bottom,
|
3842
|
+
left: left
|
3843
|
+
};
|
3844
|
+
}
|
3845
|
+
});
|
3846
|
+
}
|
3847
|
+
}
|
3848
|
+
|
3849
|
+
function create() {
|
3850
|
+
if (instance.props.followCursor) {
|
3851
|
+
activeInstances.push({
|
3852
|
+
instance: instance,
|
3853
|
+
doc: doc
|
3854
|
+
});
|
3855
|
+
addMouseCoordsListener(doc);
|
3856
|
+
}
|
3857
|
+
}
|
3858
|
+
|
3859
|
+
function destroy() {
|
3860
|
+
activeInstances = activeInstances.filter(function (data) {
|
3861
|
+
return data.instance !== instance;
|
3862
|
+
});
|
3863
|
+
|
3864
|
+
if (activeInstances.filter(function (data) {
|
3865
|
+
return data.doc === doc;
|
3866
|
+
}).length === 0) {
|
3867
|
+
removeMouseCoordsListener(doc);
|
3868
|
+
}
|
3869
|
+
}
|
3870
|
+
|
3871
|
+
return {
|
3872
|
+
onCreate: create,
|
3873
|
+
onDestroy: destroy,
|
3874
|
+
onBeforeUpdate: function onBeforeUpdate() {
|
3875
|
+
prevProps = instance.props;
|
3876
|
+
},
|
3877
|
+
onAfterUpdate: function onAfterUpdate(_, _ref2) {
|
3878
|
+
var followCursor = _ref2.followCursor;
|
3879
|
+
|
3880
|
+
if (isInternalUpdate) {
|
3881
|
+
return;
|
3882
|
+
}
|
3883
|
+
|
3884
|
+
if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
|
3885
|
+
destroy();
|
3886
|
+
|
3887
|
+
if (followCursor) {
|
3888
|
+
create();
|
3889
|
+
|
3890
|
+
if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
|
3891
|
+
addListener();
|
3892
|
+
}
|
3893
|
+
} else {
|
3894
|
+
removeListener();
|
3895
|
+
unsetGetReferenceClientRect();
|
3896
|
+
}
|
3897
|
+
}
|
3898
|
+
},
|
3899
|
+
onMount: function onMount() {
|
3900
|
+
if (instance.props.followCursor && !wasFocusEvent) {
|
3901
|
+
if (isUnmounted) {
|
3902
|
+
onMouseMove(mouseCoords);
|
3903
|
+
isUnmounted = false;
|
3904
|
+
}
|
3905
|
+
|
3906
|
+
if (!getIsInitialBehavior()) {
|
3907
|
+
addListener();
|
3908
|
+
}
|
3909
|
+
}
|
3910
|
+
},
|
3911
|
+
onTrigger: function onTrigger(_, event) {
|
3912
|
+
if (isMouseEvent(event)) {
|
3913
|
+
mouseCoords = {
|
3914
|
+
clientX: event.clientX,
|
3915
|
+
clientY: event.clientY
|
3916
|
+
};
|
3917
|
+
}
|
3918
|
+
|
3919
|
+
wasFocusEvent = event.type === 'focus';
|
3920
|
+
},
|
3921
|
+
onHidden: function onHidden() {
|
3922
|
+
if (instance.props.followCursor) {
|
3923
|
+
unsetGetReferenceClientRect();
|
3924
|
+
removeListener();
|
3925
|
+
isUnmounted = true;
|
3926
|
+
}
|
3927
|
+
}
|
3928
|
+
};
|
3929
|
+
}
|
3930
|
+
};
|
3931
|
+
|
3932
|
+
function getProps(props, modifier) {
|
3933
|
+
var _props$popperOptions;
|
3934
|
+
|
3935
|
+
return {
|
3936
|
+
popperOptions: Object.assign({}, props.popperOptions, {
|
3937
|
+
modifiers: [].concat((((_props$popperOptions = props.popperOptions) == null ? void 0 : _props$popperOptions.modifiers) || []).filter(function (_ref) {
|
3938
|
+
var name = _ref.name;
|
3939
|
+
return name !== modifier.name;
|
3940
|
+
}), [modifier])
|
3941
|
+
})
|
3942
|
+
};
|
3943
|
+
}
|
3944
|
+
|
3945
|
+
var inlinePositioning = {
|
3946
|
+
name: 'inlinePositioning',
|
3947
|
+
defaultValue: false,
|
3948
|
+
fn: function fn(instance) {
|
3949
|
+
var reference = instance.reference;
|
3950
|
+
|
3951
|
+
function isEnabled() {
|
3952
|
+
return !!instance.props.inlinePositioning;
|
3953
|
+
}
|
3954
|
+
|
3955
|
+
var placement;
|
3956
|
+
var cursorRectIndex = -1;
|
3957
|
+
var isInternalUpdate = false;
|
3958
|
+
var modifier = {
|
3959
|
+
name: 'tippyInlinePositioning',
|
3960
|
+
enabled: true,
|
3961
|
+
phase: 'afterWrite',
|
3962
|
+
fn: function fn(_ref2) {
|
3963
|
+
var state = _ref2.state;
|
3964
|
+
|
3965
|
+
if (isEnabled()) {
|
3966
|
+
if (placement !== state.placement) {
|
3967
|
+
instance.setProps({
|
3968
|
+
getReferenceClientRect: function getReferenceClientRect() {
|
3969
|
+
return _getReferenceClientRect(state.placement);
|
3970
|
+
}
|
3971
|
+
});
|
3972
|
+
}
|
3973
|
+
|
3974
|
+
placement = state.placement;
|
3975
|
+
}
|
3976
|
+
}
|
3977
|
+
};
|
3978
|
+
|
3979
|
+
function _getReferenceClientRect(placement) {
|
3980
|
+
return getInlineBoundingClientRect(getBasePlacement$1(placement), reference.getBoundingClientRect(), arrayFrom(reference.getClientRects()), cursorRectIndex);
|
3981
|
+
}
|
3982
|
+
|
3983
|
+
function setInternalProps(partialProps) {
|
3984
|
+
isInternalUpdate = true;
|
3985
|
+
instance.setProps(partialProps);
|
3986
|
+
isInternalUpdate = false;
|
3987
|
+
}
|
3988
|
+
|
3989
|
+
function addModifier() {
|
3990
|
+
if (!isInternalUpdate) {
|
3991
|
+
setInternalProps(getProps(instance.props, modifier));
|
3992
|
+
}
|
3993
|
+
}
|
3994
|
+
|
3995
|
+
return {
|
3996
|
+
onCreate: addModifier,
|
3997
|
+
onAfterUpdate: addModifier,
|
3998
|
+
onTrigger: function onTrigger(_, event) {
|
3999
|
+
if (isMouseEvent(event)) {
|
4000
|
+
var rects = arrayFrom(instance.reference.getClientRects());
|
4001
|
+
var cursorRect = rects.find(function (rect) {
|
4002
|
+
return rect.left - 2 <= event.clientX && rect.right + 2 >= event.clientX && rect.top - 2 <= event.clientY && rect.bottom + 2 >= event.clientY;
|
4003
|
+
});
|
4004
|
+
cursorRectIndex = rects.indexOf(cursorRect);
|
4005
|
+
}
|
4006
|
+
},
|
4007
|
+
onUntrigger: function onUntrigger() {
|
4008
|
+
cursorRectIndex = -1;
|
4009
|
+
}
|
4010
|
+
};
|
4011
|
+
}
|
4012
|
+
};
|
4013
|
+
function getInlineBoundingClientRect(currentBasePlacement, boundingRect, clientRects, cursorRectIndex) {
|
4014
|
+
// Not an inline element, or placement is not yet known
|
4015
|
+
if (clientRects.length < 2 || currentBasePlacement === null) {
|
4016
|
+
return boundingRect;
|
4017
|
+
} // There are two rects and they are disjoined
|
4018
|
+
|
4019
|
+
|
4020
|
+
if (clientRects.length === 2 && cursorRectIndex >= 0 && clientRects[0].left > clientRects[1].right) {
|
4021
|
+
return clientRects[cursorRectIndex] || boundingRect;
|
4022
|
+
}
|
4023
|
+
|
4024
|
+
switch (currentBasePlacement) {
|
4025
|
+
case 'top':
|
4026
|
+
case 'bottom':
|
4027
|
+
{
|
4028
|
+
var firstRect = clientRects[0];
|
4029
|
+
var lastRect = clientRects[clientRects.length - 1];
|
4030
|
+
var isTop = currentBasePlacement === 'top';
|
4031
|
+
var top = firstRect.top;
|
4032
|
+
var bottom = lastRect.bottom;
|
4033
|
+
var left = isTop ? firstRect.left : lastRect.left;
|
4034
|
+
var right = isTop ? firstRect.right : lastRect.right;
|
4035
|
+
var width = right - left;
|
4036
|
+
var height = bottom - top;
|
4037
|
+
return {
|
4038
|
+
top: top,
|
4039
|
+
bottom: bottom,
|
4040
|
+
left: left,
|
4041
|
+
right: right,
|
4042
|
+
width: width,
|
4043
|
+
height: height
|
4044
|
+
};
|
4045
|
+
}
|
4046
|
+
|
4047
|
+
case 'left':
|
4048
|
+
case 'right':
|
4049
|
+
{
|
4050
|
+
var minLeft = Math.min.apply(Math, clientRects.map(function (rects) {
|
4051
|
+
return rects.left;
|
4052
|
+
}));
|
4053
|
+
var maxRight = Math.max.apply(Math, clientRects.map(function (rects) {
|
4054
|
+
return rects.right;
|
4055
|
+
}));
|
4056
|
+
var measureRects = clientRects.filter(function (rect) {
|
4057
|
+
return currentBasePlacement === 'left' ? rect.left === minLeft : rect.right === maxRight;
|
4058
|
+
});
|
4059
|
+
var _top = measureRects[0].top;
|
4060
|
+
var _bottom = measureRects[measureRects.length - 1].bottom;
|
4061
|
+
var _left = minLeft;
|
4062
|
+
var _right = maxRight;
|
4063
|
+
|
4064
|
+
var _width = _right - _left;
|
4065
|
+
|
4066
|
+
var _height = _bottom - _top;
|
4067
|
+
|
4068
|
+
return {
|
4069
|
+
top: _top,
|
4070
|
+
bottom: _bottom,
|
4071
|
+
left: _left,
|
4072
|
+
right: _right,
|
4073
|
+
width: _width,
|
4074
|
+
height: _height
|
4075
|
+
};
|
4076
|
+
}
|
4077
|
+
|
4078
|
+
default:
|
4079
|
+
{
|
4080
|
+
return boundingRect;
|
4081
|
+
}
|
4082
|
+
}
|
4083
|
+
}
|
4084
|
+
|
4085
|
+
var sticky = {
|
4086
|
+
name: 'sticky',
|
4087
|
+
defaultValue: false,
|
4088
|
+
fn: function fn(instance) {
|
4089
|
+
var reference = instance.reference,
|
4090
|
+
popper = instance.popper;
|
4091
|
+
|
4092
|
+
function getReference() {
|
4093
|
+
return instance.popperInstance ? instance.popperInstance.state.elements.reference : reference;
|
4094
|
+
}
|
4095
|
+
|
4096
|
+
function shouldCheck(value) {
|
4097
|
+
return instance.props.sticky === true || instance.props.sticky === value;
|
4098
|
+
}
|
4099
|
+
|
4100
|
+
var prevRefRect = null;
|
4101
|
+
var prevPopRect = null;
|
4102
|
+
|
4103
|
+
function updatePosition() {
|
4104
|
+
var currentRefRect = shouldCheck('reference') ? getReference().getBoundingClientRect() : null;
|
4105
|
+
var currentPopRect = shouldCheck('popper') ? popper.getBoundingClientRect() : null;
|
4106
|
+
|
4107
|
+
if (currentRefRect && areRectsDifferent(prevRefRect, currentRefRect) || currentPopRect && areRectsDifferent(prevPopRect, currentPopRect)) {
|
4108
|
+
if (instance.popperInstance) {
|
4109
|
+
instance.popperInstance.update();
|
4110
|
+
}
|
4111
|
+
}
|
4112
|
+
|
4113
|
+
prevRefRect = currentRefRect;
|
4114
|
+
prevPopRect = currentPopRect;
|
4115
|
+
|
4116
|
+
if (instance.state.isMounted) {
|
4117
|
+
requestAnimationFrame(updatePosition);
|
4118
|
+
}
|
4119
|
+
}
|
4120
|
+
|
4121
|
+
return {
|
4122
|
+
onMount: function onMount() {
|
4123
|
+
if (instance.props.sticky) {
|
4124
|
+
updatePosition();
|
4125
|
+
}
|
4126
|
+
}
|
4127
|
+
};
|
4128
|
+
}
|
4129
|
+
};
|
4130
|
+
|
4131
|
+
function areRectsDifferent(rectA, rectB) {
|
4132
|
+
if (rectA && rectB) {
|
4133
|
+
return rectA.top !== rectB.top || rectA.right !== rectB.right || rectA.bottom !== rectB.bottom || rectA.left !== rectB.left;
|
4134
|
+
}
|
4135
|
+
|
4136
|
+
return true;
|
4137
|
+
}
|
4138
|
+
|
4139
|
+
tippy.setDefaultProps({
|
4140
|
+
render: render
|
4141
|
+
});
|
4142
|
+
|
4143
|
+
tippy.setDefaultProps({
|
4144
|
+
//@ts-ignore
|
4145
|
+
onShow: instance => {
|
4146
|
+
if (!instance.props.content)
|
4147
|
+
return false;
|
4148
|
+
},
|
4149
|
+
});
|
4150
|
+
function useTippy(el, opts = {}, settings = { mount: true }) {
|
4151
|
+
const vm = getCurrentInstance();
|
4152
|
+
const instance = ref();
|
4153
|
+
let container = null;
|
4154
|
+
const getContainer = () => {
|
4155
|
+
if (container)
|
4156
|
+
return container;
|
4157
|
+
container = document.createElement('fragment');
|
4158
|
+
return container;
|
4159
|
+
};
|
4160
|
+
const getContent = (content) => {
|
4161
|
+
let newContent;
|
4162
|
+
let unwrappedContent = isRef(content)
|
4163
|
+
? content.value
|
4164
|
+
: content;
|
4165
|
+
if (isVNode(unwrappedContent)) {
|
4166
|
+
if (vm) {
|
4167
|
+
unwrappedContent.appContext = vm.appContext;
|
4168
|
+
}
|
4169
|
+
render$1(unwrappedContent, getContainer());
|
4170
|
+
newContent = () => getContainer();
|
4171
|
+
}
|
4172
|
+
else if (typeof unwrappedContent === 'object') {
|
4173
|
+
let comp = h(unwrappedContent);
|
4174
|
+
if (vm) {
|
4175
|
+
comp.appContext = vm.appContext;
|
4176
|
+
}
|
4177
|
+
render$1(comp, getContainer());
|
4178
|
+
newContent = () => getContainer();
|
4179
|
+
}
|
4180
|
+
else {
|
4181
|
+
newContent = unwrappedContent;
|
4182
|
+
}
|
4183
|
+
return newContent;
|
4184
|
+
};
|
4185
|
+
const getProps = (opts) => {
|
4186
|
+
let options = {};
|
4187
|
+
if (isRef(opts)) {
|
4188
|
+
options = opts.value;
|
4189
|
+
}
|
4190
|
+
else if (isReactive(opts)) {
|
4191
|
+
options = { ...opts };
|
4192
|
+
}
|
4193
|
+
else {
|
4194
|
+
options = { ...opts };
|
4195
|
+
}
|
4196
|
+
if (options.content) {
|
4197
|
+
options.content = getContent(options.content);
|
4198
|
+
}
|
4199
|
+
if (options.triggerTarget) {
|
4200
|
+
options.triggerTarget = isRef(options.triggerTarget)
|
4201
|
+
? options.triggerTarget.value
|
4202
|
+
: options.triggerTarget;
|
4203
|
+
}
|
4204
|
+
return options;
|
4205
|
+
};
|
4206
|
+
const refresh = () => {
|
4207
|
+
if (!instance.value)
|
4208
|
+
return;
|
4209
|
+
instance.value.setProps(getProps(opts));
|
4210
|
+
};
|
4211
|
+
const refreshContent = () => {
|
4212
|
+
if (!instance.value || !opts.content)
|
4213
|
+
return;
|
4214
|
+
instance.value.setContent(getContent(opts.content));
|
4215
|
+
};
|
4216
|
+
const setContent = (value) => {
|
4217
|
+
var _a;
|
4218
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.setContent(getContent(value));
|
4219
|
+
};
|
4220
|
+
const setProps = (value) => {
|
4221
|
+
var _a;
|
4222
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.setProps(getProps(value));
|
4223
|
+
};
|
4224
|
+
const destroy = () => {
|
4225
|
+
if (instance.value) {
|
4226
|
+
instance.value.destroy();
|
4227
|
+
instance.value = undefined;
|
4228
|
+
}
|
4229
|
+
container = null;
|
4230
|
+
};
|
4231
|
+
const show = () => {
|
4232
|
+
var _a;
|
4233
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.show();
|
4234
|
+
};
|
4235
|
+
const hide = () => {
|
4236
|
+
var _a;
|
4237
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.hide();
|
4238
|
+
};
|
4239
|
+
const disable = () => {
|
4240
|
+
var _a;
|
4241
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.disable();
|
4242
|
+
};
|
4243
|
+
const enable = () => {
|
4244
|
+
var _a;
|
4245
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.enable();
|
4246
|
+
};
|
4247
|
+
const unmount = () => {
|
4248
|
+
var _a;
|
4249
|
+
(_a = instance.value) === null || _a === void 0 ? void 0 : _a.unmount();
|
4250
|
+
};
|
4251
|
+
const mount = () => {
|
4252
|
+
if (!el)
|
4253
|
+
return;
|
4254
|
+
let target = isRef(el) ? el.value : el;
|
4255
|
+
if (typeof target === 'function')
|
4256
|
+
target = target();
|
4257
|
+
if (target) {
|
4258
|
+
instance.value = tippy(target, getProps(opts));
|
4259
|
+
//@ts-ignore
|
4260
|
+
target.$tippy = response;
|
4261
|
+
}
|
4262
|
+
};
|
4263
|
+
const response = {
|
4264
|
+
tippy: instance,
|
4265
|
+
refresh,
|
4266
|
+
refreshContent,
|
4267
|
+
setContent,
|
4268
|
+
setProps,
|
4269
|
+
destroy,
|
4270
|
+
hide,
|
4271
|
+
show,
|
4272
|
+
disable,
|
4273
|
+
enable,
|
4274
|
+
unmount,
|
4275
|
+
mount,
|
4276
|
+
};
|
4277
|
+
if (settings.mount) {
|
4278
|
+
if (vm) {
|
4279
|
+
if (vm.isMounted) {
|
4280
|
+
mount();
|
4281
|
+
}
|
4282
|
+
else {
|
4283
|
+
onMounted(mount);
|
4284
|
+
}
|
4285
|
+
onUnmounted(() => {
|
4286
|
+
destroy();
|
4287
|
+
});
|
4288
|
+
}
|
4289
|
+
else {
|
4290
|
+
mount();
|
4291
|
+
}
|
4292
|
+
}
|
4293
|
+
if (isRef(opts) || isReactive(opts)) {
|
4294
|
+
watch(opts, refresh, { immediate: false });
|
4295
|
+
}
|
4296
|
+
else if (isRef(opts.content)) {
|
4297
|
+
watch(opts.content, refreshContent, { immediate: false });
|
4298
|
+
}
|
4299
|
+
return response;
|
4300
|
+
}
|
4301
|
+
|
4302
|
+
function useTippyComponent(opts = {}, children) {
|
4303
|
+
const instance = ref();
|
4304
|
+
return {
|
4305
|
+
instance,
|
4306
|
+
TippyComponent: h(TippyComponent, {
|
4307
|
+
...opts,
|
4308
|
+
onVnodeMounted: vnode => {
|
4309
|
+
//@ts-ignore
|
4310
|
+
instance.value = vnode.component.ctx;
|
4311
|
+
},
|
4312
|
+
}, children),
|
4313
|
+
};
|
4314
|
+
}
|
4315
|
+
|
4316
|
+
function useSingleton(instances, optionalProps) {
|
4317
|
+
const singleton = ref();
|
4318
|
+
onMounted(() => {
|
4319
|
+
const pendingTippyInstances = Array.isArray(instances)
|
4320
|
+
? instances.map(i => i.value)
|
4321
|
+
: typeof instances === 'function'
|
4322
|
+
? instances()
|
4323
|
+
: instances.value;
|
4324
|
+
const tippyInstances = pendingTippyInstances
|
4325
|
+
.map((instance) => {
|
4326
|
+
if (instance instanceof Element) {
|
4327
|
+
//@ts-ignore
|
4328
|
+
return instance._tippy;
|
4329
|
+
}
|
4330
|
+
return instance;
|
4331
|
+
})
|
4332
|
+
.filter(Boolean);
|
4333
|
+
singleton.value = createSingleton(tippyInstances, optionalProps
|
4334
|
+
? { allowHTML: true, ...optionalProps }
|
4335
|
+
: { allowHTML: true });
|
4336
|
+
});
|
4337
|
+
return {
|
4338
|
+
singleton,
|
4339
|
+
};
|
4340
|
+
}
|
4341
|
+
|
4342
|
+
// const pluginProps = [
|
4343
|
+
// 'animateFill',
|
4344
|
+
// 'followCursor',
|
4345
|
+
// 'inlinePositioning',
|
4346
|
+
// 'sticky',
|
4347
|
+
// ]
|
4348
|
+
const booleanProps = [
|
4349
|
+
'a11y',
|
4350
|
+
'allowHTML',
|
4351
|
+
'arrow',
|
4352
|
+
'flip',
|
4353
|
+
'flipOnUpdate',
|
4354
|
+
'hideOnClick',
|
4355
|
+
'ignoreAttributes',
|
4356
|
+
'inertia',
|
4357
|
+
'interactive',
|
4358
|
+
'lazy',
|
4359
|
+
'multiple',
|
4360
|
+
'showOnInit',
|
4361
|
+
'touch',
|
4362
|
+
'touchHold',
|
4363
|
+
];
|
4364
|
+
let props = {};
|
4365
|
+
Object.keys(tippy.defaultProps).forEach((prop) => {
|
4366
|
+
if (booleanProps.includes(prop)) {
|
4367
|
+
props[prop] = {
|
4368
|
+
type: Boolean,
|
4369
|
+
default: function () {
|
4370
|
+
return tippy.defaultProps[prop];
|
4371
|
+
},
|
4372
|
+
};
|
4373
|
+
}
|
4374
|
+
else {
|
4375
|
+
props[prop] = {
|
4376
|
+
default: function () {
|
4377
|
+
return tippy.defaultProps[prop];
|
4378
|
+
},
|
4379
|
+
};
|
4380
|
+
}
|
4381
|
+
});
|
4382
|
+
props['to'] = {};
|
4383
|
+
props['tag'] = {
|
4384
|
+
default: 'span'
|
4385
|
+
};
|
4386
|
+
props['contentTag'] = {
|
4387
|
+
default: 'span'
|
4388
|
+
};
|
4389
|
+
props['contentClass'] = {
|
4390
|
+
default: null
|
4391
|
+
};
|
4392
|
+
const TippyComponent = defineComponent({
|
4393
|
+
props,
|
4394
|
+
setup(props, { slots }) {
|
4395
|
+
const elem = ref();
|
4396
|
+
const contentElem = ref();
|
4397
|
+
const mounted = ref(false);
|
4398
|
+
let options = { ...props };
|
4399
|
+
for (const prop of ['to', 'tag', 'contentTag', 'contentClass']) {
|
4400
|
+
if (options.hasOwnProperty(prop)) {
|
4401
|
+
// @ts-ignore
|
4402
|
+
delete options[prop];
|
4403
|
+
}
|
4404
|
+
}
|
4405
|
+
let target = elem;
|
4406
|
+
if (props.to) {
|
4407
|
+
if (typeof Element !== 'undefined' && props.to instanceof Element) {
|
4408
|
+
target = () => props.to;
|
4409
|
+
}
|
4410
|
+
else if (typeof props.to === 'string' || props.to instanceof String) {
|
4411
|
+
target = () => document.querySelector(props.to);
|
4412
|
+
}
|
4413
|
+
}
|
4414
|
+
const tippy = useTippy(target, options);
|
4415
|
+
onMounted(() => {
|
4416
|
+
mounted.value = true;
|
4417
|
+
nextTick(() => {
|
4418
|
+
if (slots.content)
|
4419
|
+
tippy.setContent(() => contentElem.value);
|
4420
|
+
});
|
4421
|
+
});
|
4422
|
+
return { elem, contentElem, mounted, ...tippy };
|
4423
|
+
},
|
4424
|
+
render() {
|
4425
|
+
let slot = this.$slots.default ? this.$slots.default(this) : [];
|
4426
|
+
return h(this.tag, { ref: 'elem', 'data-v-tippy': '' }, this.$slots.content ? [
|
4427
|
+
slot,
|
4428
|
+
h(this.contentTag, { ref: 'contentElem', style: { display: this.mounted ? 'inherit' : 'none' }, class: this.contentClass }, this.$slots.content(this)),
|
4429
|
+
] : slot);
|
4430
|
+
},
|
4431
|
+
});
|
4432
|
+
|
4433
|
+
const booleanProps$1 = [
|
4434
|
+
'a11y',
|
4435
|
+
'allowHTML',
|
4436
|
+
'arrow',
|
4437
|
+
'flip',
|
4438
|
+
'flipOnUpdate',
|
4439
|
+
'hideOnClick',
|
4440
|
+
'ignoreAttributes',
|
4441
|
+
'inertia',
|
4442
|
+
'interactive',
|
4443
|
+
'lazy',
|
4444
|
+
'multiple',
|
4445
|
+
'showOnInit',
|
4446
|
+
'touch',
|
4447
|
+
'touchHold',
|
4448
|
+
];
|
4449
|
+
let props$1 = {};
|
4450
|
+
Object.keys(tippy.defaultProps).forEach((prop) => {
|
4451
|
+
if (booleanProps$1.includes(prop)) {
|
4452
|
+
props$1[prop] = {
|
4453
|
+
type: Boolean,
|
4454
|
+
default: function () {
|
4455
|
+
return tippy.defaultProps[prop];
|
4456
|
+
},
|
4457
|
+
};
|
4458
|
+
}
|
4459
|
+
else {
|
4460
|
+
props$1[prop] = {
|
4461
|
+
default: function () {
|
4462
|
+
return tippy.defaultProps[prop];
|
4463
|
+
},
|
4464
|
+
};
|
4465
|
+
}
|
4466
|
+
});
|
4467
|
+
const TippySingleton = defineComponent({
|
4468
|
+
props: props$1,
|
4469
|
+
setup(props) {
|
4470
|
+
const instances = ref([]);
|
4471
|
+
const { singleton } = useSingleton(instances, props);
|
4472
|
+
return { instances, singleton };
|
4473
|
+
},
|
4474
|
+
mounted() {
|
4475
|
+
var _a;
|
4476
|
+
const parent = this.$el.parentElement;
|
4477
|
+
const elements = parent.querySelectorAll('[data-v-tippy]');
|
4478
|
+
this.instances = Array.from(elements)
|
4479
|
+
.map((el) => el._tippy)
|
4480
|
+
.filter(Boolean);
|
4481
|
+
(_a = this.singleton) === null || _a === void 0 ? void 0 : _a.setInstances(this.instances);
|
4482
|
+
},
|
4483
|
+
render() {
|
4484
|
+
let slot = this.$slots.default ? this.$slots.default() : [];
|
4485
|
+
return h(() => slot);
|
4486
|
+
},
|
4487
|
+
});
|
4488
|
+
|
4489
|
+
const directive = {
|
4490
|
+
mounted(el, binding, vnode) {
|
4491
|
+
const opts = typeof binding.value === "string" ? { content: binding.value } : binding.value || {};
|
4492
|
+
const modifiers = Object.keys(binding.modifiers || {});
|
4493
|
+
const placement = modifiers.find(modifier => modifier !== 'arrow');
|
4494
|
+
const withArrow = modifiers.findIndex(modifier => modifier === 'arrow') !== -1;
|
4495
|
+
if (placement) {
|
4496
|
+
opts.placement = opts.placement || placement;
|
4497
|
+
}
|
4498
|
+
if (withArrow) {
|
4499
|
+
opts.arrow = opts.arrow !== undefined ? opts.arrow : true;
|
4500
|
+
}
|
4501
|
+
if (vnode.props && vnode.props.onTippyShow) {
|
4502
|
+
opts.onShow = function (...args) {
|
4503
|
+
var _a;
|
4504
|
+
return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyShow(...args);
|
4505
|
+
};
|
4506
|
+
}
|
4507
|
+
if (vnode.props && vnode.props.onTippyShown) {
|
4508
|
+
opts.onShown = function (...args) {
|
4509
|
+
var _a;
|
4510
|
+
return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyShown(...args);
|
4511
|
+
};
|
4512
|
+
}
|
4513
|
+
if (vnode.props && vnode.props.onTippyHidden) {
|
4514
|
+
opts.onHidden = function (...args) {
|
4515
|
+
var _a;
|
4516
|
+
return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyHidden(...args);
|
4517
|
+
};
|
4518
|
+
}
|
4519
|
+
if (vnode.props && vnode.props.onTippyHide) {
|
4520
|
+
opts.onHide = function (...args) {
|
4521
|
+
var _a;
|
4522
|
+
return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyHide(...args);
|
4523
|
+
};
|
4524
|
+
}
|
4525
|
+
if (vnode.props && vnode.props.onTippyMount) {
|
4526
|
+
opts.onMount = function (...args) {
|
4527
|
+
var _a;
|
4528
|
+
return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyMount(...args);
|
4529
|
+
};
|
4530
|
+
}
|
4531
|
+
if (el.getAttribute('title') && !opts.content) {
|
4532
|
+
opts.content = el.getAttribute('title');
|
4533
|
+
el.removeAttribute('title');
|
4534
|
+
}
|
4535
|
+
if (el.getAttribute('content') && !opts.content) {
|
4536
|
+
opts.content = el.getAttribute('content');
|
4537
|
+
}
|
4538
|
+
useTippy(el, opts);
|
4539
|
+
},
|
4540
|
+
unmounted(el) {
|
4541
|
+
if (el.$tippy) {
|
4542
|
+
el.$tippy.destroy();
|
4543
|
+
}
|
4544
|
+
else if (el._tippy) {
|
4545
|
+
el._tippy.destroy();
|
4546
|
+
}
|
4547
|
+
},
|
4548
|
+
updated(el, binding) {
|
4549
|
+
const opts = typeof binding.value === "string" ? { content: binding.value } : binding.value || {};
|
4550
|
+
if (el.getAttribute('title') && !opts.content) {
|
4551
|
+
opts.content = el.getAttribute('title');
|
4552
|
+
el.removeAttribute('title');
|
4553
|
+
}
|
4554
|
+
if (el.getAttribute('content') && !opts.content) {
|
4555
|
+
opts.content = el.getAttribute('content');
|
4556
|
+
}
|
4557
|
+
if (el.$tippy) {
|
4558
|
+
el.$tippy.setProps(opts || {});
|
4559
|
+
}
|
4560
|
+
else if (el._tippy) {
|
4561
|
+
el._tippy.setProps(opts || {});
|
4562
|
+
}
|
4563
|
+
},
|
4564
|
+
};
|
4565
|
+
|
4566
|
+
const plugin = {
|
4567
|
+
install(app, options = {}) {
|
4568
|
+
tippy.setDefaultProps(options.defaultProps || {});
|
4569
|
+
app.directive(options.directive || 'tippy', directive);
|
4570
|
+
app.component(options.component || 'tippy', TippyComponent);
|
4571
|
+
app.component(options.componentSingleton || 'tippy-singleton', TippySingleton);
|
4572
|
+
},
|
4573
|
+
};
|
4574
|
+
|
4575
|
+
const setDefaultProps$1 = tippy.setDefaultProps;
|
4576
|
+
setDefaultProps$1({
|
4577
|
+
ignoreAttributes: true,
|
4578
|
+
plugins: [sticky, inlinePositioning, followCursor, animateFill],
|
4579
|
+
});
|
4580
|
+
|
4581
|
+
export default plugin;
|
4582
|
+
export { TippyComponent as Tippy, TippySingleton, directive, plugin, ROUND_ARROW as roundArrow, setDefaultProps$1 as setDefaultProps, tippy, useSingleton, useTippy, useTippyComponent };
|