d2fc298fcd
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
6517 lines
No EOL
212 KiB
JavaScript
6517 lines
No EOL
212 KiB
JavaScript
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],{
|
||
|
||
/***/ "./node_modules/v-tooltip/dist/v-tooltip.esm.js":
|
||
/*!******************************************************!*\
|
||
!*** ./node_modules/v-tooltip/dist/v-tooltip.esm.js ***!
|
||
\******************************************************/
|
||
/*! exports provided: install, VTooltip, VClosePopover, VPopover, createTooltip, destroyTooltip, default */
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
__webpack_require__.r(__webpack_exports__);
|
||
/* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VTooltip", function() { return VTooltip; });
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VClosePopover", function() { return VClosePopover; });
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VPopover", function() { return VPopover; });
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createTooltip", function() { return createTooltip; });
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "destroyTooltip", function() { return destroyTooltip; });
|
||
/**!
|
||
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
||
* @version 1.14.3
|
||
* @license
|
||
* Copyright (c) 2016 Federico Zivolo and contributors
|
||
*
|
||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
* of this software and associated documentation files (the "Software"), to deal
|
||
* in the Software without restriction, including without limitation the rights
|
||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
* copies of the Software, and to permit persons to whom the Software is
|
||
* furnished to do so, subject to the following conditions:
|
||
*
|
||
* The above copyright notice and this permission notice shall be included in all
|
||
* copies or substantial portions of the Software.
|
||
*
|
||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
* SOFTWARE.
|
||
*/
|
||
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||
|
||
var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
|
||
var timeoutDuration = 0;
|
||
for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
|
||
if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
|
||
timeoutDuration = 1;
|
||
break;
|
||
}
|
||
}
|
||
|
||
function microtaskDebounce(fn) {
|
||
var called = false;
|
||
return function () {
|
||
if (called) {
|
||
return;
|
||
}
|
||
called = true;
|
||
window.Promise.resolve().then(function () {
|
||
called = false;
|
||
fn();
|
||
});
|
||
};
|
||
}
|
||
|
||
function taskDebounce(fn) {
|
||
var scheduled = false;
|
||
return function () {
|
||
if (!scheduled) {
|
||
scheduled = true;
|
||
setTimeout(function () {
|
||
scheduled = false;
|
||
fn();
|
||
}, timeoutDuration);
|
||
}
|
||
};
|
||
}
|
||
|
||
var supportsMicroTasks = isBrowser && window.Promise;
|
||
|
||
/**
|
||
* Create a debounced version of a method, that's asynchronously deferred
|
||
* but called in the minimum time possible.
|
||
*
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Function} fn
|
||
* @returns {Function}
|
||
*/
|
||
var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
|
||
|
||
/**
|
||
* Check if the given variable is a function
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Any} functionToCheck - variable to check
|
||
* @returns {Boolean} answer to: is a function?
|
||
*/
|
||
function isFunction(functionToCheck) {
|
||
var getType = {};
|
||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
||
}
|
||
|
||
/**
|
||
* Get CSS computed property of the given element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Eement} element
|
||
* @argument {String} property
|
||
*/
|
||
function getStyleComputedProperty(element, property) {
|
||
if (element.nodeType !== 1) {
|
||
return [];
|
||
}
|
||
// NOTE: 1 DOM access here
|
||
var css = getComputedStyle(element, null);
|
||
return property ? css[property] : css;
|
||
}
|
||
|
||
/**
|
||
* Returns the parentNode or the host of the element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @returns {Element} parent
|
||
*/
|
||
function getParentNode(element) {
|
||
if (element.nodeName === 'HTML') {
|
||
return element;
|
||
}
|
||
return element.parentNode || element.host;
|
||
}
|
||
|
||
/**
|
||
* Returns the scrolling parent of the given element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @returns {Element} scroll parent
|
||
*/
|
||
function getScrollParent(element) {
|
||
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
|
||
if (!element) {
|
||
return document.body;
|
||
}
|
||
|
||
switch (element.nodeName) {
|
||
case 'HTML':
|
||
case 'BODY':
|
||
return element.ownerDocument.body;
|
||
case '#document':
|
||
return element.body;
|
||
}
|
||
|
||
// Firefox want us to check `-x` and `-y` variations as well
|
||
|
||
var _getStyleComputedProp = getStyleComputedProperty(element),
|
||
overflow = _getStyleComputedProp.overflow,
|
||
overflowX = _getStyleComputedProp.overflowX,
|
||
overflowY = _getStyleComputedProp.overflowY;
|
||
|
||
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
|
||
return element;
|
||
}
|
||
|
||
return getScrollParent(getParentNode(element));
|
||
}
|
||
|
||
var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
|
||
var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
|
||
|
||
/**
|
||
* Determines if the browser is Internet Explorer
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {Number} version to check
|
||
* @returns {Boolean} isIE
|
||
*/
|
||
function isIE(version) {
|
||
if (version === 11) {
|
||
return isIE11;
|
||
}
|
||
if (version === 10) {
|
||
return isIE10;
|
||
}
|
||
return isIE11 || isIE10;
|
||
}
|
||
|
||
/**
|
||
* Returns the offset parent of the given element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @returns {Element} offset parent
|
||
*/
|
||
function getOffsetParent(element) {
|
||
if (!element) {
|
||
return document.documentElement;
|
||
}
|
||
|
||
var noOffsetParent = isIE(10) ? document.body : null;
|
||
|
||
// NOTE: 1 DOM access here
|
||
var offsetParent = element.offsetParent;
|
||
// Skip hidden elements which don't have an offsetParent
|
||
while (offsetParent === noOffsetParent && element.nextElementSibling) {
|
||
offsetParent = (element = element.nextElementSibling).offsetParent;
|
||
}
|
||
|
||
var nodeName = offsetParent && offsetParent.nodeName;
|
||
|
||
if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
|
||
return element ? element.ownerDocument.documentElement : document.documentElement;
|
||
}
|
||
|
||
// .offsetParent will return the closest TD or TABLE in case
|
||
// no offsetParent is present, I hate this job...
|
||
if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
|
||
return getOffsetParent(offsetParent);
|
||
}
|
||
|
||
return offsetParent;
|
||
}
|
||
|
||
function isOffsetContainer(element) {
|
||
var nodeName = element.nodeName;
|
||
|
||
if (nodeName === 'BODY') {
|
||
return false;
|
||
}
|
||
return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
|
||
}
|
||
|
||
/**
|
||
* Finds the root node (document, shadowDOM root) of the given element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} node
|
||
* @returns {Element} root node
|
||
*/
|
||
function getRoot(node) {
|
||
if (node.parentNode !== null) {
|
||
return getRoot(node.parentNode);
|
||
}
|
||
|
||
return node;
|
||
}
|
||
|
||
/**
|
||
* Finds the offset parent common to the two provided nodes
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element1
|
||
* @argument {Element} element2
|
||
* @returns {Element} common offset parent
|
||
*/
|
||
function findCommonOffsetParent(element1, element2) {
|
||
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
|
||
if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
|
||
return document.documentElement;
|
||
}
|
||
|
||
// Here we make sure to give as "start" the element that comes first in the DOM
|
||
var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
|
||
var start = order ? element1 : element2;
|
||
var end = order ? element2 : element1;
|
||
|
||
// Get common ancestor container
|
||
var range = document.createRange();
|
||
range.setStart(start, 0);
|
||
range.setEnd(end, 0);
|
||
var commonAncestorContainer = range.commonAncestorContainer;
|
||
|
||
// Both nodes are inside #document
|
||
|
||
if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
|
||
if (isOffsetContainer(commonAncestorContainer)) {
|
||
return commonAncestorContainer;
|
||
}
|
||
|
||
return getOffsetParent(commonAncestorContainer);
|
||
}
|
||
|
||
// one of the nodes is inside shadowDOM, find which one
|
||
var element1root = getRoot(element1);
|
||
if (element1root.host) {
|
||
return findCommonOffsetParent(element1root.host, element2);
|
||
} else {
|
||
return findCommonOffsetParent(element1, getRoot(element2).host);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Gets the scroll value of the given element in the given side (top and left)
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @argument {String} side `top` or `left`
|
||
* @returns {number} amount of scrolled pixels
|
||
*/
|
||
function getScroll(element) {
|
||
var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
|
||
|
||
var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
|
||
var nodeName = element.nodeName;
|
||
|
||
if (nodeName === 'BODY' || nodeName === 'HTML') {
|
||
var html = element.ownerDocument.documentElement;
|
||
var scrollingElement = element.ownerDocument.scrollingElement || html;
|
||
return scrollingElement[upperSide];
|
||
}
|
||
|
||
return element[upperSide];
|
||
}
|
||
|
||
/*
|
||
* Sum or subtract the element scroll values (left and top) from a given rect object
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {Object} rect - Rect object you want to change
|
||
* @param {HTMLElement} element - The element from the function reads the scroll values
|
||
* @param {Boolean} subtract - set to true if you want to subtract the scroll values
|
||
* @return {Object} rect - The modifier rect object
|
||
*/
|
||
function includeScroll(rect, element) {
|
||
var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||
|
||
var scrollTop = getScroll(element, 'top');
|
||
var scrollLeft = getScroll(element, 'left');
|
||
var modifier = subtract ? -1 : 1;
|
||
rect.top += scrollTop * modifier;
|
||
rect.bottom += scrollTop * modifier;
|
||
rect.left += scrollLeft * modifier;
|
||
rect.right += scrollLeft * modifier;
|
||
return rect;
|
||
}
|
||
|
||
/*
|
||
* Helper to detect borders of a given element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {CSSStyleDeclaration} styles
|
||
* Result of `getStyleComputedProperty` on the given element
|
||
* @param {String} axis - `x` or `y`
|
||
* @return {number} borders - The borders size of the given axis
|
||
*/
|
||
|
||
function getBordersSize(styles, axis) {
|
||
var sideA = axis === 'x' ? 'Left' : 'Top';
|
||
var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
|
||
|
||
return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
|
||
}
|
||
|
||
function getSize(axis, body, html, computedStyle) {
|
||
return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);
|
||
}
|
||
|
||
function getWindowSizes() {
|
||
var body = document.body;
|
||
var html = document.documentElement;
|
||
var computedStyle = isIE(10) && getComputedStyle(html);
|
||
|
||
return {
|
||
height: getSize('Height', body, html, computedStyle),
|
||
width: getSize('Width', body, html, computedStyle)
|
||
};
|
||
}
|
||
|
||
var classCallCheck = function (instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
};
|
||
|
||
var createClass = function () {
|
||
function defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor) descriptor.writable = true;
|
||
Object.defineProperty(target, descriptor.key, descriptor);
|
||
}
|
||
}
|
||
|
||
return function (Constructor, protoProps, staticProps) {
|
||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps) defineProperties(Constructor, staticProps);
|
||
return Constructor;
|
||
};
|
||
}();
|
||
|
||
|
||
|
||
|
||
|
||
var defineProperty = function (obj, key, value) {
|
||
if (key in obj) {
|
||
Object.defineProperty(obj, key, {
|
||
value: value,
|
||
enumerable: true,
|
||
configurable: true,
|
||
writable: true
|
||
});
|
||
} else {
|
||
obj[key] = value;
|
||
}
|
||
|
||
return obj;
|
||
};
|
||
|
||
var _extends = Object.assign || function (target) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var source = arguments[i];
|
||
|
||
for (var key in source) {
|
||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||
target[key] = source[key];
|
||
}
|
||
}
|
||
}
|
||
|
||
return target;
|
||
};
|
||
|
||
/**
|
||
* Given element offsets, generate an output similar to getBoundingClientRect
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Object} offsets
|
||
* @returns {Object} ClientRect like output
|
||
*/
|
||
function getClientRect(offsets) {
|
||
return _extends({}, offsets, {
|
||
right: offsets.left + offsets.width,
|
||
bottom: offsets.top + offsets.height
|
||
});
|
||
}
|
||
|
||
/**
|
||
* Get bounding client rect of given element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {HTMLElement} element
|
||
* @return {Object} client rect
|
||
*/
|
||
function getBoundingClientRect(element) {
|
||
var rect = {};
|
||
|
||
// IE10 10 FIX: Please, don't ask, the element isn't
|
||
// considered in DOM in some circumstances...
|
||
// This isn't reproducible in IE10 compatibility mode of IE11
|
||
try {
|
||
if (isIE(10)) {
|
||
rect = element.getBoundingClientRect();
|
||
var scrollTop = getScroll(element, 'top');
|
||
var scrollLeft = getScroll(element, 'left');
|
||
rect.top += scrollTop;
|
||
rect.left += scrollLeft;
|
||
rect.bottom += scrollTop;
|
||
rect.right += scrollLeft;
|
||
} else {
|
||
rect = element.getBoundingClientRect();
|
||
}
|
||
} catch (e) {}
|
||
|
||
var result = {
|
||
left: rect.left,
|
||
top: rect.top,
|
||
width: rect.right - rect.left,
|
||
height: rect.bottom - rect.top
|
||
};
|
||
|
||
// subtract scrollbar size from sizes
|
||
var sizes = element.nodeName === 'HTML' ? getWindowSizes() : {};
|
||
var width = sizes.width || element.clientWidth || result.right - result.left;
|
||
var height = sizes.height || element.clientHeight || result.bottom - result.top;
|
||
|
||
var horizScrollbar = element.offsetWidth - width;
|
||
var vertScrollbar = element.offsetHeight - height;
|
||
|
||
// if an hypothetical scrollbar is detected, we must be sure it's not a `border`
|
||
// we make this check conditional for performance reasons
|
||
if (horizScrollbar || vertScrollbar) {
|
||
var styles = getStyleComputedProperty(element);
|
||
horizScrollbar -= getBordersSize(styles, 'x');
|
||
vertScrollbar -= getBordersSize(styles, 'y');
|
||
|
||
result.width -= horizScrollbar;
|
||
result.height -= vertScrollbar;
|
||
}
|
||
|
||
return getClientRect(result);
|
||
}
|
||
|
||
function getOffsetRectRelativeToArbitraryNode(children, parent) {
|
||
var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||
|
||
var isIE10 = isIE(10);
|
||
var isHTML = parent.nodeName === 'HTML';
|
||
var childrenRect = getBoundingClientRect(children);
|
||
var parentRect = getBoundingClientRect(parent);
|
||
var scrollParent = getScrollParent(children);
|
||
|
||
var styles = getStyleComputedProperty(parent);
|
||
var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
|
||
var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
|
||
|
||
// In cases where the parent is fixed, we must ignore negative scroll in offset calc
|
||
if (fixedPosition && parent.nodeName === 'HTML') {
|
||
parentRect.top = Math.max(parentRect.top, 0);
|
||
parentRect.left = Math.max(parentRect.left, 0);
|
||
}
|
||
var offsets = getClientRect({
|
||
top: childrenRect.top - parentRect.top - borderTopWidth,
|
||
left: childrenRect.left - parentRect.left - borderLeftWidth,
|
||
width: childrenRect.width,
|
||
height: childrenRect.height
|
||
});
|
||
offsets.marginTop = 0;
|
||
offsets.marginLeft = 0;
|
||
|
||
// Subtract margins of documentElement in case it's being used as parent
|
||
// we do this only on HTML because it's the only element that behaves
|
||
// differently when margins are applied to it. The margins are included in
|
||
// the box of the documentElement, in the other cases not.
|
||
if (!isIE10 && isHTML) {
|
||
var marginTop = parseFloat(styles.marginTop, 10);
|
||
var marginLeft = parseFloat(styles.marginLeft, 10);
|
||
|
||
offsets.top -= borderTopWidth - marginTop;
|
||
offsets.bottom -= borderTopWidth - marginTop;
|
||
offsets.left -= borderLeftWidth - marginLeft;
|
||
offsets.right -= borderLeftWidth - marginLeft;
|
||
|
||
// Attach marginTop and marginLeft because in some circumstances we may need them
|
||
offsets.marginTop = marginTop;
|
||
offsets.marginLeft = marginLeft;
|
||
}
|
||
|
||
if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
|
||
offsets = includeScroll(offsets, parent);
|
||
}
|
||
|
||
return offsets;
|
||
}
|
||
|
||
function getViewportOffsetRectRelativeToArtbitraryNode(element) {
|
||
var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||
|
||
var html = element.ownerDocument.documentElement;
|
||
var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
|
||
var width = Math.max(html.clientWidth, window.innerWidth || 0);
|
||
var height = Math.max(html.clientHeight, window.innerHeight || 0);
|
||
|
||
var scrollTop = !excludeScroll ? getScroll(html) : 0;
|
||
var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
|
||
|
||
var offset = {
|
||
top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
|
||
left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
|
||
width: width,
|
||
height: height
|
||
};
|
||
|
||
return getClientRect(offset);
|
||
}
|
||
|
||
/**
|
||
* Check if the given element is fixed or is inside a fixed parent
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @argument {Element} customContainer
|
||
* @returns {Boolean} answer to "isFixed?"
|
||
*/
|
||
function isFixed(element) {
|
||
var nodeName = element.nodeName;
|
||
if (nodeName === 'BODY' || nodeName === 'HTML') {
|
||
return false;
|
||
}
|
||
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
||
return true;
|
||
}
|
||
return isFixed(getParentNode(element));
|
||
}
|
||
|
||
/**
|
||
* Finds the first parent of an element that has a transformed property defined
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @returns {Element} first transformed parent or documentElement
|
||
*/
|
||
|
||
function getFixedPositionOffsetParent(element) {
|
||
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
|
||
if (!element || !element.parentElement || isIE()) {
|
||
return document.documentElement;
|
||
}
|
||
var el = element.parentElement;
|
||
while (el && getStyleComputedProperty(el, 'transform') === 'none') {
|
||
el = el.parentElement;
|
||
}
|
||
return el || document.documentElement;
|
||
}
|
||
|
||
/**
|
||
* Computed the boundaries limits and return them
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {HTMLElement} popper
|
||
* @param {HTMLElement} reference
|
||
* @param {number} padding
|
||
* @param {HTMLElement} boundariesElement - Element used to define the boundaries
|
||
* @param {Boolean} fixedPosition - Is in fixed position mode
|
||
* @returns {Object} Coordinates of the boundaries
|
||
*/
|
||
function getBoundaries(popper, reference, padding, boundariesElement) {
|
||
var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
||
|
||
// NOTE: 1 DOM access here
|
||
|
||
var boundaries = { top: 0, left: 0 };
|
||
var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
|
||
|
||
// Handle viewport case
|
||
if (boundariesElement === 'viewport') {
|
||
boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
|
||
} else {
|
||
// Handle other cases based on DOM element used as boundaries
|
||
var boundariesNode = void 0;
|
||
if (boundariesElement === 'scrollParent') {
|
||
boundariesNode = getScrollParent(getParentNode(reference));
|
||
if (boundariesNode.nodeName === 'BODY') {
|
||
boundariesNode = popper.ownerDocument.documentElement;
|
||
}
|
||
} else if (boundariesElement === 'window') {
|
||
boundariesNode = popper.ownerDocument.documentElement;
|
||
} else {
|
||
boundariesNode = boundariesElement;
|
||
}
|
||
|
||
var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
|
||
|
||
// In case of HTML, we need a different computation
|
||
if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
|
||
var _getWindowSizes = getWindowSizes(),
|
||
height = _getWindowSizes.height,
|
||
width = _getWindowSizes.width;
|
||
|
||
boundaries.top += offsets.top - offsets.marginTop;
|
||
boundaries.bottom = height + offsets.top;
|
||
boundaries.left += offsets.left - offsets.marginLeft;
|
||
boundaries.right = width + offsets.left;
|
||
} else {
|
||
// for all the other DOM elements, this one is good
|
||
boundaries = offsets;
|
||
}
|
||
}
|
||
|
||
// Add paddings
|
||
boundaries.left += padding;
|
||
boundaries.top += padding;
|
||
boundaries.right -= padding;
|
||
boundaries.bottom -= padding;
|
||
|
||
return boundaries;
|
||
}
|
||
|
||
function getArea(_ref) {
|
||
var width = _ref.width,
|
||
height = _ref.height;
|
||
|
||
return width * height;
|
||
}
|
||
|
||
/**
|
||
* Utility used to transform the `auto` placement to the placement with more
|
||
* available space.
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Object} data - The data object generated by update method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
|
||
var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
||
|
||
if (placement.indexOf('auto') === -1) {
|
||
return placement;
|
||
}
|
||
|
||
var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
|
||
|
||
var rects = {
|
||
top: {
|
||
width: boundaries.width,
|
||
height: refRect.top - boundaries.top
|
||
},
|
||
right: {
|
||
width: boundaries.right - refRect.right,
|
||
height: boundaries.height
|
||
},
|
||
bottom: {
|
||
width: boundaries.width,
|
||
height: boundaries.bottom - refRect.bottom
|
||
},
|
||
left: {
|
||
width: refRect.left - boundaries.left,
|
||
height: boundaries.height
|
||
}
|
||
};
|
||
|
||
var sortedAreas = Object.keys(rects).map(function (key) {
|
||
return _extends({
|
||
key: key
|
||
}, rects[key], {
|
||
area: getArea(rects[key])
|
||
});
|
||
}).sort(function (a, b) {
|
||
return b.area - a.area;
|
||
});
|
||
|
||
var filteredAreas = sortedAreas.filter(function (_ref2) {
|
||
var width = _ref2.width,
|
||
height = _ref2.height;
|
||
return width >= popper.clientWidth && height >= popper.clientHeight;
|
||
});
|
||
|
||
var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
|
||
|
||
var variation = placement.split('-')[1];
|
||
|
||
return computedPlacement + (variation ? '-' + variation : '');
|
||
}
|
||
|
||
/**
|
||
* Get offsets to the reference element
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {Object} state
|
||
* @param {Element} popper - the popper element
|
||
* @param {Element} reference - the reference element (the popper will be relative to this)
|
||
* @param {Element} fixedPosition - is in fixed position mode
|
||
* @returns {Object} An object containing the offsets which will be applied to the popper
|
||
*/
|
||
function getReferenceOffsets(state, popper, reference) {
|
||
var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
||
|
||
var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
|
||
return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
|
||
}
|
||
|
||
/**
|
||
* Get the outer sizes of the given element (offset size + margins)
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element
|
||
* @returns {Object} object containing width and height properties
|
||
*/
|
||
function getOuterSizes(element) {
|
||
var styles = getComputedStyle(element);
|
||
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
||
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
||
var result = {
|
||
width: element.offsetWidth + y,
|
||
height: element.offsetHeight + x
|
||
};
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Get the opposite placement of the given one
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {String} placement
|
||
* @returns {String} flipped placement
|
||
*/
|
||
function getOppositePlacement(placement) {
|
||
var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
|
||
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
||
return hash[matched];
|
||
});
|
||
}
|
||
|
||
/**
|
||
* Get offsets to the popper
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {Object} position - CSS position the Popper will get applied
|
||
* @param {HTMLElement} popper - the popper element
|
||
* @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
|
||
* @param {String} placement - one of the valid placement options
|
||
* @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
|
||
*/
|
||
function getPopperOffsets(popper, referenceOffsets, placement) {
|
||
placement = placement.split('-')[0];
|
||
|
||
// Get popper node sizes
|
||
var popperRect = getOuterSizes(popper);
|
||
|
||
// Add position, width and height to our offsets object
|
||
var popperOffsets = {
|
||
width: popperRect.width,
|
||
height: popperRect.height
|
||
};
|
||
|
||
// depending by the popper placement we have to compute its offsets slightly differently
|
||
var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
|
||
var mainSide = isHoriz ? 'top' : 'left';
|
||
var secondarySide = isHoriz ? 'left' : 'top';
|
||
var measurement = isHoriz ? 'height' : 'width';
|
||
var secondaryMeasurement = !isHoriz ? 'height' : 'width';
|
||
|
||
popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
|
||
if (placement === secondarySide) {
|
||
popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
|
||
} else {
|
||
popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
|
||
}
|
||
|
||
return popperOffsets;
|
||
}
|
||
|
||
/**
|
||
* Mimics the `find` method of Array
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Array} arr
|
||
* @argument prop
|
||
* @argument value
|
||
* @returns index or -1
|
||
*/
|
||
function find(arr, check) {
|
||
// use native find if supported
|
||
if (Array.prototype.find) {
|
||
return arr.find(check);
|
||
}
|
||
|
||
// use `filter` to obtain the same behavior of `find`
|
||
return arr.filter(check)[0];
|
||
}
|
||
|
||
/**
|
||
* Return the index of the matching object
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Array} arr
|
||
* @argument prop
|
||
* @argument value
|
||
* @returns index or -1
|
||
*/
|
||
function findIndex(arr, prop, value) {
|
||
// use native findIndex if supported
|
||
if (Array.prototype.findIndex) {
|
||
return arr.findIndex(function (cur) {
|
||
return cur[prop] === value;
|
||
});
|
||
}
|
||
|
||
// use `find` + `indexOf` if `findIndex` isn't supported
|
||
var match = find(arr, function (obj) {
|
||
return obj[prop] === value;
|
||
});
|
||
return arr.indexOf(match);
|
||
}
|
||
|
||
/**
|
||
* Loop trough the list of modifiers and run them in order,
|
||
* each of them will then edit the data object.
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {dataObject} data
|
||
* @param {Array} modifiers
|
||
* @param {String} ends - Optional modifier name used as stopper
|
||
* @returns {dataObject}
|
||
*/
|
||
function runModifiers(modifiers, data, ends) {
|
||
var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
|
||
|
||
modifiersToRun.forEach(function (modifier) {
|
||
if (modifier['function']) {
|
||
// eslint-disable-line dot-notation
|
||
console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
|
||
}
|
||
var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
|
||
if (modifier.enabled && isFunction(fn)) {
|
||
// Add properties to offsets to make them a complete clientRect object
|
||
// we do this before each modifier to make sure the previous one doesn't
|
||
// mess with these values
|
||
data.offsets.popper = getClientRect(data.offsets.popper);
|
||
data.offsets.reference = getClientRect(data.offsets.reference);
|
||
|
||
data = fn(data, modifier);
|
||
}
|
||
});
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* Updates the position of the popper, computing the new offsets and applying
|
||
* the new style.<br />
|
||
* Prefer `scheduleUpdate` over `update` because of performance reasons.
|
||
* @method
|
||
* @memberof Popper
|
||
*/
|
||
function update() {
|
||
// if popper is destroyed, don't perform any further update
|
||
if (this.state.isDestroyed) {
|
||
return;
|
||
}
|
||
|
||
var data = {
|
||
instance: this,
|
||
styles: {},
|
||
arrowStyles: {},
|
||
attributes: {},
|
||
flipped: false,
|
||
offsets: {}
|
||
};
|
||
|
||
// compute reference element offsets
|
||
data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
|
||
|
||
// compute auto placement, store placement inside the data object,
|
||
// modifiers will be able to edit `placement` if needed
|
||
// and refer to originalPlacement to know the original value
|
||
data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
|
||
|
||
// store the computed placement inside `originalPlacement`
|
||
data.originalPlacement = data.placement;
|
||
|
||
data.positionFixed = this.options.positionFixed;
|
||
|
||
// compute the popper offsets
|
||
data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
|
||
|
||
data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
|
||
|
||
// run the modifiers
|
||
data = runModifiers(this.modifiers, data);
|
||
|
||
// the first `update` will call `onCreate` callback
|
||
// the other ones will call `onUpdate` callback
|
||
if (!this.state.isCreated) {
|
||
this.state.isCreated = true;
|
||
this.options.onCreate(data);
|
||
} else {
|
||
this.options.onUpdate(data);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Helper used to know if the given modifier is enabled.
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @returns {Boolean}
|
||
*/
|
||
function isModifierEnabled(modifiers, modifierName) {
|
||
return modifiers.some(function (_ref) {
|
||
var name = _ref.name,
|
||
enabled = _ref.enabled;
|
||
return enabled && name === modifierName;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* Get the prefixed supported property name
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {String} property (camelCase)
|
||
* @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
|
||
*/
|
||
function getSupportedPropertyName(property) {
|
||
var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
|
||
var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
|
||
|
||
for (var i = 0; i < prefixes.length; i++) {
|
||
var prefix = prefixes[i];
|
||
var toCheck = prefix ? '' + prefix + upperProp : property;
|
||
if (typeof document.body.style[toCheck] !== 'undefined') {
|
||
return toCheck;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* Destroy the popper
|
||
* @method
|
||
* @memberof Popper
|
||
*/
|
||
function destroy() {
|
||
this.state.isDestroyed = true;
|
||
|
||
// touch DOM only if `applyStyle` modifier is enabled
|
||
if (isModifierEnabled(this.modifiers, 'applyStyle')) {
|
||
this.popper.removeAttribute('x-placement');
|
||
this.popper.style.position = '';
|
||
this.popper.style.top = '';
|
||
this.popper.style.left = '';
|
||
this.popper.style.right = '';
|
||
this.popper.style.bottom = '';
|
||
this.popper.style.willChange = '';
|
||
this.popper.style[getSupportedPropertyName('transform')] = '';
|
||
}
|
||
|
||
this.disableEventListeners();
|
||
|
||
// remove the popper if user explicity asked for the deletion on destroy
|
||
// do not use `remove` because IE11 doesn't support it
|
||
if (this.options.removeOnDestroy) {
|
||
this.popper.parentNode.removeChild(this.popper);
|
||
}
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* Get the window associated with the element
|
||
* @argument {Element} element
|
||
* @returns {Window}
|
||
*/
|
||
function getWindow(element) {
|
||
var ownerDocument = element.ownerDocument;
|
||
return ownerDocument ? ownerDocument.defaultView : window;
|
||
}
|
||
|
||
function attachToScrollParents(scrollParent, event, callback, scrollParents) {
|
||
var isBody = scrollParent.nodeName === 'BODY';
|
||
var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
|
||
target.addEventListener(event, callback, { passive: true });
|
||
|
||
if (!isBody) {
|
||
attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
|
||
}
|
||
scrollParents.push(target);
|
||
}
|
||
|
||
/**
|
||
* Setup needed event listeners used to update the popper position
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @private
|
||
*/
|
||
function setupEventListeners(reference, options, state, updateBound) {
|
||
// Resize event listener on window
|
||
state.updateBound = updateBound;
|
||
getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
|
||
|
||
// Scroll event listener on scroll parents
|
||
var scrollElement = getScrollParent(reference);
|
||
attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
|
||
state.scrollElement = scrollElement;
|
||
state.eventsEnabled = true;
|
||
|
||
return state;
|
||
}
|
||
|
||
/**
|
||
* It will add resize/scroll events and start recalculating
|
||
* position of the popper element when they are triggered.
|
||
* @method
|
||
* @memberof Popper
|
||
*/
|
||
function enableEventListeners() {
|
||
if (!this.state.eventsEnabled) {
|
||
this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Remove event listeners used to update the popper position
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @private
|
||
*/
|
||
function removeEventListeners(reference, state) {
|
||
// Remove resize event listener on window
|
||
getWindow(reference).removeEventListener('resize', state.updateBound);
|
||
|
||
// Remove scroll event listener on scroll parents
|
||
state.scrollParents.forEach(function (target) {
|
||
target.removeEventListener('scroll', state.updateBound);
|
||
});
|
||
|
||
// Reset state
|
||
state.updateBound = null;
|
||
state.scrollParents = [];
|
||
state.scrollElement = null;
|
||
state.eventsEnabled = false;
|
||
return state;
|
||
}
|
||
|
||
/**
|
||
* It will remove resize/scroll events and won't recalculate popper position
|
||
* when they are triggered. It also won't trigger onUpdate callback anymore,
|
||
* unless you call `update` method manually.
|
||
* @method
|
||
* @memberof Popper
|
||
*/
|
||
function disableEventListeners() {
|
||
if (this.state.eventsEnabled) {
|
||
cancelAnimationFrame(this.scheduleUpdate);
|
||
this.state = removeEventListeners(this.reference, this.state);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Tells if a given input is a number
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {*} input to check
|
||
* @return {Boolean}
|
||
*/
|
||
function isNumeric(n) {
|
||
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
||
}
|
||
|
||
/**
|
||
* Set the style to the given popper
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element - Element to apply the style to
|
||
* @argument {Object} styles
|
||
* Object with a list of properties and values which will be applied to the element
|
||
*/
|
||
function setStyles(element, styles) {
|
||
Object.keys(styles).forEach(function (prop) {
|
||
var unit = '';
|
||
// add unit if the value is numeric and is one of the following
|
||
if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
|
||
unit = 'px';
|
||
}
|
||
element.style[prop] = styles[prop] + unit;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* Set the attributes to the given popper
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {Element} element - Element to apply the attributes to
|
||
* @argument {Object} styles
|
||
* Object with a list of properties and values which will be applied to the element
|
||
*/
|
||
function setAttributes(element, attributes) {
|
||
Object.keys(attributes).forEach(function (prop) {
|
||
var value = attributes[prop];
|
||
if (value !== false) {
|
||
element.setAttribute(prop, attributes[prop]);
|
||
} else {
|
||
element.removeAttribute(prop);
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by `update` method
|
||
* @argument {Object} data.styles - List of style properties - values to apply to popper element
|
||
* @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The same data object
|
||
*/
|
||
function applyStyle(data) {
|
||
// any property present in `data.styles` will be applied to the popper,
|
||
// in this way we can make the 3rd party modifiers add custom styles to it
|
||
// Be aware, modifiers could override the properties defined in the previous
|
||
// lines of this modifier!
|
||
setStyles(data.instance.popper, data.styles);
|
||
|
||
// any property present in `data.attributes` will be applied to the popper,
|
||
// they will be set as HTML attributes of the element
|
||
setAttributes(data.instance.popper, data.attributes);
|
||
|
||
// if arrowElement is defined and arrowStyles has some properties
|
||
if (data.arrowElement && Object.keys(data.arrowStyles).length) {
|
||
setStyles(data.arrowElement, data.arrowStyles);
|
||
}
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* Set the x-placement attribute before everything else because it could be used
|
||
* to add margins to the popper margins needs to be calculated to get the
|
||
* correct popper offsets.
|
||
* @method
|
||
* @memberof Popper.modifiers
|
||
* @param {HTMLElement} reference - The reference element used to position the popper
|
||
* @param {HTMLElement} popper - The HTML element used as popper
|
||
* @param {Object} options - Popper.js options
|
||
*/
|
||
function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
|
||
// compute reference element offsets
|
||
var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
|
||
|
||
// compute auto placement, store placement inside the data object,
|
||
// modifiers will be able to edit `placement` if needed
|
||
// and refer to originalPlacement to know the original value
|
||
var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
|
||
|
||
popper.setAttribute('x-placement', placement);
|
||
|
||
// Apply `position` to popper before anything else because
|
||
// without the position applied we can't guarantee correct computations
|
||
setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
|
||
|
||
return options;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by `update` method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function computeStyle(data, options) {
|
||
var x = options.x,
|
||
y = options.y;
|
||
var popper = data.offsets.popper;
|
||
|
||
// Remove this legacy support in Popper.js v2
|
||
|
||
var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
|
||
return modifier.name === 'applyStyle';
|
||
}).gpuAcceleration;
|
||
if (legacyGpuAccelerationOption !== undefined) {
|
||
console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
|
||
}
|
||
var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
|
||
|
||
var offsetParent = getOffsetParent(data.instance.popper);
|
||
var offsetParentRect = getBoundingClientRect(offsetParent);
|
||
|
||
// Styles
|
||
var styles = {
|
||
position: popper.position
|
||
};
|
||
|
||
// Avoid blurry text by using full pixel integers.
|
||
// For pixel-perfect positioning, top/bottom prefers rounded
|
||
// values, while left/right prefers floored values.
|
||
var offsets = {
|
||
left: Math.floor(popper.left),
|
||
top: Math.round(popper.top),
|
||
bottom: Math.round(popper.bottom),
|
||
right: Math.floor(popper.right)
|
||
};
|
||
|
||
var sideA = x === 'bottom' ? 'top' : 'bottom';
|
||
var sideB = y === 'right' ? 'left' : 'right';
|
||
|
||
// if gpuAcceleration is set to `true` and transform is supported,
|
||
// we use `translate3d` to apply the position to the popper we
|
||
// automatically use the supported prefixed version if needed
|
||
var prefixedProperty = getSupportedPropertyName('transform');
|
||
|
||
// now, let's make a step back and look at this code closely (wtf?)
|
||
// If the content of the popper grows once it's been positioned, it
|
||
// may happen that the popper gets misplaced because of the new content
|
||
// overflowing its reference element
|
||
// To avoid this problem, we provide two options (x and y), which allow
|
||
// the consumer to define the offset origin.
|
||
// If we position a popper on top of a reference element, we can set
|
||
// `x` to `top` to make the popper grow towards its top instead of
|
||
// its bottom.
|
||
var left = void 0,
|
||
top = void 0;
|
||
if (sideA === 'bottom') {
|
||
top = -offsetParentRect.height + offsets.bottom;
|
||
} else {
|
||
top = offsets.top;
|
||
}
|
||
if (sideB === 'right') {
|
||
left = -offsetParentRect.width + offsets.right;
|
||
} else {
|
||
left = offsets.left;
|
||
}
|
||
if (gpuAcceleration && prefixedProperty) {
|
||
styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
|
||
styles[sideA] = 0;
|
||
styles[sideB] = 0;
|
||
styles.willChange = 'transform';
|
||
} else {
|
||
// othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
|
||
var invertTop = sideA === 'bottom' ? -1 : 1;
|
||
var invertLeft = sideB === 'right' ? -1 : 1;
|
||
styles[sideA] = top * invertTop;
|
||
styles[sideB] = left * invertLeft;
|
||
styles.willChange = sideA + ', ' + sideB;
|
||
}
|
||
|
||
// Attributes
|
||
var attributes = {
|
||
'x-placement': data.placement
|
||
};
|
||
|
||
// Update `data` attributes, styles and arrowStyles
|
||
data.attributes = _extends({}, attributes, data.attributes);
|
||
data.styles = _extends({}, styles, data.styles);
|
||
data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* Helper used to know if the given modifier depends from another one.<br />
|
||
* It checks if the needed modifier is listed and enabled.
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @param {Array} modifiers - list of modifiers
|
||
* @param {String} requestingName - name of requesting modifier
|
||
* @param {String} requestedName - name of requested modifier
|
||
* @returns {Boolean}
|
||
*/
|
||
function isModifierRequired(modifiers, requestingName, requestedName) {
|
||
var requesting = find(modifiers, function (_ref) {
|
||
var name = _ref.name;
|
||
return name === requestingName;
|
||
});
|
||
|
||
var isRequired = !!requesting && modifiers.some(function (modifier) {
|
||
return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
|
||
});
|
||
|
||
if (!isRequired) {
|
||
var _requesting = '`' + requestingName + '`';
|
||
var requested = '`' + requestedName + '`';
|
||
console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
|
||
}
|
||
return isRequired;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by update method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function arrow(data, options) {
|
||
var _data$offsets$arrow;
|
||
|
||
// arrow depends on keepTogether in order to work
|
||
if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
|
||
return data;
|
||
}
|
||
|
||
var arrowElement = options.element;
|
||
|
||
// if arrowElement is a string, suppose it's a CSS selector
|
||
if (typeof arrowElement === 'string') {
|
||
arrowElement = data.instance.popper.querySelector(arrowElement);
|
||
|
||
// if arrowElement is not found, don't run the modifier
|
||
if (!arrowElement) {
|
||
return data;
|
||
}
|
||
} else {
|
||
// if the arrowElement isn't a query selector we must check that the
|
||
// provided DOM node is child of its popper node
|
||
if (!data.instance.popper.contains(arrowElement)) {
|
||
console.warn('WARNING: `arrow.element` must be child of its popper element!');
|
||
return data;
|
||
}
|
||
}
|
||
|
||
var placement = data.placement.split('-')[0];
|
||
var _data$offsets = data.offsets,
|
||
popper = _data$offsets.popper,
|
||
reference = _data$offsets.reference;
|
||
|
||
var isVertical = ['left', 'right'].indexOf(placement) !== -1;
|
||
|
||
var len = isVertical ? 'height' : 'width';
|
||
var sideCapitalized = isVertical ? 'Top' : 'Left';
|
||
var side = sideCapitalized.toLowerCase();
|
||
var altSide = isVertical ? 'left' : 'top';
|
||
var opSide = isVertical ? 'bottom' : 'right';
|
||
var arrowElementSize = getOuterSizes(arrowElement)[len];
|
||
|
||
//
|
||
// extends keepTogether behavior making sure the popper and its
|
||
// reference have enough pixels in conjuction
|
||
//
|
||
|
||
// top/left side
|
||
if (reference[opSide] - arrowElementSize < popper[side]) {
|
||
data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
|
||
}
|
||
// bottom/right side
|
||
if (reference[side] + arrowElementSize > popper[opSide]) {
|
||
data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
|
||
}
|
||
data.offsets.popper = getClientRect(data.offsets.popper);
|
||
|
||
// compute center of the popper
|
||
var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
|
||
|
||
// Compute the sideValue using the updated popper offsets
|
||
// take popper margin in account because we don't have this info available
|
||
var css = getStyleComputedProperty(data.instance.popper);
|
||
var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
|
||
var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
|
||
var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
|
||
|
||
// prevent arrowElement from being placed not contiguously to its popper
|
||
sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
|
||
|
||
data.arrowElement = arrowElement;
|
||
data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* Get the opposite placement variation of the given one
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {String} placement variation
|
||
* @returns {String} flipped placement variation
|
||
*/
|
||
function getOppositeVariation(variation) {
|
||
if (variation === 'end') {
|
||
return 'start';
|
||
} else if (variation === 'start') {
|
||
return 'end';
|
||
}
|
||
return variation;
|
||
}
|
||
|
||
/**
|
||
* List of accepted placements to use as values of the `placement` option.<br />
|
||
* Valid placements are:
|
||
* - `auto`
|
||
* - `top`
|
||
* - `right`
|
||
* - `bottom`
|
||
* - `left`
|
||
*
|
||
* Each placement can have a variation from this list:
|
||
* - `-start`
|
||
* - `-end`
|
||
*
|
||
* Variations are interpreted easily if you think of them as the left to right
|
||
* written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
|
||
* is right.<br />
|
||
* Vertically (`left` and `right`), `start` is top and `end` is bottom.
|
||
*
|
||
* Some valid examples are:
|
||
* - `top-end` (on top of reference, right aligned)
|
||
* - `right-start` (on right of reference, top aligned)
|
||
* - `bottom` (on bottom, centered)
|
||
* - `auto-right` (on the side with more space available, alignment depends by placement)
|
||
*
|
||
* @static
|
||
* @type {Array}
|
||
* @enum {String}
|
||
* @readonly
|
||
* @method placements
|
||
* @memberof Popper
|
||
*/
|
||
var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
|
||
|
||
// Get rid of `auto` `auto-start` and `auto-end`
|
||
var validPlacements = placements.slice(3);
|
||
|
||
/**
|
||
* Given an initial placement, returns all the subsequent placements
|
||
* clockwise (or counter-clockwise).
|
||
*
|
||
* @method
|
||
* @memberof Popper.Utils
|
||
* @argument {String} placement - A valid placement (it accepts variations)
|
||
* @argument {Boolean} counter - Set to true to walk the placements counterclockwise
|
||
* @returns {Array} placements including their variations
|
||
*/
|
||
function clockwise(placement) {
|
||
var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||
|
||
var index = validPlacements.indexOf(placement);
|
||
var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
|
||
return counter ? arr.reverse() : arr;
|
||
}
|
||
|
||
var BEHAVIORS = {
|
||
FLIP: 'flip',
|
||
CLOCKWISE: 'clockwise',
|
||
COUNTERCLOCKWISE: 'counterclockwise'
|
||
};
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by update method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function flip(data, options) {
|
||
// if `inner` modifier is enabled, we can't use the `flip` modifier
|
||
if (isModifierEnabled(data.instance.modifiers, 'inner')) {
|
||
return data;
|
||
}
|
||
|
||
if (data.flipped && data.placement === data.originalPlacement) {
|
||
// seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
|
||
return data;
|
||
}
|
||
|
||
var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
|
||
|
||
var placement = data.placement.split('-')[0];
|
||
var placementOpposite = getOppositePlacement(placement);
|
||
var variation = data.placement.split('-')[1] || '';
|
||
|
||
var flipOrder = [];
|
||
|
||
switch (options.behavior) {
|
||
case BEHAVIORS.FLIP:
|
||
flipOrder = [placement, placementOpposite];
|
||
break;
|
||
case BEHAVIORS.CLOCKWISE:
|
||
flipOrder = clockwise(placement);
|
||
break;
|
||
case BEHAVIORS.COUNTERCLOCKWISE:
|
||
flipOrder = clockwise(placement, true);
|
||
break;
|
||
default:
|
||
flipOrder = options.behavior;
|
||
}
|
||
|
||
flipOrder.forEach(function (step, index) {
|
||
if (placement !== step || flipOrder.length === index + 1) {
|
||
return data;
|
||
}
|
||
|
||
placement = data.placement.split('-')[0];
|
||
placementOpposite = getOppositePlacement(placement);
|
||
|
||
var popperOffsets = data.offsets.popper;
|
||
var refOffsets = data.offsets.reference;
|
||
|
||
// using floor because the reference offsets may contain decimals we are not going to consider here
|
||
var floor = Math.floor;
|
||
var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
|
||
|
||
var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
|
||
var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
|
||
var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
|
||
var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
|
||
|
||
var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
|
||
|
||
// flip the variation if required
|
||
var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
|
||
var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
|
||
|
||
if (overlapsRef || overflowsBoundaries || flippedVariation) {
|
||
// this boolean to detect any flip loop
|
||
data.flipped = true;
|
||
|
||
if (overlapsRef || overflowsBoundaries) {
|
||
placement = flipOrder[index + 1];
|
||
}
|
||
|
||
if (flippedVariation) {
|
||
variation = getOppositeVariation(variation);
|
||
}
|
||
|
||
data.placement = placement + (variation ? '-' + variation : '');
|
||
|
||
// this object contains `position`, we want to preserve it along with
|
||
// any additional property we may add in the future
|
||
data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
|
||
|
||
data = runModifiers(data.instance.modifiers, data, 'flip');
|
||
}
|
||
});
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by update method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function keepTogether(data) {
|
||
var _data$offsets = data.offsets,
|
||
popper = _data$offsets.popper,
|
||
reference = _data$offsets.reference;
|
||
|
||
var placement = data.placement.split('-')[0];
|
||
var floor = Math.floor;
|
||
var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
|
||
var side = isVertical ? 'right' : 'bottom';
|
||
var opSide = isVertical ? 'left' : 'top';
|
||
var measurement = isVertical ? 'width' : 'height';
|
||
|
||
if (popper[side] < floor(reference[opSide])) {
|
||
data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
|
||
}
|
||
if (popper[opSide] > floor(reference[side])) {
|
||
data.offsets.popper[opSide] = floor(reference[side]);
|
||
}
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* Converts a string containing value + unit into a px value number
|
||
* @function
|
||
* @memberof {modifiers~offset}
|
||
* @private
|
||
* @argument {String} str - Value + unit string
|
||
* @argument {String} measurement - `height` or `width`
|
||
* @argument {Object} popperOffsets
|
||
* @argument {Object} referenceOffsets
|
||
* @returns {Number|String}
|
||
* Value in pixels, or original string if no values were extracted
|
||
*/
|
||
function toValue(str, measurement, popperOffsets, referenceOffsets) {
|
||
// separate value from unit
|
||
var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
|
||
var value = +split[1];
|
||
var unit = split[2];
|
||
|
||
// If it's not a number it's an operator, I guess
|
||
if (!value) {
|
||
return str;
|
||
}
|
||
|
||
if (unit.indexOf('%') === 0) {
|
||
var element = void 0;
|
||
switch (unit) {
|
||
case '%p':
|
||
element = popperOffsets;
|
||
break;
|
||
case '%':
|
||
case '%r':
|
||
default:
|
||
element = referenceOffsets;
|
||
}
|
||
|
||
var rect = getClientRect(element);
|
||
return rect[measurement] / 100 * value;
|
||
} else if (unit === 'vh' || unit === 'vw') {
|
||
// if is a vh or vw, we calculate the size based on the viewport
|
||
var size = void 0;
|
||
if (unit === 'vh') {
|
||
size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
||
} else {
|
||
size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
||
}
|
||
return size / 100 * value;
|
||
} else {
|
||
// if is an explicit pixel unit, we get rid of the unit and keep the value
|
||
// if is an implicit unit, it's px, and we return just the value
|
||
return value;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
|
||
* @function
|
||
* @memberof {modifiers~offset}
|
||
* @private
|
||
* @argument {String} offset
|
||
* @argument {Object} popperOffsets
|
||
* @argument {Object} referenceOffsets
|
||
* @argument {String} basePlacement
|
||
* @returns {Array} a two cells array with x and y offsets in numbers
|
||
*/
|
||
function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
|
||
var offsets = [0, 0];
|
||
|
||
// Use height if placement is left or right and index is 0 otherwise use width
|
||
// in this way the first offset will use an axis and the second one
|
||
// will use the other one
|
||
var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
|
||
|
||
// Split the offset string to obtain a list of values and operands
|
||
// The regex addresses values with the plus or minus sign in front (+10, -20, etc)
|
||
var fragments = offset.split(/(\+|\-)/).map(function (frag) {
|
||
return frag.trim();
|
||
});
|
||
|
||
// Detect if the offset string contains a pair of values or a single one
|
||
// they could be separated by comma or space
|
||
var divider = fragments.indexOf(find(fragments, function (frag) {
|
||
return frag.search(/,|\s/) !== -1;
|
||
}));
|
||
|
||
if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
|
||
console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
|
||
}
|
||
|
||
// If divider is found, we divide the list of values and operands to divide
|
||
// them by ofset X and Y.
|
||
var splitRegex = /\s*,\s*|\s+/;
|
||
var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
|
||
|
||
// Convert the values with units to absolute pixels to allow our computations
|
||
ops = ops.map(function (op, index) {
|
||
// Most of the units rely on the orientation of the popper
|
||
var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
|
||
var mergeWithPrevious = false;
|
||
return op
|
||
// This aggregates any `+` or `-` sign that aren't considered operators
|
||
// e.g.: 10 + +5 => [10, +, +5]
|
||
.reduce(function (a, b) {
|
||
if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
|
||
a[a.length - 1] = b;
|
||
mergeWithPrevious = true;
|
||
return a;
|
||
} else if (mergeWithPrevious) {
|
||
a[a.length - 1] += b;
|
||
mergeWithPrevious = false;
|
||
return a;
|
||
} else {
|
||
return a.concat(b);
|
||
}
|
||
}, [])
|
||
// Here we convert the string values into number values (in px)
|
||
.map(function (str) {
|
||
return toValue(str, measurement, popperOffsets, referenceOffsets);
|
||
});
|
||
});
|
||
|
||
// Loop trough the offsets arrays and execute the operations
|
||
ops.forEach(function (op, index) {
|
||
op.forEach(function (frag, index2) {
|
||
if (isNumeric(frag)) {
|
||
offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
|
||
}
|
||
});
|
||
});
|
||
return offsets;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by update method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @argument {Number|String} options.offset=0
|
||
* The offset value as described in the modifier description
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function offset(data, _ref) {
|
||
var offset = _ref.offset;
|
||
var placement = data.placement,
|
||
_data$offsets = data.offsets,
|
||
popper = _data$offsets.popper,
|
||
reference = _data$offsets.reference;
|
||
|
||
var basePlacement = placement.split('-')[0];
|
||
|
||
var offsets = void 0;
|
||
if (isNumeric(+offset)) {
|
||
offsets = [+offset, 0];
|
||
} else {
|
||
offsets = parseOffset(offset, popper, reference, basePlacement);
|
||
}
|
||
|
||
if (basePlacement === 'left') {
|
||
popper.top += offsets[0];
|
||
popper.left -= offsets[1];
|
||
} else if (basePlacement === 'right') {
|
||
popper.top += offsets[0];
|
||
popper.left += offsets[1];
|
||
} else if (basePlacement === 'top') {
|
||
popper.left += offsets[0];
|
||
popper.top -= offsets[1];
|
||
} else if (basePlacement === 'bottom') {
|
||
popper.left += offsets[0];
|
||
popper.top += offsets[1];
|
||
}
|
||
|
||
data.popper = popper;
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by `update` method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function preventOverflow(data, options) {
|
||
var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
|
||
|
||
// If offsetParent is the reference element, we really want to
|
||
// go one step up and use the next offsetParent as reference to
|
||
// avoid to make this modifier completely useless and look like broken
|
||
if (data.instance.reference === boundariesElement) {
|
||
boundariesElement = getOffsetParent(boundariesElement);
|
||
}
|
||
|
||
// NOTE: DOM access here
|
||
// resets the popper's position so that the document size can be calculated excluding
|
||
// the size of the popper element itself
|
||
var transformProp = getSupportedPropertyName('transform');
|
||
var popperStyles = data.instance.popper.style; // assignment to help minification
|
||
var top = popperStyles.top,
|
||
left = popperStyles.left,
|
||
transform = popperStyles[transformProp];
|
||
|
||
popperStyles.top = '';
|
||
popperStyles.left = '';
|
||
popperStyles[transformProp] = '';
|
||
|
||
var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
|
||
|
||
// NOTE: DOM access here
|
||
// restores the original style properties after the offsets have been computed
|
||
popperStyles.top = top;
|
||
popperStyles.left = left;
|
||
popperStyles[transformProp] = transform;
|
||
|
||
options.boundaries = boundaries;
|
||
|
||
var order = options.priority;
|
||
var popper = data.offsets.popper;
|
||
|
||
var check = {
|
||
primary: function primary(placement) {
|
||
var value = popper[placement];
|
||
if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
|
||
value = Math.max(popper[placement], boundaries[placement]);
|
||
}
|
||
return defineProperty({}, placement, value);
|
||
},
|
||
secondary: function secondary(placement) {
|
||
var mainSide = placement === 'right' ? 'left' : 'top';
|
||
var value = popper[mainSide];
|
||
if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
|
||
value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
|
||
}
|
||
return defineProperty({}, mainSide, value);
|
||
}
|
||
};
|
||
|
||
order.forEach(function (placement) {
|
||
var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
|
||
popper = _extends({}, popper, check[side](placement));
|
||
});
|
||
|
||
data.offsets.popper = popper;
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by `update` method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function shift(data) {
|
||
var placement = data.placement;
|
||
var basePlacement = placement.split('-')[0];
|
||
var shiftvariation = placement.split('-')[1];
|
||
|
||
// if shift shiftvariation is specified, run the modifier
|
||
if (shiftvariation) {
|
||
var _data$offsets = data.offsets,
|
||
reference = _data$offsets.reference,
|
||
popper = _data$offsets.popper;
|
||
|
||
var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
|
||
var side = isVertical ? 'left' : 'top';
|
||
var measurement = isVertical ? 'width' : 'height';
|
||
|
||
var shiftOffsets = {
|
||
start: defineProperty({}, side, reference[side]),
|
||
end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
|
||
};
|
||
|
||
data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
|
||
}
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by update method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function hide(data) {
|
||
if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
|
||
return data;
|
||
}
|
||
|
||
var refRect = data.offsets.reference;
|
||
var bound = find(data.instance.modifiers, function (modifier) {
|
||
return modifier.name === 'preventOverflow';
|
||
}).boundaries;
|
||
|
||
if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
|
||
// Avoid unnecessary DOM access if visibility hasn't changed
|
||
if (data.hide === true) {
|
||
return data;
|
||
}
|
||
|
||
data.hide = true;
|
||
data.attributes['x-out-of-boundaries'] = '';
|
||
} else {
|
||
// Avoid unnecessary DOM access if visibility hasn't changed
|
||
if (data.hide === false) {
|
||
return data;
|
||
}
|
||
|
||
data.hide = false;
|
||
data.attributes['x-out-of-boundaries'] = false;
|
||
}
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* @function
|
||
* @memberof Modifiers
|
||
* @argument {Object} data - The data object generated by `update` method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {Object} The data object, properly modified
|
||
*/
|
||
function inner(data) {
|
||
var placement = data.placement;
|
||
var basePlacement = placement.split('-')[0];
|
||
var _data$offsets = data.offsets,
|
||
popper = _data$offsets.popper,
|
||
reference = _data$offsets.reference;
|
||
|
||
var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
|
||
|
||
var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
|
||
|
||
popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
|
||
|
||
data.placement = getOppositePlacement(placement);
|
||
data.offsets.popper = getClientRect(popper);
|
||
|
||
return data;
|
||
}
|
||
|
||
/**
|
||
* Modifier function, each modifier can have a function of this type assigned
|
||
* to its `fn` property.<br />
|
||
* These functions will be called on each update, this means that you must
|
||
* make sure they are performant enough to avoid performance bottlenecks.
|
||
*
|
||
* @function ModifierFn
|
||
* @argument {dataObject} data - The data object generated by `update` method
|
||
* @argument {Object} options - Modifiers configuration and options
|
||
* @returns {dataObject} The data object, properly modified
|
||
*/
|
||
|
||
/**
|
||
* Modifiers are plugins used to alter the behavior of your poppers.<br />
|
||
* Popper.js uses a set of 9 modifiers to provide all the basic functionalities
|
||
* needed by the library.
|
||
*
|
||
* Usually you don't want to override the `order`, `fn` and `onLoad` props.
|
||
* All the other properties are configurations that could be tweaked.
|
||
* @namespace modifiers
|
||
*/
|
||
var modifiers = {
|
||
/**
|
||
* Modifier used to shift the popper on the start or end of its reference
|
||
* element.<br />
|
||
* It will read the variation of the `placement` property.<br />
|
||
* It can be one either `-end` or `-start`.
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
shift: {
|
||
/** @prop {number} order=100 - Index used to define the order of execution */
|
||
order: 100,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: shift
|
||
},
|
||
|
||
/**
|
||
* The `offset` modifier can shift your popper on both its axis.
|
||
*
|
||
* It accepts the following units:
|
||
* - `px` or unitless, interpreted as pixels
|
||
* - `%` or `%r`, percentage relative to the length of the reference element
|
||
* - `%p`, percentage relative to the length of the popper element
|
||
* - `vw`, CSS viewport width unit
|
||
* - `vh`, CSS viewport height unit
|
||
*
|
||
* For length is intended the main axis relative to the placement of the popper.<br />
|
||
* This means that if the placement is `top` or `bottom`, the length will be the
|
||
* `width`. In case of `left` or `right`, it will be the height.
|
||
*
|
||
* You can provide a single value (as `Number` or `String`), or a pair of values
|
||
* as `String` divided by a comma or one (or more) white spaces.<br />
|
||
* The latter is a deprecated method because it leads to confusion and will be
|
||
* removed in v2.<br />
|
||
* Additionally, it accepts additions and subtractions between different units.
|
||
* Note that multiplications and divisions aren't supported.
|
||
*
|
||
* Valid examples are:
|
||
* ```
|
||
* 10
|
||
* '10%'
|
||
* '10, 10'
|
||
* '10%, 10'
|
||
* '10 + 10%'
|
||
* '10 - 5vh + 3%'
|
||
* '-10px + 5vh, 5px - 6%'
|
||
* ```
|
||
* > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
|
||
* > with their reference element, unfortunately, you will have to disable the `flip` modifier.
|
||
* > More on this [reading this issue](https://github.com/FezVrasta/popper.js/issues/373)
|
||
*
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
offset: {
|
||
/** @prop {number} order=200 - Index used to define the order of execution */
|
||
order: 200,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: offset,
|
||
/** @prop {Number|String} offset=0
|
||
* The offset value as described in the modifier description
|
||
*/
|
||
offset: 0
|
||
},
|
||
|
||
/**
|
||
* Modifier used to prevent the popper from being positioned outside the boundary.
|
||
*
|
||
* An scenario exists where the reference itself is not within the boundaries.<br />
|
||
* We can say it has "escaped the boundaries" — or just "escaped".<br />
|
||
* In this case we need to decide whether the popper should either:
|
||
*
|
||
* - detach from the reference and remain "trapped" in the boundaries, or
|
||
* - if it should ignore the boundary and "escape with its reference"
|
||
*
|
||
* When `escapeWithReference` is set to`true` and reference is completely
|
||
* outside its boundaries, the popper will overflow (or completely leave)
|
||
* the boundaries in order to remain attached to the edge of the reference.
|
||
*
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
preventOverflow: {
|
||
/** @prop {number} order=300 - Index used to define the order of execution */
|
||
order: 300,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: preventOverflow,
|
||
/**
|
||
* @prop {Array} [priority=['left','right','top','bottom']]
|
||
* Popper will try to prevent overflow following these priorities by default,
|
||
* then, it could overflow on the left and on top of the `boundariesElement`
|
||
*/
|
||
priority: ['left', 'right', 'top', 'bottom'],
|
||
/**
|
||
* @prop {number} padding=5
|
||
* Amount of pixel used to define a minimum distance between the boundaries
|
||
* and the popper this makes sure the popper has always a little padding
|
||
* between the edges of its container
|
||
*/
|
||
padding: 5,
|
||
/**
|
||
* @prop {String|HTMLElement} boundariesElement='scrollParent'
|
||
* Boundaries used by the modifier, can be `scrollParent`, `window`,
|
||
* `viewport` or any DOM element.
|
||
*/
|
||
boundariesElement: 'scrollParent'
|
||
},
|
||
|
||
/**
|
||
* Modifier used to make sure the reference and its popper stay near eachothers
|
||
* without leaving any gap between the two. Expecially useful when the arrow is
|
||
* enabled and you want to assure it to point to its reference element.
|
||
* It cares only about the first axis, you can still have poppers with margin
|
||
* between the popper and its reference element.
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
keepTogether: {
|
||
/** @prop {number} order=400 - Index used to define the order of execution */
|
||
order: 400,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: keepTogether
|
||
},
|
||
|
||
/**
|
||
* This modifier is used to move the `arrowElement` of the popper to make
|
||
* sure it is positioned between the reference element and its popper element.
|
||
* It will read the outer size of the `arrowElement` node to detect how many
|
||
* pixels of conjuction are needed.
|
||
*
|
||
* It has no effect if no `arrowElement` is provided.
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
arrow: {
|
||
/** @prop {number} order=500 - Index used to define the order of execution */
|
||
order: 500,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: arrow,
|
||
/** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
|
||
element: '[x-arrow]'
|
||
},
|
||
|
||
/**
|
||
* Modifier used to flip the popper's placement when it starts to overlap its
|
||
* reference element.
|
||
*
|
||
* Requires the `preventOverflow` modifier before it in order to work.
|
||
*
|
||
* **NOTE:** this modifier will interrupt the current update cycle and will
|
||
* restart it if it detects the need to flip the placement.
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
flip: {
|
||
/** @prop {number} order=600 - Index used to define the order of execution */
|
||
order: 600,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: flip,
|
||
/**
|
||
* @prop {String|Array} behavior='flip'
|
||
* The behavior used to change the popper's placement. It can be one of
|
||
* `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
|
||
* placements (with optional variations).
|
||
*/
|
||
behavior: 'flip',
|
||
/**
|
||
* @prop {number} padding=5
|
||
* The popper will flip if it hits the edges of the `boundariesElement`
|
||
*/
|
||
padding: 5,
|
||
/**
|
||
* @prop {String|HTMLElement} boundariesElement='viewport'
|
||
* The element which will define the boundaries of the popper position,
|
||
* the popper will never be placed outside of the defined boundaries
|
||
* (except if keepTogether is enabled)
|
||
*/
|
||
boundariesElement: 'viewport'
|
||
},
|
||
|
||
/**
|
||
* Modifier used to make the popper flow toward the inner of the reference element.
|
||
* By default, when this modifier is disabled, the popper will be placed outside
|
||
* the reference element.
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
inner: {
|
||
/** @prop {number} order=700 - Index used to define the order of execution */
|
||
order: 700,
|
||
/** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
|
||
enabled: false,
|
||
/** @prop {ModifierFn} */
|
||
fn: inner
|
||
},
|
||
|
||
/**
|
||
* Modifier used to hide the popper when its reference element is outside of the
|
||
* popper boundaries. It will set a `x-out-of-boundaries` attribute which can
|
||
* be used to hide with a CSS selector the popper when its reference is
|
||
* out of boundaries.
|
||
*
|
||
* Requires the `preventOverflow` modifier before it in order to work.
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
hide: {
|
||
/** @prop {number} order=800 - Index used to define the order of execution */
|
||
order: 800,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: hide
|
||
},
|
||
|
||
/**
|
||
* Computes the style that will be applied to the popper element to gets
|
||
* properly positioned.
|
||
*
|
||
* Note that this modifier will not touch the DOM, it just prepares the styles
|
||
* so that `applyStyle` modifier can apply it. This separation is useful
|
||
* in case you need to replace `applyStyle` with a custom implementation.
|
||
*
|
||
* This modifier has `850` as `order` value to maintain backward compatibility
|
||
* with previous versions of Popper.js. Expect the modifiers ordering method
|
||
* to change in future major versions of the library.
|
||
*
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
computeStyle: {
|
||
/** @prop {number} order=850 - Index used to define the order of execution */
|
||
order: 850,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: computeStyle,
|
||
/**
|
||
* @prop {Boolean} gpuAcceleration=true
|
||
* If true, it uses the CSS 3d transformation to position the popper.
|
||
* Otherwise, it will use the `top` and `left` properties.
|
||
*/
|
||
gpuAcceleration: true,
|
||
/**
|
||
* @prop {string} [x='bottom']
|
||
* Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
|
||
* Change this if your popper should grow in a direction different from `bottom`
|
||
*/
|
||
x: 'bottom',
|
||
/**
|
||
* @prop {string} [x='left']
|
||
* Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
|
||
* Change this if your popper should grow in a direction different from `right`
|
||
*/
|
||
y: 'right'
|
||
},
|
||
|
||
/**
|
||
* Applies the computed styles to the popper element.
|
||
*
|
||
* All the DOM manipulations are limited to this modifier. This is useful in case
|
||
* you want to integrate Popper.js inside a framework or view library and you
|
||
* want to delegate all the DOM manipulations to it.
|
||
*
|
||
* Note that if you disable this modifier, you must make sure the popper element
|
||
* has its position set to `absolute` before Popper.js can do its work!
|
||
*
|
||
* Just disable this modifier and define you own to achieve the desired effect.
|
||
*
|
||
* @memberof modifiers
|
||
* @inner
|
||
*/
|
||
applyStyle: {
|
||
/** @prop {number} order=900 - Index used to define the order of execution */
|
||
order: 900,
|
||
/** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
|
||
enabled: true,
|
||
/** @prop {ModifierFn} */
|
||
fn: applyStyle,
|
||
/** @prop {Function} */
|
||
onLoad: applyStyleOnLoad,
|
||
/**
|
||
* @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
|
||
* @prop {Boolean} gpuAcceleration=true
|
||
* If true, it uses the CSS 3d transformation to position the popper.
|
||
* Otherwise, it will use the `top` and `left` properties.
|
||
*/
|
||
gpuAcceleration: undefined
|
||
}
|
||
};
|
||
|
||
/**
|
||
* The `dataObject` is an object containing all the informations used by Popper.js
|
||
* this object get passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
|
||
* @name dataObject
|
||
* @property {Object} data.instance The Popper.js instance
|
||
* @property {String} data.placement Placement applied to popper
|
||
* @property {String} data.originalPlacement Placement originally defined on init
|
||
* @property {Boolean} data.flipped True if popper has been flipped by flip modifier
|
||
* @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper.
|
||
* @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
|
||
* @property {Object} data.styles Any CSS property defined here will be applied to the popper, it expects the JavaScript nomenclature (eg. `marginBottom`)
|
||
* @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow, it expects the JavaScript nomenclature (eg. `marginBottom`)
|
||
* @property {Object} data.boundaries Offsets of the popper boundaries
|
||
* @property {Object} data.offsets The measurements of popper, reference and arrow elements.
|
||
* @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
|
||
* @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
|
||
* @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
|
||
*/
|
||
|
||
/**
|
||
* Default options provided to Popper.js constructor.<br />
|
||
* These can be overriden using the `options` argument of Popper.js.<br />
|
||
* To override an option, simply pass as 3rd argument an object with the same
|
||
* structure of this object, example:
|
||
* ```
|
||
* new Popper(ref, pop, {
|
||
* modifiers: {
|
||
* preventOverflow: { enabled: false }
|
||
* }
|
||
* })
|
||
* ```
|
||
* @type {Object}
|
||
* @static
|
||
* @memberof Popper
|
||
*/
|
||
var Defaults = {
|
||
/**
|
||
* Popper's placement
|
||
* @prop {Popper.placements} placement='bottom'
|
||
*/
|
||
placement: 'bottom',
|
||
|
||
/**
|
||
* Set this to true if you want popper to position it self in 'fixed' mode
|
||
* @prop {Boolean} positionFixed=false
|
||
*/
|
||
positionFixed: false,
|
||
|
||
/**
|
||
* Whether events (resize, scroll) are initially enabled
|
||
* @prop {Boolean} eventsEnabled=true
|
||
*/
|
||
eventsEnabled: true,
|
||
|
||
/**
|
||
* Set to true if you want to automatically remove the popper when
|
||
* you call the `destroy` method.
|
||
* @prop {Boolean} removeOnDestroy=false
|
||
*/
|
||
removeOnDestroy: false,
|
||
|
||
/**
|
||
* Callback called when the popper is created.<br />
|
||
* By default, is set to no-op.<br />
|
||
* Access Popper.js instance with `data.instance`.
|
||
* @prop {onCreate}
|
||
*/
|
||
onCreate: function onCreate() {},
|
||
|
||
/**
|
||
* Callback called when the popper is updated, this callback is not called
|
||
* on the initialization/creation of the popper, but only on subsequent
|
||
* updates.<br />
|
||
* By default, is set to no-op.<br />
|
||
* Access Popper.js instance with `data.instance`.
|
||
* @prop {onUpdate}
|
||
*/
|
||
onUpdate: function onUpdate() {},
|
||
|
||
/**
|
||
* List of modifiers used to modify the offsets before they are applied to the popper.
|
||
* They provide most of the functionalities of Popper.js
|
||
* @prop {modifiers}
|
||
*/
|
||
modifiers: modifiers
|
||
};
|
||
|
||
/**
|
||
* @callback onCreate
|
||
* @param {dataObject} data
|
||
*/
|
||
|
||
/**
|
||
* @callback onUpdate
|
||
* @param {dataObject} data
|
||
*/
|
||
|
||
// Utils
|
||
// Methods
|
||
var Popper = function () {
|
||
/**
|
||
* Create a new Popper.js instance
|
||
* @class Popper
|
||
* @param {HTMLElement|referenceObject} reference - The reference element used to position the popper
|
||
* @param {HTMLElement} popper - The HTML element used as popper.
|
||
* @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
|
||
* @return {Object} instance - The generated Popper.js instance
|
||
*/
|
||
function Popper(reference, popper) {
|
||
var _this = this;
|
||
|
||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||
classCallCheck(this, Popper);
|
||
|
||
this.scheduleUpdate = function () {
|
||
return requestAnimationFrame(_this.update);
|
||
};
|
||
|
||
// make update() debounced, so that it only runs at most once-per-tick
|
||
this.update = debounce(this.update.bind(this));
|
||
|
||
// with {} we create a new object with the options inside it
|
||
this.options = _extends({}, Popper.Defaults, options);
|
||
|
||
// init state
|
||
this.state = {
|
||
isDestroyed: false,
|
||
isCreated: false,
|
||
scrollParents: []
|
||
};
|
||
|
||
// get reference and popper elements (allow jQuery wrappers)
|
||
this.reference = reference && reference.jquery ? reference[0] : reference;
|
||
this.popper = popper && popper.jquery ? popper[0] : popper;
|
||
|
||
// Deep merge modifiers options
|
||
this.options.modifiers = {};
|
||
Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
|
||
_this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
|
||
});
|
||
|
||
// Refactoring modifiers' list (Object => Array)
|
||
this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
|
||
return _extends({
|
||
name: name
|
||
}, _this.options.modifiers[name]);
|
||
})
|
||
// sort the modifiers by order
|
||
.sort(function (a, b) {
|
||
return a.order - b.order;
|
||
});
|
||
|
||
// modifiers have the ability to execute arbitrary code when Popper.js get inited
|
||
// such code is executed in the same order of its modifier
|
||
// they could add new properties to their options configuration
|
||
// BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
|
||
this.modifiers.forEach(function (modifierOptions) {
|
||
if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
|
||
modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
|
||
}
|
||
});
|
||
|
||
// fire the first update to position the popper in the right place
|
||
this.update();
|
||
|
||
var eventsEnabled = this.options.eventsEnabled;
|
||
if (eventsEnabled) {
|
||
// setup event listeners, they will take care of update the position in specific situations
|
||
this.enableEventListeners();
|
||
}
|
||
|
||
this.state.eventsEnabled = eventsEnabled;
|
||
}
|
||
|
||
// We can't use class properties because they don't get listed in the
|
||
// class prototype and break stuff like Sinon stubs
|
||
|
||
|
||
createClass(Popper, [{
|
||
key: 'update',
|
||
value: function update$$1() {
|
||
return update.call(this);
|
||
}
|
||
}, {
|
||
key: 'destroy',
|
||
value: function destroy$$1() {
|
||
return destroy.call(this);
|
||
}
|
||
}, {
|
||
key: 'enableEventListeners',
|
||
value: function enableEventListeners$$1() {
|
||
return enableEventListeners.call(this);
|
||
}
|
||
}, {
|
||
key: 'disableEventListeners',
|
||
value: function disableEventListeners$$1() {
|
||
return disableEventListeners.call(this);
|
||
}
|
||
|
||
/**
|
||
* Schedule an update, it will run on the next UI update available
|
||
* @method scheduleUpdate
|
||
* @memberof Popper
|
||
*/
|
||
|
||
|
||
/**
|
||
* Collection of utilities useful when writing custom modifiers.
|
||
* Starting from version 1.7, this method is available only if you
|
||
* include `popper-utils.js` before `popper.js`.
|
||
*
|
||
* **DEPRECATION**: This way to access PopperUtils is deprecated
|
||
* and will be removed in v2! Use the PopperUtils module directly instead.
|
||
* Due to the high instability of the methods contained in Utils, we can't
|
||
* guarantee them to follow semver. Use them at your own risk!
|
||
* @static
|
||
* @private
|
||
* @type {Object}
|
||
* @deprecated since version 1.8
|
||
* @member Utils
|
||
* @memberof Popper
|
||
*/
|
||
|
||
}]);
|
||
return Popper;
|
||
}();
|
||
|
||
/**
|
||
* The `referenceObject` is an object that provides an interface compatible with Popper.js
|
||
* and lets you use it as replacement of a real DOM node.<br />
|
||
* You can use this method to position a popper relatively to a set of coordinates
|
||
* in case you don't have a DOM node to use as reference.
|
||
*
|
||
* ```
|
||
* new Popper(referenceObject, popperNode);
|
||
* ```
|
||
*
|
||
* NB: This feature isn't supported in Internet Explorer 10
|
||
* @name referenceObject
|
||
* @property {Function} data.getBoundingClientRect
|
||
* A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
|
||
* @property {number} data.clientWidth
|
||
* An ES6 getter that will return the width of the virtual reference element.
|
||
* @property {number} data.clientHeight
|
||
* An ES6 getter that will return the height of the virtual reference element.
|
||
*/
|
||
|
||
|
||
Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
|
||
Popper.placements = placements;
|
||
Popper.Defaults = Defaults;
|
||
|
||
var SVGAnimatedString = function SVGAnimatedString() {};
|
||
if (typeof window !== 'undefined') {
|
||
SVGAnimatedString = window.SVGAnimatedString;
|
||
}
|
||
|
||
function convertToArray(value) {
|
||
if (typeof value === 'string') {
|
||
value = value.split(' ');
|
||
}
|
||
return value;
|
||
}
|
||
|
||
/**
|
||
* Add classes to an element.
|
||
* This method checks to ensure that the classes don't already exist before adding them.
|
||
* It uses el.className rather than classList in order to be IE friendly.
|
||
* @param {object} el - The element to add the classes to.
|
||
* @param {classes} string - List of space separated classes to be added to the element.
|
||
*/
|
||
function addClasses(el, classes) {
|
||
var newClasses = convertToArray(classes);
|
||
var classList = void 0;
|
||
if (el.className instanceof SVGAnimatedString) {
|
||
classList = convertToArray(el.className.baseVal);
|
||
} else {
|
||
classList = convertToArray(el.className);
|
||
}
|
||
newClasses.forEach(function (newClass) {
|
||
if (classList.indexOf(newClass) === -1) {
|
||
classList.push(newClass);
|
||
}
|
||
});
|
||
if (el instanceof SVGElement) {
|
||
el.setAttribute('class', classList.join(' '));
|
||
} else {
|
||
el.className = classList.join(' ');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Remove classes from an element.
|
||
* It uses el.className rather than classList in order to be IE friendly.
|
||
* @export
|
||
* @param {any} el The element to remove the classes from.
|
||
* @param {any} classes List of space separated classes to be removed from the element.
|
||
*/
|
||
function removeClasses(el, classes) {
|
||
var newClasses = convertToArray(classes);
|
||
var classList = void 0;
|
||
if (el.className instanceof SVGAnimatedString) {
|
||
classList = convertToArray(el.className.baseVal);
|
||
} else {
|
||
classList = convertToArray(el.className);
|
||
}
|
||
newClasses.forEach(function (newClass) {
|
||
var index = classList.indexOf(newClass);
|
||
if (index !== -1) {
|
||
classList.splice(index, 1);
|
||
}
|
||
});
|
||
if (el instanceof SVGElement) {
|
||
el.setAttribute('class', classList.join(' '));
|
||
} else {
|
||
el.className = classList.join(' ');
|
||
}
|
||
}
|
||
|
||
var supportsPassive = false;
|
||
|
||
if (typeof window !== 'undefined') {
|
||
supportsPassive = false;
|
||
try {
|
||
var opts = Object.defineProperty({}, 'passive', {
|
||
get: function get() {
|
||
supportsPassive = true;
|
||
}
|
||
});
|
||
window.addEventListener('test', null, opts);
|
||
} catch (e) {}
|
||
}
|
||
|
||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
||
return typeof obj;
|
||
} : function (obj) {
|
||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||
};
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
var classCallCheck$1 = function (instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
};
|
||
|
||
var createClass$1 = function () {
|
||
function defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor) descriptor.writable = true;
|
||
Object.defineProperty(target, descriptor.key, descriptor);
|
||
}
|
||
}
|
||
|
||
return function (Constructor, protoProps, staticProps) {
|
||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps) defineProperties(Constructor, staticProps);
|
||
return Constructor;
|
||
};
|
||
}();
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
var _extends$1 = Object.assign || function (target) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var source = arguments[i];
|
||
|
||
for (var key in source) {
|
||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||
target[key] = source[key];
|
||
}
|
||
}
|
||
}
|
||
|
||
return target;
|
||
};
|
||
|
||
/* Forked from https://github.com/FezVrasta/popper.js/blob/master/packages/tooltip/src/index.js */
|
||
|
||
var DEFAULT_OPTIONS = {
|
||
container: false,
|
||
delay: 0,
|
||
html: false,
|
||
placement: 'top',
|
||
title: '',
|
||
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
|
||
trigger: 'hover focus',
|
||
offset: 0
|
||
};
|
||
|
||
var openTooltips = [];
|
||
|
||
var Tooltip = function () {
|
||
/**
|
||
* Create a new Tooltip.js instance
|
||
* @class Tooltip
|
||
* @param {HTMLElement} reference - The DOM node used as reference of the tooltip (it can be a jQuery element).
|
||
* @param {Object} options
|
||
* @param {String} options.placement=bottom
|
||
* Placement of the popper accepted values: `top(-start, -end), right(-start, -end), bottom(-start, -end),
|
||
* left(-start, -end)`
|
||
* @param {HTMLElement|String|false} options.container=false - Append the tooltip to a specific element.
|
||
* @param {Number|Object} options.delay=0
|
||
* Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type.
|
||
* If a number is supplied, delay is applied to both hide/show.
|
||
* Object structure is: `{ show: 500, hide: 100 }`
|
||
* @param {Boolean} options.html=false - Insert HTML into the tooltip. If false, the content will inserted with `innerText`.
|
||
* @param {String|PlacementFunction} options.placement='top' - One of the allowed placements, or a function returning one of them.
|
||
* @param {String} [options.template='<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>']
|
||
* Base HTML to used when creating the tooltip.
|
||
* The tooltip's `title` will be injected into the `.tooltip-inner` or `.tooltip__inner`.
|
||
* `.tooltip-arrow` or `.tooltip__arrow` will become the tooltip's arrow.
|
||
* The outermost wrapper element should have the `.tooltip` class.
|
||
* @param {String|HTMLElement|TitleFunction} options.title='' - Default title value if `title` attribute isn't present.
|
||
* @param {String} [options.trigger='hover focus']
|
||
* How tooltip is triggered - click, hover, focus, manual.
|
||
* You may pass multiple triggers; separate them with a space. `manual` cannot be combined with any other trigger.
|
||
* @param {HTMLElement} options.boundariesElement
|
||
* The element used as boundaries for the tooltip. For more information refer to Popper.js'
|
||
* [boundariesElement docs](https://popper.js.org/popper-documentation.html)
|
||
* @param {Number|String} options.offset=0 - Offset of the tooltip relative to its reference. For more information refer to Popper.js'
|
||
* [offset docs](https://popper.js.org/popper-documentation.html)
|
||
* @param {Object} options.popperOptions={} - Popper options, will be passed directly to popper instance. For more information refer to Popper.js'
|
||
* [options docs](https://popper.js.org/popper-documentation.html)
|
||
* @return {Object} instance - The generated tooltip instance
|
||
*/
|
||
function Tooltip(reference, options) {
|
||
classCallCheck$1(this, Tooltip);
|
||
|
||
_initialiseProps.call(this);
|
||
|
||
// apply user options over default ones
|
||
options = _extends$1({}, DEFAULT_OPTIONS, options);
|
||
|
||
reference.jquery && (reference = reference[0]);
|
||
|
||
// cache reference and options
|
||
this.reference = reference;
|
||
this.options = options;
|
||
|
||
// set initial state
|
||
this._isOpen = false;
|
||
|
||
this._init();
|
||
}
|
||
|
||
//
|
||
// Public methods
|
||
//
|
||
|
||
/**
|
||
* Reveals an element's tooltip. This is considered a "manual" triggering of the tooltip.
|
||
* Tooltips with zero-length titles are never displayed.
|
||
* @method Tooltip#show
|
||
* @memberof Tooltip
|
||
*/
|
||
|
||
|
||
/**
|
||
* Hides an element’s tooltip. This is considered a “manual” triggering of the tooltip.
|
||
* @method Tooltip#hide
|
||
* @memberof Tooltip
|
||
*/
|
||
|
||
|
||
/**
|
||
* Hides and destroys an element’s tooltip.
|
||
* @method Tooltip#dispose
|
||
* @memberof Tooltip
|
||
*/
|
||
|
||
|
||
/**
|
||
* Toggles an element’s tooltip. This is considered a “manual” triggering of the tooltip.
|
||
* @method Tooltip#toggle
|
||
* @memberof Tooltip
|
||
*/
|
||
|
||
|
||
createClass$1(Tooltip, [{
|
||
key: 'setClasses',
|
||
value: function setClasses(classes) {
|
||
this._classes = classes;
|
||
}
|
||
}, {
|
||
key: 'setContent',
|
||
value: function setContent(content) {
|
||
this.options.title = content;
|
||
if (this._tooltipNode) {
|
||
this._setContent(content, this.options);
|
||
}
|
||
}
|
||
}, {
|
||
key: 'setOptions',
|
||
value: function setOptions(options) {
|
||
var classesUpdated = false;
|
||
var classes = options && options.classes || directive.options.defaultClass;
|
||
if (this._classes !== classes) {
|
||
this.setClasses(classes);
|
||
classesUpdated = true;
|
||
}
|
||
|
||
options = getOptions(options);
|
||
|
||
var needPopperUpdate = false;
|
||
var needRestart = false;
|
||
|
||
if (this.options.offset !== options.offset || this.options.placement !== options.placement) {
|
||
needPopperUpdate = true;
|
||
}
|
||
|
||
if (this.options.template !== options.template || this.options.trigger !== options.trigger || this.options.container !== options.container || classesUpdated) {
|
||
needRestart = true;
|
||
}
|
||
|
||
for (var key in options) {
|
||
this.options[key] = options[key];
|
||
}
|
||
|
||
if (this._tooltipNode) {
|
||
if (needRestart) {
|
||
var isOpen = this._isOpen;
|
||
|
||
this.dispose();
|
||
this._init();
|
||
|
||
if (isOpen) {
|
||
this.show();
|
||
}
|
||
} else if (needPopperUpdate) {
|
||
this.popperInstance.update();
|
||
}
|
||
}
|
||
}
|
||
|
||
//
|
||
// Private methods
|
||
//
|
||
|
||
}, {
|
||
key: '_init',
|
||
value: function _init() {
|
||
// get events list
|
||
var events = typeof this.options.trigger === 'string' ? this.options.trigger.split(' ').filter(function (trigger) {
|
||
return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
|
||
}) : [];
|
||
this._isDisposed = false;
|
||
this._enableDocumentTouch = events.indexOf('manual') === -1;
|
||
|
||
// set event listeners
|
||
this._setEventListeners(this.reference, events, this.options);
|
||
}
|
||
|
||
/**
|
||
* Creates a new tooltip node
|
||
* @memberof Tooltip
|
||
* @private
|
||
* @param {HTMLElement} reference
|
||
* @param {String} template
|
||
* @param {String|HTMLElement|TitleFunction} title
|
||
* @param {Boolean} allowHtml
|
||
* @return {HTMLelement} tooltipNode
|
||
*/
|
||
|
||
}, {
|
||
key: '_create',
|
||
value: function _create(reference, template) {
|
||
// create tooltip element
|
||
var tooltipGenerator = window.document.createElement('div');
|
||
tooltipGenerator.innerHTML = template.trim();
|
||
var tooltipNode = tooltipGenerator.childNodes[0];
|
||
|
||
// add unique ID to our tooltip (needed for accessibility reasons)
|
||
tooltipNode.id = 'tooltip_' + Math.random().toString(36).substr(2, 10);
|
||
|
||
// Initially hide the tooltip
|
||
// The attribute will be switched in a next frame so
|
||
// CSS transitions can play
|
||
tooltipNode.setAttribute('aria-hidden', 'true');
|
||
|
||
if (this.options.autoHide && this.options.trigger.indexOf('hover') !== -1) {
|
||
tooltipNode.addEventListener('mouseenter', this.hide);
|
||
tooltipNode.addEventListener('click', this.hide);
|
||
}
|
||
|
||
// return the generated tooltip node
|
||
return tooltipNode;
|
||
}
|
||
}, {
|
||
key: '_setContent',
|
||
value: function _setContent(content, options) {
|
||
var _this = this;
|
||
|
||
this.asyncContent = false;
|
||
this._applyContent(content, options).then(function () {
|
||
_this.popperInstance.update();
|
||
});
|
||
}
|
||
}, {
|
||
key: '_applyContent',
|
||
value: function _applyContent(title, options) {
|
||
var _this2 = this;
|
||
|
||
return new Promise(function (resolve, reject) {
|
||
var allowHtml = options.html;
|
||
var rootNode = _this2._tooltipNode;
|
||
if (!rootNode) return;
|
||
var titleNode = rootNode.querySelector(_this2.options.innerSelector);
|
||
if (title.nodeType === 1) {
|
||
// if title is a node, append it only if allowHtml is true
|
||
if (allowHtml) {
|
||
while (titleNode.firstChild) {
|
||
titleNode.removeChild(titleNode.firstChild);
|
||
}
|
||
titleNode.appendChild(title);
|
||
}
|
||
} else if (typeof title === 'function') {
|
||
// if title is a function, call it and set innerText or innerHtml depending by `allowHtml` value
|
||
var result = title();
|
||
if (result && typeof result.then === 'function') {
|
||
_this2.asyncContent = true;
|
||
options.loadingClass && addClasses(rootNode, options.loadingClass);
|
||
if (options.loadingContent) {
|
||
_this2._applyContent(options.loadingContent, options);
|
||
}
|
||
result.then(function (asyncResult) {
|
||
options.loadingClass && removeClasses(rootNode, options.loadingClass);
|
||
return _this2._applyContent(asyncResult, options);
|
||
}).then(resolve).catch(reject);
|
||
} else {
|
||
_this2._applyContent(result, options).then(resolve).catch(reject);
|
||
}
|
||
return;
|
||
} else {
|
||
// if it's just a simple text, set innerText or innerHtml depending by `allowHtml` value
|
||
allowHtml ? titleNode.innerHTML = title : titleNode.innerText = title;
|
||
}
|
||
resolve();
|
||
});
|
||
}
|
||
}, {
|
||
key: '_show',
|
||
value: function _show(reference, options) {
|
||
if (options && typeof options.container === 'string') {
|
||
var container = document.querySelector(options.container);
|
||
if (!container) return;
|
||
}
|
||
|
||
clearTimeout(this._disposeTimer);
|
||
|
||
options = Object.assign({}, options);
|
||
delete options.offset;
|
||
|
||
var updateClasses = true;
|
||
if (this._tooltipNode) {
|
||
addClasses(this._tooltipNode, this._classes);
|
||
updateClasses = false;
|
||
}
|
||
|
||
var result = this._ensureShown(reference, options);
|
||
|
||
if (updateClasses && this._tooltipNode) {
|
||
addClasses(this._tooltipNode, this._classes);
|
||
}
|
||
|
||
addClasses(reference, ['v-tooltip-open']);
|
||
|
||
return result;
|
||
}
|
||
}, {
|
||
key: '_ensureShown',
|
||
value: function _ensureShown(reference, options) {
|
||
var _this3 = this;
|
||
|
||
// don't show if it's already visible
|
||
if (this._isOpen) {
|
||
return this;
|
||
}
|
||
this._isOpen = true;
|
||
|
||
openTooltips.push(this);
|
||
|
||
// if the tooltipNode already exists, just show it
|
||
if (this._tooltipNode) {
|
||
this._tooltipNode.style.display = '';
|
||
this._tooltipNode.setAttribute('aria-hidden', 'false');
|
||
this.popperInstance.enableEventListeners();
|
||
this.popperInstance.update();
|
||
if (this.asyncContent) {
|
||
this._setContent(options.title, options);
|
||
}
|
||
return this;
|
||
}
|
||
|
||
// get title
|
||
var title = reference.getAttribute('title') || options.title;
|
||
|
||
// don't show tooltip if no title is defined
|
||
if (!title) {
|
||
return this;
|
||
}
|
||
|
||
// create tooltip node
|
||
var tooltipNode = this._create(reference, options.template);
|
||
this._tooltipNode = tooltipNode;
|
||
|
||
this._setContent(title, options);
|
||
|
||
// Add `aria-describedby` to our reference element for accessibility reasons
|
||
reference.setAttribute('aria-describedby', tooltipNode.id);
|
||
|
||
// append tooltip to container
|
||
var container = this._findContainer(options.container, reference);
|
||
|
||
this._append(tooltipNode, container);
|
||
|
||
var popperOptions = _extends$1({}, options.popperOptions, {
|
||
placement: options.placement
|
||
});
|
||
|
||
popperOptions.modifiers = _extends$1({}, popperOptions.modifiers, {
|
||
arrow: {
|
||
element: this.options.arrowSelector
|
||
}
|
||
});
|
||
|
||
if (options.boundariesElement) {
|
||
popperOptions.modifiers.preventOverflow = {
|
||
boundariesElement: options.boundariesElement
|
||
};
|
||
}
|
||
|
||
this.popperInstance = new Popper(reference, tooltipNode, popperOptions);
|
||
|
||
// Fix position
|
||
requestAnimationFrame(function () {
|
||
if (!_this3._isDisposed && _this3.popperInstance) {
|
||
_this3.popperInstance.update();
|
||
|
||
// Show the tooltip
|
||
requestAnimationFrame(function () {
|
||
if (!_this3._isDisposed) {
|
||
_this3._isOpen && tooltipNode.setAttribute('aria-hidden', 'false');
|
||
} else {
|
||
_this3.dispose();
|
||
}
|
||
});
|
||
} else {
|
||
_this3.dispose();
|
||
}
|
||
});
|
||
|
||
return this;
|
||
}
|
||
}, {
|
||
key: '_noLongerOpen',
|
||
value: function _noLongerOpen() {
|
||
var index = openTooltips.indexOf(this);
|
||
if (index !== -1) {
|
||
openTooltips.splice(index, 1);
|
||
}
|
||
}
|
||
}, {
|
||
key: '_hide',
|
||
value: function _hide() /* reference, options */{
|
||
var _this4 = this;
|
||
|
||
// don't hide if it's already hidden
|
||
if (!this._isOpen) {
|
||
return this;
|
||
}
|
||
|
||
this._isOpen = false;
|
||
this._noLongerOpen();
|
||
|
||
// hide tooltipNode
|
||
this._tooltipNode.style.display = 'none';
|
||
this._tooltipNode.setAttribute('aria-hidden', 'true');
|
||
|
||
this.popperInstance.disableEventListeners();
|
||
|
||
clearTimeout(this._disposeTimer);
|
||
var disposeTime = directive.options.disposeTimeout;
|
||
if (disposeTime !== null) {
|
||
this._disposeTimer = setTimeout(function () {
|
||
if (_this4._tooltipNode) {
|
||
_this4._tooltipNode.removeEventListener('mouseenter', _this4.hide);
|
||
_this4._tooltipNode.removeEventListener('click', _this4.hide);
|
||
// Don't remove popper instance, just the HTML element
|
||
_this4._tooltipNode.parentNode.removeChild(_this4._tooltipNode);
|
||
_this4._tooltipNode = null;
|
||
}
|
||
}, disposeTime);
|
||
}
|
||
|
||
removeClasses(this.reference, ['v-tooltip-open']);
|
||
|
||
return this;
|
||
}
|
||
}, {
|
||
key: '_dispose',
|
||
value: function _dispose() {
|
||
var _this5 = this;
|
||
|
||
this._isDisposed = true;
|
||
|
||
// remove event listeners first to prevent any unexpected behaviour
|
||
this._events.forEach(function (_ref) {
|
||
var func = _ref.func,
|
||
event = _ref.event;
|
||
|
||
_this5.reference.removeEventListener(event, func);
|
||
});
|
||
this._events = [];
|
||
|
||
if (this._tooltipNode) {
|
||
this._hide();
|
||
|
||
this._tooltipNode.removeEventListener('mouseenter', this.hide);
|
||
this._tooltipNode.removeEventListener('click', this.hide);
|
||
|
||
// destroy instance
|
||
this.popperInstance.destroy();
|
||
|
||
// destroy tooltipNode if removeOnDestroy is not set, as popperInstance.destroy() already removes the element
|
||
if (!this.popperInstance.options.removeOnDestroy) {
|
||
this._tooltipNode.parentNode.removeChild(this._tooltipNode);
|
||
this._tooltipNode = null;
|
||
}
|
||
} else {
|
||
this._noLongerOpen();
|
||
}
|
||
return this;
|
||
}
|
||
}, {
|
||
key: '_findContainer',
|
||
value: function _findContainer(container, reference) {
|
||
// if container is a query, get the relative element
|
||
if (typeof container === 'string') {
|
||
container = window.document.querySelector(container);
|
||
} else if (container === false) {
|
||
// if container is `false`, set it to reference parent
|
||
container = reference.parentNode;
|
||
}
|
||
return container;
|
||
}
|
||
|
||
/**
|
||
* Append tooltip to container
|
||
* @memberof Tooltip
|
||
* @private
|
||
* @param {HTMLElement} tooltip
|
||
* @param {HTMLElement|String|false} container
|
||
*/
|
||
|
||
}, {
|
||
key: '_append',
|
||
value: function _append(tooltipNode, container) {
|
||
container.appendChild(tooltipNode);
|
||
}
|
||
}, {
|
||
key: '_setEventListeners',
|
||
value: function _setEventListeners(reference, events, options) {
|
||
var _this6 = this;
|
||
|
||
var directEvents = [];
|
||
var oppositeEvents = [];
|
||
|
||
events.forEach(function (event) {
|
||
switch (event) {
|
||
case 'hover':
|
||
directEvents.push('mouseenter');
|
||
oppositeEvents.push('mouseleave');
|
||
if (_this6.options.hideOnTargetClick) oppositeEvents.push('click');
|
||
break;
|
||
case 'focus':
|
||
directEvents.push('focus');
|
||
oppositeEvents.push('blur');
|
||
if (_this6.options.hideOnTargetClick) oppositeEvents.push('click');
|
||
break;
|
||
case 'click':
|
||
directEvents.push('click');
|
||
oppositeEvents.push('click');
|
||
break;
|
||
}
|
||
});
|
||
|
||
// schedule show tooltip
|
||
directEvents.forEach(function (event) {
|
||
var func = function func(evt) {
|
||
if (_this6._isOpen === true) {
|
||
return;
|
||
}
|
||
evt.usedByTooltip = true;
|
||
_this6._scheduleShow(reference, options.delay, options, evt);
|
||
};
|
||
_this6._events.push({ event: event, func: func });
|
||
reference.addEventListener(event, func);
|
||
});
|
||
|
||
// schedule hide tooltip
|
||
oppositeEvents.forEach(function (event) {
|
||
var func = function func(evt) {
|
||
if (evt.usedByTooltip === true) {
|
||
return;
|
||
}
|
||
_this6._scheduleHide(reference, options.delay, options, evt);
|
||
};
|
||
_this6._events.push({ event: event, func: func });
|
||
reference.addEventListener(event, func);
|
||
});
|
||
}
|
||
}, {
|
||
key: '_onDocumentTouch',
|
||
value: function _onDocumentTouch(event) {
|
||
if (this._enableDocumentTouch) {
|
||
this._scheduleHide(this.reference, this.options.delay, this.options, event);
|
||
}
|
||
}
|
||
}, {
|
||
key: '_scheduleShow',
|
||
value: function _scheduleShow(reference, delay, options /*, evt */) {
|
||
var _this7 = this;
|
||
|
||
// defaults to 0
|
||
var computedDelay = delay && delay.show || delay || 0;
|
||
clearTimeout(this._scheduleTimer);
|
||
this._scheduleTimer = window.setTimeout(function () {
|
||
return _this7._show(reference, options);
|
||
}, computedDelay);
|
||
}
|
||
}, {
|
||
key: '_scheduleHide',
|
||
value: function _scheduleHide(reference, delay, options, evt) {
|
||
var _this8 = this;
|
||
|
||
// defaults to 0
|
||
var computedDelay = delay && delay.hide || delay || 0;
|
||
clearTimeout(this._scheduleTimer);
|
||
this._scheduleTimer = window.setTimeout(function () {
|
||
if (_this8._isOpen === false) {
|
||
return;
|
||
}
|
||
if (!document.body.contains(_this8._tooltipNode)) {
|
||
return;
|
||
}
|
||
|
||
// if we are hiding because of a mouseleave, we must check that the new
|
||
// reference isn't the tooltip, because in this case we don't want to hide it
|
||
if (evt.type === 'mouseleave') {
|
||
var isSet = _this8._setTooltipNodeEvent(evt, reference, delay, options);
|
||
|
||
// if we set the new event, don't hide the tooltip yet
|
||
// the new event will take care to hide it if necessary
|
||
if (isSet) {
|
||
return;
|
||
}
|
||
}
|
||
|
||
_this8._hide(reference, options);
|
||
}, computedDelay);
|
||
}
|
||
}]);
|
||
return Tooltip;
|
||
}();
|
||
|
||
// Hide tooltips on touch devices
|
||
|
||
|
||
var _initialiseProps = function _initialiseProps() {
|
||
var _this9 = this;
|
||
|
||
this.show = function () {
|
||
_this9._show(_this9.reference, _this9.options);
|
||
};
|
||
|
||
this.hide = function () {
|
||
_this9._hide();
|
||
};
|
||
|
||
this.dispose = function () {
|
||
_this9._dispose();
|
||
};
|
||
|
||
this.toggle = function () {
|
||
if (_this9._isOpen) {
|
||
return _this9.hide();
|
||
} else {
|
||
return _this9.show();
|
||
}
|
||
};
|
||
|
||
this._events = [];
|
||
|
||
this._setTooltipNodeEvent = function (evt, reference, delay, options) {
|
||
var relatedreference = evt.relatedreference || evt.toElement || evt.relatedTarget;
|
||
|
||
var callback = function callback(evt2) {
|
||
var relatedreference2 = evt2.relatedreference || evt2.toElement || evt2.relatedTarget;
|
||
|
||
// Remove event listener after call
|
||
_this9._tooltipNode.removeEventListener(evt.type, callback);
|
||
|
||
// If the new reference is not the reference element
|
||
if (!reference.contains(relatedreference2)) {
|
||
// Schedule to hide tooltip
|
||
_this9._scheduleHide(reference, options.delay, options, evt2);
|
||
}
|
||
};
|
||
|
||
if (_this9._tooltipNode.contains(relatedreference)) {
|
||
// listen to mouseleave on the tooltip element to be able to hide the tooltip
|
||
_this9._tooltipNode.addEventListener(evt.type, callback);
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
};
|
||
};
|
||
|
||
if (typeof document !== 'undefined') {
|
||
document.addEventListener('touchstart', function (event) {
|
||
for (var i = 0; i < openTooltips.length; i++) {
|
||
openTooltips[i]._onDocumentTouch(event);
|
||
}
|
||
}, supportsPassive ? {
|
||
passive: true,
|
||
capture: true
|
||
} : true);
|
||
}
|
||
|
||
/**
|
||
* Placement function, its context is the Tooltip instance.
|
||
* @memberof Tooltip
|
||
* @callback PlacementFunction
|
||
* @param {HTMLElement} tooltip - tooltip DOM node.
|
||
* @param {HTMLElement} reference - reference DOM node.
|
||
* @return {String} placement - One of the allowed placement options.
|
||
*/
|
||
|
||
/**
|
||
* Title function, its context is the Tooltip instance.
|
||
* @memberof Tooltip
|
||
* @callback TitleFunction
|
||
* @return {String} placement - The desired title.
|
||
*/
|
||
|
||
var state = {
|
||
enabled: true
|
||
};
|
||
|
||
var positions = ['top', 'top-start', 'top-end', 'right', 'right-start', 'right-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end'];
|
||
|
||
var defaultOptions = {
|
||
// Default tooltip placement relative to target element
|
||
defaultPlacement: 'top',
|
||
// Default CSS classes applied to the tooltip element
|
||
defaultClass: 'vue-tooltip-theme',
|
||
// Default CSS classes applied to the target element of the tooltip
|
||
defaultTargetClass: 'has-tooltip',
|
||
// Is the content HTML by default?
|
||
defaultHtml: true,
|
||
// Default HTML template of the tooltip element
|
||
// It must include `tooltip-arrow` & `tooltip-inner` CSS classes (can be configured, see below)
|
||
// Change if the classes conflict with other libraries (for example bootstrap)
|
||
defaultTemplate: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
|
||
// Selector used to get the arrow element in the tooltip template
|
||
defaultArrowSelector: '.tooltip-arrow, .tooltip__arrow',
|
||
// Selector used to get the inner content element in the tooltip template
|
||
defaultInnerSelector: '.tooltip-inner, .tooltip__inner',
|
||
// Delay (ms)
|
||
defaultDelay: 0,
|
||
// Default events that trigger the tooltip
|
||
defaultTrigger: 'hover focus',
|
||
// Default position offset (px)
|
||
defaultOffset: 0,
|
||
// Default container where the tooltip will be appended
|
||
defaultContainer: 'body',
|
||
defaultBoundariesElement: undefined,
|
||
defaultPopperOptions: {},
|
||
// Class added when content is loading
|
||
defaultLoadingClass: 'tooltip-loading',
|
||
// Displayed when tooltip content is loading
|
||
defaultLoadingContent: '...',
|
||
// Hide on mouseover tooltip
|
||
autoHide: true,
|
||
// Close tooltip on click on tooltip target?
|
||
defaultHideOnTargetClick: true,
|
||
// Auto destroy tooltip DOM nodes (ms)
|
||
disposeTimeout: 5000,
|
||
// Options for popover
|
||
popover: {
|
||
defaultPlacement: 'bottom',
|
||
// Use the `popoverClass` prop for theming
|
||
defaultClass: 'vue-popover-theme',
|
||
// Base class (change if conflicts with other libraries)
|
||
defaultBaseClass: 'tooltip popover',
|
||
// Wrapper class (contains arrow and inner)
|
||
defaultWrapperClass: 'wrapper',
|
||
// Inner content class
|
||
defaultInnerClass: 'tooltip-inner popover-inner',
|
||
// Arrow class
|
||
defaultArrowClass: 'tooltip-arrow popover-arrow',
|
||
defaultDelay: 0,
|
||
defaultTrigger: 'click',
|
||
defaultOffset: 0,
|
||
defaultContainer: 'body',
|
||
defaultBoundariesElement: undefined,
|
||
defaultPopperOptions: {},
|
||
// Hides if clicked outside of popover
|
||
defaultAutoHide: true,
|
||
// Update popper on content resize
|
||
defaultHandleResize: true
|
||
}
|
||
};
|
||
|
||
function getOptions(options) {
|
||
var result = {
|
||
placement: typeof options.placement !== 'undefined' ? options.placement : directive.options.defaultPlacement,
|
||
delay: typeof options.delay !== 'undefined' ? options.delay : directive.options.defaultDelay,
|
||
html: typeof options.html !== 'undefined' ? options.html : directive.options.defaultHtml,
|
||
template: typeof options.template !== 'undefined' ? options.template : directive.options.defaultTemplate,
|
||
arrowSelector: typeof options.arrowSelector !== 'undefined' ? options.arrowSelector : directive.options.defaultArrowSelector,
|
||
innerSelector: typeof options.innerSelector !== 'undefined' ? options.innerSelector : directive.options.defaultInnerSelector,
|
||
trigger: typeof options.trigger !== 'undefined' ? options.trigger : directive.options.defaultTrigger,
|
||
offset: typeof options.offset !== 'undefined' ? options.offset : directive.options.defaultOffset,
|
||
container: typeof options.container !== 'undefined' ? options.container : directive.options.defaultContainer,
|
||
boundariesElement: typeof options.boundariesElement !== 'undefined' ? options.boundariesElement : directive.options.defaultBoundariesElement,
|
||
autoHide: typeof options.autoHide !== 'undefined' ? options.autoHide : directive.options.autoHide,
|
||
hideOnTargetClick: typeof options.hideOnTargetClick !== 'undefined' ? options.hideOnTargetClick : directive.options.defaultHideOnTargetClick,
|
||
loadingClass: typeof options.loadingClass !== 'undefined' ? options.loadingClass : directive.options.defaultLoadingClass,
|
||
loadingContent: typeof options.loadingContent !== 'undefined' ? options.loadingContent : directive.options.defaultLoadingContent,
|
||
popperOptions: _extends$1({}, typeof options.popperOptions !== 'undefined' ? options.popperOptions : directive.options.defaultPopperOptions)
|
||
};
|
||
|
||
if (result.offset) {
|
||
var typeofOffset = _typeof(result.offset);
|
||
var offset = result.offset;
|
||
|
||
// One value -> switch
|
||
if (typeofOffset === 'number' || typeofOffset === 'string' && offset.indexOf(',') === -1) {
|
||
offset = '0, ' + offset;
|
||
}
|
||
|
||
if (!result.popperOptions.modifiers) {
|
||
result.popperOptions.modifiers = {};
|
||
}
|
||
result.popperOptions.modifiers.offset = {
|
||
offset: offset
|
||
};
|
||
}
|
||
|
||
if (result.trigger && result.trigger.indexOf('click') !== -1) {
|
||
result.hideOnTargetClick = false;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
function getPlacement(value, modifiers) {
|
||
var placement = value.placement;
|
||
for (var i = 0; i < positions.length; i++) {
|
||
var pos = positions[i];
|
||
if (modifiers[pos]) {
|
||
placement = pos;
|
||
}
|
||
}
|
||
return placement;
|
||
}
|
||
|
||
function getContent(value) {
|
||
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
|
||
if (type === 'string') {
|
||
return value;
|
||
} else if (value && type === 'object') {
|
||
return value.content;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function createTooltip(el, value) {
|
||
var modifiers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||
|
||
var content = getContent(value);
|
||
var classes = typeof value.classes !== 'undefined' ? value.classes : directive.options.defaultClass;
|
||
var opts = _extends$1({
|
||
title: content
|
||
}, getOptions(_extends$1({}, value, {
|
||
placement: getPlacement(value, modifiers)
|
||
})));
|
||
var tooltip = el._tooltip = new Tooltip(el, opts);
|
||
tooltip.setClasses(classes);
|
||
tooltip._vueEl = el;
|
||
|
||
// Class on target
|
||
var targetClasses = typeof value.targetClasses !== 'undefined' ? value.targetClasses : directive.options.defaultTargetClass;
|
||
el._tooltipTargetClasses = targetClasses;
|
||
addClasses(el, targetClasses);
|
||
|
||
return tooltip;
|
||
}
|
||
|
||
function destroyTooltip(el) {
|
||
if (el._tooltip) {
|
||
el._tooltip.dispose();
|
||
delete el._tooltip;
|
||
delete el._tooltipOldShow;
|
||
}
|
||
|
||
if (el._tooltipTargetClasses) {
|
||
removeClasses(el, el._tooltipTargetClasses);
|
||
delete el._tooltipTargetClasses;
|
||
}
|
||
}
|
||
|
||
function bind(el, _ref) {
|
||
var value = _ref.value,
|
||
oldValue = _ref.oldValue,
|
||
modifiers = _ref.modifiers;
|
||
|
||
var content = getContent(value);
|
||
if (!content || !state.enabled) {
|
||
destroyTooltip(el);
|
||
} else {
|
||
var tooltip = void 0;
|
||
if (el._tooltip) {
|
||
tooltip = el._tooltip;
|
||
// Content
|
||
tooltip.setContent(content);
|
||
// Options
|
||
tooltip.setOptions(_extends$1({}, value, {
|
||
placement: getPlacement(value, modifiers)
|
||
}));
|
||
} else {
|
||
tooltip = createTooltip(el, value, modifiers);
|
||
}
|
||
|
||
// Manual show
|
||
if (typeof value.show !== 'undefined' && value.show !== el._tooltipOldShow) {
|
||
el._tooltipOldShow = value.show;
|
||
value.show ? tooltip.show() : tooltip.hide();
|
||
}
|
||
}
|
||
}
|
||
|
||
var directive = {
|
||
options: defaultOptions,
|
||
bind: bind,
|
||
update: bind,
|
||
unbind: function unbind(el) {
|
||
destroyTooltip(el);
|
||
}
|
||
};
|
||
|
||
function addListeners(el) {
|
||
el.addEventListener('click', onClick);
|
||
el.addEventListener('touchstart', onTouchStart, supportsPassive ? {
|
||
passive: true
|
||
} : false);
|
||
}
|
||
|
||
function removeListeners(el) {
|
||
el.removeEventListener('click', onClick);
|
||
el.removeEventListener('touchstart', onTouchStart);
|
||
el.removeEventListener('touchend', onTouchEnd);
|
||
el.removeEventListener('touchcancel', onTouchCancel);
|
||
}
|
||
|
||
function onClick(event) {
|
||
var el = event.currentTarget;
|
||
event.closePopover = !el.$_vclosepopover_touch;
|
||
event.closeAllPopover = el.$_closePopoverModifiers && !!el.$_closePopoverModifiers.all;
|
||
}
|
||
|
||
function onTouchStart(event) {
|
||
if (event.changedTouches.length === 1) {
|
||
var el = event.currentTarget;
|
||
el.$_vclosepopover_touch = true;
|
||
var touch = event.changedTouches[0];
|
||
el.$_vclosepopover_touchPoint = touch;
|
||
el.addEventListener('touchend', onTouchEnd);
|
||
el.addEventListener('touchcancel', onTouchCancel);
|
||
}
|
||
}
|
||
|
||
function onTouchEnd(event) {
|
||
var el = event.currentTarget;
|
||
el.$_vclosepopover_touch = false;
|
||
if (event.changedTouches.length === 1) {
|
||
var touch = event.changedTouches[0];
|
||
var firstTouch = el.$_vclosepopover_touchPoint;
|
||
event.closePopover = Math.abs(touch.screenY - firstTouch.screenY) < 20 && Math.abs(touch.screenX - firstTouch.screenX) < 20;
|
||
event.closeAllPopover = el.$_closePopoverModifiers && !!el.$_closePopoverModifiers.all;
|
||
}
|
||
}
|
||
|
||
function onTouchCancel(event) {
|
||
var el = event.currentTarget;
|
||
el.$_vclosepopover_touch = false;
|
||
}
|
||
|
||
var vclosepopover = {
|
||
bind: function bind(el, _ref) {
|
||
var value = _ref.value,
|
||
modifiers = _ref.modifiers;
|
||
|
||
el.$_closePopoverModifiers = modifiers;
|
||
if (typeof value === 'undefined' || value) {
|
||
addListeners(el);
|
||
}
|
||
},
|
||
update: function update(el, _ref2) {
|
||
var value = _ref2.value,
|
||
oldValue = _ref2.oldValue,
|
||
modifiers = _ref2.modifiers;
|
||
|
||
el.$_closePopoverModifiers = modifiers;
|
||
if (value !== oldValue) {
|
||
if (typeof value === 'undefined' || value) {
|
||
addListeners(el);
|
||
} else {
|
||
removeListeners(el);
|
||
}
|
||
}
|
||
},
|
||
unbind: function unbind(el) {
|
||
removeListeners(el);
|
||
}
|
||
};
|
||
|
||
function getInternetExplorerVersion() {
|
||
var ua = window.navigator.userAgent;
|
||
|
||
var msie = ua.indexOf('MSIE ');
|
||
if (msie > 0) {
|
||
// IE 10 or older => return version number
|
||
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
||
}
|
||
|
||
var trident = ua.indexOf('Trident/');
|
||
if (trident > 0) {
|
||
// IE 11 => return version number
|
||
var rv = ua.indexOf('rv:');
|
||
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
|
||
}
|
||
|
||
var edge = ua.indexOf('Edge/');
|
||
if (edge > 0) {
|
||
// Edge (IE 12+) => return version number
|
||
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
|
||
}
|
||
|
||
// other browser
|
||
return -1;
|
||
}
|
||
|
||
var isIE$1 = void 0;
|
||
|
||
function initCompat() {
|
||
if (!initCompat.init) {
|
||
initCompat.init = true;
|
||
isIE$1 = getInternetExplorerVersion() !== -1;
|
||
}
|
||
}
|
||
|
||
var ResizeObserver = { render: function render() {
|
||
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { staticClass: "resize-observer", attrs: { "tabindex": "-1" } });
|
||
}, staticRenderFns: [], _scopeId: 'data-v-b329ee4c',
|
||
name: 'resize-observer',
|
||
|
||
methods: {
|
||
notify: function notify() {
|
||
this.$emit('notify');
|
||
},
|
||
addResizeHandlers: function addResizeHandlers() {
|
||
this._resizeObject.contentDocument.defaultView.addEventListener('resize', this.notify);
|
||
if (this._w !== this.$el.offsetWidth || this._h !== this.$el.offsetHeight) {
|
||
this.notify();
|
||
}
|
||
},
|
||
removeResizeHandlers: function removeResizeHandlers() {
|
||
if (this._resizeObject && this._resizeObject.onload) {
|
||
if (!isIE$1 && this._resizeObject.contentDocument) {
|
||
this._resizeObject.contentDocument.defaultView.removeEventListener('resize', this.notify);
|
||
}
|
||
delete this._resizeObject.onload;
|
||
}
|
||
}
|
||
},
|
||
|
||
mounted: function mounted() {
|
||
var _this = this;
|
||
|
||
initCompat();
|
||
this.$nextTick(function () {
|
||
_this._w = _this.$el.offsetWidth;
|
||
_this._h = _this.$el.offsetHeight;
|
||
});
|
||
var object = document.createElement('object');
|
||
this._resizeObject = object;
|
||
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
|
||
object.setAttribute('aria-hidden', 'true');
|
||
object.setAttribute('tabindex', -1);
|
||
object.onload = this.addResizeHandlers;
|
||
object.type = 'text/html';
|
||
if (isIE$1) {
|
||
this.$el.appendChild(object);
|
||
}
|
||
object.data = 'about:blank';
|
||
if (!isIE$1) {
|
||
this.$el.appendChild(object);
|
||
}
|
||
},
|
||
beforeDestroy: function beforeDestroy() {
|
||
this.removeResizeHandlers();
|
||
}
|
||
};
|
||
|
||
// Install the components
|
||
function install$1(Vue) {
|
||
Vue.component('resize-observer', ResizeObserver);
|
||
/* -- Add more components here -- */
|
||
}
|
||
|
||
/* -- Plugin definition & Auto-install -- */
|
||
/* You shouldn't have to modify the code below */
|
||
|
||
// Plugin
|
||
var plugin$2 = {
|
||
// eslint-disable-next-line no-undef
|
||
version: "0.4.4",
|
||
install: install$1
|
||
};
|
||
|
||
// Auto-install
|
||
var GlobalVue$1 = null;
|
||
if (typeof window !== 'undefined') {
|
||
GlobalVue$1 = window.Vue;
|
||
} else if (typeof global !== 'undefined') {
|
||
GlobalVue$1 = global.Vue;
|
||
}
|
||
if (GlobalVue$1) {
|
||
GlobalVue$1.use(plugin$2);
|
||
}
|
||
|
||
function getDefault(key) {
|
||
var value = directive.options.popover[key];
|
||
if (typeof value === 'undefined') {
|
||
return directive.options[key];
|
||
}
|
||
return value;
|
||
}
|
||
|
||
var isIOS = false;
|
||
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
||
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||
}
|
||
|
||
var openPopovers = [];
|
||
|
||
var Element = function Element() {};
|
||
if (typeof window !== 'undefined') {
|
||
Element = window.Element;
|
||
}
|
||
|
||
var Popover = { render: function render() {
|
||
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { staticClass: "v-popover", class: _vm.cssClass }, [_c('span', { ref: "trigger", staticClass: "trigger", staticStyle: { "display": "inline-block" }, attrs: { "aria-describedby": _vm.popoverId, "tabindex": _vm.trigger.indexOf('focus') !== -1 ? 0 : -1 } }, [_vm._t("default")], 2), _vm._v(" "), _c('div', { ref: "popover", class: [_vm.popoverBaseClass, _vm.popoverClass, _vm.cssClass], style: {
|
||
visibility: _vm.isOpen ? 'visible' : 'hidden'
|
||
}, attrs: { "id": _vm.popoverId, "aria-hidden": _vm.isOpen ? 'false' : 'true' } }, [_c('div', { class: _vm.popoverWrapperClass }, [_c('div', { ref: "inner", class: _vm.popoverInnerClass, staticStyle: { "position": "relative" } }, [_c('div', [_vm._t("popover")], 2), _vm._v(" "), _vm.handleResize ? _c('ResizeObserver', { on: { "notify": _vm.$_handleResize } }) : _vm._e()], 1), _vm._v(" "), _c('div', { ref: "arrow", class: _vm.popoverArrowClass })])])]);
|
||
}, staticRenderFns: [],
|
||
name: 'VPopover',
|
||
|
||
components: {
|
||
ResizeObserver: ResizeObserver
|
||
},
|
||
|
||
props: {
|
||
open: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
disabled: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
placement: {
|
||
type: String,
|
||
default: function _default() {
|
||
return getDefault('defaultPlacement');
|
||
}
|
||
},
|
||
delay: {
|
||
type: [String, Number, Object],
|
||
default: function _default() {
|
||
return getDefault('defaultDelay');
|
||
}
|
||
},
|
||
offset: {
|
||
type: [String, Number],
|
||
default: function _default() {
|
||
return getDefault('defaultOffset');
|
||
}
|
||
},
|
||
trigger: {
|
||
type: String,
|
||
default: function _default() {
|
||
return getDefault('defaultTrigger');
|
||
}
|
||
},
|
||
container: {
|
||
type: [String, Object, Element, Boolean],
|
||
default: function _default() {
|
||
return getDefault('defaultContainer');
|
||
}
|
||
},
|
||
boundariesElement: {
|
||
type: [String, Element],
|
||
default: function _default() {
|
||
return getDefault('defaultBoundariesElement');
|
||
}
|
||
},
|
||
popperOptions: {
|
||
type: Object,
|
||
default: function _default() {
|
||
return getDefault('defaultPopperOptions');
|
||
}
|
||
},
|
||
popoverClass: {
|
||
type: [String, Array],
|
||
default: function _default() {
|
||
return getDefault('defaultClass');
|
||
}
|
||
},
|
||
popoverBaseClass: {
|
||
type: [String, Array],
|
||
default: function _default() {
|
||
return directive.options.popover.defaultBaseClass;
|
||
}
|
||
},
|
||
popoverInnerClass: {
|
||
type: [String, Array],
|
||
default: function _default() {
|
||
return directive.options.popover.defaultInnerClass;
|
||
}
|
||
},
|
||
popoverWrapperClass: {
|
||
type: [String, Array],
|
||
default: function _default() {
|
||
return directive.options.popover.defaultWrapperClass;
|
||
}
|
||
},
|
||
popoverArrowClass: {
|
||
type: [String, Array],
|
||
default: function _default() {
|
||
return directive.options.popover.defaultArrowClass;
|
||
}
|
||
},
|
||
autoHide: {
|
||
type: Boolean,
|
||
default: function _default() {
|
||
return directive.options.popover.defaultAutoHide;
|
||
}
|
||
},
|
||
handleResize: {
|
||
type: Boolean,
|
||
default: function _default() {
|
||
return directive.options.popover.defaultHandleResize;
|
||
}
|
||
},
|
||
openGroup: {
|
||
type: String,
|
||
default: null
|
||
}
|
||
},
|
||
|
||
data: function data() {
|
||
return {
|
||
isOpen: false,
|
||
id: Math.random().toString(36).substr(2, 10)
|
||
};
|
||
},
|
||
|
||
|
||
computed: {
|
||
cssClass: function cssClass() {
|
||
return {
|
||
'open': this.isOpen
|
||
};
|
||
},
|
||
popoverId: function popoverId() {
|
||
return 'popover_' + this.id;
|
||
}
|
||
},
|
||
|
||
watch: {
|
||
open: function open(val) {
|
||
if (val) {
|
||
this.show();
|
||
} else {
|
||
this.hide();
|
||
}
|
||
},
|
||
disabled: function disabled(val, oldVal) {
|
||
if (val !== oldVal) {
|
||
if (val) {
|
||
this.hide();
|
||
} else if (this.open) {
|
||
this.show();
|
||
}
|
||
}
|
||
},
|
||
container: function container(val) {
|
||
if (this.isOpen && this.popperInstance) {
|
||
var popoverNode = this.$refs.popover;
|
||
var reference = this.$refs.trigger;
|
||
|
||
var container = this.$_findContainer(this.container, reference);
|
||
if (!container) {
|
||
console.warn('No container for popover', this);
|
||
return;
|
||
}
|
||
|
||
container.appendChild(popoverNode);
|
||
this.popperInstance.scheduleUpdate();
|
||
}
|
||
},
|
||
trigger: function trigger(val) {
|
||
this.$_removeEventListeners();
|
||
this.$_addEventListeners();
|
||
},
|
||
placement: function placement(val) {
|
||
var _this = this;
|
||
|
||
this.$_updatePopper(function () {
|
||
_this.popperInstance.options.placement = val;
|
||
});
|
||
},
|
||
|
||
|
||
offset: '$_restartPopper',
|
||
|
||
boundariesElement: '$_restartPopper',
|
||
|
||
popperOptions: {
|
||
handler: '$_restartPopper',
|
||
deep: true
|
||
}
|
||
},
|
||
|
||
created: function created() {
|
||
this.$_isDisposed = false;
|
||
this.$_mounted = false;
|
||
this.$_events = [];
|
||
this.$_preventOpen = false;
|
||
},
|
||
mounted: function mounted() {
|
||
var popoverNode = this.$refs.popover;
|
||
popoverNode.parentNode && popoverNode.parentNode.removeChild(popoverNode);
|
||
|
||
this.$_init();
|
||
|
||
if (this.open) {
|
||
this.show();
|
||
}
|
||
},
|
||
beforeDestroy: function beforeDestroy() {
|
||
this.dispose();
|
||
},
|
||
|
||
|
||
methods: {
|
||
show: function show() {
|
||
var _this2 = this;
|
||
|
||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
||
event = _ref.event,
|
||
_ref$skipDelay = _ref.skipDelay,
|
||
skipDelay = _ref$skipDelay === undefined ? false : _ref$skipDelay,
|
||
_ref$force = _ref.force,
|
||
force = _ref$force === undefined ? false : _ref$force;
|
||
|
||
if (force || !this.disabled) {
|
||
this.$_scheduleShow(event);
|
||
this.$emit('show');
|
||
}
|
||
this.$emit('update:open', true);
|
||
this.$_beingShowed = true;
|
||
requestAnimationFrame(function () {
|
||
_this2.$_beingShowed = false;
|
||
});
|
||
},
|
||
hide: function hide() {
|
||
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
||
event = _ref2.event,
|
||
_ref2$skipDelay = _ref2.skipDelay;
|
||
|
||
this.$_scheduleHide(event);
|
||
|
||
this.$emit('hide');
|
||
this.$emit('update:open', false);
|
||
},
|
||
dispose: function dispose() {
|
||
this.$_isDisposed = true;
|
||
this.$_removeEventListeners();
|
||
this.hide({ skipDelay: true });
|
||
if (this.popperInstance) {
|
||
this.popperInstance.destroy();
|
||
|
||
// destroy tooltipNode if removeOnDestroy is not set, as popperInstance.destroy() already removes the element
|
||
if (!this.popperInstance.options.removeOnDestroy) {
|
||
var popoverNode = this.$refs.popover;
|
||
popoverNode.parentNode && popoverNode.parentNode.removeChild(popoverNode);
|
||
}
|
||
}
|
||
this.$_mounted = false;
|
||
this.popperInstance = null;
|
||
this.isOpen = false;
|
||
|
||
this.$emit('dispose');
|
||
},
|
||
$_init: function $_init() {
|
||
if (this.trigger.indexOf('manual') === -1) {
|
||
this.$_addEventListeners();
|
||
}
|
||
},
|
||
$_show: function $_show() {
|
||
var _this3 = this;
|
||
|
||
var reference = this.$refs.trigger;
|
||
var popoverNode = this.$refs.popover;
|
||
|
||
clearTimeout(this.$_disposeTimer);
|
||
|
||
// Already open
|
||
if (this.isOpen) {
|
||
return;
|
||
}
|
||
|
||
// Popper is already initialized
|
||
if (this.popperInstance) {
|
||
this.isOpen = true;
|
||
this.popperInstance.enableEventListeners();
|
||
this.popperInstance.scheduleUpdate();
|
||
}
|
||
|
||
if (!this.$_mounted) {
|
||
var container = this.$_findContainer(this.container, reference);
|
||
if (!container) {
|
||
console.warn('No container for popover', this);
|
||
return;
|
||
}
|
||
container.appendChild(popoverNode);
|
||
this.$_mounted = true;
|
||
}
|
||
|
||
if (!this.popperInstance) {
|
||
var popperOptions = _extends$1({}, this.popperOptions, {
|
||
placement: this.placement
|
||
});
|
||
|
||
popperOptions.modifiers = _extends$1({}, popperOptions.modifiers, {
|
||
arrow: _extends$1({}, popperOptions.modifiers && popperOptions.modifiers.arrow, {
|
||
element: this.$refs.arrow
|
||
})
|
||
});
|
||
|
||
if (this.offset) {
|
||
var offset = this.$_getOffset();
|
||
|
||
popperOptions.modifiers.offset = _extends$1({}, popperOptions.modifiers && popperOptions.modifiers.offset, {
|
||
offset: offset
|
||
});
|
||
}
|
||
|
||
if (this.boundariesElement) {
|
||
popperOptions.modifiers.preventOverflow = _extends$1({}, popperOptions.modifiers && popperOptions.modifiers.preventOverflow, {
|
||
boundariesElement: this.boundariesElement
|
||
});
|
||
}
|
||
|
||
this.popperInstance = new Popper(reference, popoverNode, popperOptions);
|
||
|
||
// Fix position
|
||
requestAnimationFrame(function () {
|
||
if (!_this3.$_isDisposed && _this3.popperInstance) {
|
||
_this3.popperInstance.scheduleUpdate();
|
||
|
||
// Show the tooltip
|
||
requestAnimationFrame(function () {
|
||
if (!_this3.$_isDisposed) {
|
||
_this3.isOpen = true;
|
||
} else {
|
||
_this3.dispose();
|
||
}
|
||
});
|
||
} else {
|
||
_this3.dispose();
|
||
}
|
||
});
|
||
}
|
||
|
||
var openGroup = this.openGroup;
|
||
if (openGroup) {
|
||
var popover = void 0;
|
||
for (var i = 0; i < openPopovers.length; i++) {
|
||
popover = openPopovers[i];
|
||
if (popover.openGroup !== openGroup) {
|
||
popover.hide();
|
||
popover.$emit('close-group');
|
||
}
|
||
}
|
||
}
|
||
|
||
openPopovers.push(this);
|
||
|
||
this.$emit('apply-show');
|
||
},
|
||
$_hide: function $_hide() {
|
||
var _this4 = this;
|
||
|
||
// Already hidden
|
||
if (!this.isOpen) {
|
||
return;
|
||
}
|
||
|
||
var index = openPopovers.indexOf(this);
|
||
if (index !== -1) {
|
||
openPopovers.splice(index, 1);
|
||
}
|
||
|
||
this.isOpen = false;
|
||
if (this.popperInstance) {
|
||
this.popperInstance.disableEventListeners();
|
||
}
|
||
|
||
clearTimeout(this.$_disposeTimer);
|
||
var disposeTime = directive.options.popover.disposeTimeout || directive.options.disposeTimeout;
|
||
if (disposeTime !== null) {
|
||
this.$_disposeTimer = setTimeout(function () {
|
||
var popoverNode = _this4.$refs.popover;
|
||
if (popoverNode) {
|
||
// Don't remove popper instance, just the HTML element
|
||
popoverNode.parentNode && popoverNode.parentNode.removeChild(popoverNode);
|
||
_this4.$_mounted = false;
|
||
}
|
||
}, disposeTime);
|
||
}
|
||
|
||
this.$emit('apply-hide');
|
||
},
|
||
$_findContainer: function $_findContainer(container, reference) {
|
||
// if container is a query, get the relative element
|
||
if (typeof container === 'string') {
|
||
container = window.document.querySelector(container);
|
||
} else if (container === false) {
|
||
// if container is `false`, set it to reference parent
|
||
container = reference.parentNode;
|
||
}
|
||
return container;
|
||
},
|
||
$_getOffset: function $_getOffset() {
|
||
var typeofOffset = _typeof(this.offset);
|
||
var offset = this.offset;
|
||
|
||
// One value -> switch
|
||
if (typeofOffset === 'number' || typeofOffset === 'string' && offset.indexOf(',') === -1) {
|
||
offset = '0, ' + offset;
|
||
}
|
||
|
||
return offset;
|
||
},
|
||
$_addEventListeners: function $_addEventListeners() {
|
||
var _this5 = this;
|
||
|
||
var reference = this.$refs.trigger;
|
||
var directEvents = [];
|
||
var oppositeEvents = [];
|
||
|
||
var events = typeof this.trigger === 'string' ? this.trigger.split(' ').filter(function (trigger) {
|
||
return ['click', 'hover', 'focus'].indexOf(trigger) !== -1;
|
||
}) : [];
|
||
|
||
events.forEach(function (event) {
|
||
switch (event) {
|
||
case 'hover':
|
||
directEvents.push('mouseenter');
|
||
oppositeEvents.push('mouseleave');
|
||
break;
|
||
case 'focus':
|
||
directEvents.push('focus');
|
||
oppositeEvents.push('blur');
|
||
break;
|
||
case 'click':
|
||
directEvents.push('click');
|
||
oppositeEvents.push('click');
|
||
break;
|
||
}
|
||
});
|
||
|
||
// schedule show tooltip
|
||
directEvents.forEach(function (event) {
|
||
var func = function func(event) {
|
||
if (_this5.isOpen) {
|
||
return;
|
||
}
|
||
event.usedByTooltip = true;
|
||
!_this5.$_preventOpen && _this5.show({ event: event });
|
||
};
|
||
_this5.$_events.push({ event: event, func: func });
|
||
reference.addEventListener(event, func);
|
||
});
|
||
|
||
// schedule hide tooltip
|
||
oppositeEvents.forEach(function (event) {
|
||
var func = function func(event) {
|
||
if (event.usedByTooltip) {
|
||
return;
|
||
}
|
||
_this5.hide({ event: event });
|
||
};
|
||
_this5.$_events.push({ event: event, func: func });
|
||
reference.addEventListener(event, func);
|
||
});
|
||
},
|
||
$_scheduleShow: function $_scheduleShow() {
|
||
var skipDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||
|
||
clearTimeout(this.$_scheduleTimer);
|
||
if (skipDelay) {
|
||
this.$_show();
|
||
} else {
|
||
// defaults to 0
|
||
var computedDelay = parseInt(this.delay && this.delay.show || this.delay || 0);
|
||
this.$_scheduleTimer = setTimeout(this.$_show.bind(this), computedDelay);
|
||
}
|
||
},
|
||
$_scheduleHide: function $_scheduleHide() {
|
||
var _this6 = this;
|
||
|
||
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
||
var skipDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||
|
||
clearTimeout(this.$_scheduleTimer);
|
||
if (skipDelay) {
|
||
this.$_hide();
|
||
} else {
|
||
// defaults to 0
|
||
var computedDelay = parseInt(this.delay && this.delay.hide || this.delay || 0);
|
||
this.$_scheduleTimer = setTimeout(function () {
|
||
if (!_this6.isOpen) {
|
||
return;
|
||
}
|
||
|
||
// if we are hiding because of a mouseleave, we must check that the new
|
||
// reference isn't the tooltip, because in this case we don't want to hide it
|
||
if (event && event.type === 'mouseleave') {
|
||
var isSet = _this6.$_setTooltipNodeEvent(event);
|
||
|
||
// if we set the new event, don't hide the tooltip yet
|
||
// the new event will take care to hide it if necessary
|
||
if (isSet) {
|
||
return;
|
||
}
|
||
}
|
||
|
||
_this6.$_hide();
|
||
}, computedDelay);
|
||
}
|
||
},
|
||
$_setTooltipNodeEvent: function $_setTooltipNodeEvent(event) {
|
||
var _this7 = this;
|
||
|
||
var reference = this.$refs.trigger;
|
||
var popoverNode = this.$refs.popover;
|
||
|
||
var relatedreference = event.relatedreference || event.toElement || event.relatedTarget;
|
||
|
||
var callback = function callback(event2) {
|
||
var relatedreference2 = event2.relatedreference || event2.toElement || event2.relatedTarget;
|
||
|
||
// Remove event listener after call
|
||
popoverNode.removeEventListener(event.type, callback);
|
||
|
||
// If the new reference is not the reference element
|
||
if (!reference.contains(relatedreference2)) {
|
||
// Schedule to hide tooltip
|
||
_this7.hide({ event: event2 });
|
||
}
|
||
};
|
||
|
||
if (popoverNode.contains(relatedreference)) {
|
||
// listen to mouseleave on the tooltip element to be able to hide the tooltip
|
||
popoverNode.addEventListener(event.type, callback);
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
},
|
||
$_removeEventListeners: function $_removeEventListeners() {
|
||
var reference = this.$refs.trigger;
|
||
this.$_events.forEach(function (_ref3) {
|
||
var func = _ref3.func,
|
||
event = _ref3.event;
|
||
|
||
reference.removeEventListener(event, func);
|
||
});
|
||
this.$_events = [];
|
||
},
|
||
$_updatePopper: function $_updatePopper(cb) {
|
||
if (this.popperInstance) {
|
||
cb();
|
||
if (this.isOpen) this.popperInstance.scheduleUpdate();
|
||
}
|
||
},
|
||
$_restartPopper: function $_restartPopper() {
|
||
if (this.popperInstance) {
|
||
var isOpen = this.isOpen;
|
||
this.dispose();
|
||
this.$_isDisposed = false;
|
||
this.$_init();
|
||
if (isOpen) {
|
||
this.show({ skipDelay: true, force: true });
|
||
}
|
||
}
|
||
},
|
||
$_handleGlobalClose: function $_handleGlobalClose(event) {
|
||
var _this8 = this;
|
||
|
||
var touch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||
|
||
if (this.$_beingShowed) return;
|
||
|
||
this.hide({ event: event });
|
||
|
||
if (event.closePopover) {
|
||
this.$emit('close-directive');
|
||
} else {
|
||
this.$emit('auto-hide');
|
||
}
|
||
|
||
if (touch) {
|
||
this.$_preventOpen = true;
|
||
setTimeout(function () {
|
||
_this8.$_preventOpen = false;
|
||
}, 300);
|
||
}
|
||
},
|
||
$_handleResize: function $_handleResize() {
|
||
if (this.isOpen && this.popperInstance) {
|
||
this.popperInstance.scheduleUpdate();
|
||
this.$emit('resize');
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||
if (isIOS) {
|
||
document.addEventListener('touchend', handleGlobalTouchend, supportsPassive ? {
|
||
passive: true,
|
||
capture: true
|
||
} : true);
|
||
} else {
|
||
window.addEventListener('click', handleGlobalClick, true);
|
||
}
|
||
}
|
||
|
||
function handleGlobalClick(event) {
|
||
handleGlobalClose(event);
|
||
}
|
||
|
||
function handleGlobalTouchend(event) {
|
||
handleGlobalClose(event, true);
|
||
}
|
||
|
||
function handleGlobalClose(event) {
|
||
var touch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||
|
||
// Delay so that close directive has time to set values
|
||
requestAnimationFrame(function () {
|
||
var popover = void 0;
|
||
for (var i = 0; i < openPopovers.length; i++) {
|
||
popover = openPopovers[i];
|
||
if (popover.$refs.popover) {
|
||
var contains = popover.$refs.popover.contains(event.target);
|
||
if (event.closeAllPopover || event.closePopover && contains || popover.autoHide && !contains) {
|
||
popover.$_handleGlobalClose(event, touch);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||
|
||
|
||
|
||
|
||
|
||
function createCommonjsModule(fn, module) {
|
||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||
}
|
||
|
||
var lodash_merge = createCommonjsModule(function (module, exports) {
|
||
/**
|
||
* Lodash (Custom Build) <https://lodash.com/>
|
||
* Build: `lodash modularize exports="npm" -o ./`
|
||
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
||
* Released under MIT license <https://lodash.com/license>
|
||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||
*/
|
||
|
||
/** Used as the size to enable large array optimizations. */
|
||
var LARGE_ARRAY_SIZE = 200;
|
||
|
||
/** Used to stand-in for `undefined` hash values. */
|
||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||
|
||
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
||
var HOT_COUNT = 800,
|
||
HOT_SPAN = 16;
|
||
|
||
/** Used as references for various `Number` constants. */
|
||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
||
/** `Object#toString` result references. */
|
||
var argsTag = '[object Arguments]',
|
||
arrayTag = '[object Array]',
|
||
asyncTag = '[object AsyncFunction]',
|
||
boolTag = '[object Boolean]',
|
||
dateTag = '[object Date]',
|
||
errorTag = '[object Error]',
|
||
funcTag = '[object Function]',
|
||
genTag = '[object GeneratorFunction]',
|
||
mapTag = '[object Map]',
|
||
numberTag = '[object Number]',
|
||
nullTag = '[object Null]',
|
||
objectTag = '[object Object]',
|
||
proxyTag = '[object Proxy]',
|
||
regexpTag = '[object RegExp]',
|
||
setTag = '[object Set]',
|
||
stringTag = '[object String]',
|
||
undefinedTag = '[object Undefined]',
|
||
weakMapTag = '[object WeakMap]';
|
||
|
||
var arrayBufferTag = '[object ArrayBuffer]',
|
||
dataViewTag = '[object DataView]',
|
||
float32Tag = '[object Float32Array]',
|
||
float64Tag = '[object Float64Array]',
|
||
int8Tag = '[object Int8Array]',
|
||
int16Tag = '[object Int16Array]',
|
||
int32Tag = '[object Int32Array]',
|
||
uint8Tag = '[object Uint8Array]',
|
||
uint8ClampedTag = '[object Uint8ClampedArray]',
|
||
uint16Tag = '[object Uint16Array]',
|
||
uint32Tag = '[object Uint32Array]';
|
||
|
||
/**
|
||
* Used to match `RegExp`
|
||
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
||
*/
|
||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
||
|
||
/** Used to detect host constructors (Safari). */
|
||
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
||
|
||
/** Used to detect unsigned integer values. */
|
||
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||
|
||
/** Used to identify `toStringTag` values of typed arrays. */
|
||
var typedArrayTags = {};
|
||
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
||
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
||
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
||
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
||
typedArrayTags[uint32Tag] = true;
|
||
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
||
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
||
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
||
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
||
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
||
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
||
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
||
typedArrayTags[weakMapTag] = false;
|
||
|
||
/** Detect free variable `global` from Node.js. */
|
||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
||
|
||
/** Detect free variable `self`. */
|
||
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
||
|
||
/** Used as a reference to the global object. */
|
||
var root = freeGlobal || freeSelf || Function('return this')();
|
||
|
||
/** Detect free variable `exports`. */
|
||
var freeExports = true && exports && !exports.nodeType && exports;
|
||
|
||
/** Detect free variable `module`. */
|
||
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
||
|
||
/** Detect the popular CommonJS extension `module.exports`. */
|
||
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||
|
||
/** Detect free variable `process` from Node.js. */
|
||
var freeProcess = moduleExports && freeGlobal.process;
|
||
|
||
/** Used to access faster Node.js helpers. */
|
||
var nodeUtil = (function() {
|
||
try {
|
||
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
||
} catch (e) {}
|
||
}());
|
||
|
||
/* Node.js helper references. */
|
||
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
||
|
||
/**
|
||
* A faster alternative to `Function#apply`, this function invokes `func`
|
||
* with the `this` binding of `thisArg` and the arguments of `args`.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to invoke.
|
||
* @param {*} thisArg The `this` binding of `func`.
|
||
* @param {Array} args The arguments to invoke `func` with.
|
||
* @returns {*} Returns the result of `func`.
|
||
*/
|
||
function apply(func, thisArg, args) {
|
||
switch (args.length) {
|
||
case 0: return func.call(thisArg);
|
||
case 1: return func.call(thisArg, args[0]);
|
||
case 2: return func.call(thisArg, args[0], args[1]);
|
||
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
||
}
|
||
return func.apply(thisArg, args);
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.times` without support for iteratee shorthands
|
||
* or max array length checks.
|
||
*
|
||
* @private
|
||
* @param {number} n The number of times to invoke `iteratee`.
|
||
* @param {Function} iteratee The function invoked per iteration.
|
||
* @returns {Array} Returns the array of results.
|
||
*/
|
||
function baseTimes(n, iteratee) {
|
||
var index = -1,
|
||
result = Array(n);
|
||
|
||
while (++index < n) {
|
||
result[index] = iteratee(index);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.unary` without support for storing metadata.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to cap arguments for.
|
||
* @returns {Function} Returns the new capped function.
|
||
*/
|
||
function baseUnary(func) {
|
||
return function(value) {
|
||
return func(value);
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Gets the value at `key` of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} [object] The object to query.
|
||
* @param {string} key The key of the property to get.
|
||
* @returns {*} Returns the property value.
|
||
*/
|
||
function getValue(object, key) {
|
||
return object == null ? undefined : object[key];
|
||
}
|
||
|
||
/**
|
||
* Creates a unary function that invokes `func` with its argument transformed.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to wrap.
|
||
* @param {Function} transform The argument transform.
|
||
* @returns {Function} Returns the new function.
|
||
*/
|
||
function overArg(func, transform) {
|
||
return function(arg) {
|
||
return func(transform(arg));
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Gets the value at `key`, unless `key` is "__proto__".
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @param {string} key The key of the property to get.
|
||
* @returns {*} Returns the property value.
|
||
*/
|
||
function safeGet(object, key) {
|
||
return key == '__proto__'
|
||
? undefined
|
||
: object[key];
|
||
}
|
||
|
||
/** Used for built-in method references. */
|
||
var arrayProto = Array.prototype,
|
||
funcProto = Function.prototype,
|
||
objectProto = Object.prototype;
|
||
|
||
/** Used to detect overreaching core-js shims. */
|
||
var coreJsData = root['__core-js_shared__'];
|
||
|
||
/** Used to resolve the decompiled source of functions. */
|
||
var funcToString = funcProto.toString;
|
||
|
||
/** Used to check objects for own properties. */
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
|
||
/** Used to detect methods masquerading as native. */
|
||
var maskSrcKey = (function() {
|
||
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
||
return uid ? ('Symbol(src)_1.' + uid) : '';
|
||
}());
|
||
|
||
/**
|
||
* Used to resolve the
|
||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||
* of values.
|
||
*/
|
||
var nativeObjectToString = objectProto.toString;
|
||
|
||
/** Used to infer the `Object` constructor. */
|
||
var objectCtorString = funcToString.call(Object);
|
||
|
||
/** Used to detect if a method is native. */
|
||
var reIsNative = RegExp('^' +
|
||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||
);
|
||
|
||
/** Built-in value references. */
|
||
var Buffer = moduleExports ? root.Buffer : undefined,
|
||
Symbol = root.Symbol,
|
||
Uint8Array = root.Uint8Array,
|
||
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
|
||
getPrototype = overArg(Object.getPrototypeOf, Object),
|
||
objectCreate = Object.create,
|
||
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
||
splice = arrayProto.splice,
|
||
symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
||
|
||
var defineProperty = (function() {
|
||
try {
|
||
var func = getNative(Object, 'defineProperty');
|
||
func({}, '', {});
|
||
return func;
|
||
} catch (e) {}
|
||
}());
|
||
|
||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
||
nativeMax = Math.max,
|
||
nativeNow = Date.now;
|
||
|
||
/* Built-in method references that are verified to be native. */
|
||
var Map = getNative(root, 'Map'),
|
||
nativeCreate = getNative(Object, 'create');
|
||
|
||
/**
|
||
* The base implementation of `_.create` without support for assigning
|
||
* properties to the created object.
|
||
*
|
||
* @private
|
||
* @param {Object} proto The object to inherit from.
|
||
* @returns {Object} Returns the new object.
|
||
*/
|
||
var baseCreate = (function() {
|
||
function object() {}
|
||
return function(proto) {
|
||
if (!isObject(proto)) {
|
||
return {};
|
||
}
|
||
if (objectCreate) {
|
||
return objectCreate(proto);
|
||
}
|
||
object.prototype = proto;
|
||
var result = new object;
|
||
object.prototype = undefined;
|
||
return result;
|
||
};
|
||
}());
|
||
|
||
/**
|
||
* Creates a hash object.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function Hash(entries) {
|
||
var index = -1,
|
||
length = entries == null ? 0 : entries.length;
|
||
|
||
this.clear();
|
||
while (++index < length) {
|
||
var entry = entries[index];
|
||
this.set(entry[0], entry[1]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Removes all key-value entries from the hash.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf Hash
|
||
*/
|
||
function hashClear() {
|
||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||
this.size = 0;
|
||
}
|
||
|
||
/**
|
||
* Removes `key` and its value from the hash.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf Hash
|
||
* @param {Object} hash The hash to modify.
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function hashDelete(key) {
|
||
var result = this.has(key) && delete this.__data__[key];
|
||
this.size -= result ? 1 : 0;
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Gets the hash value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf Hash
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function hashGet(key) {
|
||
var data = this.__data__;
|
||
if (nativeCreate) {
|
||
var result = data[key];
|
||
return result === HASH_UNDEFINED ? undefined : result;
|
||
}
|
||
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
||
}
|
||
|
||
/**
|
||
* Checks if a hash value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf Hash
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function hashHas(key) {
|
||
var data = this.__data__;
|
||
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
||
}
|
||
|
||
/**
|
||
* Sets the hash `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf Hash
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the hash instance.
|
||
*/
|
||
function hashSet(key, value) {
|
||
var data = this.__data__;
|
||
this.size += this.has(key) ? 0 : 1;
|
||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||
return this;
|
||
}
|
||
|
||
// Add methods to `Hash`.
|
||
Hash.prototype.clear = hashClear;
|
||
Hash.prototype['delete'] = hashDelete;
|
||
Hash.prototype.get = hashGet;
|
||
Hash.prototype.has = hashHas;
|
||
Hash.prototype.set = hashSet;
|
||
|
||
/**
|
||
* Creates an list cache object.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function ListCache(entries) {
|
||
var index = -1,
|
||
length = entries == null ? 0 : entries.length;
|
||
|
||
this.clear();
|
||
while (++index < length) {
|
||
var entry = entries[index];
|
||
this.set(entry[0], entry[1]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Removes all key-value entries from the list cache.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf ListCache
|
||
*/
|
||
function listCacheClear() {
|
||
this.__data__ = [];
|
||
this.size = 0;
|
||
}
|
||
|
||
/**
|
||
* Removes `key` and its value from the list cache.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function listCacheDelete(key) {
|
||
var data = this.__data__,
|
||
index = assocIndexOf(data, key);
|
||
|
||
if (index < 0) {
|
||
return false;
|
||
}
|
||
var lastIndex = data.length - 1;
|
||
if (index == lastIndex) {
|
||
data.pop();
|
||
} else {
|
||
splice.call(data, index, 1);
|
||
}
|
||
--this.size;
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* Gets the list cache value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function listCacheGet(key) {
|
||
var data = this.__data__,
|
||
index = assocIndexOf(data, key);
|
||
|
||
return index < 0 ? undefined : data[index][1];
|
||
}
|
||
|
||
/**
|
||
* Checks if a list cache value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function listCacheHas(key) {
|
||
return assocIndexOf(this.__data__, key) > -1;
|
||
}
|
||
|
||
/**
|
||
* Sets the list cache `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf ListCache
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the list cache instance.
|
||
*/
|
||
function listCacheSet(key, value) {
|
||
var data = this.__data__,
|
||
index = assocIndexOf(data, key);
|
||
|
||
if (index < 0) {
|
||
++this.size;
|
||
data.push([key, value]);
|
||
} else {
|
||
data[index][1] = value;
|
||
}
|
||
return this;
|
||
}
|
||
|
||
// Add methods to `ListCache`.
|
||
ListCache.prototype.clear = listCacheClear;
|
||
ListCache.prototype['delete'] = listCacheDelete;
|
||
ListCache.prototype.get = listCacheGet;
|
||
ListCache.prototype.has = listCacheHas;
|
||
ListCache.prototype.set = listCacheSet;
|
||
|
||
/**
|
||
* Creates a map cache object to store key-value pairs.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function MapCache(entries) {
|
||
var index = -1,
|
||
length = entries == null ? 0 : entries.length;
|
||
|
||
this.clear();
|
||
while (++index < length) {
|
||
var entry = entries[index];
|
||
this.set(entry[0], entry[1]);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Removes all key-value entries from the map.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf MapCache
|
||
*/
|
||
function mapCacheClear() {
|
||
this.size = 0;
|
||
this.__data__ = {
|
||
'hash': new Hash,
|
||
'map': new (Map || ListCache),
|
||
'string': new Hash
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Removes `key` and its value from the map.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function mapCacheDelete(key) {
|
||
var result = getMapData(this, key)['delete'](key);
|
||
this.size -= result ? 1 : 0;
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Gets the map value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function mapCacheGet(key) {
|
||
return getMapData(this, key).get(key);
|
||
}
|
||
|
||
/**
|
||
* Checks if a map value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function mapCacheHas(key) {
|
||
return getMapData(this, key).has(key);
|
||
}
|
||
|
||
/**
|
||
* Sets the map `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf MapCache
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the map cache instance.
|
||
*/
|
||
function mapCacheSet(key, value) {
|
||
var data = getMapData(this, key),
|
||
size = data.size;
|
||
|
||
data.set(key, value);
|
||
this.size += data.size == size ? 0 : 1;
|
||
return this;
|
||
}
|
||
|
||
// Add methods to `MapCache`.
|
||
MapCache.prototype.clear = mapCacheClear;
|
||
MapCache.prototype['delete'] = mapCacheDelete;
|
||
MapCache.prototype.get = mapCacheGet;
|
||
MapCache.prototype.has = mapCacheHas;
|
||
MapCache.prototype.set = mapCacheSet;
|
||
|
||
/**
|
||
* Creates a stack cache object to store key-value pairs.
|
||
*
|
||
* @private
|
||
* @constructor
|
||
* @param {Array} [entries] The key-value pairs to cache.
|
||
*/
|
||
function Stack(entries) {
|
||
var data = this.__data__ = new ListCache(entries);
|
||
this.size = data.size;
|
||
}
|
||
|
||
/**
|
||
* Removes all key-value entries from the stack.
|
||
*
|
||
* @private
|
||
* @name clear
|
||
* @memberOf Stack
|
||
*/
|
||
function stackClear() {
|
||
this.__data__ = new ListCache;
|
||
this.size = 0;
|
||
}
|
||
|
||
/**
|
||
* Removes `key` and its value from the stack.
|
||
*
|
||
* @private
|
||
* @name delete
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the value to remove.
|
||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||
*/
|
||
function stackDelete(key) {
|
||
var data = this.__data__,
|
||
result = data['delete'](key);
|
||
|
||
this.size = data.size;
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Gets the stack value for `key`.
|
||
*
|
||
* @private
|
||
* @name get
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the value to get.
|
||
* @returns {*} Returns the entry value.
|
||
*/
|
||
function stackGet(key) {
|
||
return this.__data__.get(key);
|
||
}
|
||
|
||
/**
|
||
* Checks if a stack value for `key` exists.
|
||
*
|
||
* @private
|
||
* @name has
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the entry to check.
|
||
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||
*/
|
||
function stackHas(key) {
|
||
return this.__data__.has(key);
|
||
}
|
||
|
||
/**
|
||
* Sets the stack `key` to `value`.
|
||
*
|
||
* @private
|
||
* @name set
|
||
* @memberOf Stack
|
||
* @param {string} key The key of the value to set.
|
||
* @param {*} value The value to set.
|
||
* @returns {Object} Returns the stack cache instance.
|
||
*/
|
||
function stackSet(key, value) {
|
||
var data = this.__data__;
|
||
if (data instanceof ListCache) {
|
||
var pairs = data.__data__;
|
||
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||
pairs.push([key, value]);
|
||
this.size = ++data.size;
|
||
return this;
|
||
}
|
||
data = this.__data__ = new MapCache(pairs);
|
||
}
|
||
data.set(key, value);
|
||
this.size = data.size;
|
||
return this;
|
||
}
|
||
|
||
// Add methods to `Stack`.
|
||
Stack.prototype.clear = stackClear;
|
||
Stack.prototype['delete'] = stackDelete;
|
||
Stack.prototype.get = stackGet;
|
||
Stack.prototype.has = stackHas;
|
||
Stack.prototype.set = stackSet;
|
||
|
||
/**
|
||
* Creates an array of the enumerable property names of the array-like `value`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @param {boolean} inherited Specify returning inherited property names.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function arrayLikeKeys(value, inherited) {
|
||
var isArr = isArray(value),
|
||
isArg = !isArr && isArguments(value),
|
||
isBuff = !isArr && !isArg && isBuffer(value),
|
||
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
||
skipIndexes = isArr || isArg || isBuff || isType,
|
||
result = skipIndexes ? baseTimes(value.length, String) : [],
|
||
length = result.length;
|
||
|
||
for (var key in value) {
|
||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||
!(skipIndexes && (
|
||
// Safari 9 has enumerable `arguments.length` in strict mode.
|
||
key == 'length' ||
|
||
// Node.js 0.10 has enumerable non-index properties on buffers.
|
||
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
||
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||
// Skip index properties.
|
||
isIndex(key, length)
|
||
))) {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* This function is like `assignValue` except that it doesn't assign
|
||
* `undefined` values.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to modify.
|
||
* @param {string} key The key of the property to assign.
|
||
* @param {*} value The value to assign.
|
||
*/
|
||
function assignMergeValue(object, key, value) {
|
||
if ((value !== undefined && !eq(object[key], value)) ||
|
||
(value === undefined && !(key in object))) {
|
||
baseAssignValue(object, key, value);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
* for equality comparisons.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to modify.
|
||
* @param {string} key The key of the property to assign.
|
||
* @param {*} value The value to assign.
|
||
*/
|
||
function assignValue(object, key, value) {
|
||
var objValue = object[key];
|
||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||
(value === undefined && !(key in object))) {
|
||
baseAssignValue(object, key, value);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
||
*
|
||
* @private
|
||
* @param {Array} array The array to inspect.
|
||
* @param {*} key The key to search for.
|
||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||
*/
|
||
function assocIndexOf(array, key) {
|
||
var length = array.length;
|
||
while (length--) {
|
||
if (eq(array[length][0], key)) {
|
||
return length;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `assignValue` and `assignMergeValue` without
|
||
* value checks.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to modify.
|
||
* @param {string} key The key of the property to assign.
|
||
* @param {*} value The value to assign.
|
||
*/
|
||
function baseAssignValue(object, key, value) {
|
||
if (key == '__proto__' && defineProperty) {
|
||
defineProperty(object, key, {
|
||
'configurable': true,
|
||
'enumerable': true,
|
||
'value': value,
|
||
'writable': true
|
||
});
|
||
} else {
|
||
object[key] = value;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `baseForOwn` which iterates over `object`
|
||
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
||
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to iterate over.
|
||
* @param {Function} iteratee The function invoked per iteration.
|
||
* @param {Function} keysFunc The function to get the keys of `object`.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
var baseFor = createBaseFor();
|
||
|
||
/**
|
||
* The base implementation of `getTag` without fallbacks for buggy environments.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @returns {string} Returns the `toStringTag`.
|
||
*/
|
||
function baseGetTag(value) {
|
||
if (value == null) {
|
||
return value === undefined ? undefinedTag : nullTag;
|
||
}
|
||
return (symToStringTag && symToStringTag in Object(value))
|
||
? getRawTag(value)
|
||
: objectToString(value);
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.isArguments`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||
*/
|
||
function baseIsArguments(value) {
|
||
return isObjectLike(value) && baseGetTag(value) == argsTag;
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.isNative` without bad shim checks.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a native function,
|
||
* else `false`.
|
||
*/
|
||
function baseIsNative(value) {
|
||
if (!isObject(value) || isMasked(value)) {
|
||
return false;
|
||
}
|
||
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
||
return pattern.test(toSource(value));
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
||
*/
|
||
function baseIsTypedArray(value) {
|
||
return isObjectLike(value) &&
|
||
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function baseKeysIn(object) {
|
||
if (!isObject(object)) {
|
||
return nativeKeysIn(object);
|
||
}
|
||
var isProto = isPrototype(object),
|
||
result = [];
|
||
|
||
for (var key in object) {
|
||
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.merge` without support for multiple sources.
|
||
*
|
||
* @private
|
||
* @param {Object} object The destination object.
|
||
* @param {Object} source The source object.
|
||
* @param {number} srcIndex The index of `source`.
|
||
* @param {Function} [customizer] The function to customize merged values.
|
||
* @param {Object} [stack] Tracks traversed source values and their merged
|
||
* counterparts.
|
||
*/
|
||
function baseMerge(object, source, srcIndex, customizer, stack) {
|
||
if (object === source) {
|
||
return;
|
||
}
|
||
baseFor(source, function(srcValue, key) {
|
||
if (isObject(srcValue)) {
|
||
stack || (stack = new Stack);
|
||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||
}
|
||
else {
|
||
var newValue = customizer
|
||
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
|
||
: undefined;
|
||
|
||
if (newValue === undefined) {
|
||
newValue = srcValue;
|
||
}
|
||
assignMergeValue(object, key, newValue);
|
||
}
|
||
}, keysIn);
|
||
}
|
||
|
||
/**
|
||
* A specialized version of `baseMerge` for arrays and objects which performs
|
||
* deep merges and tracks traversed objects enabling objects with circular
|
||
* references to be merged.
|
||
*
|
||
* @private
|
||
* @param {Object} object The destination object.
|
||
* @param {Object} source The source object.
|
||
* @param {string} key The key of the value to merge.
|
||
* @param {number} srcIndex The index of `source`.
|
||
* @param {Function} mergeFunc The function to merge values.
|
||
* @param {Function} [customizer] The function to customize assigned values.
|
||
* @param {Object} [stack] Tracks traversed source values and their merged
|
||
* counterparts.
|
||
*/
|
||
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
||
var objValue = safeGet(object, key),
|
||
srcValue = safeGet(source, key),
|
||
stacked = stack.get(srcValue);
|
||
|
||
if (stacked) {
|
||
assignMergeValue(object, key, stacked);
|
||
return;
|
||
}
|
||
var newValue = customizer
|
||
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||
: undefined;
|
||
|
||
var isCommon = newValue === undefined;
|
||
|
||
if (isCommon) {
|
||
var isArr = isArray(srcValue),
|
||
isBuff = !isArr && isBuffer(srcValue),
|
||
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
||
|
||
newValue = srcValue;
|
||
if (isArr || isBuff || isTyped) {
|
||
if (isArray(objValue)) {
|
||
newValue = objValue;
|
||
}
|
||
else if (isArrayLikeObject(objValue)) {
|
||
newValue = copyArray(objValue);
|
||
}
|
||
else if (isBuff) {
|
||
isCommon = false;
|
||
newValue = cloneBuffer(srcValue, true);
|
||
}
|
||
else if (isTyped) {
|
||
isCommon = false;
|
||
newValue = cloneTypedArray(srcValue, true);
|
||
}
|
||
else {
|
||
newValue = [];
|
||
}
|
||
}
|
||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||
newValue = objValue;
|
||
if (isArguments(objValue)) {
|
||
newValue = toPlainObject(objValue);
|
||
}
|
||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||
newValue = initCloneObject(srcValue);
|
||
}
|
||
}
|
||
else {
|
||
isCommon = false;
|
||
}
|
||
}
|
||
if (isCommon) {
|
||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||
stack.set(srcValue, newValue);
|
||
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
||
stack['delete'](srcValue);
|
||
}
|
||
assignMergeValue(object, key, newValue);
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to apply a rest parameter to.
|
||
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||
* @returns {Function} Returns the new function.
|
||
*/
|
||
function baseRest(func, start) {
|
||
return setToString(overRest(func, start, identity), func + '');
|
||
}
|
||
|
||
/**
|
||
* The base implementation of `setToString` without support for hot loop shorting.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to modify.
|
||
* @param {Function} string The `toString` result.
|
||
* @returns {Function} Returns `func`.
|
||
*/
|
||
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
||
return defineProperty(func, 'toString', {
|
||
'configurable': true,
|
||
'enumerable': false,
|
||
'value': constant(string),
|
||
'writable': true
|
||
});
|
||
};
|
||
|
||
/**
|
||
* Creates a clone of `buffer`.
|
||
*
|
||
* @private
|
||
* @param {Buffer} buffer The buffer to clone.
|
||
* @param {boolean} [isDeep] Specify a deep clone.
|
||
* @returns {Buffer} Returns the cloned buffer.
|
||
*/
|
||
function cloneBuffer(buffer, isDeep) {
|
||
if (isDeep) {
|
||
return buffer.slice();
|
||
}
|
||
var length = buffer.length,
|
||
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||
|
||
buffer.copy(result);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Creates a clone of `arrayBuffer`.
|
||
*
|
||
* @private
|
||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||
*/
|
||
function cloneArrayBuffer(arrayBuffer) {
|
||
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
||
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Creates a clone of `typedArray`.
|
||
*
|
||
* @private
|
||
* @param {Object} typedArray The typed array to clone.
|
||
* @param {boolean} [isDeep] Specify a deep clone.
|
||
* @returns {Object} Returns the cloned typed array.
|
||
*/
|
||
function cloneTypedArray(typedArray, isDeep) {
|
||
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
||
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
||
}
|
||
|
||
/**
|
||
* Copies the values of `source` to `array`.
|
||
*
|
||
* @private
|
||
* @param {Array} source The array to copy values from.
|
||
* @param {Array} [array=[]] The array to copy values to.
|
||
* @returns {Array} Returns `array`.
|
||
*/
|
||
function copyArray(source, array) {
|
||
var index = -1,
|
||
length = source.length;
|
||
|
||
array || (array = Array(length));
|
||
while (++index < length) {
|
||
array[index] = source[index];
|
||
}
|
||
return array;
|
||
}
|
||
|
||
/**
|
||
* Copies properties of `source` to `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} source The object to copy properties from.
|
||
* @param {Array} props The property identifiers to copy.
|
||
* @param {Object} [object={}] The object to copy properties to.
|
||
* @param {Function} [customizer] The function to customize copied values.
|
||
* @returns {Object} Returns `object`.
|
||
*/
|
||
function copyObject(source, props, object, customizer) {
|
||
var isNew = !object;
|
||
object || (object = {});
|
||
|
||
var index = -1,
|
||
length = props.length;
|
||
|
||
while (++index < length) {
|
||
var key = props[index];
|
||
|
||
var newValue = customizer
|
||
? customizer(object[key], source[key], key, object, source)
|
||
: undefined;
|
||
|
||
if (newValue === undefined) {
|
||
newValue = source[key];
|
||
}
|
||
if (isNew) {
|
||
baseAssignValue(object, key, newValue);
|
||
} else {
|
||
assignValue(object, key, newValue);
|
||
}
|
||
}
|
||
return object;
|
||
}
|
||
|
||
/**
|
||
* Creates a function like `_.assign`.
|
||
*
|
||
* @private
|
||
* @param {Function} assigner The function to assign values.
|
||
* @returns {Function} Returns the new assigner function.
|
||
*/
|
||
function createAssigner(assigner) {
|
||
return baseRest(function(object, sources) {
|
||
var index = -1,
|
||
length = sources.length,
|
||
customizer = length > 1 ? sources[length - 1] : undefined,
|
||
guard = length > 2 ? sources[2] : undefined;
|
||
|
||
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
||
? (length--, customizer)
|
||
: undefined;
|
||
|
||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||
customizer = length < 3 ? undefined : customizer;
|
||
length = 1;
|
||
}
|
||
object = Object(object);
|
||
while (++index < length) {
|
||
var source = sources[index];
|
||
if (source) {
|
||
assigner(object, source, index, customizer);
|
||
}
|
||
}
|
||
return object;
|
||
});
|
||
}
|
||
|
||
/**
|
||
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
||
*
|
||
* @private
|
||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||
* @returns {Function} Returns the new base function.
|
||
*/
|
||
function createBaseFor(fromRight) {
|
||
return function(object, iteratee, keysFunc) {
|
||
var index = -1,
|
||
iterable = Object(object),
|
||
props = keysFunc(object),
|
||
length = props.length;
|
||
|
||
while (length--) {
|
||
var key = props[fromRight ? length : ++index];
|
||
if (iteratee(iterable[key], key, iterable) === false) {
|
||
break;
|
||
}
|
||
}
|
||
return object;
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Gets the data for `map`.
|
||
*
|
||
* @private
|
||
* @param {Object} map The map to query.
|
||
* @param {string} key The reference key.
|
||
* @returns {*} Returns the map data.
|
||
*/
|
||
function getMapData(map, key) {
|
||
var data = map.__data__;
|
||
return isKeyable(key)
|
||
? data[typeof key == 'string' ? 'string' : 'hash']
|
||
: data.map;
|
||
}
|
||
|
||
/**
|
||
* Gets the native function at `key` of `object`.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @param {string} key The key of the method to get.
|
||
* @returns {*} Returns the function if it's native, else `undefined`.
|
||
*/
|
||
function getNative(object, key) {
|
||
var value = getValue(object, key);
|
||
return baseIsNative(value) ? value : undefined;
|
||
}
|
||
|
||
/**
|
||
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to query.
|
||
* @returns {string} Returns the raw `toStringTag`.
|
||
*/
|
||
function getRawTag(value) {
|
||
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
||
tag = value[symToStringTag];
|
||
|
||
try {
|
||
value[symToStringTag] = undefined;
|
||
var unmasked = true;
|
||
} catch (e) {}
|
||
|
||
var result = nativeObjectToString.call(value);
|
||
if (unmasked) {
|
||
if (isOwn) {
|
||
value[symToStringTag] = tag;
|
||
} else {
|
||
delete value[symToStringTag];
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Initializes an object clone.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to clone.
|
||
* @returns {Object} Returns the initialized clone.
|
||
*/
|
||
function initCloneObject(object) {
|
||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||
? baseCreate(getPrototype(object))
|
||
: {};
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is a valid array-like index.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||
*/
|
||
function isIndex(value, length) {
|
||
var type = typeof value;
|
||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||
|
||
return !!length &&
|
||
(type == 'number' ||
|
||
(type != 'symbol' && reIsUint.test(value))) &&
|
||
(value > -1 && value % 1 == 0 && value < length);
|
||
}
|
||
|
||
/**
|
||
* Checks if the given arguments are from an iteratee call.
|
||
*
|
||
* @private
|
||
* @param {*} value The potential iteratee value argument.
|
||
* @param {*} index The potential iteratee index or key argument.
|
||
* @param {*} object The potential iteratee object argument.
|
||
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
||
* else `false`.
|
||
*/
|
||
function isIterateeCall(value, index, object) {
|
||
if (!isObject(object)) {
|
||
return false;
|
||
}
|
||
var type = typeof index;
|
||
if (type == 'number'
|
||
? (isArrayLike(object) && isIndex(index, object.length))
|
||
: (type == 'string' && index in object)
|
||
) {
|
||
return eq(object[index], value);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is suitable for use as unique object key.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
||
*/
|
||
function isKeyable(value) {
|
||
var type = typeof value;
|
||
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||
? (value !== '__proto__')
|
||
: (value === null);
|
||
}
|
||
|
||
/**
|
||
* Checks if `func` has its source masked.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to check.
|
||
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
||
*/
|
||
function isMasked(func) {
|
||
return !!maskSrcKey && (maskSrcKey in func);
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is likely a prototype object.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
||
*/
|
||
function isPrototype(value) {
|
||
var Ctor = value && value.constructor,
|
||
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
|
||
|
||
return value === proto;
|
||
}
|
||
|
||
/**
|
||
* This function is like
|
||
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||
* except that it includes inherited enumerable properties.
|
||
*
|
||
* @private
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
*/
|
||
function nativeKeysIn(object) {
|
||
var result = [];
|
||
if (object != null) {
|
||
for (var key in Object(object)) {
|
||
result.push(key);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Converts `value` to a string using `Object.prototype.toString`.
|
||
*
|
||
* @private
|
||
* @param {*} value The value to convert.
|
||
* @returns {string} Returns the converted string.
|
||
*/
|
||
function objectToString(value) {
|
||
return nativeObjectToString.call(value);
|
||
}
|
||
|
||
/**
|
||
* A specialized version of `baseRest` which transforms the rest array.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to apply a rest parameter to.
|
||
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||
* @param {Function} transform The rest array transform.
|
||
* @returns {Function} Returns the new function.
|
||
*/
|
||
function overRest(func, start, transform) {
|
||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||
return function() {
|
||
var args = arguments,
|
||
index = -1,
|
||
length = nativeMax(args.length - start, 0),
|
||
array = Array(length);
|
||
|
||
while (++index < length) {
|
||
array[index] = args[start + index];
|
||
}
|
||
index = -1;
|
||
var otherArgs = Array(start + 1);
|
||
while (++index < start) {
|
||
otherArgs[index] = args[index];
|
||
}
|
||
otherArgs[start] = transform(array);
|
||
return apply(func, this, otherArgs);
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Sets the `toString` method of `func` to return `string`.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to modify.
|
||
* @param {Function} string The `toString` result.
|
||
* @returns {Function} Returns `func`.
|
||
*/
|
||
var setToString = shortOut(baseSetToString);
|
||
|
||
/**
|
||
* Creates a function that'll short out and invoke `identity` instead
|
||
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
||
* milliseconds.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to restrict.
|
||
* @returns {Function} Returns the new shortable function.
|
||
*/
|
||
function shortOut(func) {
|
||
var count = 0,
|
||
lastCalled = 0;
|
||
|
||
return function() {
|
||
var stamp = nativeNow(),
|
||
remaining = HOT_SPAN - (stamp - lastCalled);
|
||
|
||
lastCalled = stamp;
|
||
if (remaining > 0) {
|
||
if (++count >= HOT_COUNT) {
|
||
return arguments[0];
|
||
}
|
||
} else {
|
||
count = 0;
|
||
}
|
||
return func.apply(undefined, arguments);
|
||
};
|
||
}
|
||
|
||
/**
|
||
* Converts `func` to its source code.
|
||
*
|
||
* @private
|
||
* @param {Function} func The function to convert.
|
||
* @returns {string} Returns the source code.
|
||
*/
|
||
function toSource(func) {
|
||
if (func != null) {
|
||
try {
|
||
return funcToString.call(func);
|
||
} catch (e) {}
|
||
try {
|
||
return (func + '');
|
||
} catch (e) {}
|
||
}
|
||
return '';
|
||
}
|
||
|
||
/**
|
||
* Performs a
|
||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||
* comparison between two values to determine if they are equivalent.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to compare.
|
||
* @param {*} other The other value to compare.
|
||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
||
* @example
|
||
*
|
||
* var object = { 'a': 1 };
|
||
* var other = { 'a': 1 };
|
||
*
|
||
* _.eq(object, object);
|
||
* // => true
|
||
*
|
||
* _.eq(object, other);
|
||
* // => false
|
||
*
|
||
* _.eq('a', 'a');
|
||
* // => true
|
||
*
|
||
* _.eq('a', Object('a'));
|
||
* // => false
|
||
*
|
||
* _.eq(NaN, NaN);
|
||
* // => true
|
||
*/
|
||
function eq(value, other) {
|
||
return value === other || (value !== value && other !== other);
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is likely an `arguments` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||
* else `false`.
|
||
* @example
|
||
*
|
||
* _.isArguments(function() { return arguments; }());
|
||
* // => true
|
||
*
|
||
* _.isArguments([1, 2, 3]);
|
||
* // => false
|
||
*/
|
||
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
||
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||
!propertyIsEnumerable.call(value, 'callee');
|
||
};
|
||
|
||
/**
|
||
* Checks if `value` is classified as an `Array` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
||
* @example
|
||
*
|
||
* _.isArray([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isArray(document.body.children);
|
||
* // => false
|
||
*
|
||
* _.isArray('abc');
|
||
* // => false
|
||
*
|
||
* _.isArray(_.noop);
|
||
* // => false
|
||
*/
|
||
var isArray = Array.isArray;
|
||
|
||
/**
|
||
* Checks if `value` is array-like. A value is considered array-like if it's
|
||
* not a function and has a `value.length` that's an integer greater than or
|
||
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||
* @example
|
||
*
|
||
* _.isArrayLike([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isArrayLike(document.body.children);
|
||
* // => true
|
||
*
|
||
* _.isArrayLike('abc');
|
||
* // => true
|
||
*
|
||
* _.isArrayLike(_.noop);
|
||
* // => false
|
||
*/
|
||
function isArrayLike(value) {
|
||
return value != null && isLength(value.length) && !isFunction(value);
|
||
}
|
||
|
||
/**
|
||
* This method is like `_.isArrayLike` except that it also checks if `value`
|
||
* is an object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
||
* else `false`.
|
||
* @example
|
||
*
|
||
* _.isArrayLikeObject([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isArrayLikeObject(document.body.children);
|
||
* // => true
|
||
*
|
||
* _.isArrayLikeObject('abc');
|
||
* // => false
|
||
*
|
||
* _.isArrayLikeObject(_.noop);
|
||
* // => false
|
||
*/
|
||
function isArrayLikeObject(value) {
|
||
return isObjectLike(value) && isArrayLike(value);
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is a buffer.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.3.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
||
* @example
|
||
*
|
||
* _.isBuffer(new Buffer(2));
|
||
* // => true
|
||
*
|
||
* _.isBuffer(new Uint8Array(2));
|
||
* // => false
|
||
*/
|
||
var isBuffer = nativeIsBuffer || stubFalse;
|
||
|
||
/**
|
||
* Checks if `value` is classified as a `Function` object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
||
* @example
|
||
*
|
||
* _.isFunction(_);
|
||
* // => true
|
||
*
|
||
* _.isFunction(/abc/);
|
||
* // => false
|
||
*/
|
||
function isFunction(value) {
|
||
if (!isObject(value)) {
|
||
return false;
|
||
}
|
||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
||
var tag = baseGetTag(value);
|
||
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is a valid array-like length.
|
||
*
|
||
* **Note:** This method is loosely based on
|
||
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
||
* @example
|
||
*
|
||
* _.isLength(3);
|
||
* // => true
|
||
*
|
||
* _.isLength(Number.MIN_VALUE);
|
||
* // => false
|
||
*
|
||
* _.isLength(Infinity);
|
||
* // => false
|
||
*
|
||
* _.isLength('3');
|
||
* // => false
|
||
*/
|
||
function isLength(value) {
|
||
return typeof value == 'number' &&
|
||
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is the
|
||
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.1.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
||
* @example
|
||
*
|
||
* _.isObject({});
|
||
* // => true
|
||
*
|
||
* _.isObject([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isObject(_.noop);
|
||
* // => true
|
||
*
|
||
* _.isObject(null);
|
||
* // => false
|
||
*/
|
||
function isObject(value) {
|
||
var type = typeof value;
|
||
return value != null && (type == 'object' || type == 'function');
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
||
* and has a `typeof` result of "object".
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
||
* @example
|
||
*
|
||
* _.isObjectLike({});
|
||
* // => true
|
||
*
|
||
* _.isObjectLike([1, 2, 3]);
|
||
* // => true
|
||
*
|
||
* _.isObjectLike(_.noop);
|
||
* // => false
|
||
*
|
||
* _.isObjectLike(null);
|
||
* // => false
|
||
*/
|
||
function isObjectLike(value) {
|
||
return value != null && typeof value == 'object';
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is a plain object, that is, an object created by the
|
||
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.8.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
||
* @example
|
||
*
|
||
* function Foo() {
|
||
* this.a = 1;
|
||
* }
|
||
*
|
||
* _.isPlainObject(new Foo);
|
||
* // => false
|
||
*
|
||
* _.isPlainObject([1, 2, 3]);
|
||
* // => false
|
||
*
|
||
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
||
* // => true
|
||
*
|
||
* _.isPlainObject(Object.create(null));
|
||
* // => true
|
||
*/
|
||
function isPlainObject(value) {
|
||
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
||
return false;
|
||
}
|
||
var proto = getPrototype(value);
|
||
if (proto === null) {
|
||
return true;
|
||
}
|
||
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
||
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
||
funcToString.call(Ctor) == objectCtorString;
|
||
}
|
||
|
||
/**
|
||
* Checks if `value` is classified as a typed array.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to check.
|
||
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
||
* @example
|
||
*
|
||
* _.isTypedArray(new Uint8Array);
|
||
* // => true
|
||
*
|
||
* _.isTypedArray([]);
|
||
* // => false
|
||
*/
|
||
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
||
|
||
/**
|
||
* Converts `value` to a plain object flattening inherited enumerable string
|
||
* keyed properties of `value` to own properties of the plain object.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.0.0
|
||
* @category Lang
|
||
* @param {*} value The value to convert.
|
||
* @returns {Object} Returns the converted plain object.
|
||
* @example
|
||
*
|
||
* function Foo() {
|
||
* this.b = 2;
|
||
* }
|
||
*
|
||
* Foo.prototype.c = 3;
|
||
*
|
||
* _.assign({ 'a': 1 }, new Foo);
|
||
* // => { 'a': 1, 'b': 2 }
|
||
*
|
||
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
|
||
* // => { 'a': 1, 'b': 2, 'c': 3 }
|
||
*/
|
||
function toPlainObject(value) {
|
||
return copyObject(value, keysIn(value));
|
||
}
|
||
|
||
/**
|
||
* Creates an array of the own and inherited enumerable property names of `object`.
|
||
*
|
||
* **Note:** Non-object values are coerced to objects.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 3.0.0
|
||
* @category Object
|
||
* @param {Object} object The object to query.
|
||
* @returns {Array} Returns the array of property names.
|
||
* @example
|
||
*
|
||
* function Foo() {
|
||
* this.a = 1;
|
||
* this.b = 2;
|
||
* }
|
||
*
|
||
* Foo.prototype.c = 3;
|
||
*
|
||
* _.keysIn(new Foo);
|
||
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
||
*/
|
||
function keysIn(object) {
|
||
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
||
}
|
||
|
||
/**
|
||
* This method is like `_.assign` except that it recursively merges own and
|
||
* inherited enumerable string keyed properties of source objects into the
|
||
* destination object. Source properties that resolve to `undefined` are
|
||
* skipped if a destination value exists. Array and plain object properties
|
||
* are merged recursively. Other objects and value types are overridden by
|
||
* assignment. Source objects are applied from left to right. Subsequent
|
||
* sources overwrite property assignments of previous sources.
|
||
*
|
||
* **Note:** This method mutates `object`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 0.5.0
|
||
* @category Object
|
||
* @param {Object} object The destination object.
|
||
* @param {...Object} [sources] The source objects.
|
||
* @returns {Object} Returns `object`.
|
||
* @example
|
||
*
|
||
* var object = {
|
||
* 'a': [{ 'b': 2 }, { 'd': 4 }]
|
||
* };
|
||
*
|
||
* var other = {
|
||
* 'a': [{ 'c': 3 }, { 'e': 5 }]
|
||
* };
|
||
*
|
||
* _.merge(object, other);
|
||
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
|
||
*/
|
||
var merge = createAssigner(function(object, source, srcIndex) {
|
||
baseMerge(object, source, srcIndex);
|
||
});
|
||
|
||
/**
|
||
* Creates a function that returns `value`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 2.4.0
|
||
* @category Util
|
||
* @param {*} value The value to return from the new function.
|
||
* @returns {Function} Returns the new constant function.
|
||
* @example
|
||
*
|
||
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
||
*
|
||
* console.log(objects);
|
||
* // => [{ 'a': 1 }, { 'a': 1 }]
|
||
*
|
||
* console.log(objects[0] === objects[1]);
|
||
* // => true
|
||
*/
|
||
function constant(value) {
|
||
return function() {
|
||
return value;
|
||
};
|
||
}
|
||
|
||
/**
|
||
* This method returns the first argument it receives.
|
||
*
|
||
* @static
|
||
* @since 0.1.0
|
||
* @memberOf _
|
||
* @category Util
|
||
* @param {*} value Any value.
|
||
* @returns {*} Returns `value`.
|
||
* @example
|
||
*
|
||
* var object = { 'a': 1 };
|
||
*
|
||
* console.log(_.identity(object) === object);
|
||
* // => true
|
||
*/
|
||
function identity(value) {
|
||
return value;
|
||
}
|
||
|
||
/**
|
||
* This method returns `false`.
|
||
*
|
||
* @static
|
||
* @memberOf _
|
||
* @since 4.13.0
|
||
* @category Util
|
||
* @returns {boolean} Returns `false`.
|
||
* @example
|
||
*
|
||
* _.times(2, _.stubFalse);
|
||
* // => [false, false]
|
||
*/
|
||
function stubFalse() {
|
||
return false;
|
||
}
|
||
|
||
module.exports = merge;
|
||
});
|
||
|
||
function install(Vue) {
|
||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||
|
||
if (install.installed) return;
|
||
install.installed = true;
|
||
|
||
var finalOptions = {};
|
||
lodash_merge(finalOptions, defaultOptions, options);
|
||
|
||
plugin.options = finalOptions;
|
||
directive.options = finalOptions;
|
||
|
||
Vue.directive('tooltip', directive);
|
||
Vue.directive('close-popover', vclosepopover);
|
||
Vue.component('v-popover', Popover);
|
||
}
|
||
|
||
var VTooltip = directive;
|
||
var VClosePopover = vclosepopover;
|
||
var VPopover = Popover;
|
||
|
||
var plugin = {
|
||
install: install,
|
||
|
||
get enabled() {
|
||
return state.enabled;
|
||
},
|
||
|
||
set enabled(value) {
|
||
state.enabled = value;
|
||
}
|
||
};
|
||
|
||
// Auto-install
|
||
var GlobalVue = null;
|
||
if (typeof window !== 'undefined') {
|
||
GlobalVue = window.Vue;
|
||
} else if (typeof global !== 'undefined') {
|
||
GlobalVue = global.Vue;
|
||
}
|
||
if (GlobalVue) {
|
||
GlobalVue.use(plugin);
|
||
}
|
||
|
||
|
||
/* harmony default export */ __webpack_exports__["default"] = (plugin);
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/vue-click-outside/index.js":
|
||
/*!*************************************************!*\
|
||
!*** ./node_modules/vue-click-outside/index.js ***!
|
||
\*************************************************/
|
||
/*! no static exports found */
|
||
/***/ (function(module, exports) {
|
||
|
||
function validate(binding) {
|
||
if (typeof binding.value !== 'function') {
|
||
console.warn('[Vue-click-outside:] provided expression', binding.expression, 'is not a function.')
|
||
return false
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
function isPopup(popupItem, elements) {
|
||
if (!popupItem || !elements)
|
||
return false
|
||
|
||
for (var i = 0, len = elements.length; i < len; i++) {
|
||
try {
|
||
if (popupItem.contains(elements[i])) {
|
||
return true
|
||
}
|
||
if (elements[i].contains(popupItem)) {
|
||
return false
|
||
}
|
||
} catch(e) {
|
||
return false
|
||
}
|
||
}
|
||
|
||
return false
|
||
}
|
||
|
||
function isServer(vNode) {
|
||
return typeof vNode.componentInstance !== 'undefined' && vNode.componentInstance.$isServer
|
||
}
|
||
|
||
exports = module.exports = {
|
||
bind: function (el, binding, vNode) {
|
||
if (!validate(binding)) return
|
||
|
||
// Define Handler and cache it on the element
|
||
function handler(e) {
|
||
if (!vNode.context) return
|
||
|
||
// some components may have related popup item, on which we shall prevent the click outside event handler.
|
||
var elements = e.path || (e.composedPath && e.composedPath())
|
||
elements && elements.length > 0 && elements.unshift(e.target)
|
||
|
||
if (el.contains(e.target) || isPopup(vNode.context.popupItem, elements)) return
|
||
|
||
el.__vueClickOutside__.callback(e)
|
||
}
|
||
|
||
// add Event Listeners
|
||
el.__vueClickOutside__ = {
|
||
handler: handler,
|
||
callback: binding.value
|
||
}
|
||
!isServer(vNode) && document.addEventListener('click', handler)
|
||
},
|
||
|
||
update: function (el, binding) {
|
||
if (validate(binding)) el.__vueClickOutside__.callback = binding.value
|
||
},
|
||
|
||
unbind: function (el, binding, vNode) {
|
||
// Remove Event Listeners
|
||
!isServer(vNode) && document.removeEventListener('click', el.__vueClickOutside__.handler)
|
||
delete el.__vueClickOutside__
|
||
}
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ "./node_modules/vue-infinite-loading/dist/vue-infinite-loading.js":
|
||
/*!************************************************************************!*\
|
||
!*** ./node_modules/vue-infinite-loading/dist/vue-infinite-loading.js ***!
|
||
\************************************************************************/
|
||
/*! no static exports found */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/*!
|
||
* vue-infinite-loading v2.4.3
|
||
* (c) 2016-2018 PeachScript
|
||
* MIT License
|
||
*/
|
||
!function(t,e){ true?module.exports=e():undefined}(this,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){var i=n(6);"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);(0,n(3).default)("09280948",i,!0,{})},function(t,e,n){var i=n(8);"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);(0,n(3).default)("65938a1f",i,!0,{})},function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",i=t[3];if(!i)return n;if(e&&"function"==typeof btoa){var r=(o=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),a=i.sources.map(function(t){return"/*# sourceURL="+i.sourceRoot+t+" */"});return[n].concat(a).concat([r]).join("\n")}var o;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var i={},r=0;r<this.length;r++){var a=this[r][0];"number"==typeof a&&(i[a]=!0)}for(r=0;r<t.length;r++){var o=t[r];"number"==typeof o[0]&&i[o[0]]||(n&&!o[2]?o[2]=n:n&&(o[2]="("+o[2]+") and ("+n+")"),e.push(o))}},e}},function(t,e,n){"use strict";function i(t,e){for(var n=[],i={},r=0;r<e.length;r++){var a=e[r],o=a[0],s={id:t+":"+r,css:a[1],media:a[2],sourceMap:a[3]};i[o]?i[o].parts.push(s):n.push(i[o]={id:o,parts:[s]})}return n}n.r(e),n.d(e,"default",function(){return b});var r="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!r)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var a={},o=r&&(document.head||document.getElementsByTagName("head")[0]),s=null,l=0,d=!1,c=function(){},u=null,p="data-vue-ssr-id",f="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function b(t,e,n,r){d=n,u=r||{};var o=i(t,e);return h(o),function(e){for(var n=[],r=0;r<o.length;r++){var s=o[r];(l=a[s.id]).refs--,n.push(l)}e?h(o=i(t,e)):o=[];for(r=0;r<n.length;r++){var l;if(0===(l=n[r]).refs){for(var d=0;d<l.parts.length;d++)l.parts[d]();delete a[l.id]}}}}function h(t){for(var e=0;e<t.length;e++){var n=t[e],i=a[n.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](n.parts[r]);for(;r<n.parts.length;r++)i.parts.push(g(n.parts[r]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var o=[];for(r=0;r<n.parts.length;r++)o.push(g(n.parts[r]));a[n.id]={id:n.id,refs:1,parts:o}}}}function m(){var t=document.createElement("style");return t.type="text/css",o.appendChild(t),t}function g(t){var e,n,i=document.querySelector("style["+p+'~="'+t.id+'"]');if(i){if(d)return c;i.parentNode.removeChild(i)}if(f){var r=l++;i=s||(s=m()),e=w.bind(null,i,r,!1),n=w.bind(null,i,r,!0)}else i=m(),e=function(t,e){var n=e.css,i=e.media,r=e.sourceMap;i&&t.setAttribute("media",i);u.ssrId&&t.setAttribute(p,e.id);r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");if(t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,i),n=function(){i.parentNode.removeChild(i)};return e(t),function(i){if(i){if(i.css===t.css&&i.media===t.media&&i.sourceMap===t.sourceMap)return;e(t=i)}else n()}}var v,y=(v=[],function(t,e){return v[t]=e,v.filter(Boolean).join("\n")});function w(t,e,n,i){var r=n?"":i.css;if(t.styleSheet)t.styleSheet.cssText=y(e,r);else{var a=document.createTextNode(r),o=t.childNodes;o[e]&&t.removeChild(o[e]),o.length?t.insertBefore(a,o[e]):t.appendChild(a)}}},function(t,e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=i=function(t){return n(t)}:t.exports=i=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},i(e)}t.exports=i},function(t,e,n){"use strict";n.r(e);var i=n(0),r=n.n(i);for(var a in i)"default"!==a&&function(t){n.d(e,t,function(){return i[t]})}(a);e.default=r.a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,'.loading-wave-dots[data-v-46b20d22]{position:relative}.loading-wave-dots[data-v-46b20d22] .wave-item{position:absolute;top:50%;left:50%;display:inline-block;margin-top:-4px;width:8px;height:8px;border-radius:50%;-webkit-animation:loading-wave-dots-data-v-46b20d22 linear 2.8s infinite;animation:loading-wave-dots-data-v-46b20d22 linear 2.8s infinite}.loading-wave-dots[data-v-46b20d22] .wave-item:first-child{margin-left:-36px}.loading-wave-dots[data-v-46b20d22] .wave-item:nth-child(2){margin-left:-20px;-webkit-animation-delay:.14s;animation-delay:.14s}.loading-wave-dots[data-v-46b20d22] .wave-item:nth-child(3){margin-left:-4px;-webkit-animation-delay:.28s;animation-delay:.28s}.loading-wave-dots[data-v-46b20d22] .wave-item:nth-child(4){margin-left:12px;-webkit-animation-delay:.42s;animation-delay:.42s}.loading-wave-dots[data-v-46b20d22] .wave-item:last-child{margin-left:28px;-webkit-animation-delay:.56s;animation-delay:.56s}@-webkit-keyframes loading-wave-dots-data-v-46b20d22{0%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}10%{-webkit-transform:translateY(-6px);transform:translateY(-6px);background:#999}20%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}to{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}}@keyframes loading-wave-dots-data-v-46b20d22{0%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}10%{-webkit-transform:translateY(-6px);transform:translateY(-6px);background:#999}20%{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}to{-webkit-transform:translateY(0);transform:translateY(0);background:#bbb}}.loading-circles[data-v-46b20d22] .circle-item{width:5px;height:5px;-webkit-animation:loading-circles-data-v-46b20d22 linear .75s infinite;animation:loading-circles-data-v-46b20d22 linear .75s infinite}.loading-circles[data-v-46b20d22] .circle-item:first-child{margin-top:-14.5px;margin-left:-2.5px}.loading-circles[data-v-46b20d22] .circle-item:nth-child(2){margin-top:-11.26px;margin-left:6.26px}.loading-circles[data-v-46b20d22] .circle-item:nth-child(3){margin-top:-2.5px;margin-left:9.5px}.loading-circles[data-v-46b20d22] .circle-item:nth-child(4){margin-top:6.26px;margin-left:6.26px}.loading-circles[data-v-46b20d22] .circle-item:nth-child(5){margin-top:9.5px;margin-left:-2.5px}.loading-circles[data-v-46b20d22] .circle-item:nth-child(6){margin-top:6.26px;margin-left:-11.26px}.loading-circles[data-v-46b20d22] .circle-item:nth-child(7){margin-top:-2.5px;margin-left:-14.5px}.loading-circles[data-v-46b20d22] .circle-item:last-child{margin-top:-11.26px;margin-left:-11.26px}@-webkit-keyframes loading-circles-data-v-46b20d22{0%{background:#dfdfdf}90%{background:#505050}to{background:#dfdfdf}}@keyframes loading-circles-data-v-46b20d22{0%{background:#dfdfdf}90%{background:#505050}to{background:#dfdfdf}}.loading-bubbles[data-v-46b20d22] .bubble-item{background:#666;-webkit-animation:loading-bubbles-data-v-46b20d22 linear .75s infinite;animation:loading-bubbles-data-v-46b20d22 linear .75s infinite}.loading-bubbles[data-v-46b20d22] .bubble-item:first-child{margin-top:-12.5px;margin-left:-.5px}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(2){margin-top:-9.26px;margin-left:8.26px}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(3){margin-top:-.5px;margin-left:11.5px}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(4){margin-top:8.26px;margin-left:8.26px}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(5){margin-top:11.5px;margin-left:-.5px}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(6){margin-top:8.26px;margin-left:-9.26px}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(7){margin-top:-.5px;margin-left:-12.5px}.loading-bubbles[data-v-46b20d22] .bubble-item:last-child{margin-top:-9.26px;margin-left:-9.26px}@-webkit-keyframes loading-bubbles-data-v-46b20d22{0%{width:1px;height:1px;box-shadow:0 0 0 3px #666}90%{width:1px;height:1px;box-shadow:0 0 0 0 #666}to{width:1px;height:1px;box-shadow:0 0 0 3px #666}}@keyframes loading-bubbles-data-v-46b20d22{0%{width:1px;height:1px;box-shadow:0 0 0 3px #666}90%{width:1px;height:1px;box-shadow:0 0 0 0 #666}to{width:1px;height:1px;box-shadow:0 0 0 3px #666}}.loading-default[data-v-46b20d22]{position:relative;border:1px solid #999;-webkit-animation:loading-rotating-data-v-46b20d22 ease 1.5s infinite;animation:loading-rotating-data-v-46b20d22 ease 1.5s infinite}.loading-default[data-v-46b20d22]:before{content:"";position:absolute;display:block;top:0;left:50%;margin-top:-3px;margin-left:-3px;width:6px;height:6px;background-color:#999;border-radius:50%}.loading-spiral[data-v-46b20d22]{border:2px solid #777;border-right-color:transparent;-webkit-animation:loading-rotating-data-v-46b20d22 linear .85s infinite;animation:loading-rotating-data-v-46b20d22 linear .85s infinite}@-webkit-keyframes loading-rotating-data-v-46b20d22{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes loading-rotating-data-v-46b20d22{0%{-webkit-transform:rotate(0);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.loading-bubbles[data-v-46b20d22],.loading-circles[data-v-46b20d22]{position:relative}.loading-bubbles[data-v-46b20d22] .bubble-item,.loading-circles[data-v-46b20d22] .circle-item{position:absolute;top:50%;left:50%;display:inline-block;border-radius:50%}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(2),.loading-circles[data-v-46b20d22] .circle-item:nth-child(2){-webkit-animation-delay:93ms;animation-delay:93ms}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(3),.loading-circles[data-v-46b20d22] .circle-item:nth-child(3){-webkit-animation-delay:.186s;animation-delay:.186s}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(4),.loading-circles[data-v-46b20d22] .circle-item:nth-child(4){-webkit-animation-delay:.279s;animation-delay:.279s}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(5),.loading-circles[data-v-46b20d22] .circle-item:nth-child(5){-webkit-animation-delay:.372s;animation-delay:.372s}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(6),.loading-circles[data-v-46b20d22] .circle-item:nth-child(6){-webkit-animation-delay:.465s;animation-delay:.465s}.loading-bubbles[data-v-46b20d22] .bubble-item:nth-child(7),.loading-circles[data-v-46b20d22] .circle-item:nth-child(7){-webkit-animation-delay:.558s;animation-delay:.558s}.loading-bubbles[data-v-46b20d22] .bubble-item:last-child,.loading-circles[data-v-46b20d22] .circle-item:last-child{-webkit-animation-delay:.651s;animation-delay:.651s}',""])},function(t,e,n){"use strict";n.r(e);var i=n(1),r=n.n(i);for(var a in i)"default"!==a&&function(t){n.d(e,t,function(){return i[t]})}(a);e.default=r.a},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".infinite-loading-container[data-v-358985eb]{clear:both;text-align:center}.infinite-loading-container[data-v-358985eb] [class^=loading-]{display:inline-block;margin:5px 0;width:28px;height:28px;font-size:28px;line-height:28px;border-radius:50%}.btn-try-infinite[data-v-358985eb]{margin-top:5px;padding:5px 10px;color:#999;font-size:14px;line-height:1;background:transparent;border:1px solid #ccc;border-radius:3px;outline:none;cursor:pointer}.btn-try-infinite[data-v-358985eb]:not(:active):hover{opacity:.8}",""])},function(t,e,n){"use strict";n.r(e);var i={throttleLimit:50,loopCheckTimeout:1e3,loopCheckMaxCalls:10},r=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){return t={passive:!0},!0}});window.addEventListener("testpassive",e,e),window.remove("testpassive",e,e)}catch(t){}return t}(),a={STATE_CHANGER:["emit `loaded` and `complete` event through component instance of `$refs` may cause error, so it will be deprecated soon, please use the `$state` argument instead (`$state` just the special `$event` variable):","\ntemplate:",'<infinite-loading @infinite="infiniteHandler"></infinite-loading>',"\nscript:\n...\ninfiniteHandler($state) {\n ajax('https://www.example.com/api/news')\n .then((res) => {\n if (res.data.length) {\n $state.loaded();\n } else {\n $state.complete();\n }\n });\n}\n...","","more details: https://github.com/PeachScript/vue-infinite-loading/issues/57#issuecomment-324370549"].join("\n"),INFINITE_EVENT:"`:on-infinite` property will be deprecated soon, please use `@infinite` event instead.",IDENTIFIER:"the `reset` event will be deprecated soon, please reset this component by change the `identifier` property."},o={INFINITE_LOOP:["executed the callback function more than ".concat(i.loopCheckMaxCalls," times for a short time, it looks like searched a wrong scroll wrapper that doest not has fixed height or maximum height, please check it. If you want to force to set a element as scroll wrapper ranther than automatic searching, you can do this:"),'\n\x3c!-- add a special attribute for the real scroll wrapper --\x3e\n<div infinite-wrapper>\n ...\n \x3c!-- set force-use-infinite-wrapper --\x3e\n <infinite-loading force-use-infinite-wrapper></infinite-loading>\n</div>\nor\n<div class="infinite-wrapper">\n ...\n \x3c!-- set force-use-infinite-wrapper as css selector of the real scroll wrapper --\x3e\n <infinite-loading force-use-infinite-wrapper=".infinite-wrapper"></infinite-loading>\n</div>\n ',"more details: https://github.com/PeachScript/vue-infinite-loading/issues/55#issuecomment-316934169"].join("\n")},s={READY:0,LOADING:1,COMPLETE:2,ERROR:3},l={color:"#666",fontSize:"14px",padding:"10px 0"},d={mode:"development",props:{spinner:"default",distance:100,forceUseInfiniteWrapper:!1},system:i,slots:{noResults:"No results :(",noMore:"No more data :)",error:"Opps, something went wrong :(",errorBtnText:"Retry",spinner:""},WARNINGS:a,ERRORS:o,STATUS:s},c=n(4),u=n.n(c),p={BUBBLES:{render:function(t){return t("span",{attrs:{class:"loading-bubbles"}},Array.apply(Array,Array(8)).map(function(){return t("span",{attrs:{class:"bubble-item"}})}))}},CIRCLES:{render:function(t){return t("span",{attrs:{class:"loading-circles"}},Array.apply(Array,Array(8)).map(function(){return t("span",{attrs:{class:"circle-item"}})}))}},DEFAULT:{render:function(t){return t("i",{attrs:{class:"loading-default"}})}},SPIRAL:{render:function(t){return t("i",{attrs:{class:"loading-spiral"}})}},WAVEDOTS:{render:function(t){return t("span",{attrs:{class:"loading-wave-dots"}},Array.apply(Array,Array(5)).map(function(){return t("span",{attrs:{class:"wave-item"}})}))}}};function f(t,e,n,i,r,a,o,s){var l,d="function"==typeof t?t.options:t;if(e&&(d.render=e,d.staticRenderFns=n,d._compiled=!0),i&&(d.functional=!0),a&&(d._scopeId="data-v-"+a),o?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},d._ssrRegister=l):r&&(l=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),l)if(d.functional){d._injectStyles=l;var c=d.render;d.render=function(t,e){return l.call(e),c(t,e)}}else{var u=d.beforeCreate;d.beforeCreate=u?[].concat(u,l):[l]}return{exports:t,options:d}}var b=f({name:"Spinner",computed:{spinnerView:function(){return p[(this.$attrs.spinner||"").toUpperCase()]||this.spinnerInConfig},spinnerInConfig:function(){return d.slots.spinner&&"string"==typeof d.slots.spinner?{render:function(){return this._v(d.slots.spinner)}}:"object"===u()(d.slots.spinner)?d.slots.spinner:p[d.props.spinner.toUpperCase()]||p.DEFAULT}}},function(){var t=this.$createElement;return(this._self._c||t)(this.spinnerView,{tag:"component"})},[],!1,function(t){var e=n(5);e.__inject__&&e.__inject__(t)},"46b20d22",null);b.options.__file="Spinner.vue";var h=b.exports;function m(t){"production"!==d.mode&&console.warn("[Vue-infinite-loading warn]: ".concat(t))}function g(t){console.error("[Vue-infinite-loading error]: ".concat(t))}var v={timers:[],caches:[],throttle:function(t){var e=this;-1===this.caches.indexOf(t)&&(this.caches.push(t),this.timers.push(setTimeout(function(){t(),e.caches.splice(e.caches.indexOf(t),1),e.timers.shift()},d.system.throttleLimit)))},reset:function(){this.timers.forEach(function(t){clearTimeout(t)}),this.timers.length=0,this.caches=[]}},y={isChecked:!1,timer:null,times:0,track:function(){var t=this;this.times+=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.isChecked=!0},d.system.loopCheckTimeout),this.times>d.system.loopCheckMaxCalls&&(g(o.INFINITE_LOOP),this.isChecked=!0)}},w={key:"_infiniteScrollHeight",getScrollElm:function(t){return t===window?document.documentElement:t},save:function(t){var e=this.getScrollElm(t);e[this.key]=e.scrollHeight},restore:function(t){var e=this.getScrollElm(t);"number"==typeof e[this.key]&&(e.scrollTop=e.scrollHeight-e[this.key]+e.scrollTop),this.remove(e)},remove:function(t){void 0!==t[this.key]&&delete t[this.key]}};function x(t){return t.replace(/[A-Z]/g,function(t){return"-".concat(t.toLowerCase())})}function k(t){return t.offsetWidth+t.offsetHeight>0}var S=f({name:"InfiniteLoading",data:function(){return{scrollParent:null,scrollHandler:null,isFirstLoad:!0,status:s.READY,slots:d.slots}},components:{Spinner:h},computed:{isShowSpinner:function(){return this.status===s.LOADING},isShowError:function(){return this.status===s.ERROR},isShowNoResults:function(){return this.status===s.COMPLETE&&this.isFirstLoad},isShowNoMore:function(){return this.status===s.COMPLETE&&!this.isFirstLoad},slotStyles:function(){var t=this,e={};return Object.keys(d.slots).forEach(function(n){var i=x(n);(!t.$slots[i]&&!d.slots[n].render||t.$slots[i]&&!t.$slots[i][0].tag)&&(e[n]=l)}),e}},props:{distance:{type:Number,default:d.props.distance},spinner:String,direction:{type:String,default:"bottom"},forceUseInfiniteWrapper:{type:[Boolean,String],default:d.props.forceUseInfiniteWrapper},identifier:{default:+new Date},onInfinite:Function},watch:{identifier:function(){this.stateChanger.reset()}},mounted:function(){var t=this;this.$watch("forceUseInfiniteWrapper",function(){t.scrollParent=t.getScrollParent()},{immediate:!0}),this.scrollHandler=function(t){this.status===s.READY&&(t&&t.constructor===Event&&k(this.$el)?v.throttle(this.attemptLoad):this.attemptLoad())}.bind(this),setTimeout(this.scrollHandler,1),this.scrollParent.addEventListener("scroll",this.scrollHandler,r),this.$on("$InfiniteLoading:loaded",function(e){t.isFirstLoad=!1,"top"===t.direction&&t.$nextTick(function(){w.restore(t.scrollParent)}),t.status===s.LOADING&&t.$nextTick(t.attemptLoad.bind(null,!0)),e&&e.target===t||m(a.STATE_CHANGER)}),this.$on("$InfiniteLoading:complete",function(e){t.status=s.COMPLETE,t.$nextTick(function(){t.$forceUpdate()}),t.scrollParent.removeEventListener("scroll",t.scrollHandler,r),e&&e.target===t||m(a.STATE_CHANGER)}),this.$on("$InfiniteLoading:reset",function(e){t.status=s.READY,t.isFirstLoad=!0,w.remove(t.scrollParent),t.scrollParent.addEventListener("scroll",t.scrollHandler,r),setTimeout(function(){v.reset(),t.scrollHandler()},1),e&&e.target===t||m(a.IDENTIFIER)}),this.stateChanger={loaded:function(){t.$emit("$InfiniteLoading:loaded",{target:t})},complete:function(){t.$emit("$InfiniteLoading:complete",{target:t})},reset:function(){t.$emit("$InfiniteLoading:reset",{target:t})},error:function(){t.status=s.ERROR,v.reset()}},this.onInfinite&&m(a.INFINITE_EVENT)},deactivated:function(){this.status===s.LOADING&&(this.status=s.READY),this.scrollParent.removeEventListener("scroll",this.scrollHandler,r)},activated:function(){this.scrollParent.addEventListener("scroll",this.scrollHandler,r)},methods:{attemptLoad:function(t){var e=this;this.status!==s.COMPLETE&&k(this.$el)&&this.getCurrentDistance()<=this.distance?(this.status=s.LOADING,"top"===this.direction&&this.$nextTick(function(){w.save(e.scrollParent)}),"function"==typeof this.onInfinite?this.onInfinite.call(null,this.stateChanger):this.$emit("infinite",this.stateChanger),!t||this.forceUseInfiniteWrapper||y.isChecked||y.track()):this.status===s.LOADING&&(this.status=s.READY)},getCurrentDistance:function(){var t;"top"===this.direction?t="number"==typeof this.scrollParent.scrollTop?this.scrollParent.scrollTop:this.scrollParent.pageYOffset:t=this.$el.getBoundingClientRect().top-(this.scrollParent===window?window.innerHeight:this.scrollParent.getBoundingClientRect().bottom);return t},getScrollParent:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$el;return"string"==typeof this.forceUseInfiniteWrapper&&(t=e.querySelector(this.forceUseInfiniteWrapper)),t||("BODY"===e.tagName?t=window:!this.forceUseInfiniteWrapper&&["scroll","auto"].indexOf(getComputedStyle(e).overflowY)>-1?t=e:(e.hasAttribute("infinite-wrapper")||e.hasAttribute("data-infinite-wrapper"))&&(t=e)),t||this.getScrollParent(e.parentNode)}},destroyed:function(){!this.status!==s.COMPLETE&&(v.reset(),w.remove(this.scrollParent),this.scrollParent.removeEventListener("scroll",this.scrollHandler,r))}},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"infinite-loading-container"},[n("div",{directives:[{name:"show",rawName:"v-show",value:t.isShowSpinner,expression:"isShowSpinner"}],staticClass:"infinite-status-prompt",style:t.slotStyles.spinner},[t._t("spinner",[n("spinner",{attrs:{spinner:t.spinner}})])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.isShowNoResults,expression:"isShowNoResults"}],staticClass:"infinite-status-prompt",style:t.slotStyles.noResults},[t._t("no-results",[t.slots.noResults.render?n(t.slots.noResults,{tag:"component"}):[t._v(t._s(t.slots.noResults))]])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.isShowNoMore,expression:"isShowNoMore"}],staticClass:"infinite-status-prompt",style:t.slotStyles.noMore},[t._t("no-more",[t.slots.noMore.render?n(t.slots.noMore,{tag:"component"}):[t._v(t._s(t.slots.noMore))]])],2),t._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:t.isShowError,expression:"isShowError"}],staticClass:"infinite-status-prompt",style:t.slotStyles.error},[t._t("error",[t.slots.error.render?n(t.slots.error,{tag:"component",attrs:{trigger:t.attemptLoad}}):[t._v("\n "+t._s(t.slots.error)+"\n "),n("br"),t._v(" "),n("button",{staticClass:"btn-try-infinite",domProps:{textContent:t._s(t.slots.errorBtnText)},on:{click:t.attemptLoad}})]],{trigger:t.attemptLoad})],2)])},[],!1,function(t){var e=n(7);e.__inject__&&e.__inject__(t)},"358985eb",null);S.options.__file="InfiniteLoading.vue";var E=S.exports;function _(t){d.mode=t.config.productionTip?"development":"production"}Object.defineProperty(E,"install",{configurable:!1,enumerable:!1,value:function(t,e){Object.assign(d.props,e&&e.props),Object.assign(d.slots,e&&e.slots),Object.assign(d.system,e&&e.system),t.component("infinite-loading",E),_(t)}}),"undefined"!=typeof window&&window.Vue&&(window.Vue.component("infinite-loading",E),_(window.Vue));e.default=E}])});
|
||
|
||
/***/ })
|
||
|
||
}]);
|
||
//# sourceMappingURL=vue-3.js.map
|