You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2022/02/23 08:26:52 UTC
[myfaces-tobago] branch tobago-4.x updated: chore: Update popper js to 1.16.1
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch tobago-4.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/tobago-4.x by this push:
new 51e7612 chore: Update popper js to 1.16.1
51e7612 is described below
commit 51e7612d03cd66f02dc601ac28b781538f68eeb9
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Wed Feb 23 09:25:49 2022 +0100
chore: Update popper js to 1.16.1
issue: TOBAGO-2115
---
.../tobago/standard/popper-js/1.12.3/popper.js.map | 1 -
.../tobago/standard/popper-js/1.12.3/popper.min.js | 5 -
.../standard/popper-js/1.12.3/popper.min.js.map | 1 -
.../popper-js/{1.12.3 => 1.16.1}/popper.js | 1198 ++++++++++----------
.../tobago/standard/popper-js/1.16.1/popper.js.map | 1 +
.../tobago/standard/popper-js/1.16.1/popper.min.js | 5 +
.../standard/popper-js/1.16.1/popper.min.js.map | 1 +
.../src/main/resources/META-INF/tobago-config.xml | 4 +-
8 files changed, 615 insertions(+), 601 deletions(-)
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.js.map b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.js.map
deleted file mode 100644
index b835632..0000000
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"popper.js","sources":["../../src/utils/isNative.js","../../src/utils/debounce.js","../../src/utils/isFunction.js","../../src/utils/getStyleComputedProperty.js","../../src/utils/getParentNode.js","../../src/utils/getScrollParent.js","../../src/utils/getOffsetParent.js","../../src/utils/isOffsetContainer.js","../../src/utils/getRoot.js","../../src/utils/findCommonOffsetParent.js","../../src/utils/getScroll.js","../../src/utils/includeScroll.js","../../src/utils/getBord [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.min.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.min.js
deleted file mode 100644
index 4553f65..0000000
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.min.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- Copyright (C) Federico Zivolo 2017
- Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).
- */(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.Popper=t()})(this,function(){'use strict';function e(e){return e&&'[object Function]'==={}.toString.call(e)}function t(e,t){if(1!==e.nodeType)return[];var o=window.getComputedStyle(e,null);return t?o[t]:o}function o(e){return'HTML'===e.nodeName?e:e.parentNode||e.host}function n(e){if(!e||-1!==['HTML','BODY','#document'].indexOf(e.nodeName))return win [...]
-//# sourceMappingURL=popper.min.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.min.js.map b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.min.js.map
deleted file mode 100644
index 69e44aa..0000000
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.min.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"popper.min.js","sources":["../../src/utils/isFunction.js","../../src/utils/getStyleComputedProperty.js","../../src/utils/getParentNode.js","../../src/utils/getScrollParent.js","../../src/utils/getOffsetParent.js","../../src/utils/isOffsetContainer.js","../../src/utils/getRoot.js","../../src/utils/findCommonOffsetParent.js","../../src/utils/getScroll.js","../../src/utils/includeScroll.js","../../src/utils/getBordersSize.js","../../src/utils/getWindowSizes.js","../../s [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.js
similarity index 66%
rename from tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.js
rename to tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.js
index 1e79ec9..7ce8395 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.12.3/popper.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.js
@@ -1,6 +1,6 @@
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
- * @version 1.12.3
+ * @version 1.16.1
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
@@ -22,67 +22,38 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global.Popper = factory());
-}(this, (function () { 'use strict';
+var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
-var nativeHints = ['native code', '[object MutationObserverConstructor]'];
-
-/**
- * Determine if a function is implemented natively (as opposed to a polyfill).
- * @method
- * @memberof Popper.Utils
- * @argument {Function | undefined} fn the function to check
- * @returns {Boolean}
- */
-var isNative = (function (fn) {
- return nativeHints.some(function (hint) {
- return (fn || '').toString().indexOf(hint) > -1;
- });
-});
-
-var isBrowser = typeof window !== '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;
+const timeoutDuration = function () {
+ const longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
+ for (let i = 0; i < longerTimeoutBrowsers.length; i += 1) {
+ if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
+ return 1;
+ }
}
-}
+ return 0;
+}();
function microtaskDebounce(fn) {
- var scheduled = false;
- var i = 0;
- var elem = document.createElement('span');
-
- // MutationObserver provides a mechanism for scheduling microtasks, which
- // are scheduled *before* the next task. This gives us a way to debounce
- // a function but ensure it's called *before* the next paint.
- var observer = new MutationObserver(function () {
- fn();
- scheduled = false;
- });
-
- observer.observe(elem, { attributes: true });
-
- return function () {
- if (!scheduled) {
- scheduled = true;
- elem.setAttribute('x-index', i);
- i = i + 1; // don't use compund (+=) because it doesn't get optimized in V8
+ let called = false;
+ return () => {
+ if (called) {
+ return;
}
+ called = true;
+ window.Promise.resolve().then(() => {
+ called = false;
+ fn();
+ });
};
}
function taskDebounce(fn) {
- var scheduled = false;
- return function () {
+ let scheduled = false;
+ return () => {
if (!scheduled) {
scheduled = true;
- setTimeout(function () {
+ setTimeout(() => {
scheduled = false;
fn();
}, timeoutDuration);
@@ -90,11 +61,7 @@ function taskDebounce(fn) {
};
}
-// It's common for MutationObserver polyfills to be seen in the wild, however
-// these rely on Mutation Events which only occur when an element is connected
-// to the DOM. The algorithm used in this module does not use a connected element,
-// and so we must ensure that a *native* MutationObserver is available.
-var supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserver);
+const supportsMicroTasks = isBrowser && window.Promise;
/**
* Create a debounced version of a method, that's asynchronously deferred
@@ -105,7 +72,7 @@ var supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserv
* @argument {Function} fn
* @returns {Function}
*/
-var debounce = supportsNativeMutationObserver ? microtaskDebounce : taskDebounce;
+var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
/**
* Check if the given variable is a function
@@ -115,7 +82,7 @@ var debounce = supportsNativeMutationObserver ? microtaskDebounce : taskDebounce
* @returns {Boolean} answer to: is a function?
*/
function isFunction(functionToCheck) {
- var getType = {};
+ const getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
}
@@ -131,7 +98,8 @@ function getStyleComputedProperty(element, property) {
return [];
}
// NOTE: 1 DOM access here
- var css = window.getComputedStyle(element, null);
+ const window = element.ownerDocument.defaultView;
+ const css = window.getComputedStyle(element, null);
return property ? css[property] : css;
}
@@ -158,18 +126,21 @@ function getParentNode(element) {
*/
function getScrollParent(element) {
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
- if (!element || ['HTML', 'BODY', '#document'].indexOf(element.nodeName) !== -1) {
- return window.document.body;
+ if (!element) {
+ return document.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;
+ switch (element.nodeName) {
+ case 'HTML':
+ case 'BODY':
+ return element.ownerDocument.body;
+ case '#document':
+ return element.body;
+ }
- if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
+ // Firefox want us to check `-x` and `-y` variations as well
+ const { overflow, overflowX, overflowY } = getStyleComputedProperty(element);
+ if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
return element;
}
@@ -177,6 +148,37 @@ function getScrollParent(element) {
}
/**
+ * Returns the reference node of the reference object, or the reference object itself.
+ * @method
+ * @memberof Popper.Utils
+ * @param {Element|Object} reference - the reference element (the popper will be relative to this)
+ * @returns {Element} parent
+ */
+function getReferenceNode(reference) {
+ return reference && reference.referenceNode ? reference.referenceNode : reference;
+}
+
+const isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
+const 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
@@ -184,17 +186,28 @@ function getScrollParent(element) {
* @returns {Element} offset parent
*/
function getOffsetParent(element) {
+ if (!element) {
+ return document.documentElement;
+ }
+
+ const noOffsetParent = isIE(10) ? document.body : null;
+
// NOTE: 1 DOM access here
- var offsetParent = element && element.offsetParent;
- var nodeName = offsetParent && offsetParent.nodeName;
+ let offsetParent = element.offsetParent || null;
+ // Skip hidden elements which don't have an offsetParent
+ while (offsetParent === noOffsetParent && element.nextElementSibling) {
+ offsetParent = (element = element.nextElementSibling).offsetParent;
+ }
+
+ const nodeName = offsetParent && offsetParent.nodeName;
if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
- return window.document.documentElement;
+ return element ? element.ownerDocument.documentElement : document.documentElement;
}
- // .offsetParent will return the closest TD or TABLE in case
+ // .offsetParent will return the closest TH, TD or TABLE in case
// no offsetParent is present, I hate this job...
- if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
+ if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
return getOffsetParent(offsetParent);
}
@@ -202,8 +215,7 @@ function getOffsetParent(element) {
}
function isOffsetContainer(element) {
- var nodeName = element.nodeName;
-
+ const { nodeName } = element;
if (nodeName === 'BODY') {
return false;
}
@@ -236,22 +248,21 @@ function getRoot(node) {
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 window.document.documentElement;
+ 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;
+ const order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
+ const start = order ? element1 : element2;
+ const end = order ? element2 : element1;
// Get common ancestor container
- var range = document.createRange();
+ const range = document.createRange();
range.setStart(start, 0);
range.setEnd(end, 0);
- var commonAncestorContainer = range.commonAncestorContainer;
+ const { commonAncestorContainer } = range;
// Both nodes are inside #document
-
if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
if (isOffsetContainer(commonAncestorContainer)) {
return commonAncestorContainer;
@@ -261,7 +272,7 @@ function findCommonOffsetParent(element1, element2) {
}
// one of the nodes is inside shadowDOM, find which one
- var element1root = getRoot(element1);
+ const element1root = getRoot(element1);
if (element1root.host) {
return findCommonOffsetParent(element1root.host, element2);
} else {
@@ -277,15 +288,13 @@ function findCommonOffsetParent(element1, element2) {
* @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;
+function getScroll(element, side = 'top') {
+ const upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
+ const nodeName = element.nodeName;
if (nodeName === 'BODY' || nodeName === 'HTML') {
- var html = window.document.documentElement;
- var scrollingElement = window.document.scrollingElement || html;
+ const html = element.ownerDocument.documentElement;
+ const scrollingElement = element.ownerDocument.scrollingElement || html;
return scrollingElement[upperSide];
}
@@ -301,12 +310,10 @@ function getScroll(element) {
* @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;
+function includeScroll(rect, element, subtract = false) {
+ const scrollTop = getScroll(element, 'top');
+ const scrollLeft = getScroll(element, 'left');
+ const modifier = subtract ? -1 : 1;
rect.top += scrollTop * modifier;
rect.bottom += scrollTop * modifier;
rect.left += scrollLeft * modifier;
@@ -325,35 +332,20 @@ function includeScroll(rect, element) {
*/
function getBordersSize(styles, axis) {
- var sideA = axis === 'x' ? 'Left' : 'Top';
- var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
+ const sideA = axis === 'x' ? 'Left' : 'Top';
+ const sideB = sideA === 'Left' ? 'Right' : 'Bottom';
- return +styles['border' + sideA + 'Width'].split('px')[0] + +styles['border' + sideB + 'Width'].split('px')[0];
+ return parseFloat(styles[`border${sideA}Width`]) + parseFloat(styles[`border${sideB}Width`]);
}
-/**
- * Tells if you are running Internet Explorer 10
- * @method
- * @memberof Popper.Utils
- * @returns {Boolean} isIE10
- */
-var isIE10 = undefined;
-
-var isIE10$1 = function () {
- if (isIE10 === undefined) {
- isIE10 = navigator.appVersion.indexOf('MSIE 10') !== -1;
- }
- return isIE10;
-};
-
function getSize(axis, body, html, computedStyle) {
- return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE10$1() ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);
+ return Math.max(body[`offset${axis}`], body[`scroll${axis}`], html[`client${axis}`], html[`offset${axis}`], html[`scroll${axis}`], isIE(10) ? parseInt(html[`offset${axis}`]) + parseInt(computedStyle[`margin${axis === 'Height' ? 'Top' : 'Left'}`]) + parseInt(computedStyle[`margin${axis === 'Height' ? 'Bottom' : 'Right'}`]) : 0);
}
-function getWindowSizes() {
- var body = window.document.body;
- var html = window.document.documentElement;
- var computedStyle = isIE10$1() && window.getComputedStyle(html);
+function getWindowSizes(document) {
+ const body = document.body;
+ const html = document.documentElement;
+ const computedStyle = isIE(10) && getComputedStyle(html);
return {
height: getSize('Height', body, html, computedStyle),
@@ -361,49 +353,6 @@ function getWindowSizes() {
};
}
-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];
@@ -440,26 +389,26 @@ function getClientRect(offsets) {
* @return {Object} client rect
*/
function getBoundingClientRect(element) {
- var rect = {};
+ let 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
- if (isIE10$1()) {
- try {
+ try {
+ if (isIE(10)) {
rect = element.getBoundingClientRect();
- var scrollTop = getScroll(element, 'top');
- var scrollLeft = getScroll(element, 'left');
+ const scrollTop = getScroll(element, 'top');
+ const scrollLeft = getScroll(element, 'left');
rect.top += scrollTop;
rect.left += scrollLeft;
rect.bottom += scrollTop;
rect.right += scrollLeft;
- } catch (err) {}
- } else {
- rect = element.getBoundingClientRect();
- }
+ } else {
+ rect = element.getBoundingClientRect();
+ }
+ } catch (e) {}
- var result = {
+ const result = {
left: rect.left,
top: rect.top,
width: rect.right - rect.left,
@@ -467,17 +416,17 @@ function getBoundingClientRect(element) {
};
// 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;
+ const sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
+ const width = sizes.width || element.clientWidth || result.width;
+ const height = sizes.height || element.clientHeight || result.height;
- var horizScrollbar = element.offsetWidth - width;
- var vertScrollbar = element.offsetHeight - height;
+ let horizScrollbar = element.offsetWidth - width;
+ let 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);
+ const styles = getStyleComputedProperty(element);
horizScrollbar -= getBordersSize(styles, 'x');
vertScrollbar -= getBordersSize(styles, 'y');
@@ -488,18 +437,23 @@ function getBoundingClientRect(element) {
return getClientRect(result);
}
-function getOffsetRectRelativeToArbitraryNode(children, parent) {
- var isIE10 = isIE10$1();
- var isHTML = parent.nodeName === 'HTML';
- var childrenRect = getBoundingClientRect(children);
- var parentRect = getBoundingClientRect(parent);
- var scrollParent = getScrollParent(children);
+function getOffsetRectRelativeToArbitraryNode(children, parent, fixedPosition = false) {
+ const isIE10 = isIE(10);
+ const isHTML = parent.nodeName === 'HTML';
+ const childrenRect = getBoundingClientRect(children);
+ const parentRect = getBoundingClientRect(parent);
+ const scrollParent = getScrollParent(children);
- var styles = getStyleComputedProperty(parent);
- var borderTopWidth = +styles.borderTopWidth.split('px')[0];
- var borderLeftWidth = +styles.borderLeftWidth.split('px')[0];
+ const styles = getStyleComputedProperty(parent);
+ const borderTopWidth = parseFloat(styles.borderTopWidth);
+ const borderLeftWidth = parseFloat(styles.borderLeftWidth);
- var offsets = getClientRect({
+ // In cases where the parent is fixed, we must ignore negative scroll in offset calc
+ if (fixedPosition && isHTML) {
+ parentRect.top = Math.max(parentRect.top, 0);
+ parentRect.left = Math.max(parentRect.left, 0);
+ }
+ let offsets = getClientRect({
top: childrenRect.top - parentRect.top - borderTopWidth,
left: childrenRect.left - parentRect.left - borderLeftWidth,
width: childrenRect.width,
@@ -513,8 +467,8 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
// 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 = +styles.marginTop.split('px')[0];
- var marginLeft = +styles.marginLeft.split('px')[0];
+ const marginTop = parseFloat(styles.marginTop);
+ const marginLeft = parseFloat(styles.marginLeft);
offsets.top -= borderTopWidth - marginTop;
offsets.bottom -= borderTopWidth - marginTop;
@@ -526,27 +480,27 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
offsets.marginLeft = marginLeft;
}
- if (isIE10 ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
+ if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
offsets = includeScroll(offsets, parent);
}
return offsets;
}
-function getViewportOffsetRectRelativeToArtbitraryNode(element) {
- var html = window.document.documentElement;
- var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
- var width = Math.max(html.clientWidth, window.innerWidth || 0);
- var height = Math.max(html.clientHeight, window.innerHeight || 0);
+function getViewportOffsetRectRelativeToArtbitraryNode(element, excludeScroll = false) {
+ const html = element.ownerDocument.documentElement;
+ const relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
+ const width = Math.max(html.clientWidth, window.innerWidth || 0);
+ const height = Math.max(html.clientHeight, window.innerHeight || 0);
- var scrollTop = getScroll(html);
- var scrollLeft = getScroll(html, 'left');
+ const scrollTop = !excludeScroll ? getScroll(html) : 0;
+ const scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
- var offset = {
+ const offset = {
top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
- width: width,
- height: height
+ width,
+ height
};
return getClientRect(offset);
@@ -561,14 +515,38 @@ function getViewportOffsetRectRelativeToArtbitraryNode(element) {
* @returns {Boolean} answer to "isFixed?"
*/
function isFixed(element) {
- var nodeName = element.nodeName;
+ const nodeName = element.nodeName;
if (nodeName === 'BODY' || nodeName === 'HTML') {
return false;
}
if (getStyleComputedProperty(element, 'position') === 'fixed') {
return true;
}
- return isFixed(getParentNode(element));
+ const parentNode = getParentNode(element);
+ if (!parentNode) {
+ return false;
+ }
+ return isFixed(parentNode);
+}
+
+/**
+ * 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;
+ }
+ let el = element.parentElement;
+ while (el && getStyleComputedProperty(el, 'transform') === 'none') {
+ el = el.parentElement;
+ }
+ return el || document.documentElement;
}
/**
@@ -579,38 +557,37 @@ function isFixed(element) {
* @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) {
+function getBoundaries(popper, reference, padding, boundariesElement, fixedPosition = false) {
// NOTE: 1 DOM access here
- var boundaries = { top: 0, left: 0 };
- var offsetParent = findCommonOffsetParent(popper, reference);
+
+ let boundaries = { top: 0, left: 0 };
+ const offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
// Handle viewport case
if (boundariesElement === 'viewport') {
- boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent);
+ boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
} else {
// Handle other cases based on DOM element used as boundaries
- var boundariesNode = void 0;
+ let boundariesNode;
if (boundariesElement === 'scrollParent') {
- boundariesNode = getScrollParent(getParentNode(popper));
+ boundariesNode = getScrollParent(getParentNode(reference));
if (boundariesNode.nodeName === 'BODY') {
- boundariesNode = window.document.documentElement;
+ boundariesNode = popper.ownerDocument.documentElement;
}
} else if (boundariesElement === 'window') {
- boundariesNode = window.document.documentElement;
+ boundariesNode = popper.ownerDocument.documentElement;
} else {
boundariesNode = boundariesElement;
}
- var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent);
+ const 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;
-
+ const { height, width } = getWindowSizes(popper.ownerDocument);
boundaries.top += offsets.top - offsets.marginTop;
boundaries.bottom = height + offsets.top;
boundaries.left += offsets.left - offsets.marginLeft;
@@ -622,18 +599,17 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
}
// Add paddings
- boundaries.left += padding;
- boundaries.top += padding;
- boundaries.right -= padding;
- boundaries.bottom -= padding;
+ padding = padding || 0;
+ const isPaddingNumber = typeof padding === 'number';
+ boundaries.left += isPaddingNumber ? padding : padding.left || 0;
+ boundaries.top += isPaddingNumber ? padding : padding.top || 0;
+ boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
+ boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
return boundaries;
}
-function getArea(_ref) {
- var width = _ref.width,
- height = _ref.height;
-
+function getArea({ width, height }) {
return width * height;
}
@@ -646,16 +622,14 @@ function getArea(_ref) {
* @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;
-
+function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement, padding = 0) {
if (placement.indexOf('auto') === -1) {
return placement;
}
- var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
+ const boundaries = getBoundaries(popper, reference, padding, boundariesElement);
- var rects = {
+ const rects = {
top: {
width: boundaries.width,
height: refRect.top - boundaries.top
@@ -674,27 +648,19 @@ function computeAutoPlacement(placement, refRect, popper, reference, boundariesE
}
};
- 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;
- });
+ const sortedAreas = Object.keys(rects).map(key => _extends({
+ key
+ }, rects[key], {
+ area: getArea(rects[key])
+ })).sort((a, b) => b.area - a.area);
- var filteredAreas = sortedAreas.filter(function (_ref2) {
- var width = _ref2.width,
- height = _ref2.height;
- return width >= popper.clientWidth && height >= popper.clientHeight;
- });
+ const filteredAreas = sortedAreas.filter(({ width, height }) => width >= popper.clientWidth && height >= popper.clientHeight);
- var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
+ const computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
- var variation = placement.split('-')[1];
+ const variation = placement.split('-')[1];
- return computedPlacement + (variation ? '-' + variation : '');
+ return computedPlacement + (variation ? `-${variation}` : '');
}
/**
@@ -704,11 +670,12 @@ function computeAutoPlacement(placement, refRect, popper, reference, boundariesE
* @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 commonOffsetParent = findCommonOffsetParent(popper, reference);
- return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent);
+function getReferenceOffsets(state, popper, reference, fixedPosition = null) {
+ const commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
+ return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
}
/**
@@ -719,10 +686,11 @@ function getReferenceOffsets(state, popper, reference) {
* @returns {Object} object containing width and height properties
*/
function getOuterSizes(element) {
- var styles = window.getComputedStyle(element);
- var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
- var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
- var result = {
+ const window = element.ownerDocument.defaultView;
+ const styles = window.getComputedStyle(element);
+ const x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
+ const y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
+ const result = {
width: element.offsetWidth + y,
height: element.offsetHeight + x
};
@@ -737,10 +705,8 @@ function getOuterSizes(element) {
* @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];
- });
+ const hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
+ return placement.replace(/left|right|bottom|top/g, matched => hash[matched]);
}
/**
@@ -757,20 +723,20 @@ function getPopperOffsets(popper, referenceOffsets, placement) {
placement = placement.split('-')[0];
// Get popper node sizes
- var popperRect = getOuterSizes(popper);
+ const popperRect = getOuterSizes(popper);
// Add position, width and height to our offsets object
- var popperOffsets = {
+ const 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';
+ const isHoriz = ['right', 'left'].indexOf(placement) !== -1;
+ const mainSide = isHoriz ? 'top' : 'left';
+ const secondarySide = isHoriz ? 'left' : 'top';
+ const measurement = isHoriz ? 'height' : 'width';
+ const secondaryMeasurement = !isHoriz ? 'height' : 'width';
popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
if (placement === secondarySide) {
@@ -813,15 +779,11 @@ function find(arr, check) {
function findIndex(arr, prop, value) {
// use native findIndex if supported
if (Array.prototype.findIndex) {
- return arr.findIndex(function (cur) {
- return cur[prop] === value;
- });
+ return arr.findIndex(cur => cur[prop] === value);
}
// use `find` + `indexOf` if `findIndex` isn't supported
- var match = find(arr, function (obj) {
- return obj[prop] === value;
- });
+ const match = find(arr, obj => obj[prop] === value);
return arr.indexOf(match);
}
@@ -836,13 +798,14 @@ function findIndex(arr, prop, value) {
* @returns {dataObject}
*/
function runModifiers(modifiers, data, ends) {
- var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
+ const modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
- modifiersToRun.forEach(function (modifier) {
- if (modifier.function) {
+ modifiersToRun.forEach(modifier => {
+ if (modifier['function']) {
+ // eslint-disable-line dot-notation
console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
}
- var fn = modifier.function || modifier.fn;
+ const 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
@@ -870,7 +833,7 @@ function update() {
return;
}
- var data = {
+ let data = {
instance: this,
styles: {},
arrowStyles: {},
@@ -880,7 +843,7 @@ function update() {
};
// compute reference element offsets
- data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference);
+ 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
@@ -890,9 +853,12 @@ function update() {
// 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 = 'absolute';
+
+ data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
// run the modifiers
data = runModifiers(this.modifiers, data);
@@ -914,11 +880,7 @@ function update() {
* @returns {Boolean}
*/
function isModifierEnabled(modifiers, modifierName) {
- return modifiers.some(function (_ref) {
- var name = _ref.name,
- enabled = _ref.enabled;
- return enabled && name === modifierName;
- });
+ return modifiers.some(({ name, enabled }) => enabled && name === modifierName);
}
/**
@@ -929,13 +891,13 @@ function isModifierEnabled(modifiers, modifierName) {
* @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);
+ const prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
+ const upperProp = property.charAt(0).toUpperCase() + property.slice(1);
- for (var i = 0; i < prefixes.length - 1; i++) {
- var prefix = prefixes[i];
- var toCheck = prefix ? '' + prefix + upperProp : property;
- if (typeof window.document.body.style[toCheck] !== 'undefined') {
+ for (let i = 0; i < prefixes.length; i++) {
+ const prefix = prefixes[i];
+ const toCheck = prefix ? `${prefix}${upperProp}` : property;
+ if (typeof document.body.style[toCheck] !== 'undefined') {
return toCheck;
}
}
@@ -943,7 +905,7 @@ function getSupportedPropertyName(property) {
}
/**
- * Destroy the popper
+ * Destroys the popper.
* @method
* @memberof Popper
*/
@@ -953,15 +915,18 @@ function destroy() {
// touch DOM only if `applyStyle` modifier is enabled
if (isModifierEnabled(this.modifiers, 'applyStyle')) {
this.popper.removeAttribute('x-placement');
- this.popper.style.left = '';
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
+ // remove the popper if user explicitly 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);
@@ -969,9 +934,19 @@ function destroy() {
return this;
}
+/**
+ * Get the window associated with the element
+ * @argument {Element} element
+ * @returns {Window}
+ */
+function getWindow(element) {
+ const ownerDocument = element.ownerDocument;
+ return ownerDocument ? ownerDocument.defaultView : window;
+}
+
function attachToScrollParents(scrollParent, event, callback, scrollParents) {
- var isBody = scrollParent.nodeName === 'BODY';
- var target = isBody ? window : scrollParent;
+ const isBody = scrollParent.nodeName === 'BODY';
+ const target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
target.addEventListener(event, callback, { passive: true });
if (!isBody) {
@@ -989,10 +964,10 @@ function attachToScrollParents(scrollParent, event, callback, scrollParents) {
function setupEventListeners(reference, options, state, updateBound) {
// Resize event listener on window
state.updateBound = updateBound;
- window.addEventListener('resize', state.updateBound, { passive: true });
+ getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
// Scroll event listener on scroll parents
- var scrollElement = getScrollParent(reference);
+ const scrollElement = getScrollParent(reference);
attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
state.scrollElement = scrollElement;
state.eventsEnabled = true;
@@ -1020,10 +995,10 @@ function enableEventListeners() {
*/
function removeEventListeners(reference, state) {
// Remove resize event listener on window
- window.removeEventListener('resize', state.updateBound);
+ getWindow(reference).removeEventListener('resize', state.updateBound);
// Remove scroll event listener on scroll parents
- state.scrollParents.forEach(function (target) {
+ state.scrollParents.forEach(target => {
target.removeEventListener('scroll', state.updateBound);
});
@@ -1037,14 +1012,14 @@ function removeEventListeners(reference, 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,
+ * 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) {
- window.cancelAnimationFrame(this.scheduleUpdate);
+ cancelAnimationFrame(this.scheduleUpdate);
this.state = removeEventListeners(this.reference, this.state);
}
}
@@ -1069,8 +1044,8 @@ function isNumeric(n) {
* 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 = '';
+ Object.keys(styles).forEach(prop => {
+ let 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';
@@ -1089,7 +1064,7 @@ function setStyles(element, styles) {
*/
function setAttributes(element, attributes) {
Object.keys(attributes).forEach(function (prop) {
- var value = attributes[prop];
+ const value = attributes[prop];
if (value !== false) {
element.setAttribute(prop, attributes[prop]);
} else {
@@ -1133,72 +1108,107 @@ function applyStyle(data) {
* @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 {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);
+ const 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);
+ const 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: 'absolute' });
+ setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
return options;
}
/**
* @function
+ * @memberof Popper.Utils
+ * @argument {Object} data - The data object generated by `update` method
+ * @argument {Boolean} shouldRound - If the offsets should be rounded at all
+ * @returns {Object} The popper's position offsets rounded
+ *
+ * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
+ * good as it can be within reason.
+ * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
+ *
+ * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
+ * as well on High DPI screens).
+ *
+ * Firefox prefers no rounding for positioning and does not have blurriness on
+ * high DPI screens.
+ *
+ * Only horizontal placement and left/right values need to be considered.
+ */
+function getRoundedOffsets(data, shouldRound) {
+ const { popper, reference } = data.offsets;
+ const { round, floor } = Math;
+ const noRound = v => v;
+
+ const referenceWidth = round(reference.width);
+ const popperWidth = round(popper.width);
+
+ const isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
+ const isVariation = data.placement.indexOf('-') !== -1;
+ const sameWidthParity = referenceWidth % 2 === popperWidth % 2;
+ const bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
+
+ const horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
+ const verticalToInteger = !shouldRound ? noRound : round;
+
+ return {
+ left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
+ top: verticalToInteger(popper.top),
+ bottom: verticalToInteger(popper.bottom),
+ right: horizontalToInteger(popper.right)
+ };
+}
+
+const isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
+
+/**
+ * @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;
+ const { x, y } = options;
+ const { popper } = data.offsets;
// Remove this legacy support in Popper.js v2
-
- var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
- return modifier.name === 'applyStyle';
- }).gpuAcceleration;
+ const legacyGpuAccelerationOption = find(data.instance.modifiers, modifier => 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;
+ const gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
- var offsetParent = getOffsetParent(data.instance.popper);
- var offsetParentRect = getBoundingClientRect(offsetParent);
+ const offsetParent = getOffsetParent(data.instance.popper);
+ const offsetParentRect = getBoundingClientRect(offsetParent);
// Styles
- var styles = {
+ const styles = {
position: popper.position
};
- // floor sides to avoid blurry text
- var offsets = {
- left: Math.floor(popper.left),
- top: Math.floor(popper.top),
- bottom: Math.floor(popper.bottom),
- right: Math.floor(popper.right)
- };
+ const offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
- var sideA = x === 'bottom' ? 'top' : 'bottom';
- var sideB = y === 'right' ? 'left' : 'right';
+ const sideA = x === 'bottom' ? 'top' : 'bottom';
+ const 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');
+ const 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
@@ -1209,34 +1219,43 @@ function computeStyle(data, options) {
// 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;
+ let left, top;
if (sideA === 'bottom') {
- top = -offsetParentRect.height + offsets.bottom;
+ // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
+ // and not the bottom of the html element
+ if (offsetParent.nodeName === 'HTML') {
+ top = -offsetParent.clientHeight + offsets.bottom;
+ } else {
+ top = -offsetParentRect.height + offsets.bottom;
+ }
} else {
top = offsets.top;
}
if (sideB === 'right') {
- left = -offsetParentRect.width + offsets.right;
+ if (offsetParent.nodeName === 'HTML') {
+ left = -offsetParent.clientWidth + offsets.right;
+ } else {
+ left = -offsetParentRect.width + offsets.right;
+ }
} else {
left = offsets.left;
}
if (gpuAcceleration && prefixedProperty) {
- styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
+ 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;
+ const invertTop = sideA === 'bottom' ? -1 : 1;
+ const invertLeft = sideB === 'right' ? -1 : 1;
styles[sideA] = top * invertTop;
styles[sideB] = left * invertLeft;
- styles.willChange = sideA + ', ' + sideB;
+ styles.willChange = `${sideA}, ${sideB}`;
}
// Attributes
- var attributes = {
+ const attributes = {
'x-placement': data.placement
};
@@ -1259,19 +1278,16 @@ function computeStyle(data, options) {
* @returns {Boolean}
*/
function isModifierRequired(modifiers, requestingName, requestedName) {
- var requesting = find(modifiers, function (_ref) {
- var name = _ref.name;
- return name === requestingName;
- });
+ const requesting = find(modifiers, ({ name }) => name === requestingName);
- var isRequired = !!requesting && modifiers.some(function (modifier) {
+ const isRequired = !!requesting && modifiers.some(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 + '!');
+ const requesting = `\`${requestingName}\``;
+ const requested = `\`${requestedName}\``;
+ console.warn(`${requested} modifier is required by ${requesting} modifier in order to work, be sure to include it before ${requesting}!`);
}
return isRequired;
}
@@ -1289,7 +1305,7 @@ function arrow(data, options) {
return data;
}
- var arrowElement = options.element;
+ let arrowElement = options.element;
// if arrowElement is a string, suppose it's a CSS selector
if (typeof arrowElement === 'string') {
@@ -1308,23 +1324,20 @@ function arrow(data, options) {
}
}
- 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;
+ const placement = data.placement.split('-')[0];
+ const { popper, reference } = data.offsets;
+ const 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];
+ const len = isVertical ? 'height' : 'width';
+ const sideCapitalized = isVertical ? 'Top' : 'Left';
+ const side = sideCapitalized.toLowerCase();
+ const altSide = isVertical ? 'left' : 'top';
+ const opSide = isVertical ? 'bottom' : 'right';
+ const arrowElementSize = getOuterSizes(arrowElement)[len];
//
// extends keepTogether behavior making sure the popper and its
- // reference have enough pixels in conjuction
+ // reference have enough pixels in conjunction
//
// top/left side
@@ -1335,22 +1348,26 @@ function arrow(data, options) {
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;
+ const 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 popperMarginSide = getStyleComputedProperty(data.instance.popper, 'margin' + sideCapitalized).replace('px', '');
- var sideValue = center - getClientRect(data.offsets.popper)[side] - popperMarginSide;
+ const css = getStyleComputedProperty(data.instance.popper);
+ const popperMarginSide = parseFloat(css[`margin${sideCapitalized}`]);
+ const popperBorderSide = parseFloat(css[`border${sideCapitalized}Width`]);
+ let 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[side] = Math.round(sideValue);
- data.offsets.arrow[altSide] = ''; // make sure to unset any eventual altSide value from the DOM node
+ data.offsets.arrow = {
+ [side]: Math.round(sideValue),
+ [altSide]: '' // make sure to unset any eventual altSide value from the DOM node
+ };
return data;
}
@@ -1393,7 +1410,7 @@ function getOppositeVariation(variation) {
* - `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)
+ * - `auto-end` (on the side with more space available, alignment depends by placement)
*
* @static
* @type {Array}
@@ -1405,7 +1422,7 @@ function getOppositeVariation(variation) {
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);
+const validPlacements = placements.slice(3);
/**
* Given an initial placement, returns all the subsequent placements
@@ -1417,15 +1434,13 @@ var validPlacements = placements.slice(3);
* @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));
+function clockwise(placement, counter = false) {
+ const index = validPlacements.indexOf(placement);
+ const arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
return counter ? arr.reverse() : arr;
}
-var BEHAVIORS = {
+const BEHAVIORS = {
FLIP: 'flip',
CLOCKWISE: 'clockwise',
COUNTERCLOCKWISE: 'counterclockwise'
@@ -1449,13 +1464,13 @@ function flip(data, options) {
return data;
}
- var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement);
+ const 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] || '';
+ let placement = data.placement.split('-')[0];
+ let placementOpposite = getOppositePlacement(placement);
+ let variation = data.placement.split('-')[1] || '';
- var flipOrder = [];
+ let flipOrder = [];
switch (options.behavior) {
case BEHAVIORS.FLIP:
@@ -1471,7 +1486,7 @@ function flip(data, options) {
flipOrder = options.behavior;
}
- flipOrder.forEach(function (step, index) {
+ flipOrder.forEach((step, index) => {
if (placement !== step || flipOrder.length === index + 1) {
return data;
}
@@ -1479,23 +1494,30 @@ function flip(data, options) {
placement = data.placement.split('-')[0];
placementOpposite = getOppositePlacement(placement);
- var popperOffsets = data.offsets.popper;
- var refOffsets = data.offsets.reference;
+ const popperOffsets = data.offsets.popper;
+ const 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);
+ const floor = Math.floor;
+ const 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);
+ const overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
+ const overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
+ const overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
+ const overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
- var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
+ const 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);
+ const isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
+
+ // flips variation if reference element overflows boundaries
+ const flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
+
+ // flips variation if popper content overflows boundaries
+ const flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
+
+ const flippedVariation = flippedVariationByRef || flippedVariationByContent;
if (overlapsRef || overflowsBoundaries || flippedVariation) {
// this boolean to detect any flip loop
@@ -1529,16 +1551,13 @@ function flip(data, 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';
+ const { popper, reference } = data.offsets;
+ const placement = data.placement.split('-')[0];
+ const floor = Math.floor;
+ const isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
+ const side = isVertical ? 'right' : 'bottom';
+ const opSide = isVertical ? 'left' : 'top';
+ const measurement = isVertical ? 'width' : 'height';
if (popper[side] < floor(reference[opSide])) {
data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
@@ -1564,9 +1583,9 @@ function keepTogether(data) {
*/
function toValue(str, measurement, popperOffsets, referenceOffsets) {
// separate value from unit
- var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
- var value = +split[1];
- var unit = split[2];
+ const split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
+ const value = +split[1];
+ const unit = split[2];
// If it's not a number it's an operator, I guess
if (!value) {
@@ -1574,7 +1593,7 @@ function toValue(str, measurement, popperOffsets, referenceOffsets) {
}
if (unit.indexOf('%') === 0) {
- var element = void 0;
+ let element;
switch (unit) {
case '%p':
element = popperOffsets;
@@ -1585,11 +1604,11 @@ function toValue(str, measurement, popperOffsets, referenceOffsets) {
element = referenceOffsets;
}
- var rect = getClientRect(element);
+ const 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;
+ let size;
if (unit === 'vh') {
size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
} else {
@@ -1615,24 +1634,20 @@ function toValue(str, measurement, popperOffsets, referenceOffsets) {
* @returns {Array} a two cells array with x and y offsets in numbers
*/
function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
- var offsets = [0, 0];
+ const 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;
+ const 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();
- });
+ const fragments = offset.split(/(\+|\-)/).map(frag => 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;
- }));
+ const divider = fragments.indexOf(find(fragments, frag => 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.');
@@ -1640,18 +1655,18 @@ function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
// 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];
+ const splitRegex = /\s*,\s*|\s+/;
+ let 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) {
+ ops = ops.map((op, index) => {
// Most of the units rely on the orientation of the popper
- var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
- var mergeWithPrevious = false;
+ const measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
+ let mergeWithPrevious = false;
return op
// This aggregates any `+` or `-` sign that aren't considered operators
// e.g.: 10 + +5 => [10, +, +5]
- .reduce(function (a, b) {
+ .reduce((a, b) => {
if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
a[a.length - 1] = b;
mergeWithPrevious = true;
@@ -1665,14 +1680,12 @@ function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
}
}, [])
// Here we convert the string values into number values (in px)
- .map(function (str) {
- return toValue(str, measurement, popperOffsets, referenceOffsets);
- });
+ .map(str => toValue(str, measurement, popperOffsets, referenceOffsets));
});
// Loop trough the offsets arrays and execute the operations
- ops.forEach(function (op, index) {
- op.forEach(function (frag, index2) {
+ ops.forEach((op, index) => {
+ op.forEach((frag, index2) => {
if (isNumeric(frag)) {
offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
}
@@ -1690,16 +1703,11 @@ function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
* 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];
+function offset(data, { offset }) {
+ const { placement, offsets: { popper, reference } } = data;
+ const basePlacement = placement.split('-')[0];
- var offsets = void 0;
+ let offsets;
if (isNumeric(+offset)) {
offsets = [+offset, 0];
} else {
@@ -1732,7 +1740,7 @@ function offset(data, _ref) {
* @returns {Object} The data object, properly modified
*/
function preventOverflow(data, options) {
- var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
+ let 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
@@ -1741,32 +1749,49 @@ function preventOverflow(data, options) {
boundariesElement = getOffsetParent(boundariesElement);
}
- var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, 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
+ const transformProp = getSupportedPropertyName('transform');
+ const popperStyles = data.instance.popper.style; // assignment to help minification
+ const { top, left, [transformProp]: transform } = popperStyles;
+ popperStyles.top = '';
+ popperStyles.left = '';
+ popperStyles[transformProp] = '';
+
+ const 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;
+ const order = options.priority;
+ let popper = data.offsets.popper;
- var check = {
- primary: function primary(placement) {
- var value = popper[placement];
+ const check = {
+ primary(placement) {
+ let value = popper[placement];
if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
value = Math.max(popper[placement], boundaries[placement]);
}
- return defineProperty({}, placement, value);
+ return { [placement]: value };
},
- secondary: function secondary(placement) {
- var mainSide = placement === 'right' ? 'left' : 'top';
- var value = popper[mainSide];
+ secondary(placement) {
+ const mainSide = placement === 'right' ? 'left' : 'top';
+ let 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);
+ return { [mainSide]: value };
}
};
- order.forEach(function (placement) {
- var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
+ order.forEach(placement => {
+ const side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
popper = _extends({}, popper, check[side](placement));
});
@@ -1783,23 +1808,22 @@ function preventOverflow(data, 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];
+ const placement = data.placement;
+ const basePlacement = placement.split('-')[0];
+ const 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])
+ const { reference, popper } = data.offsets;
+ const isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
+ const side = isVertical ? 'left' : 'top';
+ const measurement = isVertical ? 'width' : 'height';
+
+ const shiftOffsets = {
+ start: { [side]: reference[side] },
+ end: {
+ [side]: reference[side] + reference[measurement] - popper[measurement]
+ }
};
data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
@@ -1820,10 +1844,8 @@ function hide(data) {
return data;
}
- var refRect = data.offsets.reference;
- var bound = find(data.instance.modifiers, function (modifier) {
- return modifier.name === 'preventOverflow';
- }).boundaries;
+ const refRect = data.offsets.reference;
+ const bound = find(data.instance.modifiers, modifier => 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
@@ -1854,15 +1876,12 @@ function hide(data) {
* @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;
+ const placement = data.placement;
+ const basePlacement = placement.split('-')[0];
+ const { popper, reference } = data.offsets;
+ const isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
- var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
-
- var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
+ const subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
@@ -1915,7 +1934,7 @@ var modifiers = {
* The `offset` modifier can shift your popper on both its axis.
*
* It accepts the following units:
- * - `px` or unitless, interpreted as pixels
+ * - `px` or unit-less, 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
@@ -1923,7 +1942,7 @@ var modifiers = {
*
* 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.
+ * `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 />
@@ -1944,7 +1963,7 @@ var modifiers = {
* ```
* > **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)
+ * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
*
* @memberof modifiers
* @inner
@@ -1965,7 +1984,7 @@ var modifiers = {
/**
* 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 />
+ * A 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:
*
@@ -1995,23 +2014,23 @@ var modifiers = {
/**
* @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
+ * and the popper. This makes sure the popper always has 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`,
+ * 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
+ * Modifier used to make sure the reference and its popper stay near each other
+ * without leaving any gap between the two. Especially useful when the arrow is
+ * enabled and you want to ensure that it points 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
@@ -2029,7 +2048,7 @@ var modifiers = {
* 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.
+ * pixels of conjunction are needed.
*
* It has no effect if no `arrowElement` is provided.
* @memberof modifiers
@@ -2068,7 +2087,7 @@ var modifiers = {
* @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).
+ * placements (with optional variations)
*/
behavior: 'flip',
/**
@@ -2078,11 +2097,27 @@ var modifiers = {
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)
+ * 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',
+ /**
+ * @prop {Boolean} flipVariations=false
+ * The popper will switch placement variation between `-start` and `-end` when
+ * the reference element overlaps its boundaries.
+ *
+ * The original placement should have a set variation.
+ */
+ flipVariations: false,
+ /**
+ * @prop {Boolean} flipVariationsByContent=false
+ * The popper will switch placement variation between `-start` and `-end` when
+ * the popper element overlaps its reference boundaries.
+ *
+ * The original placement should have a set variation.
*/
- boundariesElement: 'viewport'
+ flipVariationsByContent: false
},
/**
@@ -2144,8 +2179,8 @@ var modifiers = {
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.
+ * If true, it uses the CSS 3D transformation to position the popper.
+ * Otherwise, it will use the `top` and `left` properties
*/
gpuAcceleration: true,
/**
@@ -2172,7 +2207,7 @@ var modifiers = {
* 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.
+ * Just disable this modifier and define your own to achieve the desired effect.
*
* @memberof modifiers
* @inner
@@ -2189,27 +2224,27 @@ var modifiers = {
/**
* @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.
+ * 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.
+ * The `dataObject` is an object containing all the information used by Popper.js.
+ * This object is 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 {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.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 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
@@ -2217,9 +2252,9 @@ var modifiers = {
/**
* 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:
+ * These can be overridden using the `options` argument of Popper.js.<br />
+ * To override an option, simply pass an object with the same
+ * structure of the `options` object, as the 3rd argument. For example:
* ```
* new Popper(ref, pop, {
* modifiers: {
@@ -2233,13 +2268,19 @@ var modifiers = {
*/
var Defaults = {
/**
- * Popper's placement
+ * Popper's placement.
* @prop {Popper.placements} placement='bottom'
*/
placement: 'bottom',
/**
- * Whether events (resize, scroll) are initially enabled
+ * 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,
@@ -2253,28 +2294,28 @@ var Defaults = {
/**
* Callback called when the popper is created.<br />
- * By default, is set to no-op.<br />
+ * By default, it is set to no-op.<br />
* Access Popper.js instance with `data.instance`.
* @prop {onCreate}
*/
- onCreate: function onCreate() {},
+ onCreate: () => {},
/**
- * Callback called when the popper is updated, this callback is not called
+ * 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 />
+ * By default, it is set to no-op.<br />
* Access Popper.js instance with `data.instance`.
* @prop {onUpdate}
*/
- onUpdate: function onUpdate() {},
+ 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
+ * They provide most of the functionalities of Popper.js.
* @prop {modifiers}
*/
- modifiers: modifiers
+ modifiers
};
/**
@@ -2289,24 +2330,17 @@ var Defaults = {
// Utils
// Methods
-var Popper = function () {
+class Popper {
/**
- * Create a new Popper.js instance
+ * Creates 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 {Element|referenceObject} reference - The reference element used to position the popper
+ * @param {Element} popper - The HTML / XML element used as the 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);
- };
+ constructor(reference, popper, options = {}) {
+ this.scheduleUpdate = () => requestAnimationFrame(this.update);
// make update() debounced, so that it only runs at most once-per-tick
this.update = debounce(this.update.bind(this));
@@ -2322,40 +2356,36 @@ var Popper = function () {
};
// get reference and popper elements (allow jQuery wrappers)
- this.reference = reference.jquery ? reference[0] : reference;
- this.popper = popper.jquery ? popper[0] : popper;
+ 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] : {});
+ Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(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]);
- })
+ this.modifiers = Object.keys(this.options.modifiers).map(name => _extends({
+ name
+ }, this.options.modifiers[name]))
// sort the modifiers by order
- .sort(function (a, b) {
- return a.order - b.order;
- });
+ .sort((a, b) => 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) {
+ this.modifiers.forEach(modifierOptions => {
if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
- modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
+ 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;
+ const eventsEnabled = this.options.eventsEnabled;
if (eventsEnabled) {
// setup event listeners, they will take care of update the position in specific situations
this.enableEventListeners();
@@ -2366,56 +2396,43 @@ var Popper = function () {
// We can't use class properties because they don't get listed in the
// class prototype and break stuff like Sinon stubs
+ update() {
+ return update.call(this);
+ }
+ destroy() {
+ return destroy.call(this);
+ }
+ enableEventListeners() {
+ return enableEventListeners.call(this);
+ }
+ disableEventListeners() {
+ return disableEventListeners.call(this);
+ }
+ /**
+ * Schedules an update. It will run on the next UI update available.
+ * @method scheduleUpdate
+ * @memberof Popper
+ */
- 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;
-}();
+ /**
+ * 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
+ */
+}
/**
* The `referenceObject` is an object that provides an interface compatible with Popper.js
@@ -2427,7 +2444,7 @@ var Popper = function () {
* new Popper(referenceObject, popperNode);
* ```
*
- * NB: This feature isn't supported in Internet Explorer 10
+ * 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.
@@ -2437,12 +2454,9 @@ var Popper = function () {
* 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;
-return Popper;
-
-})));
+export default Popper;
//# sourceMappingURL=popper.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.js.map b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.js.map
new file mode 100644
index 0000000..98948de
--- /dev/null
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"popper.js","sources":["../src/utils/isBrowser.js","../src/utils/debounce.js","../src/utils/isFunction.js","../src/utils/getStyleComputedProperty.js","../src/utils/getParentNode.js","../src/utils/getScrollParent.js","../src/utils/getReferenceNode.js","../src/utils/isIE.js","../src/utils/getOffsetParent.js","../src/utils/isOffsetContainer.js","../src/utils/getRoot.js","../src/utils/findCommonOffsetParent.js","../src/utils/getScroll.js","../src/utils/includeScroll.js"," [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.min.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.min.js
new file mode 100644
index 0000000..ad9949c
--- /dev/null
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.min.js
@@ -0,0 +1,5 @@
+/*
+ Copyright (C) Federico Zivolo 2020
+ Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).
+ */var e='undefined'!=typeof window&&'undefined'!=typeof document&&'undefined'!=typeof navigator;const t=function(){const t=['Edge','Trident','Firefox'];for(let o=0;o<t.length;o+=1)if(e&&0<=navigator.userAgent.indexOf(t[o]))return 1;return 0}();function o(e){let t=!1;return()=>{t||(t=!0,window.Promise.resolve().then(()=>{t=!1,e()}))}}function n(e){let o=!1;return()=>{o||(o=!0,setTimeout(()=>{o=!1,e()},t))}}const i=e&&window.Promise;var r=i?o:n;function p(e){return e&&'[object Function]'= [...]
+//# sourceMappingURL=popper.min.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.min.js.map b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.min.js.map
new file mode 100644
index 0000000..ee76585
--- /dev/null
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/popper-js/1.16.1/popper.min.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"popper.min.js","sources":["../src/utils/isBrowser.js","../src/utils/debounce.js","../src/utils/isFunction.js","../src/utils/getStyleComputedProperty.js","../src/utils/getParentNode.js","../src/utils/getScrollParent.js","../src/utils/getReferenceNode.js","../src/utils/isIE.js","../src/utils/getOffsetParent.js","../src/utils/isOffsetContainer.js","../src/utils/getRoot.js","../src/utils/findCommonOffsetParent.js","../src/utils/getScroll.js","../src/utils/includeScroll.j [...]
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
index 72c640d..f6f8ade 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
@@ -39,7 +39,7 @@
<resources production="true">
<script name="/tobago/standard/jquery/jquery-3.6.0.min.js"/>
<script name="/tobago/standard/jquery-ui/1.13.1.custom/jquery-ui.min.js"/>
- <script name="/tobago/standard/popper-js/1.12.3/popper.min.js"/>
+ <script name="/tobago/standard/popper-js/1.16.1/popper.min.js"/>
<script name="/tobago/standard/tobago-bootstrap/${project.version}/js/bootstrap.min.js"/>
<script name="/tobago/standard/moment/2.29.1/moment-with-locales.min.js"/>
<script name="/tobago/standard/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"/>
@@ -52,7 +52,7 @@
<resources production="false">
<script name="/tobago/standard/jquery/jquery-3.6.0.js"/>
<script name="/tobago/standard/jquery-ui/1.13.1.custom/jquery-ui.js"/>
- <script name="/tobago/standard/popper-js/1.12.3/popper.js"/>
+ <script name="/tobago/standard/popper-js/1.16.1/popper.js"/>
<script name="/tobago/standard/tobago-bootstrap/${project.version}/js/bootstrap.js"/>
<script name="/tobago/standard/moment/2.29.1/moment-with-locales.js"/>
<script name="/tobago/standard/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.js"/>