shorter-js
Advanced tools
Comparing version 0.3.0-alpha1 to 0.3.0-alpha2
/*! | ||
* shorter-js v0.3.0alpha1 (https://github.com/thednp/shorter-js) | ||
* shorter-js v0.3.0alpha2 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2022 © dnp_theme | ||
@@ -660,3 +660,6 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* A global namespace for: | ||
* * `transitionProperty` string for Firefox, | ||
* * `transition` property for all other browsers. | ||
* | ||
* @type {string} | ||
@@ -667,3 +670,6 @@ */ | ||
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* A global namespace for: | ||
* * `transitionProperty` string for Firefox, | ||
* * `webkitTransition` for older Chrome / Safari browsers, | ||
* * `transition` property for all other browsers. | ||
* @type {string} | ||
@@ -748,2 +754,10 @@ */ | ||
const { userAgent: userAgentString } = navigator; | ||
/** | ||
* A global namespace for `navigator.userAgent` string. | ||
* @type {string} | ||
*/ | ||
const userAgent = userAgentString; | ||
const mobileBrands = /iPhone|iPad|iPod|Android/i; | ||
@@ -757,7 +771,7 @@ let isMobileCheck = false; | ||
} else { | ||
isMobileCheck = mobileBrands.test(navigator.userAgent); | ||
isMobileCheck = mobileBrands.test(userAgent); | ||
} | ||
/** | ||
* A global namespace for mobile detection. | ||
* A global `boolean` for mobile detection. | ||
* @type {boolean} | ||
@@ -773,3 +787,3 @@ */ | ||
/** | ||
* A global boolean for Apple browsers. | ||
* A global `boolean` for Apple browsers. | ||
* @type {boolean} | ||
@@ -781,2 +795,7 @@ */ | ||
/** | ||
* A global boolean for Gecko browsers. | ||
*/ | ||
const isFirefox = userAgent ? userAgent.includes('Firefox') : false; | ||
/** | ||
* A global `boolean` for CSS3 3D transform support. | ||
@@ -837,3 +856,6 @@ * @type {boolean} | ||
/** | ||
* A global namespace for passive events support. | ||
* A global `boolean` for passive events support, | ||
* in general event options are not suited for scroll prevention. | ||
* | ||
* @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection | ||
* @type {boolean} | ||
@@ -859,3 +881,3 @@ */ | ||
/** | ||
* A global namespace for CSS3 transform support. | ||
* A global `boolean` for CSS3 transform support. | ||
* @type {boolean} | ||
@@ -866,3 +888,3 @@ */ | ||
/** | ||
* A global namespace for touch events support. | ||
* A global `boolean` for touch events support. | ||
* @type {boolean} | ||
@@ -879,3 +901,3 @@ */ | ||
/** | ||
* A global namespace for CSS3 transition support. | ||
* A global `boolean` for CSS3 transition support. | ||
* @type {boolean} | ||
@@ -917,100 +939,26 @@ */ | ||
/** | ||
* Checks if an element is an `HTMLElement`. | ||
* Shortcut for `Array.from()` static method. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Array<any>} | ||
*/ | ||
const isHTMLElement = (element) => element && element instanceof HTMLElement; | ||
const ArrayFrom = (arr) => Array.from(arr); | ||
/** | ||
* Utility to check if target is typeof `HTMLElement` | ||
* Utility to check if target is typeof `HTMLElement`, `Element`, `Node` | ||
* or find one that matches a selector. | ||
* | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {HTMLElement=} parent optional `HTMLElement` to look into | ||
* @param {(Node | Element | HTMLElement)=} parent optional node to look into | ||
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result | ||
*/ | ||
function querySelector(selector, parent) { | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return typeof selector === 'object' ? selector : lookUp.querySelector(selector); | ||
const nodeTypes = [HTMLElement, Element, Node]; | ||
const lookUp = parent && nodeTypes.some((x) => parent instanceof x) ? parent : document; | ||
return nodeTypes.some((x) => selector instanceof x) | ||
// @ts-ignore -- we must include ShadowRoot Node | ||
? selector : lookUp.querySelector(selector); | ||
} | ||
/** @type {Map<HTMLElement, any>} */ | ||
const TimeCache = new Map(); | ||
/** | ||
* An interface for one or more `TimerHandler`s per `Element`. | ||
* @see https://github.com/thednp/navbar.js/ | ||
*/ | ||
const Timer = { | ||
/** | ||
* Sets a new timeout timer for an element, or element -> key association. | ||
* @param {HTMLElement | string} target target element | ||
* @param {ReturnType<TimerHandler>} callback the callback | ||
* @param {number} delay the execution delay | ||
* @param {string=} key a unique | ||
*/ | ||
set: (target, callback, delay, key) => { | ||
const element = querySelector(target); | ||
if (!element) return; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
TimeCache.set(element, new Map()); | ||
} | ||
const keyTimers = TimeCache.get(element); | ||
keyTimers.set(key, setTimeout(callback, delay)); | ||
} else { | ||
TimeCache.set(element, setTimeout(callback, delay)); | ||
} | ||
}, | ||
/** | ||
* Returns the timer associated with the target. | ||
* @param {HTMLElement | string} target target element | ||
* @param {string=} key a unique | ||
* @returns {ReturnType<TimerHandler>?} the timer | ||
*/ | ||
get: (target, key) => { | ||
const element = querySelector(target); | ||
if (!element) return null; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
TimeCache.set(element, new Map()); | ||
} | ||
const keyTimers = TimeCache.get(element); | ||
if (keyTimers.has(key)) { | ||
return keyTimers.get(key); | ||
} | ||
} else if (TimeCache.has(element)) { | ||
return TimeCache.get(element); | ||
} | ||
return null; | ||
}, | ||
/** | ||
* Clears the element's timer. | ||
* @param {HTMLElement} target target element | ||
* @param {string=} key a unique | ||
*/ | ||
clear: (target, key) => { | ||
const element = querySelector(target); | ||
const timers = element && TimeCache.get(element); | ||
if (!timers) return; | ||
if (key && key.length) { | ||
if (timers.has(key)) { | ||
clearTimeout(timers.get(key)); | ||
timers.delete(key); | ||
} | ||
} else { | ||
clearTimeout(timers); | ||
TimeCache.delete(element); | ||
} | ||
}, | ||
}; | ||
/** @type {Map<string, Map<HTMLElement, SHORTER.Component>>} */ | ||
@@ -1101,3 +1049,3 @@ const componentData = new Map(); | ||
* @param {HTMLElement} element target | ||
* @param {string=} property the css property | ||
* @param {string} property the css property | ||
* @return {string} the css property value | ||
@@ -1108,5 +1056,5 @@ */ | ||
return property && property in computedStyle | ||
? computedStyle.getPropertyValue(property) | ||
: ''; | ||
// @ts-ignore -- must use camelcase strings, | ||
// or non-camelcase strings with `getPropertyValue` | ||
return property in computedStyle ? computedStyle[property] : ''; | ||
} | ||
@@ -1388,10 +1336,24 @@ | ||
// general event options | ||
/** | ||
* Shortcut for `Float32Array.from()` static method. | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Float32Array} | ||
*/ | ||
const Float32ArrayFrom = (arr) => Float32Array.from(Array.from(arr)); | ||
/** | ||
* A global namespace for most scroll event listeners. | ||
* Shortcut for `Float64Array.from()` static method. | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Float64Array} | ||
*/ | ||
const passiveHandler = supportPassive ? { passive: true } : false; | ||
const Float64ArrayFrom = (arr) => Float64Array.from(Array.from(arr)); | ||
/** | ||
* Utility to focus an `HTMLElement` target. | ||
* | ||
* @param {HTMLElement} element is the target | ||
*/ | ||
const focus = (element) => element.focus(); | ||
/** | ||
* The raw value or a given component option. | ||
@@ -1437,3 +1399,3 @@ * | ||
/** | ||
* Utility to normalize component options | ||
* Utility to normalize component options. | ||
* | ||
@@ -1479,2 +1441,107 @@ * @param {HTMLElement} element target | ||
/** | ||
* Shortcut for `Object.assign()` static method. | ||
* @param {Record<string, any>} obj a target object | ||
* @param {Record<string, any>} source a source object | ||
*/ | ||
const ObjectAssign = (obj, source) => Object.assign(obj, source); | ||
/** | ||
* Shortcut for `Object.values()` static method. | ||
* @param {Record<string, any>} obj a target object | ||
* @returns {any[]} | ||
*/ | ||
const ObjectValues = (obj) => Object.values(obj); | ||
/** | ||
* A global namespace for most scroll event listeners. | ||
*/ | ||
const passiveHandler = supportPassive ? { passive: true } : false; | ||
/** | ||
* Utility to force re-paint of an `HTMLElement` target. | ||
* | ||
* @param {HTMLElement} element is the target | ||
* @return {number} the `Element.offsetHeight` value | ||
*/ | ||
const reflow = (element) => element.offsetHeight; | ||
/** @type {Map<HTMLElement, any>} */ | ||
const TimeCache = new Map(); | ||
/** | ||
* An interface for one or more `TimerHandler`s per `Element`. | ||
* @see https://github.com/thednp/navbar.js/ | ||
*/ | ||
const Timer = { | ||
/** | ||
* Sets a new timeout timer for an element, or element -> key association. | ||
* @param {HTMLElement | string} target target element | ||
* @param {ReturnType<TimerHandler>} callback the callback | ||
* @param {number} delay the execution delay | ||
* @param {string=} key a unique | ||
*/ | ||
set: (target, callback, delay, key) => { | ||
const element = querySelector(target); | ||
if (!element) return; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
TimeCache.set(element, new Map()); | ||
} | ||
const keyTimers = TimeCache.get(element); | ||
keyTimers.set(key, setTimeout(callback, delay)); | ||
} else { | ||
TimeCache.set(element, setTimeout(callback, delay)); | ||
} | ||
}, | ||
/** | ||
* Returns the timer associated with the target. | ||
* @param {HTMLElement | string} target target element | ||
* @param {string=} key a unique | ||
* @returns {ReturnType<TimerHandler>?} the timer | ||
*/ | ||
get: (target, key) => { | ||
const element = querySelector(target); | ||
if (!element) return null; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
TimeCache.set(element, new Map()); | ||
} | ||
const keyTimers = TimeCache.get(element); | ||
if (keyTimers.has(key)) { | ||
return keyTimers.get(key); | ||
} | ||
} else if (TimeCache.has(element)) { | ||
return TimeCache.get(element); | ||
} | ||
return null; | ||
}, | ||
/** | ||
* Clears the element's timer. | ||
* @param {HTMLElement} target target element | ||
* @param {string=} key a unique | ||
*/ | ||
clear: (target, key) => { | ||
const element = querySelector(target); | ||
const timers = element && TimeCache.get(element); | ||
if (!timers) return; | ||
if (key && key.length) { | ||
if (timers.has(key)) { | ||
clearTimeout(timers.get(key)); | ||
timers.delete(key); | ||
} | ||
} else { | ||
clearTimeout(timers); | ||
TimeCache.delete(element); | ||
} | ||
}, | ||
}; | ||
/** | ||
* Utility to wrap a callback in a try() catch(e) | ||
@@ -1492,60 +1559,280 @@ * | ||
/** | ||
* Utility to force re-paint of an `HTMLElement` target. | ||
* Shortcut for `HTMLElement.getAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
*/ | ||
const getAttribute = (element, attribute) => element.getAttribute(attribute); | ||
/** | ||
* Shortcut for `SVGElement.getAttributeNS()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
* @param {string=} ns attribute namespace | ||
*/ | ||
const getAttributeNS = (element, attribute, ns) => element.getAttributeNS(ns || null, attribute); | ||
/** | ||
* Checks if an element is an `HTMLElement`. | ||
* | ||
* @param {HTMLElement} element is the target | ||
* @return {number} the `Element.offsetHeight` value | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const reflow = (element) => element.offsetHeight; | ||
const isHTMLElement = (element) => element instanceof HTMLElement; | ||
/** | ||
* Utility to focus an `HTMLElement` target. | ||
* Returns the bounding client rect of a target `HTMLElement`. | ||
* | ||
* @param {HTMLElement} element is the target | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {boolean=} includeScale when *true*, the target scale is also computed | ||
* @returns {SHORTER.BoundingClientRect} the bounding client rect object | ||
*/ | ||
const focus = (element) => element.focus(); | ||
function getBoundingClientRect(element, includeScale) { | ||
const clientRect = element.getBoundingClientRect(); | ||
let scaleX = 1; | ||
let scaleY = 1; | ||
if (includeScale && isHTMLElement(element)) { | ||
scaleX = element.offsetWidth > 0 | ||
? Math.round(clientRect.width) / element.offsetWidth || 1 : 1; | ||
scaleY = element.offsetHeight > 0 | ||
? Math.round(clientRect.height) / element.offsetHeight || 1 : 1; | ||
} | ||
return { | ||
width: clientRect.width / scaleX, | ||
height: clientRect.height / scaleY, | ||
top: clientRect.top / scaleY, | ||
right: clientRect.right / scaleX, | ||
bottom: clientRect.bottom / scaleY, | ||
left: clientRect.left / scaleX, | ||
x: clientRect.left / scaleX, | ||
y: clientRect.top / scaleY, | ||
}; | ||
} | ||
/** | ||
* Shortcut for `Array.from()` static method. | ||
* Returns the `document.documentElement` or the `<html>` element. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* @param {Node | Window} node | ||
* @returns {HTMLElement} | ||
*/ | ||
function getDocumentElement(node) { | ||
const doc = (node instanceof Node ? node.ownerDocument : node.document) || window.document; | ||
return doc.documentElement; | ||
} | ||
/** | ||
* Returns an `{x,y}` object with the target | ||
* `Element` / `Node` scroll position. | ||
* | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Array<any>} | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {HTMLElement | Window} element target node / element | ||
* @returns {{x: number, y: number}} the scroll tuple | ||
*/ | ||
const ArrayFrom = (arr) => Array.from(arr); | ||
function getNodeScroll(element) { | ||
const isWin = 'scrollX' in element; | ||
const x = isWin ? element.scrollX : element.scrollLeft; | ||
const y = isWin ? element.scrollY : element.scrollTop; | ||
return { x, y }; | ||
} | ||
/** | ||
* Shortcut for `Float32Array.from()` static method. | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Float32Array} | ||
* Check if a target element is a `<table>`, `<td>` or `<th>`. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
*/ | ||
const Float32ArrayFrom = (arr) => Float32Array.from(Array.from(arr)); | ||
const isTableElement = (element) => ['TABLE', 'TD', 'TH'].includes(element.tagName); | ||
/** | ||
* Shortcut for `Float64Array.from()` static method. | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Float64Array} | ||
* Check if target is a `ShadowRoot`. | ||
* | ||
* @param {HTMLElement} element target | ||
* @returns {boolean} the query result | ||
*/ | ||
const Float64ArrayFrom = (arr) => Float64Array.from(Array.from(arr)); | ||
const isShadowRoot = (element) => { | ||
// eslint-disable-next-line no-restricted-globals | ||
const OwnElement = (self || window).ShadowRoot; | ||
return element instanceof OwnElement || element instanceof ShadowRoot; | ||
}; | ||
/** | ||
* Shortcut for `Object.assign()` static method. | ||
* @param {Record<string, any>} obj a target object | ||
* @param {Record<string, any>} source a source object | ||
* Returns the `parentNode` also going through `ShadowRoot`. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {Node | Element} node the target node | ||
* @returns {Node} the apropriate parent node | ||
*/ | ||
const ObjectAssign = (obj, source) => Object.assign(obj, source); | ||
function getParentNode(node) { | ||
if (node.nodeName === 'HTML') { | ||
return node; | ||
} | ||
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle | ||
// @ts-ignore | ||
node.assignedSlot // step into the shadow DOM of the parent of a slotted node | ||
|| node.parentNode | ||
|| (// @ts-ignore DOM Element detected | ||
isShadowRoot(node) ? node.host : null) // ShadowRoot detected | ||
|| getDocumentElement(node) // fallback | ||
); | ||
} | ||
/** | ||
* Shortcut for `Object.values()` static method. | ||
* @param {Record<string, any>} obj a target object | ||
* @returns {any[]} | ||
* Check if a target node is `window`. | ||
* | ||
* @param {any} node the target node | ||
* @returns {boolean} the query result | ||
*/ | ||
const ObjectValues = (obj) => Object.values(obj); | ||
function isWindow(node) { | ||
// eslint-disable-next-line no-restricted-globals | ||
return [self, window].includes(node); | ||
} | ||
/** | ||
* Shortcut for `HTMLElement.getAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
* Returns the `Window` object. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {(Node | Element)=} node target node | ||
* @returns {Window} the `Window` object | ||
*/ | ||
const getAttribute = (element, attribute) => element.getAttribute(attribute); | ||
function getWindow(node) { | ||
if (node == null) { | ||
return window; | ||
} | ||
if (!isWindow(node)) { | ||
const { ownerDocument } = node; | ||
return ownerDocument ? ownerDocument.defaultView || window : window; | ||
} | ||
// @ts-ignore | ||
return node; | ||
} | ||
/** | ||
* @param {Node} element | ||
* @returns {boolean} | ||
*/ | ||
function isContainingBlock(element) { | ||
// TODO: Try and use feature detection here instead | ||
const { | ||
transform, perspective, contain, willChange, filter, | ||
// @ts-ignore | ||
} = getComputedStyle(element); | ||
// This is non-exhaustive but covers the most common CSS properties that | ||
// create a containing block. | ||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block | ||
return transform !== 'none' | ||
|| perspective !== 'none' | ||
|| contain === 'paint' | ||
|| ['transform', 'perspective'].includes(willChange) | ||
|| (isFirefox && willChange === 'filter') | ||
|| (isFirefox && (filter ? filter !== 'none' : false)); | ||
} | ||
/** | ||
* @param {Node} element | ||
* @returns {(Node | ParentNode)?} | ||
*/ | ||
function getContainingBlock(element) { | ||
let currentNode = getParentNode(element); | ||
while (isHTMLElement(currentNode) && !['HTML', 'BODY'].includes(currentNode.nodeName)) { | ||
if (isContainingBlock(currentNode)) { | ||
return currentNode; | ||
} | ||
// @ts-ignore | ||
currentNode = currentNode.parentNode; | ||
} | ||
return null; | ||
} | ||
/** | ||
* @param {HTMLElement} element | ||
* @returns {HTMLElement?} | ||
*/ | ||
function getTrueOffsetParent(element) { | ||
if (!isHTMLElement(element) || getElementStyle(element, 'position') === 'fixed') { | ||
return null; | ||
} | ||
// @ts-ignore | ||
return element.offsetParent; | ||
} | ||
/** | ||
* Returns the best possible container for offsets computation. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {HTMLElement} element target element | ||
* @returns {HTMLElement | Window | Node} the best `Node` / `Element` match | ||
*/ | ||
function getOffsetParent(element) { | ||
// eslint-disable-next-line no-restricted-globals | ||
const win = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
while (offsetParent && isTableElement(offsetParent) | ||
&& getElementStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
} | ||
if (offsetParent | ||
&& (['HTML', 'BODY'].includes(offsetParent.tagName) | ||
&& getElementStyle(offsetParent, 'position') === 'static' | ||
&& !isContainingBlock(offsetParent))) { | ||
return win; | ||
} | ||
return offsetParent || getContainingBlock(element) || win; | ||
} | ||
/** | ||
* Checks if a target `HTMLElement` is affected by scale. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {HTMLElement} element target | ||
* @returns {boolean} the query result | ||
*/ | ||
function isScaledElement(element) { | ||
const rect = getBoundingClientRect(element); | ||
return Math.round(rect.width) !== element.offsetWidth | ||
|| Math.round(rect.height) !== element.offsetHeight; | ||
} | ||
/** | ||
* Returns the rect relative to an offset parent. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {HTMLElement} offsetParent the container / offset parent | ||
* @param {{x: number, y: number}} scroll | ||
* @returns {Record<string, number>} | ||
*/ | ||
function getRectRelativeToOffsetParent(element, offsetParent, scroll) { | ||
const isParentAnElement = isHTMLElement(offsetParent); | ||
const rect = getBoundingClientRect(element, isParentAnElement && isScaledElement(offsetParent)); | ||
const offsets = { x: 0, y: 0 }; | ||
if (isParentAnElement) { | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
offsets.x = offsetRect.x + offsetParent.clientLeft; | ||
offsets.y = offsetRect.y + offsetParent.clientTop; | ||
} | ||
return { | ||
x: rect.left + scroll.x - offsets.x, | ||
y: rect.top + scroll.y - offsets.y, | ||
width: rect.width, | ||
height: rect.height, | ||
}; | ||
} | ||
/** | ||
* Shortcut for `HTMLElement.setAttribute()` method. | ||
@@ -1559,2 +1846,11 @@ * @param {HTMLElement} element target element | ||
/** | ||
* Shortcut for `SVGElement.setAttributeNS()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} att attribute name | ||
* @param {string} value attribute value | ||
* @param {string=} ns attribute namespace | ||
*/ | ||
const setAttributeNS = (element, att, value, ns) => element.setAttributeNS(ns || null, att, value); | ||
/** | ||
* Shortcut for `HTMLElement.removeAttribute()` method. | ||
@@ -1567,4 +1863,12 @@ * @param {HTMLElement} element target element | ||
/** | ||
* Shortcut for `HTMLElement.style.propertyName` method. | ||
* Shortcut for `HTMLElement.removeAttributeNS()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} att attribute name | ||
* @param {string=} ns attribute namespace | ||
*/ | ||
const removeAttributeNS = (element, att, ns) => element.removeAttributeNS(ns || null, att); | ||
/** | ||
* Shortcut for multiple uses of `HTMLElement.style.propertyName` method. | ||
* @param {HTMLElement} element target element | ||
* @param {Partial<CSSStyleDeclaration>} styles attribute value | ||
@@ -1575,2 +1879,18 @@ */ | ||
/** | ||
* Shortcut for `Array.isArray()` static method. | ||
* | ||
* @param {any} arr array-like iterable object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isArray = (arr) => Array.isArray(arr); | ||
/** | ||
* Checks if an object is an `Element`. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isElement = (element) => element instanceof Element; | ||
/** | ||
* Utility to determine if an `HTMLElement` | ||
@@ -1580,9 +1900,9 @@ * is partially visible in viewport. | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
* @return {boolean} the query result | ||
*/ | ||
function isElementInScrollRange(element) { | ||
const isElementInScrollRange = (element) => { | ||
const bcr = element.getBoundingClientRect(); | ||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
} | ||
}; | ||
@@ -1594,6 +1914,6 @@ /** | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
* @return {boolean} the query result | ||
*/ | ||
function isElementInViewport(element) { | ||
const bcr = element.getBoundingClientRect(); | ||
const isElementInViewport = (element) => { | ||
const bcr = getBoundingClientRect(element, true); | ||
return ( | ||
@@ -1605,6 +1925,32 @@ bcr.top >= 0 | ||
); | ||
} | ||
}; | ||
/** | ||
* Checks if an element is an `<svg>`, `<img>` or `<video>`. | ||
* Checks if an object is an `Array` in which all items are `Element`. | ||
* | ||
* @param {any} object the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isElementsArray = (object) => Array.isArray(object) | ||
&& object.every((el) => isHTMLElement(el)); | ||
/** | ||
* Checks if an object is an `HTMLCollection`. | ||
* | ||
* @param {any} object the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isHTMLCollection = (object) => object instanceof HTMLCollection; | ||
/** | ||
* Check if a target element is an `<img>`. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
*/ | ||
const isHTMLImageElement = (element) => element instanceof HTMLImageElement; | ||
/** | ||
* Checks if an element is an `<svg>` (or any type of SVG element), | ||
* `<img>` or `<video>`. | ||
* | ||
* *Tooltip* / *Popover* works different with media elements. | ||
@@ -1619,55 +1965,67 @@ * @param {any} element the target element | ||
/** | ||
* Checks if a page is Right To Left. | ||
* Checks if an object is a `Node`. | ||
* | ||
* @param {any} node the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isRTL = () => document.documentElement.dir === 'rtl'; | ||
const isNode = (node) => node instanceof Node; | ||
/** | ||
* Shortcut for `typeof` static method. | ||
* Checks if an object is a `NodeList`. | ||
* | ||
* @param {any} str array-like iterable object | ||
* @param {any} object the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isString = (str) => str && typeof str === 'string'; | ||
const isNodeList = (object) => object instanceof NodeList; | ||
/** | ||
* Shortcut for `Array.isArray()` static method. | ||
* | ||
* @param {any} arr array-like iterable object | ||
* Checks if a page is Right To Left. | ||
* @returns {boolean} the query result | ||
*/ | ||
const isArray = (arr) => Array.isArray(arr); | ||
const isRTL = () => [ | ||
document.body, | ||
document.documentElement, | ||
].some((el) => el.dir === 'rtl'); | ||
/** | ||
* Checks if an object is an `Element`. | ||
* Shortcut for `typeof SOMETHING === string` static method. | ||
* | ||
* @param {any} element the target object | ||
* @param {any} str array-like iterable object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isElement = (element) => element && element instanceof Element; | ||
const isString = (str) => typeof str === 'string'; | ||
/** | ||
* Checks if an object is an `HTMLCollection`. | ||
* | ||
* @param {any} object the target object | ||
* Check if an element is an `<svg>` or any other SVG element. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
*/ | ||
const isHTMLCollection = (object) => object instanceof HTMLCollection; | ||
const isSVGElement = (element) => element instanceof SVGElement; | ||
/** | ||
* Checks if an object is a `NodeList`. | ||
* Shortcut for `HTMLElement.closest` method. | ||
* | ||
* @param {any} object the target object | ||
* @returns {boolean} the query result | ||
* @param {HTMLElement} element optional Element to look into | ||
* @param {string} selector the selector name | ||
* @return {HTMLElement?} the query result | ||
*/ | ||
const isNodeList = (object) => object instanceof NodeList; | ||
function closest(element, selector) { | ||
if (element && selector) return element.closest(selector); | ||
return null; | ||
} | ||
/** | ||
* Checks if an object is an `Array` in which all items are `Element`. | ||
* Returns an `Array` of `Node` elements that are registered as | ||
* `CustomElement`. | ||
* @see https://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements | ||
* | ||
* @param {any} object the target object | ||
* @returns {boolean} the query result | ||
* | ||
* @param {HTMLElement=} parent parent to look into | ||
* @returns {Node[]} the query result | ||
*/ | ||
const isElementsArray = (object) => Array.isArray(object) | ||
&& object.every((el) => isHTMLElement(el)); | ||
function getCustomElements(parent) { | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return [...lookUp.querySelectorAll('*')] | ||
.filter((x) => customElements.get(x.nodeName.toLowerCase())); | ||
} | ||
@@ -1678,7 +2036,9 @@ /** | ||
* @param {string} selector the input selector | ||
* @param {HTMLElement=} parent optional Element to look into | ||
* @param {(Node | Element | HTMLElement)=} parent optional node to look into | ||
* @return {NodeListOf<HTMLElement>} the query result | ||
*/ | ||
function querySelectorAll(selector, parent) { | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
const lookUp = parent && [HTMLElement, Element, Node] | ||
.some((x) => parent instanceof x) ? parent : document; | ||
// @ts-ignore -- we must include ShadowRoot Node | ||
return lookUp.querySelectorAll(selector); | ||
@@ -1713,3 +2073,3 @@ } | ||
var version = "0.3.0alpha1"; | ||
var version = "0.3.0alpha2"; | ||
@@ -1807,2 +2167,3 @@ // @ts-ignore | ||
isApple, | ||
isFirefox, | ||
support3DTransform, | ||
@@ -1843,2 +2204,3 @@ supportPassive, | ||
userAgentData, | ||
userAgent, | ||
addClass, | ||
@@ -1868,12 +2230,26 @@ removeClass, | ||
getElementTransitionDelayLegacy: getElementTransitionDelay, | ||
getNodeScroll, | ||
getOffsetParent, | ||
getParentNode, | ||
getRectRelativeToOffsetParent, | ||
getWindow, | ||
isArray, | ||
isString, | ||
isElement, | ||
isNode, | ||
isHTMLElement, | ||
isHTMLImageElement, | ||
isSVGElement, | ||
isNodeList, | ||
isHTMLCollection, | ||
isScaledElement, | ||
isTableElement, | ||
isShadowRoot, | ||
isElementsArray, | ||
isWindow, | ||
isMedia, | ||
isRTL, | ||
closest, | ||
querySelector, | ||
getCustomElements, | ||
querySelectorAll, | ||
@@ -1893,7 +2269,12 @@ getElementsByClassName, | ||
ObjectValues, | ||
getBoundingClientRect, | ||
getDocumentElement, | ||
getElementStyle, | ||
setElementStyle, | ||
getAttribute, | ||
getAttributeNS, | ||
setAttribute, | ||
setAttributeNS, | ||
removeAttribute, | ||
removeAttributeNS, | ||
Version, | ||
@@ -1900,0 +2281,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.3.0alpha1 | dnp_theme © 2022 | MIT-License | ||
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u=/iPhone|iPad|iPod|Android/i;let l=!1;l=navigator.userAgentData?navigator.userAgentData.brands.some(e=>u.test(e.brand)):u.test(navigator.userAgent);const m=l,d=navigator.userAgentData,g=/(iPhone|iPod|iPad)/,v=d?d.brands.some(e=>g.test(e.brand)):g.test(navigator.userAgent),E="webkitPerspective"in document.head.style||"perspective"in document.head.style;function p(e,t,n,i){const o=i||!1;e.addEventListener(t,n,o)}function y(e,t,n,i){const o=i||!1;e.removeEventListener(t,n,o)}function b(e,t,n,i){p(e,t,(function o(a){a.target===e&&(n.apply(e,[a]),y(e,t,o,i))}),i)}const h=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});b(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),f="webkitTransform"in document.head.style||"transform"in document.head.style,w="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,A="webkitTransition"in document.head.style||"transition"in document.head.style;const L=e=>e&&e instanceof HTMLElement;function D(e,t){const n=t&&L(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}const T=new Map,N={set:(e,t,n,i)=>{const o=D(e);if(o)if(i&&i.length){T.has(o)||T.set(o,new Map);T.get(o).set(i,setTimeout(t,n))}else T.set(o,setTimeout(t,n))},get:(e,t)=>{const n=D(e);if(!n)return null;if(t&&t.length){T.has(n)||T.set(n,new Map);const e=T.get(n);if(e.has(t))return e.get(t)}else if(T.has(n))return T.get(n);return null},clear:(e,t)=>{const n=D(e),i=n&&T.get(n);i&&(t&&t.length?i.has(t)&&(clearTimeout(i.get(t)),i.delete(t)):(clearTimeout(i),T.delete(n)))}},C=new Map,z={set:(e,t,n)=>{const i=D(e);if(!i)return;C.has(t)||C.set(t,new Map);C.get(t).set(i,n)},getAllFor:e=>{const t=C.get(e);return t||null},get:(e,t)=>{const n=D(e),i=z.getAllFor(t),o=n&&i&&i.get(n);return o||null},remove:(e,t)=>{const n=D(e),i=C.get(t);i&&n&&(i.delete(n),0===i.size&&C.delete(t))}};function M(e,t){const n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function O(e){const t=M(e,"animationName"),n=M(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function S(e){const t=M(e,"animationName"),n=M(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){const t=M(e,i),o=M(e,n),a=o.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function P(e){const n=M(e,i),o=M(e,t),a=o.includes("ms")?1:1e3,r=k&&n&&"none"!==n?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function H(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function F(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function B(e){const t=M(e,c),n=M(e,r),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){const t=M(e,c),n=M(e,a),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function Q(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const j=e=>Object.keys(e);const R=(e,t)=>Object.assign(e,t);const V={ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:o,transitionDuration:"transitionDuration",transitionDurationLegacy:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:m,isApple:v,support3DTransform:E,supportPassive:h,supportTransform:f,supportTouch:w,supportAnimation:k,supportTransition:A,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:p,off:y,one:b,Data:z,Timer:N,getInstance:(e,t)=>z.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const i=new Event("animationend"),o=S(e),a=O(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){let n=0;const i=new Event(o),a=P(e),r=I(e);if(k&&a){const s=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,s),n=1)};e.addEventListener(o,s),setTimeout(()=>{n||e.dispatchEvent(i)},a+r+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){let n=0;const i=new Event("transitionend"),o=F(e),a=H(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){let n=0;const i=new Event(s),o=x(e),a=B(e);if(A&&o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!h&&{passive:!0},getElementAnimationDuration:S,getElementAnimationDurationLegacy:P,getElementAnimationDelay:O,getElementAnimationDelayLegacy:I,getElementTransitionDuration:F,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:B,isArray:e=>Array.isArray(e),isString:e=>e&&"string"==typeof e,isElement:e=>e&&e instanceof Element,isHTMLElement:L,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isElementsArray:e=>Array.isArray(e)&&e.every(e=>L(e)),isMedia:e=>e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:()=>"rtl"===document.documentElement.dir,querySelector:D,querySelectorAll:function(e,t){return(t&&L(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&L(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&L(t)?t:document).getElementsByTagName(e)},normalizeValue:Q,normalizeOptions:function(e,t,n,i){const o={...e.dataset},a={},r={};return j(o).forEach(e=>{const t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=Q(o[e])}),j(n).forEach(e=>{n[e]=Q(n[e])}),j(t).forEach(e=>{a[e]=e in n?n[e]:e in r?r[e]:t[e]}),a},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(`${t} ${e}`)}},reflow:e=>e.offsetHeight,focus:e=>e.focus(),ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:R,ObjectKeys:j,ObjectValues:e=>Object.values(e),getElementStyle:M,setElementStyle:(e,t)=>R(e.style,t),getAttribute:(e,t)=>e.getAttribute(t),setAttribute:(e,t,n)=>e.setAttribute(t,n),removeAttribute:(e,t)=>e.removeAttribute(t),Version:"0.3.0alpha1"};export{V as default}; | ||
// shorter-js v0.3.0alpha2 | dnp_theme © 2022 | MIT-License | ||
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",{userAgent:u}=navigator,l=u,m=/iPhone|iPad|iPod|Android/i;let d=!1;d=navigator.userAgentData?navigator.userAgentData.brands.some(e=>m.test(e.brand)):m.test(l);const g=d,f=navigator.userAgentData,E=/(iPhone|iPod|iPad)/,p=f?f.brands.some(e=>E.test(e.brand)):E.test(navigator.userAgent),v=!!l&&l.includes("Firefox"),y="webkitPerspective"in document.head.style||"perspective"in document.head.style;function b(e,t,n,o){const i=o||!1;e.addEventListener(t,n,i)}function h(e,t,n,o){const i=o||!1;e.removeEventListener(t,n,i)}function w(e,t,n,o){b(e,t,(function i(a){a.target===e&&(n.apply(e,[a]),h(e,t,i,o))}),o)}const A=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});w(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),k="webkitTransform"in document.head.style||"transform"in document.head.style,L="ontouchstart"in window||"msMaxTouchPoints"in navigator,D="webkitAnimation"in document.head.style||"animation"in document.head.style,N="webkitTransition"in document.head.style||"transition"in document.head.style;function T(e,t){const n=[HTMLElement,Element,Node],o=t&&n.some(e=>t instanceof e)?t:document;return n.some(t=>e instanceof t)?e:o.querySelector(e)}const S=new Map,M={set:(e,t,n)=>{const o=T(e);if(!o)return;S.has(t)||S.set(t,new Map);S.get(t).set(o,n)},getAllFor:e=>{const t=S.get(e);return t||null},get:(e,t)=>{const n=T(e),o=M.getAllFor(t),i=n&&o&&o.get(n);return i||null},remove:(e,t)=>{const n=T(e),o=S.get(t);o&&n&&(o.delete(n),0===o.size&&S.delete(t))}};function C(e,t){const n=getComputedStyle(e);return t in n?n[t]:""}function O(e){const t=C(e,"animationName"),n=C(e,"animationDelay"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function z(e){const t=C(e,"animationName"),n=C(e,"animationDuration"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function H(e){const t=C(e,o),i=C(e,n),a=i.includes("ms")?1:1e3,r=D&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function P(e){const n=C(e,o),i=C(e,t),a=i.includes("ms")?1:1e3,r=D&&n&&"none"!==n?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function I(e){const t=C(e,"transitionProperty"),n=C(e,"transitionDelay"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function x(e){const t=C(e,"transitionProperty"),n=C(e,"transitionDuration"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function B(e){const t=C(e,c),n=C(e,r),o=n.includes("ms")?1:1e3,i=N&&t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function F(e){const t=C(e,c),n=C(e,a),o=n.includes("ms")?1:1e3,i=N&&t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function R(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const W=e=>Object.keys(e);const Q=(e,t)=>Object.assign(e,t),V=!!A&&{passive:!0},j=new Map;const q=e=>e instanceof HTMLElement;function U(e,t){const n=e.getBoundingClientRect();let o=1,i=1;return t&&q(e)&&(o=e.offsetWidth>0&&Math.round(n.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Math.round(n.height)/e.offsetHeight||1),{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function G(e){return((e instanceof Node?e.ownerDocument:e.document)||window.document).documentElement}const Y=e=>["TABLE","TD","TH"].includes(e.tagName),K=e=>e instanceof(self||window).ShadowRoot||e instanceof ShadowRoot;function X(e){return"HTML"===e.nodeName?e:e.assignedSlot||e.parentNode||(K(e)?e.host:null)||G(e)}function $(e){return[self,window].includes(e)}function Z(e){if(null==e)return window;if(!$(e)){const{ownerDocument:t}=e;return t&&t.defaultView||window}return e}function J(e){const{transform:t,perspective:n,contain:o,willChange:i,filter:a}=getComputedStyle(e);return"none"!==t||"none"!==n||"paint"===o||["transform","perspective"].includes(i)||v&&"filter"===i||v&&!!a&&"none"!==a}function _(e){return q(e)&&"fixed"!==C(e,"position")?e.offsetParent:null}function ee(e){const t=U(e);return Math.round(t.width)!==e.offsetWidth||Math.round(t.height)!==e.offsetHeight}const te={ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:o,animationEndEvent:"animationend",animationEndEventLegacy:i,transitionDuration:"transitionDuration",transitionDurationLegacy:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:g,isApple:p,isFirefox:v,support3DTransform:y,supportPassive:A,supportTransform:k,supportTouch:L,supportAnimation:D,supportTransition:N,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",userAgent:l,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:b,off:h,one:w,Data:M,Timer:{set:(e,t,n,o)=>{const i=T(e);if(i)if(o&&o.length){j.has(i)||j.set(i,new Map);j.get(i).set(o,setTimeout(t,n))}else j.set(i,setTimeout(t,n))},get:(e,t)=>{const n=T(e);if(!n)return null;if(t&&t.length){j.has(n)||j.set(n,new Map);const e=j.get(n);if(e.has(t))return e.get(t)}else if(j.has(n))return j.get(n);return null},clear:(e,t)=>{const n=T(e),o=n&&j.get(n);o&&(t&&t.length?o.has(t)&&(clearTimeout(o.get(t)),o.delete(t)):(clearTimeout(o),j.delete(n)))}},getInstance:(e,t)=>M.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const o=new Event("animationend"),i=z(e),a=O(e);if(i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},emulateAnimationEndLegacy:function(e,t){let n=0;const o=new Event(i),a=P(e),r=H(e);if(D&&a){const s=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(i,s),n=1)};e.addEventListener(i,s),setTimeout(()=>{n||e.dispatchEvent(o)},a+r+17)}else t.apply(e,[o])},emulateTransitionEnd:function(e,t){let n=0;const o=new Event("transitionend"),i=x(e),a=I(e);if(i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},emulateTransitionEndLegacy:function(e,t){let n=0;const o=new Event(s),i=F(e),a=B(e);if(N&&i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},isElementInScrollRange:e=>{const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:e=>{const t=U(e,!0);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:V,getElementAnimationDuration:z,getElementAnimationDurationLegacy:P,getElementAnimationDelay:O,getElementAnimationDelayLegacy:H,getElementTransitionDuration:x,getElementTransitionDurationLegacy:F,getElementTransitionDelay:I,getElementTransitionDelayLegacy:B,getNodeScroll:function(e){const t="scrollX"in e;return{x:t?e.scrollX:e.scrollLeft,y:t?e.scrollY:e.scrollTop}},getOffsetParent:function(e){const t=Z(e);let n=_(e);for(;n&&Y(n)&&"static"===C(n,"position");)n=_(n);return n&&["HTML","BODY"].includes(n.tagName)&&"static"===C(n,"position")&&!J(n)?t:n||function(e){let t=X(e);for(;q(t)&&!["HTML","BODY"].includes(t.nodeName);){if(J(t))return t;t=t.parentNode}return null}(e)||t},getParentNode:X,getRectRelativeToOffsetParent:function(e,t,n){const o=q(t),i=U(e,o&&ee(t)),a={x:0,y:0};if(o){const e=U(t,!0);a.x=e.x+t.clientLeft,a.y=e.y+t.clientTop}return{x:i.left+n.x-a.x,y:i.top+n.y-a.y,width:i.width,height:i.height}},getWindow:Z,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isElement:e=>e instanceof Element,isNode:e=>e instanceof Node,isHTMLElement:q,isHTMLImageElement:e=>e instanceof HTMLImageElement,isSVGElement:e=>e instanceof SVGElement,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isScaledElement:ee,isTableElement:Y,isShadowRoot:K,isElementsArray:e=>Array.isArray(e)&&e.every(e=>q(e)),isWindow:$,isMedia:e=>e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:()=>[document.body,document.documentElement].some(e=>"rtl"===e.dir),closest:function(e,t){return e&&t?e.closest(t):null},querySelector:T,getCustomElements:function(e){return[...(e&&q(e)?e:document).querySelectorAll("*")].filter(e=>customElements.get(e.nodeName.toLowerCase()))},querySelectorAll:function(e,t){return(t&&[HTMLElement,Element,Node].some(e=>t instanceof e)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&q(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&q(t)?t:document).getElementsByTagName(e)},normalizeValue:R,normalizeOptions:function(e,t,n,o){const i={...e.dataset},a={},r={};return W(i).forEach(e=>{const t=o&&e.includes(o)?e.replace(o,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=R(i[e])}),W(n).forEach(e=>{n[e]=R(n[e])}),W(t).forEach(e=>{a[e]=e in n?n[e]:e in r?r[e]:t[e]}),a},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(`${t} ${e}`)}},reflow:e=>e.offsetHeight,focus:e=>e.focus(),ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:Q,ObjectKeys:W,ObjectValues:e=>Object.values(e),getBoundingClientRect:U,getDocumentElement:G,getElementStyle:C,setElementStyle:(e,t)=>Q(e.style,t),getAttribute:(e,t)=>e.getAttribute(t),getAttributeNS:(e,t,n)=>e.getAttributeNS(n||null,t),setAttribute:(e,t,n)=>e.setAttribute(t,n),setAttributeNS:(e,t,n,o)=>e.setAttributeNS(o||null,t,n),removeAttribute:(e,t)=>e.removeAttribute(t),removeAttributeNS:(e,t,n)=>e.removeAttributeNS(n||null,t),Version:"0.3.0alpha2"};export{te as default}; |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.3.0alpha1 | dnp_theme © 2022 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",r="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=/iPhone|iPad|iPod|Android/i,l=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m=navigator.userAgentData,d=/(iPhone|iPod|iPad)/,v=m?m.brands.some((function(e){return d.test(e.brand)})):d.test(navigator.userAgent),f="webkitPerspective"in document.head.style||"perspective"in document.head.style;function g(e,t,n,i){var r=i||!1;e.addEventListener(t,n,r)}function p(e,t,n,i){var r=i||!1;e.removeEventListener(t,n,r)}function y(e,t,n,i){g(e,t,(function r(o){o.target===e&&(n.apply(e,[o]),p(e,t,r,i))}),i)}var E=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});y(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,h="ontouchstart"in window||"msMaxTouchPoints"in navigator,w="webkitAnimation"in document.head.style||"animation"in document.head.style,k="webkitTransition"in document.head.style||"transition"in document.head.style;var A=function(e){return e&&e instanceof HTMLElement};function L(e,t){var n=t&&A(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}var D=new Map,T={set:function(e,t,n,i){var r=L(e);r&&(i&&i.length?(D.has(r)||D.set(r,new Map),D.get(r).set(i,setTimeout(t,n))):D.set(r,setTimeout(t,n)))},get:function(e,t){var n=L(e);if(!n)return null;if(t&&t.length){D.has(n)||D.set(n,new Map);var i=D.get(n);if(i.has(t))return i.get(t)}else if(D.has(n))return D.get(n);return null},clear:function(e,t){var n=L(e),i=n&&D.get(n);i&&(t&&t.length?i.has(t)&&(clearTimeout(i.get(t)),i.delete(t)):(clearTimeout(i),D.delete(n)))}},N=new Map,C={set:function(e,t,n){var i=L(e);i&&(N.has(t)||N.set(t,new Map),N.get(t).set(i,n))},getAllFor:function(e){var t=N.get(e);return t||null},get:function(e,t){var n=L(e),i=C.getAllFor(t),r=n&&i&&i.get(n);return r||null},remove:function(e,t){var n=L(e),i=N.get(t);i&&n&&(i.delete(n),0===i.size&&N.delete(t))}};function O(e,t){var n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function z(e){var t=O(e,"animationName"),n=O(e,"animationDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function M(e){var t=O(e,"animationName"),n=O(e,"animationDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function S(e){var t=O(e,i),r=O(e,n),o=r.includes("ms")?1:1e3,a=w&&t&&"none"!==t?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function I(e){var n=O(e,i),r=O(e,t),o=r.includes("ms")?1:1e3,a=w&&n&&"none"!==n?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function P(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function H(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function F(e){var t=O(e,s),n=O(e,a),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function B(e){var t=O(e,s),n=O(e,o),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function x(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var j=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)};return{ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:r,transitionDuration:"transitionDuration",transitionDurationLegacy:o,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:u,transitionProperty:"transitionProperty",transitionPropertyLegacy:s,isMobile:l,isApple:v,support3DTransform:f,supportPassive:E,supportTransform:b,supportTouch:h,supportAnimation:w,supportTransition:k,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:g,off:p,one:y,Data:C,Timer:T,getInstance:function(e,t){return C.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),r=M(e),o=z(e);if(r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",a),n=1)};e.addEventListener("animationend",a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(r),o=I(e),a=S(e);if(w&&o){var u=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(r,u),n=1)};e.addEventListener(r,u),setTimeout((function(){n||e.dispatchEvent(i)}),o+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),r=H(e),o=P(e);if(r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",a),n=1)};e.addEventListener("transitionend",a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(u),r=B(e),o=F(e);if(k&&r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(u,a),n=1)};e.addEventListener(u,a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!E&&{passive:!0},getElementAnimationDuration:M,getElementAnimationDurationLegacy:I,getElementAnimationDelay:z,getElementAnimationDelayLegacy:S,getElementTransitionDuration:H,getElementTransitionDurationLegacy:B,getElementTransitionDelay:P,getElementTransitionDelayLegacy:F,isArray:function(e){return Array.isArray(e)},isString:function(e){return e&&"string"==typeof e},isElement:function(e){return e&&e instanceof Element},isHTMLElement:A,isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return A(e)}))},isMedia:function(e){return e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return"rtl"===document.documentElement.dir},querySelector:L,querySelectorAll:function(e,t){return(t&&A(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&A(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&A(t)?t:document).getElementsByTagName(e)},normalizeValue:x,normalizeOptions:function(e,t,n,i){var r=Object.assign({},e.dataset),o={},a={};return j(r).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=x(r[e])})),j(n).forEach((function(e){n[e]=x(n[e])})),j(t).forEach((function(e){o[e]=e in n?n[e]:e in a?a[e]:t[e]})),o},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},focus:function(e){return e.focus()},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){return Float32Array.from(Array.from(e))},Float64ArrayFrom:function(e){return Float64Array.from(Array.from(e))},ObjectAssign:R,ObjectKeys:j,ObjectValues:function(e){return Object.values(e)},getElementStyle:O,setElementStyle:function(e,t){return R(e.style,t)},getAttribute:function(e,t){return e.getAttribute(t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},Version:"0.3.0alpha1"}})); | ||
// shorter-js v0.3.0alpha2 | dnp_theme © 2022 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",r="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=navigator.userAgent,l=/iPhone|iPad|iPod|Android/i,m=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return l.test(e.brand)})):l.test(c),d=navigator.userAgentData,f=/(iPhone|iPod|iPad)/,v=d?d.brands.some((function(e){return f.test(e.brand)})):f.test(navigator.userAgent),g=!!c&&c.includes("Firefox"),p="webkitPerspective"in document.head.style||"perspective"in document.head.style;function E(e,t,n,i){var o=i||!1;e.addEventListener(t,n,o)}function y(e,t,n,i){var o=i||!1;e.removeEventListener(t,n,o)}function b(e,t,n,i){E(e,t,(function o(r){r.target===e&&(n.apply(e,[r]),y(e,t,o,i))}),i)}var h=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});b(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),w="webkitTransform"in document.head.style||"transform"in document.head.style,A="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,L="webkitTransition"in document.head.style||"transition"in document.head.style;function D(e,t){var n=[HTMLElement,Element,Node],i=t&&n.some((function(e){return t instanceof e}))?t:document;return n.some((function(t){return e instanceof t}))?e:i.querySelector(e)}var T=new Map,N={set:function(e,t,n){var i=D(e);i&&(T.has(t)||T.set(t,new Map),T.get(t).set(i,n))},getAllFor:function(e){var t=T.get(e);return t||null},get:function(e,t){var n=D(e),i=N.getAllFor(t),o=n&&i&&i.get(n);return o||null},remove:function(e,t){var n=D(e),i=T.get(t);i&&n&&(i.delete(n),0===i.size&&T.delete(t))}};function S(e,t){var n=getComputedStyle(e);return t in n?n[t]:""}function M(e){var t=S(e,"animationName"),n=S(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function C(e){var t=S(e,"animationName"),n=S(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function O(e){var t=S(e,i),o=S(e,n),r=o.includes("ms")?1:1e3,a=k&&t&&"none"!==t?parseFloat(o)*r:0;return Number.isNaN(a)?0:a}function z(e){var n=S(e,i),o=S(e,t),r=o.includes("ms")?1:1e3,a=k&&n&&"none"!==n?parseFloat(o)*r:0;return Number.isNaN(a)?0:a}function H(e){var t=S(e,"transitionProperty"),n=S(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function P(e){var t=S(e,"transitionProperty"),n=S(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){var t=S(e,s),n=S(e,a),i=n.includes("ms")?1:1e3,o=L&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){var t=S(e,s),n=S(e,r),i=n.includes("ms")?1:1e3,o=L&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function B(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var F=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)},W=!!h&&{passive:!0},j=new Map;var Q=function(e){return e instanceof HTMLElement};function V(e,t){var n=e.getBoundingClientRect(),i=1,o=1;return t&&Q(e)&&(i=e.offsetWidth>0&&Math.round(n.width)/e.offsetWidth||1,o=e.offsetHeight>0&&Math.round(n.height)/e.offsetHeight||1),{width:n.width/i,height:n.height/o,top:n.top/o,right:n.right/i,bottom:n.bottom/o,left:n.left/i,x:n.left/i,y:n.top/o}}function q(e){return((e instanceof Node?e.ownerDocument:e.document)||window.document).documentElement}var U=function(e){return["TABLE","TD","TH"].includes(e.tagName)},G=function(e){return e instanceof(self||window).ShadowRoot||e instanceof ShadowRoot};function Y(e){return"HTML"===e.nodeName?e:e.assignedSlot||e.parentNode||(G(e)?e.host:null)||q(e)}function K(e){return[self,window].includes(e)}function X(e){if(null==e)return window;if(!K(e)){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Z(e){var t=getComputedStyle(e),n=t.transform,i=t.perspective,o=t.contain,r=t.willChange,a=t.filter;return"none"!==n||"none"!==i||"paint"===o||["transform","perspective"].includes(r)||g&&"filter"===r||g&&!!a&&"none"!==a}function J(e){return Q(e)&&"fixed"!==S(e,"position")?e.offsetParent:null}function $(e){var t=V(e);return Math.round(t.width)!==e.offsetWidth||Math.round(t.height)!==e.offsetHeight}return{ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:o,transitionDuration:"transitionDuration",transitionDurationLegacy:r,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:u,transitionProperty:"transitionProperty",transitionPropertyLegacy:s,isMobile:m,isApple:v,isFirefox:g,support3DTransform:p,supportPassive:h,supportTransform:w,supportTouch:A,supportAnimation:k,supportTransition:L,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",userAgent:c,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:E,off:y,one:b,Data:N,Timer:{set:function(e,t,n,i){var o=D(e);o&&(i&&i.length?(j.has(o)||j.set(o,new Map),j.get(o).set(i,setTimeout(t,n))):j.set(o,setTimeout(t,n)))},get:function(e,t){var n=D(e);if(!n)return null;if(t&&t.length){j.has(n)||j.set(n,new Map);var i=j.get(n);if(i.has(t))return i.get(t)}else if(j.has(n))return j.get(n);return null},clear:function(e,t){var n=D(e),i=n&&j.get(n);i&&(t&&t.length?i.has(t)&&(clearTimeout(i.get(t)),i.delete(t)):(clearTimeout(i),j.delete(n)))}},getInstance:function(e,t){return N.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),o=C(e),r=M(e);if(o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",a),n=1)};e.addEventListener("animationend",a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(o),r=z(e),a=O(e);if(k&&r){var u=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,u),n=1)};e.addEventListener(o,u),setTimeout((function(){n||e.dispatchEvent(i)}),r+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),o=P(e),r=H(e);if(o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",a),n=1)};e.addEventListener("transitionend",a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(u),o=x(e),r=I(e);if(L&&o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(u,a),n=1)};e.addEventListener(u,a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=V(e,!0);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:W,getElementAnimationDuration:C,getElementAnimationDurationLegacy:z,getElementAnimationDelay:M,getElementAnimationDelayLegacy:O,getElementTransitionDuration:P,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:I,getNodeScroll:function(e){var t="scrollX"in e;return{x:t?e.scrollX:e.scrollLeft,y:t?e.scrollY:e.scrollTop}},getOffsetParent:function(e){for(var t=X(e),n=J(e);n&&U(n)&&"static"===S(n,"position");)n=J(n);return n&&["HTML","BODY"].includes(n.tagName)&&"static"===S(n,"position")&&!Z(n)?t:n||function(e){for(var t=Y(e);Q(t)&&!["HTML","BODY"].includes(t.nodeName);){if(Z(t))return t;t=t.parentNode}return null}(e)||t},getParentNode:Y,getRectRelativeToOffsetParent:function(e,t,n){var i=Q(t),o=V(e,i&&$(t)),r={x:0,y:0};if(i){var a=V(t,!0);r.x=a.x+t.clientLeft,r.y=a.y+t.clientTop}return{x:o.left+n.x-r.x,y:o.top+n.y-r.y,width:o.width,height:o.height}},getWindow:X,isArray:function(e){return Array.isArray(e)},isString:function(e){return"string"==typeof e},isElement:function(e){return e instanceof Element},isNode:function(e){return e instanceof Node},isHTMLElement:Q,isHTMLImageElement:function(e){return e instanceof HTMLImageElement},isSVGElement:function(e){return e instanceof SVGElement},isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isScaledElement:$,isTableElement:U,isShadowRoot:G,isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return Q(e)}))},isWindow:K,isMedia:function(e){return e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return[document.body,document.documentElement].some((function(e){return"rtl"===e.dir}))},closest:function(e,t){return e&&t?e.closest(t):null},querySelector:D,getCustomElements:function(e){var t=e&&Q(e)?e:document;return[].concat(t.querySelectorAll("*")).filter((function(e){return customElements.get(e.nodeName.toLowerCase())}))},querySelectorAll:function(e,t){return(t&&[HTMLElement,Element,Node].some((function(e){return t instanceof e}))?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&Q(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&Q(t)?t:document).getElementsByTagName(e)},normalizeValue:B,normalizeOptions:function(e,t,n,i){var o=Object.assign({},e.dataset),r={},a={};return F(o).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=B(o[e])})),F(n).forEach((function(e){n[e]=B(n[e])})),F(t).forEach((function(e){r[e]=e in n?n[e]:e in a?a[e]:t[e]})),r},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},focus:function(e){return e.focus()},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){return Float32Array.from(Array.from(e))},Float64ArrayFrom:function(e){return Float64Array.from(Array.from(e))},ObjectAssign:R,ObjectKeys:F,ObjectValues:function(e){return Object.values(e)},getBoundingClientRect:V,getDocumentElement:q,getElementStyle:S,setElementStyle:function(e,t){return R(e.style,t)},getAttribute:function(e,t){return e.getAttribute(t)},getAttributeNS:function(e,t,n){return e.getAttributeNS(n||null,t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},setAttributeNS:function(e,t,n,i){return e.setAttributeNS(i||null,t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},removeAttributeNS:function(e,t,n){return e.removeAttributeNS(n||null,t)},Version:"0.3.0alpha2"}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.3.0alpha1", | ||
"version": "0.3.0alpha2", | ||
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.", | ||
@@ -5,0 +5,0 @@ "main": "dist/shorter-js.min.js", |
@@ -9,3 +9,3 @@ import userAgentData from '../strings/userAgentData'; | ||
/** | ||
* A global boolean for Apple browsers. | ||
* A global `boolean` for Apple browsers. | ||
* @type {boolean} | ||
@@ -12,0 +12,0 @@ */ |
import userAgentData from '../strings/userAgentData'; | ||
import userAgent from '../strings/userAgent'; | ||
@@ -11,7 +12,7 @@ const mobileBrands = /iPhone|iPad|iPod|Android/i; | ||
} else { | ||
isMobileCheck = mobileBrands.test(navigator.userAgent); | ||
isMobileCheck = mobileBrands.test(userAgent); | ||
} | ||
/** | ||
* A global namespace for mobile detection. | ||
* A global `boolean` for mobile detection. | ||
* @type {boolean} | ||
@@ -18,0 +19,0 @@ */ |
@@ -5,3 +5,6 @@ import DOMContentLoadedEvent from '../strings/DOMContentLoadedEvent'; | ||
/** | ||
* A global namespace for passive events support. | ||
* A global `boolean` for passive events support, | ||
* in general event options are not suited for scroll prevention. | ||
* | ||
* @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection | ||
* @type {boolean} | ||
@@ -8,0 +11,0 @@ */ |
/** | ||
* A global namespace for touch events support. | ||
* A global `boolean` for touch events support. | ||
* @type {boolean} | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* A global namespace for CSS3 transform support. | ||
* A global `boolean` for CSS3 transform support. | ||
* @type {boolean} | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* A global namespace for CSS3 transition support. | ||
* A global `boolean` for CSS3 transition support. | ||
* @type {boolean} | ||
@@ -4,0 +4,0 @@ */ |
107
src/index.js
@@ -122,2 +122,3 @@ // strings | ||
import userAgentData from './strings/userAgentData'; | ||
import userAgent from './strings/userAgent'; | ||
@@ -127,2 +128,3 @@ // boolean | ||
import isApple from './boolean/isApple'; | ||
import isFirefox from './boolean/isFirefox'; | ||
import support3DTransform from './boolean/support3DTransform'; | ||
@@ -146,3 +148,3 @@ import supportPassive from './boolean/supportPassive'; | ||
// misc | ||
import Timer from './misc/timer'; | ||
import ArrayFrom from './misc/ArrayFrom'; | ||
import Data, { getInstance } from './misc/data'; | ||
@@ -153,44 +155,66 @@ import emulateAnimationEnd from './misc/emulateAnimationEnd'; | ||
import emulateTransitionEndLegacy from './misc/emulateTransitionEndLegacy'; | ||
import passiveHandler from './misc/passiveHandler'; | ||
import getElementAnimationDuration from './misc/getElementAnimationDuration'; | ||
import getElementAnimationDurationLegacy from './misc/getElementAnimationDurationLegacy'; | ||
import getElementAnimationDelay from './misc/getElementAnimationDelay'; | ||
import getElementAnimationDelayLegacy from './misc/getElementAnimationDelayLegacy'; | ||
import getElementTransitionDuration from './misc/getElementTransitionDuration'; | ||
import getElementTransitionDurationLegacy from './misc/getElementTransitionDurationLegacy'; | ||
import getElementTransitionDelay from './misc/getElementTransitionDelay'; | ||
import getElementTransitionDelayLegacy from './misc/getElementTransitionDelayLegacy'; | ||
import normalizeValue from './misc/normalizeValue'; | ||
import normalizeOptions from './misc/normalizeOptions'; | ||
import tryWrapper from './misc/tryWrapper'; | ||
import reflow from './misc/reflow'; | ||
import focus from './misc/focus'; | ||
import ArrayFrom from './misc/ArrayFrom'; | ||
import Float32ArrayFrom from './misc/Float32ArrayFrom'; | ||
import Float64ArrayFrom from './misc/Float64ArrayFrom'; | ||
import focus from './misc/focus'; | ||
import normalizeOptions from './misc/normalizeOptions'; | ||
import normalizeValue from './misc/normalizeValue'; | ||
import ObjectAssign from './misc/ObjectAssign'; | ||
import ObjectKeys from './misc/ObjectKeys'; | ||
import ObjectValues from './misc/ObjectValues'; | ||
import passiveHandler from './misc/passiveHandler'; | ||
import reflow from './misc/reflow'; | ||
import Timer from './misc/timer'; | ||
import tryWrapper from './misc/tryWrapper'; | ||
import getAttribute from './manipulate/getAttribute'; | ||
// get | ||
import getAttribute from './get/getAttribute'; | ||
import getAttributeNS from './get/getAttributeNS'; | ||
import getBoundingClientRect from './get/getBoundingClientRect'; | ||
import getDocumentElement from './get/getDocumentElement'; | ||
import getElementAnimationDuration from './get/getElementAnimationDuration'; | ||
import getElementAnimationDurationLegacy from './get/getElementAnimationDurationLegacy'; | ||
import getElementAnimationDelayLegacy from './get/getElementAnimationDelayLegacy'; | ||
import getElementAnimationDelay from './get/getElementAnimationDelay'; | ||
import getElementStyle from './get/getElementStyle'; | ||
import getElementTransitionDuration from './get/getElementTransitionDuration'; | ||
import getElementTransitionDurationLegacy from './get/getElementTransitionDurationLegacy'; | ||
import getElementTransitionDelay from './get/getElementTransitionDelay'; | ||
import getElementTransitionDelayLegacy from './get/getElementTransitionDelayLegacy'; | ||
import getNodeScroll from './get/getNodeScroll'; | ||
import getOffsetParent from './get/getOffsetParent'; | ||
import getParentNode from './get/getParentNode'; | ||
import getRectRelativeToOffsetParent from './get/getRectRelativeToOffsetParent'; | ||
import getWindow from './get/getWindow'; | ||
// manipulate | ||
import setAttribute from './manipulate/setAttribute'; | ||
import setAttributeNS from './manipulate/setAttributeNS'; | ||
import removeAttribute from './manipulate/removeAttribute'; | ||
import getElementStyle from './manipulate/getElementStyle'; | ||
import removeAttributeNS from './manipulate/removeAttributeNS'; | ||
import setElementStyle from './manipulate/setElementStyle'; | ||
import isElementInScrollRange from './misc/isElementInScrollRange'; | ||
import isElementInViewport from './misc/isElementInViewport'; | ||
import isMedia from './misc/isMedia'; | ||
import isRTL from './misc/isRTL'; | ||
import isString from './misc/isString'; | ||
import isArray from './misc/isArray'; | ||
import isElement from './misc/isElement'; | ||
import isHTMLElement from './misc/isHTMLElement'; | ||
import isHTMLCollection from './misc/isHTMLCollection'; | ||
import isNodeList from './misc/isNodeList'; | ||
import isElementsArray from './misc/isElementsArray'; | ||
// is | ||
import isArray from './is/isArray'; | ||
import isElement from './is/isElement'; | ||
import isElementInScrollRange from './is/isElementInScrollRange'; | ||
import isElementInViewport from './is/isElementInViewport'; | ||
import isElementsArray from './is/isElementsArray'; | ||
import isHTMLCollection from './is/isHTMLCollection'; | ||
import isHTMLElement from './is/isHTMLElement'; | ||
import isHTMLImageElement from './is/isHTMLImageElement'; | ||
import isMedia from './is/isMedia'; | ||
import isNode from './is/isNode'; | ||
import isNodeList from './is/isNodeList'; | ||
import isRTL from './is/isRTL'; | ||
import isScaledElement from './is/isScaledElement'; | ||
import isShadowRoot from './is/isShadowRoot'; | ||
import isString from './is/isString'; | ||
import isSVGElement from './is/isSVGElement'; | ||
import isTableElement from './is/isTableElement'; | ||
import isWindow from './is/isWindow'; | ||
// selectors | ||
import closest from './selectors/closest'; | ||
import querySelector from './selectors/querySelector'; | ||
import getCustomElements from './selectors/getCustomElements'; | ||
import querySelectorAll from './selectors/querySelectorAll'; | ||
@@ -283,2 +307,3 @@ import getElementsByTagName from './selectors/getElementsByTagName'; | ||
isApple, | ||
isFirefox, | ||
support3DTransform, | ||
@@ -319,2 +344,3 @@ supportPassive, | ||
userAgentData, | ||
userAgent, | ||
addClass, | ||
@@ -344,12 +370,26 @@ removeClass, | ||
getElementTransitionDelayLegacy, | ||
getNodeScroll, | ||
getOffsetParent, | ||
getParentNode, | ||
getRectRelativeToOffsetParent, | ||
getWindow, | ||
isArray, | ||
isString, | ||
isElement, | ||
isNode, | ||
isHTMLElement, | ||
isHTMLImageElement, | ||
isSVGElement, | ||
isNodeList, | ||
isHTMLCollection, | ||
isScaledElement, | ||
isTableElement, | ||
isShadowRoot, | ||
isElementsArray, | ||
isWindow, | ||
isMedia, | ||
isRTL, | ||
closest, | ||
querySelector, | ||
getCustomElements, | ||
querySelectorAll, | ||
@@ -369,7 +409,12 @@ getElementsByClassName, | ||
ObjectValues, | ||
getBoundingClientRect, | ||
getDocumentElement, | ||
getElementStyle, | ||
setElementStyle, | ||
getAttribute, | ||
getAttributeNS, | ||
setAttribute, | ||
setAttributeNS, | ||
removeAttribute, | ||
removeAttributeNS, | ||
Version, | ||
@@ -376,0 +421,0 @@ }; |
import ObjectAssign from '../misc/ObjectAssign'; | ||
/** | ||
* Shortcut for `HTMLElement.style.propertyName` method. | ||
* Shortcut for multiple uses of `HTMLElement.style.propertyName` method. | ||
* @param {HTMLElement} element target element | ||
@@ -6,0 +6,0 @@ * @param {Partial<CSSStyleDeclaration>} styles attribute value |
import animationEndEvent from '../strings/animationEndEvent'; | ||
import getElementAnimationDelay from './getElementAnimationDelay'; | ||
import getElementAnimationDuration from './getElementAnimationDuration'; | ||
import getElementAnimationDelay from '../get/getElementAnimationDelay'; | ||
import getElementAnimationDuration from '../get/getElementAnimationDuration'; | ||
@@ -5,0 +5,0 @@ /** |
import supportAnimation from '../boolean/supportAnimation'; | ||
import animationEndEvent from '../strings/animationEndEventLegacy'; | ||
import getElementAnimationDelay from './getElementAnimationDelayLegacy'; | ||
import getElementAnimationDuration from './getElementAnimationDurationLegacy'; | ||
import getElementAnimationDelay from '../get/getElementAnimationDelayLegacy'; | ||
import getElementAnimationDuration from '../get/getElementAnimationDurationLegacy'; | ||
@@ -6,0 +6,0 @@ /** |
import transitionEndEvent from '../strings/transitionEndEvent'; | ||
import getElementTransitionDelay from './getElementTransitionDelay'; | ||
import getElementTransitionDuration from './getElementTransitionDuration'; | ||
import getElementTransitionDelay from '../get/getElementTransitionDelay'; | ||
import getElementTransitionDuration from '../get/getElementTransitionDuration'; | ||
@@ -5,0 +5,0 @@ /** |
import supportTransition from '../boolean/supportTransition'; | ||
import transitionEndEvent from '../strings/transitionEndEventLegacy'; | ||
import getElementTransitionDelay from './getElementTransitionDelayLegacy'; | ||
import getElementTransitionDuration from './getElementTransitionDurationLegacy'; | ||
import getElementTransitionDelay from '../get/getElementTransitionDelayLegacy'; | ||
import getElementTransitionDuration from '../get/getElementTransitionDurationLegacy'; | ||
@@ -6,0 +6,0 @@ /** |
@@ -5,3 +5,3 @@ import normalizeValue from './normalizeValue'; | ||
/** | ||
* Utility to normalize component options | ||
* Utility to normalize component options. | ||
* | ||
@@ -8,0 +8,0 @@ * @param {HTMLElement} element target |
@@ -1,4 +0,1 @@ | ||
// general event options | ||
// not suited for scroll prevention | ||
// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection | ||
import supportPassive from '../boolean/supportPassive'; | ||
@@ -5,0 +2,0 @@ |
@@ -1,2 +0,2 @@ | ||
import isHTMLElement from '../misc/isHTMLElement'; | ||
import isHTMLElement from '../is/isHTMLElement'; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import isHTMLElement from '../misc/isHTMLElement'; | ||
import isHTMLElement from '../is/isHTMLElement'; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,14 +0,16 @@ | ||
import isHTMLElement from '../misc/isHTMLElement'; | ||
/** | ||
* Utility to check if target is typeof `HTMLElement` | ||
* Utility to check if target is typeof `HTMLElement`, `Element`, `Node` | ||
* or find one that matches a selector. | ||
* | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {HTMLElement=} parent optional `HTMLElement` to look into | ||
* @param {(Node | Element | HTMLElement)=} parent optional node to look into | ||
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result | ||
*/ | ||
export default function querySelector(selector, parent) { | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return typeof selector === 'object' ? selector : lookUp.querySelector(selector); | ||
const nodeTypes = [HTMLElement, Element, Node]; | ||
const lookUp = parent && nodeTypes.some((x) => parent instanceof x) ? parent : document; | ||
return nodeTypes.some((x) => selector instanceof x) | ||
// @ts-ignore -- we must include ShadowRoot Node | ||
? selector : lookUp.querySelector(selector); | ||
} |
@@ -1,3 +0,1 @@ | ||
import isHTMLElement from '../misc/isHTMLElement'; | ||
/** | ||
@@ -7,8 +5,10 @@ * A shortcut for `(document|Element).querySelectorAll`. | ||
* @param {string} selector the input selector | ||
* @param {HTMLElement=} parent optional Element to look into | ||
* @param {(Node | Element | HTMLElement)=} parent optional node to look into | ||
* @return {NodeListOf<HTMLElement>} the query result | ||
*/ | ||
export default function querySelectorAll(selector, parent) { | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
const lookUp = parent && [HTMLElement, Element, Node] | ||
.some((x) => parent instanceof x) ? parent : document; | ||
// @ts-ignore -- we must include ShadowRoot Node | ||
return lookUp.querySelectorAll(selector); | ||
} |
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* A global namespace for: | ||
* * `transitionProperty` string for Firefox, | ||
* * `transition` property for all other browsers. | ||
* | ||
* @type {string} | ||
@@ -4,0 +7,0 @@ */ |
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* A global namespace for: | ||
* * `transitionProperty` string for Firefox, | ||
* * `webkitTransition` for older Chrome / Safari browsers, | ||
* * `transition` property for all other browsers. | ||
* @type {string} | ||
*/ | ||
const transitionProperty = 'webkitTransition' in document.head.style ? 'webkitTransitionProperty' : 'transitionProperty'; | ||
export default transitionProperty; |
@@ -110,10 +110,31 @@ export as namespace SHORTER; | ||
export { default as scrollWidth } from "shorter-js/src/strings/scrollWidth"; | ||
export { default as userAgentData } from "shorter-js/src/strings/userAgentData"; | ||
export { default as userAgent } from "shorter-js/src/strings/userAgent"; | ||
export { default as isApple } from "shorter-js/src/boolean/isApple"; | ||
export { default as isFirefox } from "shorter-js/src/boolean/isFirefox"; | ||
export { default as isMobile } from "shorter-js/src/boolean/isMobile"; | ||
export { default as isApple } from "shorter-js/src/boolean/isApple"; | ||
export { default as support3DTransform } from "shorter-js/src/boolean/support3DTransform"; | ||
export { default as supportAnimation } from "shorter-js/src/boolean/supportAnimation"; | ||
export { default as supportPassive } from "shorter-js/src/boolean/supportPassive"; | ||
export { default as supportTouch } from "shorter-js/src/boolean/supportTouch"; | ||
export { default as supportTransform } from "shorter-js/src/boolean/supportTransform"; | ||
export { default as supportTouch } from "shorter-js/src/boolean/supportTouch"; | ||
export { default as supportAnimation } from "shorter-js/src/boolean/supportAnimation"; | ||
export { default as supportTransition } from "shorter-js/src/boolean/supportTransition"; | ||
export { default as getAttribute } from "shorter-js/src/get/getAttribute"; | ||
export { default as getAttributeNS } from "shorter-js/src/get/getAttributeNS"; | ||
export { default as getBoundingClientRect } from "shorter-js/src/get/getBoundingClientRect"; | ||
export { default as getDocumentElement } from "shorter-js/src/get/getDocumentElement"; | ||
export { default as getElementAnimationDuration } from "shorter-js/src/get/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "shorter-js/src/get/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "shorter-js/src/get/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "shorter-js/src/get/getElementAnimationDelayLegacy"; | ||
export { default as getElementStyle } from "shorter-js/src/get/getElementStyle"; | ||
export { default as getElementTransitionDuration } from "shorter-js/src/get/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "shorter-js/src/get/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "shorter-js/src/get/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "shorter-js/src/get/getElementTransitionDelayLegacy"; | ||
export { default as getNodeScroll } from "shorter-js/src/get/getNodeScroll"; | ||
export { default as getOffsetParent } from "shorter-js/src/get/getOffsetParent"; | ||
export { default as getParentNode } from "shorter-js/src/get/getParentNode"; | ||
export { default as getRectRelativeToOffsetParent } from "shorter-js/src/get/getRectRelativeToOffsetParent"; | ||
export { default as getWindow } from "shorter-js/src/get/getWindow"; | ||
export { default as addClass } from "shorter-js/src/class/addClass"; | ||
@@ -131,15 +152,3 @@ export { default as removeClass } from "shorter-js/src/class/removeClass"; | ||
export { default as emulateTransitionEndLegacy } from "shorter-js/src/misc/emulateTransitionEndLegacy"; | ||
export { default as isElementInScrollRange } from "shorter-js/src/misc/isElementInScrollRange"; | ||
export { default as isElementInViewport } from "shorter-js/src/misc/isElementInViewport"; | ||
export { default as isMedia } from "shorter-js/src/misc/isMedia"; | ||
export { default as isRTL } from "shorter-js/src/misc/isRTL"; | ||
export { default as passiveHandler } from "shorter-js/src/misc/passiveHandler"; | ||
export { default as getElementAnimationDuration } from "shorter-js/src/misc/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "shorter-js/src/misc/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "shorter-js/src/misc/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "shorter-js/src/misc/getElementAnimationDelayLegacy"; | ||
export { default as getElementTransitionDuration } from "shorter-js/src/misc/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "shorter-js/src/misc/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "shorter-js/src/misc/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "shorter-js/src/misc/getElementTransitionDelayLegacy"; | ||
export { default as normalizeValue } from "shorter-js/src/misc/normalizeValue"; | ||
@@ -156,15 +165,27 @@ export { default as normalizeOptions } from "shorter-js/src/misc/normalizeOptions"; | ||
export { default as ObjectAssign } from "shorter-js/src/misc/ObjectAssign"; | ||
export { default as getAttribute } from "shorter-js/src/manipulate/getAttribute"; | ||
export { default as setAttribute } from "shorter-js/src/manipulate/setAttribute"; | ||
export { default as setAttributeNS } from "shorter-js/src/manipulate/setAttributeNS"; | ||
export { default as removeAttribute } from "shorter-js/src/manipulate/removeAttribute"; | ||
export { default as getElementStyle } from "shorter-js/src/manipulate/getElementStyle"; | ||
export { default as removeAttributeNS } from "shorter-js/src/manipulate/removeAttributeNS"; | ||
export { default as setElementStyle } from "shorter-js/src/manipulate/setElementStyle"; | ||
export { default as isArray } from "shorter-js/src/misc/isArray"; | ||
export { default as isString } from "shorter-js/src/misc/isString"; | ||
export { default as isElement } from "shorter-js/src/misc/isElement"; | ||
export { default as isNodeList } from "shorter-js/src/misc/isNodeList"; | ||
export { default as isHTMLElement } from "shorter-js/src/misc/isHTMLElement"; | ||
export { default as isHTMLCollection } from "shorter-js/src/misc/isHTMLCollection"; | ||
export { default as isElementsArray } from "shorter-js/src/misc/isElementsArray"; | ||
export { default as isArray } from "shorter-js/src/is/isArray"; | ||
export { default as isElement } from "shorter-js/src/is/isElement"; | ||
export { default as isElementInScrollRange } from "shorter-js/src/is/isElementInScrollRange"; | ||
export { default as isElementInViewport } from "shorter-js/src/is/isElementInViewport"; | ||
export { default as isElementsArray } from "shorter-js/src/is/isElementsArray"; | ||
export { default as isHTMLCollection } from "shorter-js/src/is/isHTMLCollection"; | ||
export { default as isHTMLElement } from "shorter-js/src/is/isHTMLElement"; | ||
export { default as isHTMLImageElement } from "shorter-js/src/is/isHTMLImageElement"; | ||
export { default as isMedia } from "shorter-js/src/is/isMedia"; | ||
export { default as isNode } from "shorter-js/src/is/isNode"; | ||
export { default as isNodeList } from "shorter-js/src/is/isNodeList"; | ||
export { default as isRTL } from "shorter-js/src/is/isRTL"; | ||
export { default as isScaledElement } from "shorter-js/src/is/isScaledElement"; | ||
export { default as isShadowRoot } from "shorter-js/src/is/isShadowRoot"; | ||
export { default as isString } from "shorter-js/src/is/isString"; | ||
export { default as isSVGElement } from "shorter-js/src/is/isSVGElement"; | ||
export { default as isTableElement } from "shorter-js/src/is/isTableElement"; | ||
export { default as isWindow } from "shorter-js/src/is/isWindow"; | ||
export { default as closest } from "shorter-js/src/selectors/closest"; | ||
export { default as getCustomElements } from "shorter-js/src/selectors/getCustomElements"; | ||
export { default as querySelector } from "shorter-js/src/selectors/querySelector"; | ||
@@ -179,2 +200,3 @@ export { default as querySelectorAll } from "shorter-js/src/selectors/querySelectorAll"; | ||
getInstance, | ||
BoundingClientRect, | ||
} from './module/types' |
@@ -121,12 +121,36 @@ // strings | ||
export { default as userAgentData } from "../../src/strings/userAgentData"; | ||
export { default as userAgent } from "../../src/strings/userAgent"; | ||
// boolean | ||
export { default as isApple } from "../../src/boolean/isApple"; | ||
export { default as isFirefox } from "../../src/boolean/isFirefox"; | ||
export { default as isMobile } from "../../src/boolean/isMobile"; | ||
export { default as isApple } from "../../src/boolean/isApple"; | ||
export { default as support3DTransform } from "../../src/boolean/support3DTransform"; | ||
export { default as supportAnimation } from "../../src/boolean/supportAnimation"; | ||
export { default as supportPassive } from "../../src/boolean/supportPassive"; | ||
export { default as supportTouch } from "../../src/boolean/supportTouch"; | ||
export { default as supportTransform } from "../../src/boolean/supportTransform"; | ||
export { default as supportTouch } from "../../src/boolean/supportTouch"; | ||
export { default as supportAnimation } from "../../src/boolean/supportAnimation"; | ||
export { default as supportTransition } from "../../src/boolean/supportTransition"; | ||
// get | ||
export { default as getAttribute } from '../../src/get/getAttribute'; | ||
export { default as getAttributeNS } from '../../src/get/getAttributeNS'; | ||
export { default as getBoundingClientRect } from '../../src/get/getBoundingClientRect'; | ||
export { default as getDocumentElement } from '../../src/get/getDocumentElement'; | ||
export { default as getElementAnimationDuration } from "../../src/get/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "../../src/get/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "../../src/get/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "../../src/get/getElementAnimationDelayLegacy"; | ||
export { default as getElementStyle } from '../../src/get/getElementStyle'; | ||
export { default as getElementTransitionDuration } from "../../src/get/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "../../src/get/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "../../src/get/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "../../src/get/getElementTransitionDelayLegacy"; | ||
export { default as getNodeScroll } from "../../src/get/getNodeScroll"; | ||
export { default as getOffsetParent } from "../../src/get/getOffsetParent"; | ||
export { default as getParentNode } from "../../src/get/getParentNode"; | ||
export { default as getRectRelativeToOffsetParent } from "../../src/get/getRectRelativeToOffsetParent"; | ||
export { default as getWindow } from "../../src/get/getWindow"; | ||
// class | ||
@@ -145,2 +169,3 @@ export { default as addClass } from "../../src/class/addClass"; | ||
export { default as Timer } from "../../src/misc/timer"; | ||
export { default as emulateAnimationEnd } from "../../src/misc/emulateAnimationEnd"; | ||
@@ -150,15 +175,4 @@ export { default as emulateAnimationEndLegacy } from "../../src/misc/emulateAnimationEndLegacy"; | ||
export { default as emulateTransitionEndLegacy } from "../../src/misc/emulateTransitionEndLegacy"; | ||
export { default as isElementInScrollRange } from "../../src/misc/isElementInScrollRange"; | ||
export { default as isElementInViewport } from "../../src/misc/isElementInViewport"; | ||
export { default as isMedia } from "../../src/misc/isMedia"; | ||
export { default as isRTL } from "../../src/misc/isRTL"; | ||
export { default as passiveHandler } from "../../src/misc/passiveHandler"; | ||
export { default as getElementAnimationDuration } from "../../src/misc/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "../../src/misc/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "../../src/misc/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "../../src/misc/getElementAnimationDelayLegacy"; | ||
export { default as getElementTransitionDuration } from "../../src/misc/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "../../src/misc/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "../../src/misc/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "../../src/misc/getElementTransitionDelayLegacy"; | ||
export { default as normalizeValue } from "../../src/misc/normalizeValue"; | ||
@@ -177,17 +191,32 @@ export { default as normalizeOptions } from "../../src/misc/normalizeOptions"; | ||
export { default as getAttribute } from '../../src/manipulate/getAttribute'; | ||
// manipulate | ||
export { default as setAttribute } from '../../src/manipulate/setAttribute'; | ||
export { default as setAttributeNS } from '../../src/manipulate/setAttributeNS'; | ||
export { default as removeAttribute } from '../../src/manipulate/removeAttribute'; | ||
export { default as getElementStyle } from '../../src/manipulate/getElementStyle'; | ||
export { default as removeAttributeNS } from '../../src/manipulate/removeAttributeNS'; | ||
export { default as setElementStyle } from '../../src/manipulate/setElementStyle'; | ||
export { default as isArray } from "../../src/misc/isArray"; | ||
export { default as isString } from "../../src/misc/isString"; | ||
export { default as isElement } from "../../src/misc/isElement"; | ||
export { default as isNodeList } from "../../src/misc/isNodeList"; | ||
export { default as isHTMLElement } from "../../src/misc/isHTMLElement"; | ||
export { default as isHTMLCollection } from "../../src/misc/isHTMLCollection"; | ||
export { default as isElementsArray } from "../../src/misc/isElementsArray"; | ||
// is | ||
export { default as isArray } from "../../src/is/isArray"; | ||
export { default as isElement } from "../../src/is/isElement"; | ||
export { default as isElementInScrollRange } from "../../src/is/isElementInScrollRange"; | ||
export { default as isElementInViewport } from "../../src/is/isElementInViewport"; | ||
export { default as isElementsArray } from "../../src/is/isElementsArray"; | ||
export { default as isHTMLCollection } from "../../src/is/isHTMLCollection"; | ||
export { default as isHTMLElement } from "../../src/is/isHTMLElement"; | ||
export { default as isHTMLImageElement } from "../../src/is/isHTMLImageElement"; | ||
export { default as isMedia } from "../../src/is/isMedia"; | ||
export { default as isNode } from "../../src/is/isNode"; | ||
export { default as isNodeList } from "../../src/is/isNodeList"; | ||
export { default as isRTL } from "../../src/is/isRTL"; | ||
export { default as isScaledElement } from "../../src/is/isScaledElement"; | ||
export { default as isShadowRoot } from "../../src/is/isShadowRoot"; | ||
export { default as isString } from "../../src/is/isString"; | ||
export { default as isSVGElement } from "../../src/is/isSVGElement"; | ||
export { default as isTableElement } from "../../src/is/isTableElement"; | ||
export { default as isWindow } from "../../src/is/isWindow"; | ||
// selectors | ||
export { default as closest } from "../../src/selectors/closest"; | ||
export { default as getCustomElements } from "../../src/selectors/getCustomElements"; | ||
export { default as querySelector } from "../../src/selectors/querySelector"; | ||
@@ -194,0 +223,0 @@ export { default as querySelectorAll } from "../../src/selectors/querySelectorAll"; |
export type Component = Record<string, any>; | ||
export type getInstance<T> = (target: HTMLElement | string, component: string) => T | null; | ||
export interface BoundingClientRect { | ||
width: number, | ||
height: number, | ||
top: number, | ||
left: number, | ||
right: number, | ||
bottom: number, | ||
x: number, | ||
y: number, | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
347479
202
8818