659 lines
101 KiB
JavaScript
659 lines
101 KiB
JavaScript
/**
|
|
* @dynamic is for runtime initializing DomHandler.browser
|
|
*
|
|
* If delete below comment, we can see this error message:
|
|
* Metadata collected contains an error that will be reported at runtime:
|
|
* Only initialized variables and constants can be referenced
|
|
* because the value of this variable is needed by the template compiler.
|
|
*/
|
|
// @dynamic
|
|
export class DomHandler {
|
|
static zindex = 1000;
|
|
static calculatedScrollbarWidth = null;
|
|
static calculatedScrollbarHeight = null;
|
|
static browser;
|
|
static addClass(element, className) {
|
|
if (element && className) {
|
|
if (element.classList)
|
|
element.classList.add(className);
|
|
else
|
|
element.className += ' ' + className;
|
|
}
|
|
}
|
|
static addMultipleClasses(element, className) {
|
|
if (element && className) {
|
|
if (element.classList) {
|
|
let styles = className.trim().split(' ');
|
|
for (let i = 0; i < styles.length; i++) {
|
|
element.classList.add(styles[i]);
|
|
}
|
|
}
|
|
else {
|
|
let styles = className.split(' ');
|
|
for (let i = 0; i < styles.length; i++) {
|
|
element.className += ' ' + styles[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
static removeClass(element, className) {
|
|
if (element && className) {
|
|
if (element.classList)
|
|
element.classList.remove(className);
|
|
else
|
|
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
|
}
|
|
}
|
|
static removeMultipleClasses(element, classNames) {
|
|
if (element && classNames) {
|
|
[classNames]
|
|
.flat()
|
|
.filter(Boolean)
|
|
.forEach((cNames) => cNames.split(' ').forEach((className) => this.removeClass(element, className)));
|
|
}
|
|
}
|
|
static hasClass(element, className) {
|
|
if (element && className) {
|
|
if (element.classList)
|
|
return element.classList.contains(className);
|
|
else
|
|
return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
|
|
}
|
|
return false;
|
|
}
|
|
static siblings(element) {
|
|
return Array.prototype.filter.call(element.parentNode.children, function (child) {
|
|
return child !== element;
|
|
});
|
|
}
|
|
static find(element, selector) {
|
|
return Array.from(element.querySelectorAll(selector));
|
|
}
|
|
static findSingle(element, selector) {
|
|
return this.isElement(element) ? element.querySelector(selector) : null;
|
|
}
|
|
static index(element) {
|
|
let children = element.parentNode.childNodes;
|
|
let num = 0;
|
|
for (var i = 0; i < children.length; i++) {
|
|
if (children[i] == element)
|
|
return num;
|
|
if (children[i].nodeType == 1)
|
|
num++;
|
|
}
|
|
return -1;
|
|
}
|
|
static indexWithinGroup(element, attributeName) {
|
|
let children = element.parentNode ? element.parentNode.childNodes : [];
|
|
let num = 0;
|
|
for (var i = 0; i < children.length; i++) {
|
|
if (children[i] == element)
|
|
return num;
|
|
if (children[i].attributes && children[i].attributes[attributeName] && children[i].nodeType == 1)
|
|
num++;
|
|
}
|
|
return -1;
|
|
}
|
|
static appendOverlay(overlay, target, appendTo = 'self') {
|
|
if (appendTo !== 'self' && overlay && target) {
|
|
this.appendChild(overlay, target);
|
|
}
|
|
}
|
|
static alignOverlay(overlay, target, appendTo = 'self', calculateMinWidth = true) {
|
|
if (overlay && target) {
|
|
if (calculateMinWidth) {
|
|
overlay.style.minWidth = `${DomHandler.getOuterWidth(target)}px`;
|
|
}
|
|
if (appendTo === 'self') {
|
|
this.relativePosition(overlay, target);
|
|
}
|
|
else {
|
|
this.absolutePosition(overlay, target);
|
|
}
|
|
}
|
|
}
|
|
static relativePosition(element, target, gutter = true) {
|
|
const getClosestRelativeElement = (el) => {
|
|
if (!el)
|
|
return;
|
|
return getComputedStyle(el).getPropertyValue('position') === 'relative' ? el : getClosestRelativeElement(el.parentElement);
|
|
};
|
|
const elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
|
|
const targetHeight = target.offsetHeight;
|
|
const targetOffset = target.getBoundingClientRect();
|
|
const windowScrollTop = this.getWindowScrollTop();
|
|
const windowScrollLeft = this.getWindowScrollLeft();
|
|
const viewport = this.getViewport();
|
|
const relativeElement = getClosestRelativeElement(element);
|
|
const relativeElementOffset = relativeElement?.getBoundingClientRect() || { top: -1 * windowScrollTop, left: -1 * windowScrollLeft };
|
|
let top, left;
|
|
if (targetOffset.top + targetHeight + elementDimensions.height > viewport.height) {
|
|
top = targetOffset.top - relativeElementOffset.top - elementDimensions.height;
|
|
element.style.transformOrigin = 'bottom';
|
|
if (targetOffset.top + top < 0) {
|
|
top = -1 * targetOffset.top;
|
|
}
|
|
}
|
|
else {
|
|
top = targetHeight + targetOffset.top - relativeElementOffset.top;
|
|
element.style.transformOrigin = 'top';
|
|
}
|
|
const horizontalOverflow = targetOffset.left + elementDimensions.width - viewport.width;
|
|
const targetLeftOffsetInSpaceOfRelativeElement = targetOffset.left - relativeElementOffset.left;
|
|
if (elementDimensions.width > viewport.width) {
|
|
// element wider then viewport and cannot fit on screen (align at left side of viewport)
|
|
left = (targetOffset.left - relativeElementOffset.left) * -1;
|
|
}
|
|
else if (horizontalOverflow > 0) {
|
|
// element wider then viewport but can be fit on screen (align at right side of viewport)
|
|
left = targetLeftOffsetInSpaceOfRelativeElement - horizontalOverflow;
|
|
}
|
|
else {
|
|
// element fits on screen (align with target)
|
|
left = targetOffset.left - relativeElementOffset.left;
|
|
}
|
|
element.style.top = top + 'px';
|
|
element.style.left = left + 'px';
|
|
gutter && (element.style.marginTop = origin === 'bottom' ? 'calc(var(--p-anchor-gutter) * -1)' : 'calc(var(--p-anchor-gutter))');
|
|
}
|
|
static absolutePosition(element, target, gutter = true) {
|
|
const elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
|
|
const elementOuterHeight = elementDimensions.height;
|
|
const elementOuterWidth = elementDimensions.width;
|
|
const targetOuterHeight = target.offsetHeight;
|
|
const targetOuterWidth = target.offsetWidth;
|
|
const targetOffset = target.getBoundingClientRect();
|
|
const windowScrollTop = this.getWindowScrollTop();
|
|
const windowScrollLeft = this.getWindowScrollLeft();
|
|
const viewport = this.getViewport();
|
|
let top, left;
|
|
if (targetOffset.top + targetOuterHeight + elementOuterHeight > viewport.height) {
|
|
top = targetOffset.top + windowScrollTop - elementOuterHeight;
|
|
element.style.transformOrigin = 'bottom';
|
|
if (top < 0) {
|
|
top = windowScrollTop;
|
|
}
|
|
}
|
|
else {
|
|
top = targetOuterHeight + targetOffset.top + windowScrollTop;
|
|
element.style.transformOrigin = 'top';
|
|
}
|
|
if (targetOffset.left + elementOuterWidth > viewport.width)
|
|
left = Math.max(0, targetOffset.left + windowScrollLeft + targetOuterWidth - elementOuterWidth);
|
|
else
|
|
left = targetOffset.left + windowScrollLeft;
|
|
element.style.top = top + 'px';
|
|
element.style.left = left + 'px';
|
|
gutter && (element.style.marginTop = origin === 'bottom' ? 'calc(var(--p-anchor-gutter) * -1)' : 'calc(var(--p-anchor-gutter))');
|
|
}
|
|
static getParents(element, parents = []) {
|
|
return element['parentNode'] === null ? parents : this.getParents(element.parentNode, parents.concat([element.parentNode]));
|
|
}
|
|
static getScrollableParents(element) {
|
|
let scrollableParents = [];
|
|
if (element) {
|
|
let parents = this.getParents(element);
|
|
const overflowRegex = /(auto|scroll)/;
|
|
const overflowCheck = (node) => {
|
|
let styleDeclaration = window['getComputedStyle'](node, null);
|
|
return overflowRegex.test(styleDeclaration.getPropertyValue('overflow')) || overflowRegex.test(styleDeclaration.getPropertyValue('overflowX')) || overflowRegex.test(styleDeclaration.getPropertyValue('overflowY'));
|
|
};
|
|
for (let parent of parents) {
|
|
let scrollSelectors = parent.nodeType === 1 && parent.dataset['scrollselectors'];
|
|
if (scrollSelectors) {
|
|
let selectors = scrollSelectors.split(',');
|
|
for (let selector of selectors) {
|
|
let el = this.findSingle(parent, selector);
|
|
if (el && overflowCheck(el)) {
|
|
scrollableParents.push(el);
|
|
}
|
|
}
|
|
}
|
|
if (parent.nodeType !== 9 && overflowCheck(parent)) {
|
|
scrollableParents.push(parent);
|
|
}
|
|
}
|
|
}
|
|
return scrollableParents;
|
|
}
|
|
static getHiddenElementOuterHeight(element) {
|
|
element.style.visibility = 'hidden';
|
|
element.style.display = 'block';
|
|
let elementHeight = element.offsetHeight;
|
|
element.style.display = 'none';
|
|
element.style.visibility = 'visible';
|
|
return elementHeight;
|
|
}
|
|
static getHiddenElementOuterWidth(element) {
|
|
element.style.visibility = 'hidden';
|
|
element.style.display = 'block';
|
|
let elementWidth = element.offsetWidth;
|
|
element.style.display = 'none';
|
|
element.style.visibility = 'visible';
|
|
return elementWidth;
|
|
}
|
|
static getHiddenElementDimensions(element) {
|
|
let dimensions = {};
|
|
element.style.visibility = 'hidden';
|
|
element.style.display = 'block';
|
|
dimensions.width = element.offsetWidth;
|
|
dimensions.height = element.offsetHeight;
|
|
element.style.display = 'none';
|
|
element.style.visibility = 'visible';
|
|
return dimensions;
|
|
}
|
|
static scrollInView(container, item) {
|
|
let borderTopValue = getComputedStyle(container).getPropertyValue('borderTopWidth');
|
|
let borderTop = borderTopValue ? parseFloat(borderTopValue) : 0;
|
|
let paddingTopValue = getComputedStyle(container).getPropertyValue('paddingTop');
|
|
let paddingTop = paddingTopValue ? parseFloat(paddingTopValue) : 0;
|
|
let containerRect = container.getBoundingClientRect();
|
|
let itemRect = item.getBoundingClientRect();
|
|
let offset = itemRect.top + document.body.scrollTop - (containerRect.top + document.body.scrollTop) - borderTop - paddingTop;
|
|
let scroll = container.scrollTop;
|
|
let elementHeight = container.clientHeight;
|
|
let itemHeight = this.getOuterHeight(item);
|
|
if (offset < 0) {
|
|
container.scrollTop = scroll + offset;
|
|
}
|
|
else if (offset + itemHeight > elementHeight) {
|
|
container.scrollTop = scroll + offset - elementHeight + itemHeight;
|
|
}
|
|
}
|
|
static fadeIn(element, duration) {
|
|
element.style.opacity = 0;
|
|
let last = +new Date();
|
|
let opacity = 0;
|
|
let tick = function () {
|
|
opacity = +element.style.opacity.replace(',', '.') + (new Date().getTime() - last) / duration;
|
|
element.style.opacity = opacity;
|
|
last = +new Date();
|
|
if (+opacity < 1) {
|
|
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16);
|
|
}
|
|
};
|
|
tick();
|
|
}
|
|
static fadeOut(element, ms) {
|
|
var opacity = 1, interval = 50, duration = ms, gap = interval / duration;
|
|
let fading = setInterval(() => {
|
|
opacity = opacity - gap;
|
|
if (opacity <= 0) {
|
|
opacity = 0;
|
|
clearInterval(fading);
|
|
}
|
|
element.style.opacity = opacity;
|
|
}, interval);
|
|
}
|
|
static getWindowScrollTop() {
|
|
let doc = document.documentElement;
|
|
return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
|
}
|
|
static getWindowScrollLeft() {
|
|
let doc = document.documentElement;
|
|
return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
|
|
}
|
|
static matches(element, selector) {
|
|
var p = Element.prototype;
|
|
var f = p['matches'] ||
|
|
p.webkitMatchesSelector ||
|
|
p['mozMatchesSelector'] ||
|
|
p['msMatchesSelector'] ||
|
|
function (s) {
|
|
return [].indexOf.call(document.querySelectorAll(s), this) !== -1;
|
|
};
|
|
return f.call(element, selector);
|
|
}
|
|
static getOuterWidth(el, margin) {
|
|
let width = el.offsetWidth;
|
|
if (margin) {
|
|
let style = getComputedStyle(el);
|
|
width += parseFloat(style.marginLeft) + parseFloat(style.marginRight);
|
|
}
|
|
return width;
|
|
}
|
|
static getHorizontalPadding(el) {
|
|
let style = getComputedStyle(el);
|
|
return parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
|
}
|
|
static getHorizontalMargin(el) {
|
|
let style = getComputedStyle(el);
|
|
return parseFloat(style.marginLeft) + parseFloat(style.marginRight);
|
|
}
|
|
static innerWidth(el) {
|
|
let width = el.offsetWidth;
|
|
let style = getComputedStyle(el);
|
|
width += parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
|
return width;
|
|
}
|
|
static width(el) {
|
|
let width = el.offsetWidth;
|
|
let style = getComputedStyle(el);
|
|
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
|
return width;
|
|
}
|
|
static getInnerHeight(el) {
|
|
let height = el.offsetHeight;
|
|
let style = getComputedStyle(el);
|
|
height += parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
return height;
|
|
}
|
|
static getOuterHeight(el, margin) {
|
|
let height = el.offsetHeight;
|
|
if (margin) {
|
|
let style = getComputedStyle(el);
|
|
height += parseFloat(style.marginTop) + parseFloat(style.marginBottom);
|
|
}
|
|
return height;
|
|
}
|
|
static getHeight(el) {
|
|
let height = el.offsetHeight;
|
|
let style = getComputedStyle(el);
|
|
height -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom) + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
return height;
|
|
}
|
|
static getWidth(el) {
|
|
let width = el.offsetWidth;
|
|
let style = getComputedStyle(el);
|
|
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
|
|
return width;
|
|
}
|
|
static getViewport() {
|
|
let win = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], w = win.innerWidth || e.clientWidth || g.clientWidth, h = win.innerHeight || e.clientHeight || g.clientHeight;
|
|
return { width: w, height: h };
|
|
}
|
|
static getOffset(el) {
|
|
var rect = el.getBoundingClientRect();
|
|
return {
|
|
top: rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0),
|
|
left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0)
|
|
};
|
|
}
|
|
static replaceElementWith(element, replacementElement) {
|
|
let parentNode = element.parentNode;
|
|
if (!parentNode)
|
|
throw `Can't replace element`;
|
|
return parentNode.replaceChild(replacementElement, element);
|
|
}
|
|
static getUserAgent() {
|
|
if (navigator && this.isClient()) {
|
|
return navigator.userAgent;
|
|
}
|
|
}
|
|
static isIE() {
|
|
var ua = window.navigator.userAgent;
|
|
var msie = ua.indexOf('MSIE ');
|
|
if (msie > 0) {
|
|
// IE 10 or older => return version number
|
|
return true;
|
|
}
|
|
var trident = ua.indexOf('Trident/');
|
|
if (trident > 0) {
|
|
// IE 11 => return version number
|
|
var rv = ua.indexOf('rv:');
|
|
return true;
|
|
}
|
|
var edge = ua.indexOf('Edge/');
|
|
if (edge > 0) {
|
|
// Edge (IE 12+) => return version number
|
|
return true;
|
|
}
|
|
// other browser
|
|
return false;
|
|
}
|
|
static isIOS() {
|
|
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window['MSStream'];
|
|
}
|
|
static isAndroid() {
|
|
return /(android)/i.test(navigator.userAgent);
|
|
}
|
|
static isTouchDevice() {
|
|
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
}
|
|
static appendChild(element, target) {
|
|
if (this.isElement(target))
|
|
target.appendChild(element);
|
|
else if (target && target.el && target.el.nativeElement)
|
|
target.el.nativeElement.appendChild(element);
|
|
else
|
|
throw 'Cannot append ' + target + ' to ' + element;
|
|
}
|
|
static removeChild(element, target) {
|
|
if (this.isElement(target))
|
|
target.removeChild(element);
|
|
else if (target.el && target.el.nativeElement)
|
|
target.el.nativeElement.removeChild(element);
|
|
else
|
|
throw 'Cannot remove ' + element + ' from ' + target;
|
|
}
|
|
static removeElement(element) {
|
|
if (!('remove' in Element.prototype))
|
|
element.parentNode.removeChild(element);
|
|
else
|
|
element.remove();
|
|
}
|
|
static isElement(obj) {
|
|
return typeof HTMLElement === 'object' ? obj instanceof HTMLElement : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string';
|
|
}
|
|
static calculateScrollbarWidth(el) {
|
|
if (el) {
|
|
let style = getComputedStyle(el);
|
|
return el.offsetWidth - el.clientWidth - parseFloat(style.borderLeftWidth) - parseFloat(style.borderRightWidth);
|
|
}
|
|
else {
|
|
if (this.calculatedScrollbarWidth !== null)
|
|
return this.calculatedScrollbarWidth;
|
|
let scrollDiv = document.createElement('div');
|
|
scrollDiv.className = 'p-scrollbar-measure';
|
|
document.body.appendChild(scrollDiv);
|
|
let scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
document.body.removeChild(scrollDiv);
|
|
this.calculatedScrollbarWidth = scrollbarWidth;
|
|
return scrollbarWidth;
|
|
}
|
|
}
|
|
static calculateScrollbarHeight() {
|
|
if (this.calculatedScrollbarHeight !== null)
|
|
return this.calculatedScrollbarHeight;
|
|
let scrollDiv = document.createElement('div');
|
|
scrollDiv.className = 'p-scrollbar-measure';
|
|
document.body.appendChild(scrollDiv);
|
|
let scrollbarHeight = scrollDiv.offsetHeight - scrollDiv.clientHeight;
|
|
document.body.removeChild(scrollDiv);
|
|
this.calculatedScrollbarWidth = scrollbarHeight;
|
|
return scrollbarHeight;
|
|
}
|
|
static invokeElementMethod(element, methodName, args) {
|
|
element[methodName].apply(element, args);
|
|
}
|
|
static clearSelection() {
|
|
if (window.getSelection) {
|
|
if (window.getSelection().empty) {
|
|
window.getSelection().empty();
|
|
}
|
|
else if (window.getSelection().removeAllRanges && window.getSelection().rangeCount > 0 && window.getSelection().getRangeAt(0).getClientRects().length > 0) {
|
|
window.getSelection().removeAllRanges();
|
|
}
|
|
}
|
|
else if (document['selection'] && document['selection'].empty) {
|
|
try {
|
|
document['selection'].empty();
|
|
}
|
|
catch (error) {
|
|
//ignore IE bug
|
|
}
|
|
}
|
|
}
|
|
static getBrowser() {
|
|
if (!this.browser) {
|
|
let matched = this.resolveUserAgent();
|
|
this.browser = {};
|
|
if (matched.browser) {
|
|
this.browser[matched.browser] = true;
|
|
this.browser['version'] = matched.version;
|
|
}
|
|
if (this.browser['chrome']) {
|
|
this.browser['webkit'] = true;
|
|
}
|
|
else if (this.browser['webkit']) {
|
|
this.browser['safari'] = true;
|
|
}
|
|
}
|
|
return this.browser;
|
|
}
|
|
static resolveUserAgent() {
|
|
let ua = navigator.userAgent.toLowerCase();
|
|
let match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || (ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua)) || [];
|
|
return {
|
|
browser: match[1] || '',
|
|
version: match[2] || '0'
|
|
};
|
|
}
|
|
static isInteger(value) {
|
|
if (Number.isInteger) {
|
|
return Number.isInteger(value);
|
|
}
|
|
else {
|
|
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
|
|
}
|
|
}
|
|
static isHidden(element) {
|
|
return !element || element.offsetParent === null;
|
|
}
|
|
static isVisible(element) {
|
|
return element && element.offsetParent != null;
|
|
}
|
|
static isExist(element) {
|
|
return element !== null && typeof element !== 'undefined' && element.nodeName && element.parentNode;
|
|
}
|
|
static focus(element, options) {
|
|
element && document.activeElement !== element && element.focus(options);
|
|
}
|
|
static getFocusableSelectorString(selector = '') {
|
|
return `button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
.p-inputtext:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
|
|
.p-button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector}`;
|
|
}
|
|
static getFocusableElements(element, selector = '') {
|
|
let focusableElements = this.find(element, this.getFocusableSelectorString(selector));
|
|
let visibleFocusableElements = [];
|
|
for (let focusableElement of focusableElements) {
|
|
const computedStyle = getComputedStyle(focusableElement);
|
|
if (this.isVisible(focusableElement) && computedStyle.display != 'none' && computedStyle.visibility != 'hidden')
|
|
visibleFocusableElements.push(focusableElement);
|
|
}
|
|
return visibleFocusableElements;
|
|
}
|
|
static getFocusableElement(element, selector = '') {
|
|
let focusableElement = this.findSingle(element, this.getFocusableSelectorString(selector));
|
|
if (focusableElement) {
|
|
const computedStyle = getComputedStyle(focusableElement);
|
|
if (this.isVisible(focusableElement) && computedStyle.display != 'none' && computedStyle.visibility != 'hidden')
|
|
return focusableElement;
|
|
}
|
|
return null;
|
|
}
|
|
static getFirstFocusableElement(element, selector) {
|
|
const focusableElements = this.getFocusableElements(element, selector);
|
|
return focusableElements.length > 0 ? focusableElements[0] : null;
|
|
}
|
|
static getLastFocusableElement(element, selector) {
|
|
const focusableElements = this.getFocusableElements(element, selector);
|
|
return focusableElements.length > 0 ? focusableElements[focusableElements.length - 1] : null;
|
|
}
|
|
static getNextFocusableElement(element, reverse = false) {
|
|
const focusableElements = DomHandler.getFocusableElements(element);
|
|
let index = 0;
|
|
if (focusableElements && focusableElements.length > 0) {
|
|
const focusedIndex = focusableElements.indexOf(focusableElements[0].ownerDocument.activeElement);
|
|
if (reverse) {
|
|
if (focusedIndex == -1 || focusedIndex === 0) {
|
|
index = focusableElements.length - 1;
|
|
}
|
|
else {
|
|
index = focusedIndex - 1;
|
|
}
|
|
}
|
|
else if (focusedIndex != -1 && focusedIndex !== focusableElements.length - 1) {
|
|
index = focusedIndex + 1;
|
|
}
|
|
}
|
|
return focusableElements[index];
|
|
}
|
|
static generateZIndex() {
|
|
this.zindex = this.zindex || 999;
|
|
return ++this.zindex;
|
|
}
|
|
static getSelection() {
|
|
if (window.getSelection)
|
|
return window.getSelection().toString();
|
|
else if (document.getSelection)
|
|
return document.getSelection().toString();
|
|
else if (document['selection'])
|
|
return document['selection'].createRange().text;
|
|
return null;
|
|
}
|
|
static getTargetElement(target, el) {
|
|
if (!target)
|
|
return null;
|
|
switch (target) {
|
|
case 'document':
|
|
return document;
|
|
case 'window':
|
|
return window;
|
|
case '@next':
|
|
return el?.nextElementSibling;
|
|
case '@prev':
|
|
return el?.previousElementSibling;
|
|
case '@parent':
|
|
return el?.parentElement;
|
|
case '@grandparent':
|
|
return el?.parentElement.parentElement;
|
|
default:
|
|
const type = typeof target;
|
|
if (type === 'string') {
|
|
return document.querySelector(target);
|
|
}
|
|
else if (type === 'object' && target.hasOwnProperty('nativeElement')) {
|
|
return this.isExist(target.nativeElement) ? target.nativeElement : undefined;
|
|
}
|
|
const isFunction = (obj) => !!(obj && obj.constructor && obj.call && obj.apply);
|
|
const element = isFunction(target) ? target() : target;
|
|
return (element && element.nodeType === 9) || this.isExist(element) ? element : null;
|
|
}
|
|
}
|
|
static isClient() {
|
|
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
}
|
|
static getAttribute(element, name) {
|
|
if (element) {
|
|
const value = element.getAttribute(name);
|
|
if (!isNaN(value)) {
|
|
return +value;
|
|
}
|
|
if (value === 'true' || value === 'false') {
|
|
return value === 'true';
|
|
}
|
|
return value;
|
|
}
|
|
return undefined;
|
|
}
|
|
static calculateBodyScrollbarWidth() {
|
|
return window.innerWidth - document.documentElement.offsetWidth;
|
|
}
|
|
static blockBodyScroll(className = 'p-overflow-hidden') {
|
|
document.body.style.setProperty('--scrollbar-width', this.calculateBodyScrollbarWidth() + 'px');
|
|
this.addClass(document.body, className);
|
|
}
|
|
static unblockBodyScroll(className = 'p-overflow-hidden') {
|
|
document.body.style.removeProperty('--scrollbar-width');
|
|
this.removeClass(document.body, className);
|
|
}
|
|
}
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9taGFuZGxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvY29tcG9uZW50cy9kb20vZG9taGFuZGxlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7OztHQU9HO0FBQ0gsV0FBVztBQUNYLE1BQU0sT0FBTy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ICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc3R5bGVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZChzdHlsZXNbaV0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbGV0IHN0eWxlczogc3RyaW5nW10gPSBjbGFzc05hbWUuc3BsaXQoJyAnKTtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0eWxlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmNsYXNzTmFtZSArPSAnICcgKyBzdHlsZXNbaV07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyByZW1vdmVDbGFzcyhlbGVtZW50OiBhbnksIGNsYXNzTmFtZTogc3RyaW5nKTogdm9pZCB7XG4gICAgICAgIGlmIChlbGVtZW50ICYmIGNsYXNzTmFtZSkge1xuICAgICAgICAgICAgaWYgKGVsZW1lbnQuY2xhc3NMaXN0KSBlbGVtZW50LmNsYXNzTGlzdC5yZW1vdmUoY2xhc3NOYW1lKTtcbiAgICAgICAgICAgIGVsc2UgZWxlbWVudC5jbGFzc05hbWUgPSBlbGVtZW50LmNsYXNzTmFtZS5yZXBsYWNlKG5ldyBSZWdFeHAoJyhefFxcXFxiKScgKyBjbGFzc05hbWUuc3BsaXQoJyAnKS5qb2luKCd8JykgKyAnKFxcXFxifCQpJywgJ2dpJyksICcgJyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBwdWJsaWMgc3RhdGljIHJlbW92ZU11bHRpcGxlQ2xhc3NlcyhlbGVtZW50LCBjbGFzc05hbWVzKSB7XG4gICAgICAgIGlmIChlbGVtZW50ICYmIGNsYXNzTmFtZXMpIHtcbiAgICAgICAgICAgIFtjbGFzc05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292ZXJmbG93JykpIHx8IG92ZXJmbG93UmVnZXgudGVzdChzdHlsZURlY2xhcmF0aW9uLmdldFByb3BlcnR5VmFsdWUoJ292ZXJmbG93WCcpKSB8fCBvdmVyZmxvd1JlZ2V4LnRlc3Qoc3R5bGVEZWNsYXJhdGlvbi5nZXRQcm9wZXJ0eVZhbHVlKCdvdmVyZmxvd1knKSk7XG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBmb3IgKGxldCBwYXJlbnQgb2YgcGFyZW50cykge1xuICAgICAgICAgICAgICAgIGxldCBzY3JvbGxTZWxlY3RvcnMgPSBwYXJlbnQubm9kZVR5cGUgPT09IDEgJiYgcGFyZW50LmRhdGFzZXRbJ3Njcm9sbHNlbGVjdG9ycyddO1xuICAgICAgICAgICAgICAgIGlmIChzY3JvbGxTZWxlY3RvcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNlbGVjdG9ycyA9IHNjcm9sbFNlbGVjdG9ycy5zcGxpdCgnLCcpO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBzZWxlY3RvciBvZiBzZWxlY3RvcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbCA9IHRoaXMuZmluZFNpbmdsZShwYXJlbnQsIHNlbGVjdG9yKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbCAmJiBvdmVyZmxvd0NoZWNrKGVsKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjcm9sbGFibGVQYXJlbnRzLnB1c2goZWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKHBhcmVudC5ub2RlVHlwZSAhPT0gOSAmJiBvdmVyZmxvd0NoZWNrKHBhcmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgc2Nyb2xsYWJsZVBhcmVudHMucHVzaChwYXJlbnQpO1xuICAgIC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1cblxuICAgIHB1YmxpYyBzdGF0aWMgaXNJRSgpIHtcbiAgICAgICAgdmFyIHVhID0gd2luZG93Lm5hdmlnYXRvci51c2VyQWdlbnQ7XG5cbiAgICAgICAgdmFyIG1zaWUgPSB1YS5pbmRleE9mKCdNU0lFICcpO1xuICAgICAgICBpZiAobXNpZSA+IDApIHtcbiAgICAgICAgICAgIC8vIElFIDEwIG9yIG9sZGVyID0+IHJldHVybiB2ZXJzaW9uIG51bWJlclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgdHJpZGVudCA9IHVhLmluZGV4T2YoJ1RyaWRlbnQvJyk7XG4gICAgICAgIGlmICh0cmlkZW50ID4gMCkge1xuICAgICAgICAgICAgLy8gSUUgMTEgPT4gcmV0dXJuIHZlcnNpb24gbnVtYmVyXG4gICAgICAgICAgICB2YXIgcnYgPSB1YS5pbmRleE9mKCdydjonKTtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGVkZ2UgPSB1YS5pbmRleE9mKCdFZGdlLycpO1xuICAgICAgICBpZiAoZWRnZSA+IDApIHtcbiAgICAgICAgICAgIC8vIEVkZ2UgKElFIDEyKykgPT4gcmV0dXJuIHZlcnNpb24gbnVtYmVyXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIG90aGVyIGJyb3dzZXJcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIHB1YmxpYyBzdGF0aWMgaXNJT1MoKSB7XG4gICAgICAgIHJldHVybiAvaVBhZHxpUGhvbmV8aVBvZC8udGVzdChuYXZpZ2F0b3IudXNlckFnZW50KSAmJiAhd2luZG93WydNU1N0cmVhbSddO1xuICAgIH1cblxuICAgIHB1YmxpYyBzdGF0aWMgaXNBbmRyb2lkKCkge1xuICAgICAgICByZXR1cm4gLyhhbmRyb2lkKS9pLnRl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bmd0aCA+IDApIHtcbiAgICAgICAgICAgIGNvbnN0IGZvY3VzZWRJbmRleCA9IGZvY3VzYWJsZUVsZW1lbnRzLmluZGV4T2YoZm9jdXNhYmxlRWxlbWVudHNbMF0ub3duZXJEb2N1bWVudC5hY3RpdmVFbGVtZW50KTtcblxuICAgICAgICAgICAgaWYgKHJldmVyc2UpIHtcbiAgICAgICAgICAgICAgICBpZiAoZm9jdXNlZEluZGV4ID09IC0xIHx8IGZvY3VzZWRJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBpbmRleCA9IGZvY3VzYWJsZUVsZW1lbnRzLmxlbmd0aCAtIDE7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBmb2N1c2VkSW5kZXggLSAxO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZm9jdXNlZEluZGV4ICE9IC0xICYmIGZvY3VzZWRJbmRleCAhPT0gZm9jdXNhYmxlRWxlbWVudHMubGVuZ3RoIC0gMSkge1xuICAgICAgICAgICAgICAgIGluZGV4ID0gZm9jdXNlZEluZGV4ICsgMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBmb2N1c2FibGVFbGVtZW50c1tpbmRleF07XG4gICAgfVxuXG4gICAgc3RhdGljIGdlbmVyYXRlWkluZGV4KCkge1xuICAgICAgICB0aGlzLnppbmRleCA9IHRoaXMuemluZGV4IHx8IDk5OTtcbiAgICAgICAgcmV0dXJuICsrdGhpcy56aW5kZXg7XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBnZXRTZWxlY3Rpb24oKSB7XG4gICAgICAgIGlmICh3aW5kb3cuZ2V0U2VsZWN0aW9uKSByZXR1cm4gd2luZG93LmdldFNlbGVjdGlvbigpLnRvU3RyaW5nKCk7XG4gICAgICAgIGVsc2UgaWYgKGRvY3VtZW50LmdldFNlbGVjdGlvbikgcmV0dXJuIGRvY3VtZW50LmdldFNlbGVjdGlvbigpLnRvU3RyaW5nKCk7XG4gICAgICAgIGVsc2UgaWYgKGRvY3VtZW50WydzZWxlY3Rpb24nXSkgcmV0dXJuIGRvY3VtZW50WydzZWxlY3Rpb24nXS5jcmVhdGVSYW5nZSgpLnRleHQ7XG5cbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBnZXRUYXJnZXRFbGVtZW50KHRhcmdldDogYW55LCBlbD86IEhUTUxFbGVtZW50KSB7XG4gICAgICAgIGlmICghdGFyZ2V0KSByZXR1cm4gbnVsbDtcblxuICAgICAgICBzd2l0Y2ggKHRhcmdldCkge1xuICAgICAgICAgICAgY2FzZSAnZG9jdW1lbnQnOlxuICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudDtcbiAgICAgICAgICAgIGNhc2UgJ3dpbmRvdyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHdpbmRvdztcbiAgICAgICAgICAgIGNhc2UgJ0BuZXh0JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZWw/Lm5leHRFbGVtZW50U2libGluZztcbiAgICAgICAgICAgIGNhc2UgJ0BwcmV2JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZWw/LnByZXZpb3VzRWxlbWVudFNpYmxpbmc7XG4gICAgICAgICAgICBjYXNlICdAcGFyZW50JzpcbiAgICAgICAgICAgICAgICByZXR1cm4gZWw/LnBhcmVudEVsZW1lbnQ7XG4gICAgICAgICAgICBjYXNlICdAZ3JhbmRwYXJlbnQnOlxuICAgICAgICAgICAgICAgIHJldHVybiBlbD8ucGFyZW50RWxlbWVudC5wYXJlbnRFbGVtZW50O1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBjb25zdCB0eXBlID0gdHlwZW9mIHRhcmdldDtcblxuICAgICAgICAgICAgICAgIGlmICh0eXBlID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQucXVlcnlTZWxlY3Rvcih0YXJnZXQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZSA9PT0gJ29iamVjdCcgJiYgdGFyZ2V0Lmhhc093blByb3BlcnR5KCduYXRpdmVFbGVtZW50JykpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaXNFeGlzdCh0YXJnZXQubmF0aXZlRWxlbWVudCkgPyB0YXJnZXQubmF0aXZlRWxlbWVudCA6IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBjb25zdCBpc0Z1bmN0aW9uID0gKG9iajogYW55KSA9PiAhIShvYmogJiYgb2JqLmNvbnN0cnVjdG9yICYmIG9iai5jYWxsICYmIG9iai5hcHBseSk7XG4gICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGlzRnVuY3Rpb24odGFyZ2V0KSA/IHRhcmdldCgpIDogdGFyZ2V0O1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIChlbGVtZW50ICYmIGVsZW1lbnQubm9kZVR5cGUgPT09IDkpIHx8IHRoaXMuaXNFeGlzdChlbGVtZW50KSA/IGVsZW1lbnQgOiBudWxsO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBpc0NsaWVudCgpIHtcbiAgICAgICAgcmV0dXJuICEhKHR5cGVvZiB3aW5kb3cgIT09ICd1bmRlZmluZWQnICYmIHdpbmRvdy5kb2N1bWVudCAmJiB3aW5kb3cuZG9jdW1lbnQuY3JlYXRlRWxlbWVudCk7XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBnZXRBdHRyaWJ1dGUoZWxlbWVudCwgbmFtZSkge1xuICAgICAgICBpZiAoZWxlbWVudCkge1xuICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBlbGVtZW50LmdldEF0dHJpYnV0ZShuYW1lKTtcblxuICAgICAgICAgICAg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