diff --git a/config/rollup/pipeline.build.js b/config/rollup/pipeline.build.js
index ba22bd4..ee56fee 100644
--- a/config/rollup/pipeline.build.js
+++ b/config/rollup/pipeline.build.js
@@ -27,14 +27,10 @@ const createOutputWithMinifiedVersion = (output, esm, buildMinifiedVersion) =>
rollupTerser({
ecma: esm ? 2015 : 5,
safari10: true,
- mangle: {
- safari10: true,
- properties: {
- regex: /^_/,
- },
- },
compress: {
evaluate: false,
+ module: !!esm,
+ passes: 3,
},
}),
],
@@ -63,6 +59,30 @@ module.exports = (esm, options, { declarationFiles = false, outputStyle = false
format: esm ? 'esm' : 'umd',
generatedCode: esm ? 'es2015' : 'es5',
file: path.resolve(distPath, `${file}${esm ? '.esm' : ''}.js`),
+ plugins: [
+ rollupTerser({
+ ecma: esm ? 2015 : 5,
+ safari10: true,
+
+ mangle: {
+ safari10: true,
+ keep_fnames: true, // eslint-disable-line camelcase
+ properties: {
+ regex: /^_/,
+ },
+ },
+ compress: {
+ defaults: false,
+ hoist_funs: true, // eslint-disable-line camelcase
+ },
+ format: {
+ beautify: true,
+ max_line_len: 80, // eslint-disable-line camelcase
+ braces: true,
+ indent_level: 2, // eslint-disable-line camelcase
+ },
+ }),
+ ],
},
esm,
buildMinifiedVersion
diff --git a/package.json b/package.json
index 94fdd36..f5f95e3 100644
--- a/package.json
+++ b/package.json
@@ -55,11 +55,11 @@
"rollup-plugin-scss": "^3.0.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-styles": "^3.10.0",
- "rollup-plugin-terser": "^6.1.0",
- "rollup-plugin-ts": "^3.0.1",
+ "rollup-plugin-terser": "^7.0.2",
+ "rollup-plugin-ts": "^3.0.2",
"should": "^13.2.3",
"tslib": "^2.4.0",
- "typescript": "^4.7.3",
+ "typescript": "^4.7.4",
"utf-8-validate": "^5.0.2"
},
"scripts": {
diff --git a/packages/overlayscrollbars/dist/overlayscrollbars.esm.js b/packages/overlayscrollbars/dist/overlayscrollbars.esm.js
index 88a3856..97fe696 100644
--- a/packages/overlayscrollbars/dist/overlayscrollbars.esm.js
+++ b/packages/overlayscrollbars/dist/overlayscrollbars.esm.js
@@ -1,2249 +1,1992 @@
-function createCache(options, update) {
- const {
- _initialValue,
- _equal,
- _alwaysUpdateValues
- } = options;
- let _value = _initialValue;
-
- let _previous;
-
- const cacheUpdateContextual = (newValue, force) => {
- const curr = _value;
- const newVal = newValue;
- const changed = force || (_equal ? !_equal(curr, newVal) : curr !== newVal);
-
- if (changed || _alwaysUpdateValues) {
- _value = newVal;
- _previous = curr;
+function createCache(t, n) {
+ const {o, u: e, _: s} = t;
+ let c = o;
+ let i;
+ const cacheUpdateContextual = (t, n) => {
+ const o = c;
+ const r = t;
+ const a = n || (e ? !e(o, r) : o !== r);
+ if (a || s) {
+ c = r;
+ i = o;
}
-
- return [_value, changed, _previous];
+ return [ c, a, i ];
};
-
- const cacheUpdateIsolated = force => cacheUpdateContextual(update(_value, _previous), force);
-
- const getCurrentCache = force => [_value, !!force, _previous];
-
- return [update ? cacheUpdateIsolated : cacheUpdateContextual, getCurrentCache];
+ const cacheUpdateIsolated = t => cacheUpdateContextual(n(c, i), t);
+ const getCurrentCache = t => [ c, !!t, i ];
+ return [ n ? cacheUpdateIsolated : cacheUpdateContextual, getCurrentCache ];
}
-const ElementNodeType = Node.ELEMENT_NODE;
-const {
- toString,
- hasOwnProperty: hasOwnProperty$1
-} = Object.prototype;
-function isUndefined(obj) {
- return obj === undefined;
+function isUndefined(t) {
+ return void 0 === t;
}
-function isNull(obj) {
- return obj === null;
-}
-const type = obj => isUndefined(obj) || isNull(obj) ? `${obj}` : toString.call(obj).replace(/^\[object (.+)\]$/, '$1').toLowerCase();
-function isNumber(obj) {
- return typeof obj === 'number';
-}
-function isString(obj) {
- return typeof obj === 'string';
-}
-function isBoolean(obj) {
- return typeof obj === 'boolean';
-}
-function isFunction(obj) {
- return typeof obj === 'function';
-}
-function isArray(obj) {
- return Array.isArray(obj);
-}
-function isObject(obj) {
- return typeof obj === 'object' && !isArray(obj) && !isNull(obj);
-}
-function isArrayLike(obj) {
- const length = !!obj && obj.length;
- const lengthCorrectFormat = isNumber(length) && length > -1 && length % 1 == 0;
- return isArray(obj) || !isFunction(obj) && lengthCorrectFormat ? length > 0 && isObject(obj) ? length - 1 in obj : true : false;
-}
-function isPlainObject(obj) {
- if (!obj || !isObject(obj) || type(obj) !== 'object') return false;
- let key;
- const cstr = 'constructor';
- const ctor = obj[cstr];
- const ctorProto = ctor && ctor.prototype;
- const hasOwnConstructor = hasOwnProperty$1.call(obj, cstr);
- const hasIsPrototypeOf = ctorProto && hasOwnProperty$1.call(ctorProto, 'isPrototypeOf');
- if (ctor && !hasOwnConstructor && !hasIsPrototypeOf) {
+function isNull(t) {
+ return null === t;
+}
+
+function isNumber(t) {
+ return "number" === typeof t;
+}
+
+function isString(t) {
+ return "string" === typeof t;
+}
+
+function isBoolean(t) {
+ return "boolean" === typeof t;
+}
+
+function isFunction(t) {
+ return "function" === typeof t;
+}
+
+function isArray(t) {
+ return Array.isArray(t);
+}
+
+function isObject(t) {
+ return "object" === typeof t && !isArray(t) && !isNull(t);
+}
+
+function isArrayLike(t) {
+ const n = !!t && t.length;
+ const o = isNumber(n) && n > -1 && n % 1 == 0;
+ return isArray(t) || !isFunction(t) && o ? n > 0 && isObject(t) ? n - 1 in t : true : false;
+}
+
+function isPlainObject(t) {
+ if (!t || !isObject(t) || "object" !== type(t)) {
return false;
}
-
- for (key in obj) {}
-
- return isUndefined(key) || hasOwnProperty$1.call(obj, key);
-}
-function isHTMLElement(obj) {
- const instanceofObj = window.HTMLElement;
- return obj ? instanceofObj ? obj instanceof instanceofObj : obj.nodeType === ElementNodeType : false;
-}
-function isElement(obj) {
- const instanceofObj = window.Element;
- return obj ? instanceofObj ? obj instanceof instanceofObj : obj.nodeType === ElementNodeType : false;
+ let n;
+ const e = "constructor";
+ const s = t[e];
+ const c = s && s.prototype;
+ const i = o.call(t, e);
+ const r = c && o.call(c, "isPrototypeOf");
+ if (s && !i && !r) {
+ return false;
+ }
+ for (n in t) {}
+ return isUndefined(n) || o.call(t, n);
}
-function each(source, callback) {
- if (isArrayLike(source)) {
- for (let i = 0; i < source.length; i++) {
- if (callback(source[i], i, source) === false) {
+function isHTMLElement(n) {
+ const o = window.HTMLElement;
+ return n ? o ? n instanceof o : n.nodeType === t : false;
+}
+
+function isElement(n) {
+ const o = window.Element;
+ return n ? o ? n instanceof o : n.nodeType === t : false;
+}
+
+function each(t, n) {
+ if (isArrayLike(t)) {
+ for (let o = 0; o < t.length; o++) {
+ if (false === n(t[o], o, t)) {
break;
}
}
- } else if (source) {
- each(Object.keys(source), key => callback(source[key], key, source));
+ } else if (t) {
+ each(Object.keys(t), (o => n(t[o], o, t)));
}
-
- return source;
+ return t;
}
-const indexOf = (arr, item, fromIndex) => arr.indexOf(item, fromIndex);
-const push = (array, items, arrayIsSingleItem) => {
- !arrayIsSingleItem && !isString(items) && isArrayLike(items) ? Array.prototype.push.apply(array, items) : array.push(items);
- return array;
-};
-const from = arr => {
- if (Array.from && arr) {
- return Array.from(arr);
+
+function assignDeep(t, n, o, e, s, c, i) {
+ const r = [ n, o, e, s, c, i ];
+ if (("object" !== typeof t || isNull(t)) && !isFunction(t)) {
+ t = {};
}
-
- const result = [];
-
- if (arr instanceof Set) {
- arr.forEach(value => {
- push(result, value);
- });
- } else {
- each(arr, elm => {
- push(result, elm);
- });
- }
-
- return result;
-};
-const isEmptyArray = array => !!array && array.length === 0;
-const runEach = (arr, args) => {
- const runFn = fn => fn && fn.apply(undefined, args || []);
-
- if (arr instanceof Set) {
- arr.forEach(runFn);
- } else {
- each(arr, runFn);
- }
-};
-
-const hasOwnProperty = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
-const keys = obj => obj ? Object.keys(obj) : [];
-function assignDeep(target, object1, object2, object3, object4, object5, object6) {
- const sources = [object1, object2, object3, object4, object5, object6];
-
- if ((typeof target !== 'object' || isNull(target)) && !isFunction(target)) {
- target = {};
- }
-
- each(sources, source => {
- each(keys(source), key => {
- const copy = source[key];
-
- if (target === copy) {
+ each(r, (n => {
+ each(keys(n), (o => {
+ const e = n[o];
+ if (t === e) {
return true;
}
-
- const copyIsArray = isArray(copy);
-
- if (copy && (isPlainObject(copy) || copyIsArray)) {
- const src = target[key];
- let clone = src;
-
- if (copyIsArray && !isArray(src)) {
- clone = [];
- } else if (!copyIsArray && !isPlainObject(src)) {
- clone = {};
+ const s = isArray(e);
+ if (e && (isPlainObject(e) || s)) {
+ const n = t[o];
+ let c = n;
+ if (s && !isArray(n)) {
+ c = [];
+ } else if (!s && !isPlainObject(n)) {
+ c = {};
}
-
- target[key] = assignDeep(clone, copy);
+ t[o] = assignDeep(c, e);
} else {
- target[key] = copy;
+ t[o] = e;
}
- });
- });
- return target;
+ }));
+ }));
+ return t;
}
-function isEmptyObject(obj) {
- for (const name in obj) return false;
+function isEmptyObject(t) {
+ for (const n in t) {
+ return false;
+ }
return true;
}
-function getSetProp(topLeft, fallback, elm, value) {
- if (isUndefined(value)) {
- return elm ? elm[topLeft] : fallback;
+function getSetProp(t, n, o, e) {
+ if (isUndefined(e)) {
+ return o ? o[t] : n;
}
-
- elm && (elm[topLeft] = value);
+ o && (o[t] = e);
}
-function attr(elm, attrName, value) {
- if (isUndefined(value)) {
- return elm ? elm.getAttribute(attrName) : null;
+function attr(t, n, o) {
+ if (isUndefined(o)) {
+ return t ? t.getAttribute(n) : null;
}
-
- elm && elm.setAttribute(attrName, value);
-}
-const attrClass = (elm, attrName, value, add) => {
- const currValues = attr(elm, attrName) || '';
- const currValuesSet = new Set(currValues.split(' '));
- currValuesSet[add ? 'add' : 'delete'](value);
- attr(elm, attrName, from(currValuesSet).join(' ').trim());
-};
-const hasAttrClass = (elm, attrName, value) => {
- const currValues = attr(elm, attrName) || '';
- const currValuesSet = new Set(currValues.split(' '));
- return currValuesSet.has(value);
-};
-const removeAttr = (elm, attrName) => {
- elm && elm.removeAttribute(attrName);
-};
-function scrollLeft(elm, value) {
- return getSetProp('scrollLeft', 0, elm, value);
-}
-function scrollTop(elm, value) {
- return getSetProp('scrollTop', 0, elm, value);
+ t && t.setAttribute(n, o);
}
-const elmPrototype = Element.prototype;
+function scrollLeft(t, n) {
+ return getSetProp("scrollLeft", 0, t, n);
+}
-const find = (selector, elm) => {
- const arr = [];
- const rootElm = elm ? isElement(elm) ? elm : null : document;
- return rootElm ? push(arr, rootElm.querySelectorAll(selector)) : arr;
-};
+function scrollTop(t, n) {
+ return getSetProp("scrollTop", 0, t, n);
+}
-const findFirst = (selector, elm) => {
- const rootElm = elm ? isElement(elm) ? elm : null : document;
- return rootElm ? rootElm.querySelector(selector) : null;
-};
-
-const is = (elm, selector) => {
- if (isElement(elm)) {
- const fn = elmPrototype.matches || elmPrototype.msMatchesSelector;
- return fn.call(elm, selector);
+function style(t, n) {
+ const o = isString(n);
+ const e = isArray(n) || o;
+ if (e) {
+ let e = o ? "" : {};
+ if (t) {
+ const s = window.getComputedStyle(t, null);
+ e = o ? getCSSVal(t, s, n) : n.reduce(((n, o) => {
+ n[o] = getCSSVal(t, s, o);
+ return n;
+ }), e);
+ }
+ return e;
}
+ each(keys(n), (o => setCSSVal(t, o, n[o])));
+}
+const t = Node.ELEMENT_NODE;
+
+const {toString: n, hasOwnProperty: o} = Object.prototype;
+
+const type = t => isUndefined(t) || isNull(t) ? `${t}` : n.call(t).replace(/^\[object (.+)\]$/, "$1").toLowerCase();
+
+const indexOf = (t, n, o) => t.indexOf(n, o);
+
+const push = (t, n, o) => {
+ !o && !isString(n) && isArrayLike(n) ? Array.prototype.push.apply(t, n) : t.push(n);
+ return t;
+};
+
+const from = t => {
+ if (Array.from && t) {
+ return Array.from(t);
+ }
+ const n = [];
+ if (t instanceof Set) {
+ t.forEach((t => {
+ push(n, t);
+ }));
+ } else {
+ each(t, (t => {
+ push(n, t);
+ }));
+ }
+ return n;
+};
+
+const isEmptyArray = t => !!t && 0 === t.length;
+
+const runEach = (t, n) => {
+ const runFn = t => t && t.apply(void 0, n || []);
+ if (t instanceof Set) {
+ t.forEach(runFn);
+ } else {
+ each(t, runFn);
+ }
+};
+
+const hasOwnProperty = (t, n) => Object.prototype.hasOwnProperty.call(t, n);
+
+const keys = t => t ? Object.keys(t) : [];
+
+const attrClass = (t, n, o, e) => {
+ const s = attr(t, n) || "";
+ const c = new Set(s.split(" "));
+ c[e ? "add" : "delete"](o);
+ attr(t, n, from(c).join(" ").trim());
+};
+
+const hasAttrClass = (t, n, o) => {
+ const e = attr(t, n) || "";
+ const s = new Set(e.split(" "));
+ return s.has(o);
+};
+
+const removeAttr = (t, n) => {
+ t && t.removeAttribute(n);
+};
+
+const e = Element.prototype;
+
+const find = (t, n) => {
+ const o = [];
+ const e = n ? isElement(n) ? n : null : document;
+ return e ? push(o, e.querySelectorAll(t)) : o;
+};
+
+const findFirst = (t, n) => {
+ const o = n ? isElement(n) ? n : null : document;
+ return o ? o.querySelector(t) : null;
+};
+
+const is = (t, n) => {
+ if (isElement(t)) {
+ const o = e.matches || e.msMatchesSelector;
+ return o.call(t, n);
+ }
return false;
};
-const contents = elm => elm ? from(elm.childNodes) : [];
+const contents = t => t ? from(t.childNodes) : [];
-const parent = elm => elm ? elm.parentElement : null;
+const parent = t => t ? t.parentElement : null;
-const closest = (elm, selector) => {
- if (isElement(elm)) {
- const closestFn = elmPrototype.closest;
-
- if (closestFn) {
- return closestFn.call(elm, selector);
+const closest = (t, n) => {
+ if (isElement(t)) {
+ const o = e.closest;
+ if (o) {
+ return o.call(t, n);
}
-
do {
- if (is(elm, selector)) {
- return elm;
+ if (is(t, n)) {
+ return t;
}
-
- elm = parent(elm);
- } while (elm);
+ t = parent(t);
+ } while (t);
}
-
return null;
};
-const liesBetween = (elm, highBoundarySelector, deepBoundarySelector) => {
- const closestHighBoundaryElm = elm && closest(elm, highBoundarySelector);
- const closestDeepBoundaryElm = elm && findFirst(deepBoundarySelector, closestHighBoundaryElm);
- return closestHighBoundaryElm && closestDeepBoundaryElm ? closestHighBoundaryElm === elm || closestDeepBoundaryElm === elm || closest(closest(elm, deepBoundarySelector), highBoundarySelector) !== closestHighBoundaryElm : false;
+const liesBetween = (t, n, o) => {
+ const e = t && closest(t, n);
+ const s = t && findFirst(o, e);
+ return e && s ? e === t || s === t || closest(closest(t, o), n) !== e : false;
};
-const before = (parentElm, preferredAnchor, insertedElms) => {
- if (insertedElms) {
- let anchor = preferredAnchor;
- let fragment;
-
- if (parentElm) {
- if (isArrayLike(insertedElms)) {
- fragment = document.createDocumentFragment();
- each(insertedElms, insertedElm => {
- if (insertedElm === anchor) {
- anchor = insertedElm.previousSibling;
+const before = (t, n, o) => {
+ if (o) {
+ let e = n;
+ let s;
+ if (t) {
+ if (isArrayLike(o)) {
+ s = document.createDocumentFragment();
+ each(o, (t => {
+ if (t === e) {
+ e = t.previousSibling;
}
-
- fragment.appendChild(insertedElm);
- });
+ s.appendChild(t);
+ }));
} else {
- fragment = insertedElms;
+ s = o;
}
-
- if (preferredAnchor) {
- if (!anchor) {
- anchor = parentElm.firstChild;
- } else if (anchor !== preferredAnchor) {
- anchor = anchor.nextSibling;
+ if (n) {
+ if (!e) {
+ e = t.firstChild;
+ } else if (e !== n) {
+ e = e.nextSibling;
}
}
-
- parentElm.insertBefore(fragment, anchor || null);
+ t.insertBefore(s, e || null);
}
}
};
-const appendChildren = (node, children) => {
- before(node, null, children);
+const appendChildren = (t, n) => {
+ before(t, null, n);
};
-const prependChildren = (node, children) => {
- before(node, node && node.firstChild, children);
-};
-const insertBefore = (node, insertedNodes) => {
- before(parent(node), node, insertedNodes);
-};
-const insertAfter = (node, insertedNodes) => {
- before(parent(node), node && node.nextSibling, insertedNodes);
-};
-const removeElements = nodes => {
- if (isArrayLike(nodes)) {
- each(from(nodes), e => removeElements(e));
- } else if (nodes) {
- const parentElm = parent(nodes);
- if (parentElm) {
- parentElm.removeChild(nodes);
+const prependChildren = (t, n) => {
+ before(t, t && t.firstChild, n);
+};
+
+const insertBefore = (t, n) => {
+ before(parent(t), t, n);
+};
+
+const insertAfter = (t, n) => {
+ before(parent(t), t && t.nextSibling, n);
+};
+
+const removeElements = t => {
+ if (isArrayLike(t)) {
+ each(from(t), (t => removeElements(t)));
+ } else if (t) {
+ const n = parent(t);
+ if (n) {
+ n.removeChild(t);
}
}
};
-const createDiv = classNames => {
- const div = document.createElement('div');
-
- if (classNames) {
- attr(div, 'class', classNames);
+const createDiv = t => {
+ const n = document.createElement("div");
+ if (t) {
+ attr(n, "class", t);
}
-
- return div;
-};
-const createDOM = html => {
- const createdDiv = createDiv();
- createdDiv.innerHTML = html.trim();
- return each(contents(createdDiv), elm => removeElements(elm));
+ return n;
};
-const firstLetterToUpper = str => str.charAt(0).toUpperCase() + str.slice(1);
+const createDOM = t => {
+ const n = createDiv();
+ n.innerHTML = t.trim();
+ return each(contents(n), (t => removeElements(t)));
+};
+
+const firstLetterToUpper = t => t.charAt(0).toUpperCase() + t.slice(1);
const getDummyStyle = () => createDiv().style;
-const cssPrefixes = ['-webkit-', '-moz-', '-o-', '-ms-'];
-const jsPrefixes = ['WebKit', 'Moz', 'O', 'MS', 'webkit', 'moz', 'o', 'ms'];
-const jsCache = {};
-const cssCache = {};
-const cssProperty = name => {
- let result = cssCache[name];
+const s = [ "-webkit-", "-moz-", "-o-", "-ms-" ];
- if (hasOwnProperty(cssCache, name)) {
- return result;
+const c = [ "WebKit", "Moz", "O", "MS", "webkit", "moz", "o", "ms" ];
+
+const i = {};
+
+const r = {};
+
+const cssProperty = t => {
+ let n = r[t];
+ if (hasOwnProperty(r, t)) {
+ return n;
}
-
- const uppercasedName = firstLetterToUpper(name);
- const elmStyle = getDummyStyle();
- each(cssPrefixes, prefix => {
- const prefixWithoutDashes = prefix.replace(/-/g, '');
- const resultPossibilities = [name, prefix + name, prefixWithoutDashes + uppercasedName, firstLetterToUpper(prefixWithoutDashes) + uppercasedName];
- return !(result = resultPossibilities.find(resultPossibility => elmStyle[resultPossibility] !== undefined));
- });
- return cssCache[name] = result || '';
-};
-const jsAPI = name => {
- let result = jsCache[name] || window[name];
-
- if (hasOwnProperty(jsCache, name)) {
- return result;
- }
-
- each(jsPrefixes, prefix => {
- result = result || window[prefix + firstLetterToUpper(name)];
- return !result;
- });
- jsCache[name] = result;
- return result;
+ const o = firstLetterToUpper(t);
+ const e = getDummyStyle();
+ each(s, (s => {
+ const c = s.replace(/-/g, "");
+ const i = [ t, s + t, c + o, firstLetterToUpper(c) + o ];
+ return !(n = i.find((t => void 0 !== e[t])));
+ }));
+ return r[t] = n || "";
};
-const MutationObserverConstructor = jsAPI('MutationObserver');
-const IntersectionObserverConstructor = jsAPI('IntersectionObserver');
-const ResizeObserverConstructor = jsAPI('ResizeObserver');
-const cAF = jsAPI('cancelAnimationFrame');
-const rAF = jsAPI('requestAnimationFrame');
+const jsAPI = t => {
+ let n = i[t] || window[t];
+ if (hasOwnProperty(i, t)) {
+ return n;
+ }
+ each(c, (o => {
+ n = n || window[o + firstLetterToUpper(t)];
+ return !n;
+ }));
+ i[t] = n;
+ return n;
+};
-const rnothtmlwhite = /[^\x20\t\r\n\f]+/g;
+const a = jsAPI("MutationObserver");
-const classListAction = (elm, className, action) => {
- let clazz;
- let i = 0;
- let result = false;
+const l = jsAPI("IntersectionObserver");
- if (elm && className && isString(className)) {
- const classes = className.match(rnothtmlwhite) || [];
- result = classes.length > 0;
+const u = jsAPI("ResizeObserver");
- while (clazz = classes[i++]) {
- result = !!action(elm.classList, clazz) && result;
+const f = jsAPI("cancelAnimationFrame");
+
+const d = jsAPI("requestAnimationFrame");
+
+const _ = /[^\x20\t\r\n\f]+/g;
+
+const classListAction = (t, n, o) => {
+ let e;
+ let s = 0;
+ let c = false;
+ if (t && n && isString(n)) {
+ const i = n.match(_) || [];
+ c = i.length > 0;
+ while (e = i[s++]) {
+ c = !!o(t.classList, e) && c;
}
}
-
- return result;
+ return c;
};
-const hasClass = (elm, className) => classListAction(elm, className, (classList, clazz) => classList.contains(clazz));
-const removeClass = (elm, className) => {
- classListAction(elm, className, (classList, clazz) => classList.remove(clazz));
-};
-const addClass = (elm, className) => {
- classListAction(elm, className, (classList, clazz) => classList.add(clazz));
- return removeClass.bind(0, elm, className);
+const hasClass = (t, n) => classListAction(t, n, ((t, n) => t.contains(n)));
+
+const removeClass = (t, n) => {
+ classListAction(t, n, ((t, n) => t.remove(n)));
};
-const equal = (a, b, props, propMutation) => {
- if (a && b) {
- let result = true;
- each(props, prop => {
- const compareA = propMutation ? propMutation(a[prop]) : a[prop];
- const compareB = propMutation ? propMutation(b[prop]) : b[prop];
+const addClass = (t, n) => {
+ classListAction(t, n, ((t, n) => t.add(n)));
+ return removeClass.bind(0, t, n);
+};
- if (compareA !== compareB) {
- result = false;
+const equal = (t, n, o, e) => {
+ if (t && n) {
+ let s = true;
+ each(o, (o => {
+ const c = e ? e(t[o]) : t[o];
+ const i = e ? e(n[o]) : n[o];
+ if (c !== i) {
+ s = false;
}
- });
- return result;
+ }));
+ return s;
}
-
return false;
};
-const equalWH = (a, b) => equal(a, b, ['w', 'h']);
-const equalXY = (a, b) => equal(a, b, ['x', 'y']);
-const equalTRBL = (a, b) => equal(a, b, ['t', 'r', 'b', 'l']);
-const equalBCRWH = (a, b, round) => equal(a, b, ['width', 'height'], round && (value => Math.round(value)));
-const clearTimeouts = id => {
- id && window.clearTimeout(id);
- id && cAF(id);
+const equalWH = (t, n) => equal(t, n, [ "w", "h" ]);
+
+const equalXY = (t, n) => equal(t, n, [ "x", "y" ]);
+
+const equalTRBL = (t, n) => equal(t, n, [ "t", "r", "b", "l" ]);
+
+const equalBCRWH = (t, n, o) => equal(t, n, [ "width", "height" ], o && (t => Math.round(t)));
+
+const clearTimeouts = t => {
+ t && window.clearTimeout(t);
+ t && f(t);
};
const noop = () => {};
-const debounce = (functionToDebounce, options) => {
- let timeoutId;
- let maxTimeoutId;
- let prevArguments;
- let latestArguments;
- const {
- _timeout,
- _maxDelay,
- _mergeParams
- } = options || {};
- const setT = window.setTimeout;
- const invokeFunctionToDebounce = function invokeFunctionToDebounce(args) {
- clearTimeouts(timeoutId);
- clearTimeouts(maxTimeoutId);
- maxTimeoutId = timeoutId = prevArguments = undefined;
- functionToDebounce.apply(this, args);
+const debounce = (t, n) => {
+ let o;
+ let e;
+ let s;
+ let c;
+ const {g: i, p: r, v: a} = n || {};
+ const l = window.setTimeout;
+ const u = function invokeFunctionToDebounce(n) {
+ clearTimeouts(o);
+ clearTimeouts(e);
+ e = o = s = void 0;
+ t.apply(this, n);
};
-
- const mergeParms = curr => _mergeParams && prevArguments ? _mergeParams(prevArguments, curr) : curr;
-
+ const mergeParms = t => a && s ? a(s, t) : t;
const flush = () => {
- if (timeoutId) {
- invokeFunctionToDebounce(mergeParms(latestArguments) || latestArguments);
+ if (o) {
+ u(mergeParms(c) || c);
}
};
-
- const debouncedFn = function debouncedFn() {
- const args = from(arguments);
- const finalTimeout = isFunction(_timeout) ? _timeout() : _timeout;
- const hasTimeout = isNumber(finalTimeout) && finalTimeout >= 0;
-
- if (hasTimeout) {
- const finalMaxWait = isFunction(_maxDelay) ? _maxDelay() : _maxDelay;
- const hasMaxWait = isNumber(finalMaxWait) && finalMaxWait >= 0;
- const setTimeoutFn = finalTimeout > 0 ? setT : rAF;
- const mergeParamsResult = mergeParms(args);
- const invokedArgs = mergeParamsResult || args;
- const boundInvoke = invokeFunctionToDebounce.bind(0, invokedArgs);
- clearTimeouts(timeoutId);
- timeoutId = setTimeoutFn(boundInvoke, finalTimeout);
-
- if (hasMaxWait && !maxTimeoutId) {
- maxTimeoutId = setT(flush, finalMaxWait);
+ const f = function debouncedFn() {
+ const t = from(arguments);
+ const n = isFunction(i) ? i() : i;
+ const a = isNumber(n) && n >= 0;
+ if (a) {
+ const i = isFunction(r) ? r() : r;
+ const a = isNumber(i) && i >= 0;
+ const f = n > 0 ? l : d;
+ const _ = mergeParms(t);
+ const g = _ || t;
+ const h = u.bind(0, g);
+ clearTimeouts(o);
+ o = f(h, n);
+ if (a && !e) {
+ e = l(flush, i);
}
-
- prevArguments = latestArguments = invokedArgs;
+ s = c = g;
} else {
- invokeFunctionToDebounce(args);
+ u(t);
}
};
-
- debouncedFn._flush = flush;
- return debouncedFn;
+ f.m = flush;
+ return f;
};
-const cssNumber = {
+const g = {
opacity: 1,
zindex: 1
};
-const parseToZeroOrNumber = (value, toFloat) => {
- const num = toFloat ? parseFloat(value) : parseInt(value, 10);
- return Number.isNaN(num) ? 0 : num;
+const parseToZeroOrNumber = (t, n) => {
+ const o = n ? parseFloat(t) : parseInt(t, 10);
+ return Number.isNaN(o) ? 0 : o;
};
-const adaptCSSVal = (prop, val) => !cssNumber[prop.toLowerCase()] && isNumber(val) ? `${val}px` : val;
+const adaptCSSVal = (t, n) => !g[t.toLowerCase()] && isNumber(n) ? `${n}px` : n;
-const getCSSVal = (elm, computedStyle, prop) => computedStyle != null ? computedStyle[prop] || computedStyle.getPropertyValue(prop) : elm.style[prop];
+const getCSSVal = (t, n, o) => null != n ? n[o] || n.getPropertyValue(o) : t.style[o];
-const setCSSVal = (elm, prop, val) => {
+const setCSSVal = (t, n, o) => {
try {
- if (elm) {
- const {
- style: elmStyle
- } = elm;
-
- if (!isUndefined(elmStyle[prop])) {
- elmStyle[prop] = adaptCSSVal(prop, val);
+ if (t) {
+ const {style: e} = t;
+ if (!isUndefined(e[n])) {
+ e[n] = adaptCSSVal(n, o);
} else {
- elmStyle.setProperty(prop, val);
+ e.setProperty(n, o);
}
}
} catch (e) {}
};
-function style(elm, styles) {
- const getSingleStyle = isString(styles);
- const getStyles = isArray(styles) || getSingleStyle;
-
- if (getStyles) {
- let getStylesResult = getSingleStyle ? '' : {};
-
- if (elm) {
- const computedStyle = window.getComputedStyle(elm, null);
- getStylesResult = getSingleStyle ? getCSSVal(elm, computedStyle, styles) : styles.reduce((result, key) => {
- result[key] = getCSSVal(elm, computedStyle, key);
- return result;
- }, getStylesResult);
- }
-
- return getStylesResult;
- }
-
- each(keys(styles), key => setCSSVal(elm, key, styles[key]));
-}
-const topRightBottomLeft = (elm, propertyPrefix, propertySuffix) => {
- const finalPrefix = propertyPrefix ? `${propertyPrefix}-` : '';
- const finalSuffix = propertySuffix ? `-${propertySuffix}` : '';
- const top = `${finalPrefix}top${finalSuffix}`;
- const right = `${finalPrefix}right${finalSuffix}`;
- const bottom = `${finalPrefix}bottom${finalSuffix}`;
- const left = `${finalPrefix}left${finalSuffix}`;
- const result = style(elm, [top, right, bottom, left]);
+const topRightBottomLeft = (t, n, o) => {
+ const e = n ? `${n}-` : "";
+ const s = o ? `-${o}` : "";
+ const c = `${e}top${s}`;
+ const i = `${e}right${s}`;
+ const r = `${e}bottom${s}`;
+ const a = `${e}left${s}`;
+ const l = style(t, [ c, i, r, a ]);
return {
- t: parseToZeroOrNumber(result[top]),
- r: parseToZeroOrNumber(result[right]),
- b: parseToZeroOrNumber(result[bottom]),
- l: parseToZeroOrNumber(result[left])
+ t: parseToZeroOrNumber(l[c]),
+ r: parseToZeroOrNumber(l[i]),
+ b: parseToZeroOrNumber(l[r]),
+ l: parseToZeroOrNumber(l[a])
};
};
-const zeroObj$1 = {
+const h = {
w: 0,
h: 0
};
+
const windowSize = () => ({
w: window.innerWidth,
h: window.innerHeight
});
-const offsetSize = elm => elm ? {
- w: elm.offsetWidth,
- h: elm.offsetHeight
-} : zeroObj$1;
-const clientSize = elm => elm ? {
- w: elm.clientWidth,
- h: elm.clientHeight
-} : zeroObj$1;
-const scrollSize = elm => elm ? {
- w: elm.scrollWidth,
- h: elm.scrollHeight
-} : zeroObj$1;
-const fractionalSize = elm => {
- const cssHeight = parseFloat(style(elm, 'height')) || 0;
- const cssWidth = parseFloat(style(elm, 'height')) || 0;
+
+const offsetSize = t => t ? {
+ w: t.offsetWidth,
+ h: t.offsetHeight
+} : h;
+
+const clientSize = t => t ? {
+ w: t.clientWidth,
+ h: t.clientHeight
+} : h;
+
+const scrollSize = t => t ? {
+ w: t.scrollWidth,
+ h: t.scrollHeight
+} : h;
+
+const fractionalSize = t => {
+ const n = parseFloat(style(t, "height")) || 0;
+ const o = parseFloat(style(t, "height")) || 0;
return {
- w: cssWidth - Math.round(cssWidth),
- h: cssHeight - Math.round(cssHeight)
+ w: o - Math.round(o),
+ h: n - Math.round(n)
};
};
-const getBoundingClientRect = elm => elm.getBoundingClientRect();
-let passiveEventsSupport;
+const getBoundingClientRect = t => t.getBoundingClientRect();
+
+let p;
const supportPassiveEvents = () => {
- if (isUndefined(passiveEventsSupport)) {
- passiveEventsSupport = false;
-
+ if (isUndefined(p)) {
+ p = false;
try {
- window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
- get: function () {
- passiveEventsSupport = true;
+ window.addEventListener("test", null, Object.defineProperty({}, "passive", {
+ get: function() {
+ p = true;
}
}));
- } catch (e) {}
+ } catch (t) {}
}
-
- return passiveEventsSupport;
+ return p;
};
-const splitEventNames = eventNames => eventNames.split(' ');
+const splitEventNames = t => t.split(" ");
-const off = (target, eventNames, listener, capture) => {
- each(splitEventNames(eventNames), eventName => {
- target.removeEventListener(eventName, listener, capture);
- });
+const off = (t, n, o, e) => {
+ each(splitEventNames(n), (n => {
+ t.removeEventListener(n, o, e);
+ }));
};
-const on = (target, eventNames, listener, options) => {
- const doSupportPassiveEvents = supportPassiveEvents();
- const passive = doSupportPassiveEvents && options && options._passive || false;
- const capture = options && options._capture || false;
- const once = options && options._once || false;
- const offListeners = [];
- const nativeOptions = doSupportPassiveEvents ? {
- passive,
- capture
- } : capture;
- each(splitEventNames(eventNames), eventName => {
- const finalListener = once ? evt => {
- target.removeEventListener(eventName, finalListener, capture);
- listener && listener(evt);
- } : listener;
- push(offListeners, off.bind(null, target, eventName, finalListener, capture));
- target.addEventListener(eventName, finalListener, nativeOptions);
- });
- return runEach.bind(0, offListeners);
-};
-const stopPropagation = evt => evt.stopPropagation();
-const preventDefault = evt => evt.preventDefault();
-const stopAndPrevent = evt => stopPropagation(evt) || preventDefault(evt);
-const zeroObj = {
+const on = (t, n, o, e) => {
+ const s = supportPassiveEvents();
+ const c = s && e && e.S || false;
+ const i = e && e.C || false;
+ const r = e && e.O || false;
+ const a = [];
+ const l = s ? {
+ passive: c,
+ capture: i
+ } : i;
+ each(splitEventNames(n), (n => {
+ const e = r ? s => {
+ t.removeEventListener(n, e, i);
+ o && o(s);
+ } : o;
+ push(a, off.bind(null, t, n, e, i));
+ t.addEventListener(n, e, l);
+ }));
+ return runEach.bind(0, a);
+};
+
+const stopPropagation = t => t.stopPropagation();
+
+const preventDefault = t => t.preventDefault();
+
+const stopAndPrevent = t => stopPropagation(t) || preventDefault(t);
+
+const v = {
x: 0,
y: 0
};
-const absoluteCoordinates = elm => {
- const rect = elm ? getBoundingClientRect(elm) : 0;
- return rect ? {
- x: rect.left + window.pageYOffset,
- y: rect.top + window.pageXOffset
- } : zeroObj;
+
+const absoluteCoordinates = t => {
+ const n = t ? getBoundingClientRect(t) : 0;
+ return n ? {
+ x: n.left + window.pageYOffset,
+ y: n.top + window.pageXOffset
+ } : v;
};
-const manageListener = (callback, listener) => {
- each(isArray(listener) ? listener : [listener], callback);
+const manageListener = (t, n) => {
+ each(isArray(n) ? n : [ n ], t);
};
-const createEventListenerHub = initialEventListeners => {
- const events = new Map();
-
- const removeEvent = (name, listener) => {
- if (name) {
- const eventSet = events.get(name);
- manageListener(currListener => {
- if (eventSet) {
- eventSet[currListener ? 'delete' : 'clear'](currListener);
+const createEventListenerHub = t => {
+ function removeEvent(t, o) {
+ if (t) {
+ const e = n.get(t);
+ manageListener((t => {
+ if (e) {
+ e[t ? "delete" : "clear"](t);
}
- }, listener);
+ }), o);
} else {
- events.forEach(eventSet => {
- eventSet.clear();
- });
- events.clear();
+ n.forEach((t => {
+ t.clear();
+ }));
+ n.clear();
}
- };
-
- const addEvent = (name, listener) => {
- const eventSet = events.get(name) || new Set();
- events.set(name, eventSet);
- manageListener(currListener => {
- currListener && eventSet.add(currListener);
- }, listener);
- return removeEvent.bind(0, name, listener);
- };
-
- const triggerEvent = (name, args) => {
- const eventSet = events.get(name);
- each(from(eventSet), event => {
- if (args) {
- event(args);
- } else {
- event();
- }
- });
- };
-
- const initialListenerKeys = keys(initialEventListeners);
- each(initialListenerKeys, key => {
- addEvent(key, initialEventListeners[key]);
- });
- return [addEvent, removeEvent, triggerEvent];
-};
-
-const getPropByPath = (obj, path) => obj ? path.split('.').reduce((o, prop) => o && hasOwnProperty(o, prop) ? o[prop] : undefined, obj) : undefined;
-
-const createOptionCheck = (options, changedOptions, force) => path => [getPropByPath(options, path), force || getPropByPath(changedOptions, path) !== undefined];
-const createState = initialState => {
- let state = initialState;
- return [() => state, newState => {
- state = assignDeep({}, state, newState);
- }];
-};
-
-const classNameEnvironment = 'os-environment';
-const classNameEnvironmentFlexboxGlue = `${classNameEnvironment}-flexbox-glue`;
-const classNameEnvironmentFlexboxGlueMax = `${classNameEnvironmentFlexboxGlue}-max`;
-const dataAttributeHost = 'data-overlayscrollbars';
-const dataAttributeHostOverflowX = `${dataAttributeHost}-overflow-x`;
-const dataAttributeHostOverflowY = `${dataAttributeHost}-overflow-y`;
-const dataValueHostOverflowVisible = 'overflowVisible';
-const dataValueHostViewportScrollbarStyling = 'viewportStyled';
-const classNamePadding = 'os-padding';
-const classNameViewport = 'os-viewport';
-const classNameViewportArrange = `${classNameViewport}-arrange`;
-const classNameContent = 'os-content';
-const classNameViewportScrollbarStyling = `${classNameViewport}-scrollbar-styled`;
-const classNameOverflowVisible = `os-overflow-visible`;
-const classNameSizeObserver = 'os-size-observer';
-const classNameSizeObserverAppear = `${classNameSizeObserver}-appear`;
-const classNameSizeObserverListener = `${classNameSizeObserver}-listener`;
-const classNameSizeObserverListenerScroll = `${classNameSizeObserverListener}-scroll`;
-const classNameSizeObserverListenerItem = `${classNameSizeObserverListener}-item`;
-const classNameSizeObserverListenerItemFinal = `${classNameSizeObserverListenerItem}-final`;
-const classNameTrinsicObserver = 'os-trinsic-observer';
-const classNameScrollbar = 'os-scrollbar';
-const classNameScrollbarHorizontal = `${classNameScrollbar}-horizontal`;
-const classNameScrollbarVertical = `${classNameScrollbar}-vertical`;
-const classNameScrollbarTrack = 'os-scrollbar-track';
-const classNameScrollbarHandle = 'os-scrollbar-handle';
-
-const stringify = value => JSON.stringify(value, (_, val) => {
- if (isFunction(val)) {
- throw new Error();
}
+ function addEvent(t, o) {
+ const e = n.get(t) || new Set;
+ n.set(t, e);
+ manageListener((t => {
+ t && e.add(t);
+ }), o);
+ return removeEvent.bind(0, t, o);
+ }
+ function triggerEvent(t, ...o) {
+ const e = n.get(t);
+ each(from(e), (t => {
+ if (o) {
+ t(o);
+ } else {
+ t();
+ }
+ }));
+ }
+ const n = new Map;
+ const o = keys(t);
+ each(o, (n => {
+ addEvent(n, t[n]);
+ }));
+ return [ addEvent, removeEvent, triggerEvent ];
+};
- return val;
-});
+const getPropByPath = (t, n) => t ? n.split(".").reduce(((t, n) => t && hasOwnProperty(t, n) ? t[n] : void 0), t) : void 0;
-const defaultOptions = {
+const createOptionCheck = (t, n, o) => e => [ getPropByPath(t, e), o || void 0 !== getPropByPath(n, e) ];
+
+const createState = t => {
+ let n = t;
+ return [ () => n, t => {
+ n = assignDeep({}, n, t);
+ } ];
+};
+
+const w = "os-environment";
+
+const b = `${w}-flexbox-glue`;
+
+const y = `${b}-max`;
+
+const m = "data-overlayscrollbars";
+
+const S = `${m}-overflow-x`;
+
+const C = `${m}-overflow-y`;
+
+const x = "overflowVisible";
+
+const O = "viewportStyled";
+
+const A = "os-padding";
+
+const $ = "os-viewport";
+
+const L = `${$}-arrange`;
+
+const I = "os-content";
+
+const T = `${$}-scrollbar-styled`;
+
+const z = `os-overflow-visible`;
+
+const D = "os-size-observer";
+
+const E = `${D}-appear`;
+
+const P = `${D}-listener`;
+
+const M = `${P}-scroll`;
+
+const j = `${P}-item`;
+
+const N = `${j}-final`;
+
+const R = "os-trinsic-observer";
+
+const F = "os-scrollbar";
+
+const H = `${F}-horizontal`;
+
+const k = `${F}-vertical`;
+
+const B = "os-scrollbar-track";
+
+const V = "os-scrollbar-handle";
+
+const opsStringify = t => JSON.stringify(t, ((t, n) => {
+ if (isFunction(n)) {
+ throw new Error;
+ }
+ return n;
+}));
+
+const U = {
paddingAbsolute: false,
updating: {
- elementEvents: [['img', 'load']],
- debounce: [0, 33],
+ elementEvents: [ [ "img", "load" ] ],
+ debounce: [ 0, 33 ],
attributes: null,
ignoreMutation: null
},
overflow: {
- x: 'scroll',
- y: 'scroll'
+ x: "scroll",
+ y: "scroll"
},
nativeScrollbarsOverlaid: {
show: false,
initialize: false
},
scrollbars: {
- visibility: 'auto',
- autoHide: 'never',
+ visibility: "auto",
+ autoHide: "never",
autoHideDelay: 800,
dragScroll: true,
clickScroll: false,
touch: true
}
};
-const getOptionsDiff = (currOptions, newOptions) => {
- const diff = {};
- const optionsKeys = keys(newOptions).concat(keys(currOptions));
- each(optionsKeys, optionKey => {
- const currOptionValue = currOptions[optionKey];
- const newOptionValue = newOptions[optionKey];
- if (isObject(currOptionValue) && isObject(newOptionValue)) {
- assignDeep(diff[optionKey] = {}, getOptionsDiff(currOptionValue, newOptionValue));
- } else if (hasOwnProperty(newOptions, optionKey) && newOptionValue !== currOptionValue) {
- let isDiff = true;
-
- if (isArray(currOptionValue) || isArray(newOptionValue)) {
+const getOptionsDiff = (t, n) => {
+ const o = {};
+ const e = keys(n).concat(keys(t));
+ each(e, (e => {
+ const s = t[e];
+ const c = n[e];
+ if (isObject(s) && isObject(c)) {
+ assignDeep(o[e] = {}, getOptionsDiff(s, c));
+ } else if (hasOwnProperty(n, e) && c !== s) {
+ let t = true;
+ if (isArray(s) || isArray(c)) {
try {
- if (stringify(currOptionValue) === stringify(newOptionValue)) {
- isDiff = false;
+ if (opsStringify(s) === opsStringify(c)) {
+ t = false;
}
- } catch (_unused) {}
+ } catch (i) {}
}
-
- if (isDiff) {
- diff[optionKey] = newOptionValue;
+ if (t) {
+ o[e] = c;
}
}
- });
- return diff;
+ }));
+ return o;
};
-let environmentInstance;
-const {
- abs,
- round
-} = Math;
+let Y;
-const diffBiggerThanOne = (valOne, valTwo) => {
- const absValOne = abs(valOne);
- const absValTwo = abs(valTwo);
- return !(absValOne === absValTwo || absValOne + 1 === absValTwo || absValOne - 1 === absValTwo);
+const {abs: q, round: G} = Math;
+
+const diffBiggerThanOne = (t, n) => {
+ const o = q(t);
+ const e = q(n);
+ return !(o === e || o + 1 === e || o - 1 === e);
};
-const getNativeScrollbarSize = (body, measureElm, measureElmChild) => {
- appendChildren(body, measureElm);
- const cSize = clientSize(measureElm);
- const oSize = offsetSize(measureElm);
- const fSize = fractionalSize(measureElmChild);
+const getNativeScrollbarSize = (t, n, o) => {
+ appendChildren(t, n);
+ const e = clientSize(n);
+ const s = offsetSize(n);
+ const c = fractionalSize(o);
return {
- x: oSize.h - cSize.h + fSize.h,
- y: oSize.w - cSize.w + fSize.w
+ x: s.h - e.h + c.h,
+ y: s.w - e.w + c.w
};
};
-const getNativeScrollbarStyling = testElm => {
- let result = false;
- const revertClass = addClass(testElm, classNameViewportScrollbarStyling);
-
+const getNativeScrollbarStyling = t => {
+ let n = false;
+ const o = addClass(t, T);
try {
- result = style(testElm, cssProperty('scrollbar-width')) === 'none' || window.getComputedStyle(testElm, '::-webkit-scrollbar').getPropertyValue('display') === 'none';
- } catch (ex) {}
-
- revertClass();
- return result;
+ n = "none" === style(t, cssProperty("scrollbar-width")) || "none" === window.getComputedStyle(t, "::-webkit-scrollbar").getPropertyValue("display");
+ } catch (e) {}
+ o();
+ return n;
};
-const getRtlScrollBehavior = (parentElm, childElm) => {
- const strHidden = 'hidden';
- style(parentElm, {
- overflowX: strHidden,
- overflowY: strHidden,
- direction: 'rtl'
+const getRtlScrollBehavior = (t, n) => {
+ const o = "hidden";
+ style(t, {
+ overflowX: o,
+ overflowY: o,
+ direction: "rtl"
});
- scrollLeft(parentElm, 0);
- const parentOffset = absoluteCoordinates(parentElm);
- const childOffset = absoluteCoordinates(childElm);
- scrollLeft(parentElm, -999);
- const childOffsetAfterScroll = absoluteCoordinates(childElm);
+ scrollLeft(t, 0);
+ const e = absoluteCoordinates(t);
+ const s = absoluteCoordinates(n);
+ scrollLeft(t, -999);
+ const c = absoluteCoordinates(n);
return {
- i: parentOffset.x === childOffset.x,
- n: childOffset.x !== childOffsetAfterScroll.x
+ i: e.x === s.x,
+ n: s.x !== c.x
};
};
-const getFlexboxGlue = (parentElm, childElm) => {
- const revertFbxGlue = addClass(parentElm, classNameEnvironmentFlexboxGlue);
- const minOffsetsizeParent = getBoundingClientRect(parentElm);
- const minOffsetsize = getBoundingClientRect(childElm);
- const supportsMin = equalBCRWH(minOffsetsize, minOffsetsizeParent, true);
- const revertFbxGlueMax = addClass(parentElm, classNameEnvironmentFlexboxGlueMax);
- const maxOffsetsizeParent = getBoundingClientRect(parentElm);
- const maxOffsetsize = getBoundingClientRect(childElm);
- const supportsMax = equalBCRWH(maxOffsetsize, maxOffsetsizeParent, true);
- revertFbxGlue();
- revertFbxGlueMax();
- return supportsMin && supportsMax;
+const getFlexboxGlue = (t, n) => {
+ const o = addClass(t, b);
+ const e = getBoundingClientRect(t);
+ const s = getBoundingClientRect(n);
+ const c = equalBCRWH(s, e, true);
+ const i = addClass(t, y);
+ const r = getBoundingClientRect(t);
+ const a = getBoundingClientRect(n);
+ const l = equalBCRWH(a, r, true);
+ o();
+ i();
+ return c && l;
};
const getWindowDPR = () => {
- const dDPI = window.screen.deviceXDPI || 0;
- const sDPI = window.screen.logicalXDPI || 1;
- return window.devicePixelRatio || dDPI / sDPI;
+ const t = window.screen.deviceXDPI || 0;
+ const n = window.screen.logicalXDPI || 1;
+ return window.devicePixelRatio || t / n;
};
-const getDefaultInitializationStrategy = nativeScrollbarStyling => ({
- _host: null,
- _viewport: null,
- _padding: !nativeScrollbarStyling,
- _content: false,
- _scrollbarsSlot: null
+const getDefaultInitializationStrategy = t => ({
+ A: !t,
+ $: false
});
const createEnvironment = () => {
- const {
- body
- } = document;
- const envDOM = createDOM(`
`);
- const envElm = envDOM[0];
- const envChildElm = envElm.firstChild;
- const [addEvent,, triggerEvent] = createEventListenerHub();
- const [updateNativeScrollbarSizeCache, getNativeScrollbarSizeCache] = createCache({
- _initialValue: getNativeScrollbarSize(body, envElm, envChildElm),
- _equal: equalXY
+ const {body: t} = document;
+ const n = createDOM(``);
+ const o = n[0];
+ const e = o.firstChild;
+ const [s, , c] = createEventListenerHub();
+ const [i, r] = createCache({
+ o: getNativeScrollbarSize(t, o, e),
+ u: equalXY
});
- const [nativeScrollbarSize] = getNativeScrollbarSizeCache();
- const nativeScrollbarStyling = getNativeScrollbarStyling(envElm);
- const nativeScrollbarIsOverlaid = {
- x: nativeScrollbarSize.x === 0,
- y: nativeScrollbarSize.y === 0
+ const [a] = r();
+ const l = getNativeScrollbarStyling(o);
+ const u = {
+ x: 0 === a.x,
+ y: 0 === a.y
};
- const initializationStrategy = getDefaultInitializationStrategy(nativeScrollbarStyling);
- const defaultDefaultOptions = assignDeep({}, defaultOptions);
- const env = {
- _nativeScrollbarSize: nativeScrollbarSize,
- _nativeScrollbarIsOverlaid: nativeScrollbarIsOverlaid,
- _nativeScrollbarStyling: nativeScrollbarStyling,
- _cssCustomProperties: style(envElm, 'zIndex') === '-1',
- _rtlScrollBehavior: getRtlScrollBehavior(envElm, envChildElm),
- _flexboxGlue: getFlexboxGlue(envElm, envChildElm),
- _addListener: listener => addEvent('_', listener),
- _getInitializationStrategy: assignDeep.bind(0, {}, initializationStrategy),
-
- _setInitializationStrategy(newInitializationStrategy) {
- assignDeep(initializationStrategy, newInitializationStrategy);
+ const f = getDefaultInitializationStrategy(l);
+ const d = assignDeep({}, U);
+ const _ = {
+ L: a,
+ I: u,
+ T: l,
+ D: "-1" === style(o, "zIndex"),
+ P: getRtlScrollBehavior(o, e),
+ M: getFlexboxGlue(o, e),
+ j: t => s("_", t),
+ N: assignDeep.bind(0, {}, f),
+ R(t) {
+ assignDeep(f, t);
},
-
- _getDefaultOptions: assignDeep.bind(0, {}, defaultDefaultOptions),
-
- _setDefaultOptions(newDefaultOptions) {
- assignDeep(defaultDefaultOptions, newDefaultOptions);
+ F: assignDeep.bind(0, {}, d),
+ H(t) {
+ assignDeep(d, t);
},
-
- _defaultInitializationStrategy: assignDeep({}, initializationStrategy),
- _defaultDefaultOptions: assignDeep({}, defaultDefaultOptions)
+ k: assignDeep({}, f),
+ B: assignDeep({}, d)
};
- removeAttr(envElm, 'style');
- removeElements(envElm);
-
- if (!nativeScrollbarStyling && (!nativeScrollbarIsOverlaid.x || !nativeScrollbarIsOverlaid.y)) {
- let size = windowSize();
- let dpr = getWindowDPR();
- window.addEventListener('resize', () => {
- const sizeNew = windowSize();
- const deltaSize = {
- w: sizeNew.w - size.w,
- h: sizeNew.h - size.h
+ removeAttr(o, "style");
+ removeElements(o);
+ if (!l && (!u.x || !u.y)) {
+ let n = windowSize();
+ let s = getWindowDPR();
+ window.addEventListener("resize", (() => {
+ const r = windowSize();
+ const a = {
+ w: r.w - n.w,
+ h: r.h - n.h
};
- if (deltaSize.w === 0 && deltaSize.h === 0) return;
- const deltaAbsSize = {
- w: abs(deltaSize.w),
- h: abs(deltaSize.h)
+ if (0 === a.w && 0 === a.h) {
+ return;
+ }
+ const l = {
+ w: q(a.w),
+ h: q(a.h)
};
- const deltaAbsRatio = {
- w: abs(round(sizeNew.w / (size.w / 100.0))),
- h: abs(round(sizeNew.h / (size.h / 100.0)))
+ const u = {
+ w: q(G(r.w / (n.w / 100))),
+ h: q(G(r.h / (n.h / 100)))
};
- const dprNew = getWindowDPR();
- const deltaIsBigger = deltaAbsSize.w > 2 && deltaAbsSize.h > 2;
- const difference = !diffBiggerThanOne(deltaAbsRatio.w, deltaAbsRatio.h);
- const dprChanged = dprNew !== dpr && dpr > 0;
- const isZoom = deltaIsBigger && difference && dprChanged;
-
- if (isZoom) {
- const [scrollbarSize, scrollbarSizeChanged] = updateNativeScrollbarSizeCache(getNativeScrollbarSize(body, envElm, envChildElm));
- assignDeep(environmentInstance._nativeScrollbarSize, scrollbarSize);
- removeElements(envElm);
-
- if (scrollbarSizeChanged) {
- triggerEvent('_');
+ const f = getWindowDPR();
+ const d = l.w > 2 && l.h > 2;
+ const _ = !diffBiggerThanOne(u.w, u.h);
+ const g = f !== s && s > 0;
+ const h = d && _ && g;
+ if (h) {
+ const [n, s] = i(getNativeScrollbarSize(t, o, e));
+ assignDeep(Y.L, n);
+ removeElements(o);
+ if (s) {
+ c("_");
}
}
-
- size = sizeNew;
- dpr = dprNew;
- });
+ n = r;
+ s = f;
+ }));
}
-
- return env;
+ return _;
};
const getEnvironment = () => {
- if (!environmentInstance) {
- environmentInstance = createEnvironment();
+ if (!Y) {
+ Y = createEnvironment();
}
-
- return environmentInstance;
+ return Y;
};
-let contentArrangeCounter = 0;
+const staticInitializationElement = (t, n, o, e) => {
+ const s = e || (isFunction(o) ? o.apply(0, t) : o);
+ return (isFunction(s) ? s.apply(0, t) : s) || n.apply(0, t);
+};
-const unwrap = elm => {
- appendChildren(parent(elm), contents(elm));
- removeElements(elm);
+const dynamicInitializationElement = (t, n, o, e) => {
+ const s = isBoolean(e) || !!e;
+ const c = s ? e : isFunction(o) ? o.apply(0, t) : o;
+ return true === c || isNull(c) || isUndefined(c) || isFunction(c) ? n.apply(0, t) : c;
+};
+
+let W = 0;
+
+const X = createDiv.bind(0, "");
+
+const unwrap = t => {
+ appendChildren(parent(t), contents(t));
+ removeElements(t);
};
const createUniqueViewportArrangeElement = () => {
- const {
- _nativeScrollbarStyling,
- _nativeScrollbarIsOverlaid,
- _cssCustomProperties
- } = getEnvironment();
- const create = !_cssCustomProperties && !_nativeScrollbarStyling && (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y);
- const result = create ? document.createElement('style') : false;
-
- if (result) {
- attr(result, 'id', `${classNameViewportArrange}-${contentArrangeCounter}`);
- contentArrangeCounter++;
+ const {T: t, I: n, D: o} = getEnvironment();
+ const e = !o && !t && (n.x || n.y);
+ const s = e ? document.createElement("style") : false;
+ if (s) {
+ attr(s, "id", `${L}-${W}`);
+ W++;
}
-
- return result;
+ return s;
};
-const staticCreationFromStrategy = (target, initializationValue, strategy) => {
- const result = initializationValue || (isFunction(strategy) ? strategy(target) : strategy);
- return result || createDiv();
+const addDataAttrHost = (t, n) => {
+ attr(t, m, n || "");
+ return removeAttr.bind(0, t, m);
};
-const dynamicCreationFromStrategy = (target, initializationValue, strategy) => {
- const takeInitializationValue = isBoolean(initializationValue) || initializationValue;
- const result = takeInitializationValue ? initializationValue : isFunction(strategy) ? strategy(target) : strategy;
- return result === true ? createDiv() : result;
-};
-
-const addDataAttrHost = (elm, value) => {
- attr(elm, dataAttributeHost, value || '');
- return removeAttr.bind(0, elm, dataAttributeHost);
-};
-
-const createStructureSetupElements = target => {
- const {
- _getInitializationStrategy,
- _nativeScrollbarStyling
- } = getEnvironment();
-
- const {
- _host: hostInitializationStrategy,
- _viewport: viewportInitializationStrategy,
- _padding: paddingInitializationStrategy,
- _content: contentInitializationStrategy
- } = _getInitializationStrategy();
-
- const targetIsElm = isHTMLElement(target);
- const targetStructureInitialization = target;
- const targetElement = targetIsElm ? target : targetStructureInitialization.target;
- const isTextarea = is(targetElement, 'textarea');
- const isBody = !isTextarea && is(targetElement, 'body');
- const ownerDocument = targetElement.ownerDocument;
- const bodyElm = ownerDocument.body;
- const wnd = ownerDocument.defaultView;
- const singleElmSupport = !!ResizeObserverConstructor && _nativeScrollbarStyling;
- const potentialViewportElement = staticCreationFromStrategy(targetElement, targetStructureInitialization.viewport, viewportInitializationStrategy);
- const potentiallySingleElm = potentialViewportElement === targetElement;
- const viewportIsTarget = singleElmSupport && potentiallySingleElm;
- const viewportElement = potentiallySingleElm && !viewportIsTarget ? staticCreationFromStrategy(targetElement) : potentialViewportElement;
- const evaluatedTargetObj = {
- _target: targetElement,
- _host: isTextarea ? staticCreationFromStrategy(targetElement, targetStructureInitialization.host, hostInitializationStrategy) : targetElement,
- _viewport: viewportElement,
- _padding: dynamicCreationFromStrategy(targetElement, targetStructureInitialization.padding, paddingInitializationStrategy),
- _content: dynamicCreationFromStrategy(targetElement, targetStructureInitialization.content, contentInitializationStrategy),
- _viewportArrange: !viewportIsTarget && createUniqueViewportArrangeElement(),
- _windowElm: wnd,
- _documentElm: ownerDocument,
- _htmlElm: parent(bodyElm),
- _bodyElm: bodyElm,
- _isTextarea: isTextarea,
- _isBody: isBody,
- _targetIsElm: targetIsElm,
- _viewportIsTarget: viewportIsTarget,
- _viewportHasClass: (className, attributeClassName) => viewportIsTarget ? hasAttrClass(viewportElement, dataAttributeHost, attributeClassName) : hasClass(viewportElement, className),
- _viewportAddRemoveClass: (className, attributeClassName, add) => viewportIsTarget ? attrClass(viewportElement, dataAttributeHost, attributeClassName, add) : (add ? addClass : removeClass)(viewportElement, className)
+const createStructureSetupElements = t => {
+ const {N: n, T: o} = getEnvironment();
+ const {V: e, U: s, A: c, $: i} = n();
+ const r = isHTMLElement(t);
+ const a = t;
+ const l = r ? t : a.target;
+ const f = is(l, "textarea");
+ const d = !f && is(l, "body");
+ const _ = l.ownerDocument;
+ const g = _.body;
+ const h = _.defaultView;
+ const p = !!u && o;
+ const v = staticInitializationElement.bind(0, [ l ]);
+ const w = dynamicInitializationElement.bind(0, [ l ]);
+ const b = v(X, s, a.viewport);
+ const y = b === l;
+ const x = p && y;
+ const O = y && !x ? v(X) : b;
+ const L = {
+ Y: l,
+ V: f ? v(X, e, a.host) : l,
+ U: O,
+ A: w(X, c, a.padding),
+ $: w(X, i, a.content),
+ q: !x && createUniqueViewportArrangeElement(),
+ G: h,
+ W: _,
+ X: parent(g),
+ J: g,
+ K: f,
+ Z: d,
+ tt: r,
+ nt: x,
+ ot: (t, n) => x ? hasAttrClass(O, m, n) : hasClass(O, t),
+ et: (t, n, o) => x ? attrClass(O, m, n, o) : (o ? addClass : removeClass)(O, t)
};
- const generatedElements = keys(evaluatedTargetObj).reduce((arr, key) => {
- const value = evaluatedTargetObj[key];
- return push(arr, value && !parent(value) ? value : false);
- }, []);
-
- const elementIsGenerated = elm => elm ? indexOf(generatedElements, elm) > -1 : null;
-
- const {
- _target,
- _host,
- _padding,
- _viewport,
- _content,
- _viewportArrange
- } = evaluatedTargetObj;
- const destroyFns = [];
- const isTextareaHostGenerated = isTextarea && elementIsGenerated(_host);
- const targetContents = isTextarea ? _target : contents([_content, _viewport, _padding, _host, _target].find(elm => elementIsGenerated(elm) === false));
- const contentSlot = _content || _viewport;
- const removeHostDataAttr = addDataAttrHost(_host, viewportIsTarget ? 'viewport' : 'host');
- const removePaddingClass = addClass(_padding, classNamePadding);
- const removeViewportClass = addClass(_viewport, !viewportIsTarget && classNameViewport);
- const removeContentClass = addClass(_content, classNameContent);
-
- if (isTextareaHostGenerated) {
- insertAfter(_target, _host);
- push(destroyFns, () => {
- insertAfter(_host, _target);
- removeElements(_host);
- });
+ const z = keys(L).reduce(((t, n) => {
+ const o = L[n];
+ return push(t, o && !parent(o) ? o : false);
+ }), []);
+ const elementIsGenerated = t => t ? indexOf(z, t) > -1 : null;
+ const {Y: D, V: E, A: P, U: M, $: j, q: N} = L;
+ const R = [];
+ const F = f && elementIsGenerated(E);
+ const H = f ? D : contents([ j, M, P, E, D ].find((t => false === elementIsGenerated(t))));
+ const k = j || M;
+ const B = addDataAttrHost(E, x ? "viewport" : "host");
+ const V = addClass(P, A);
+ const U = addClass(M, !x && $);
+ const Y = addClass(j, I);
+ if (F) {
+ insertAfter(D, E);
+ push(R, (() => {
+ insertAfter(E, D);
+ removeElements(E);
+ }));
}
-
- appendChildren(contentSlot, targetContents);
- appendChildren(_host, _padding);
- appendChildren(_padding || _host, !viewportIsTarget && _viewport);
- appendChildren(_viewport, _content);
- push(destroyFns, () => {
- removeHostDataAttr();
- removeAttr(_viewport, dataAttributeHostOverflowX);
- removeAttr(_viewport, dataAttributeHostOverflowY);
-
- if (elementIsGenerated(_content)) {
- unwrap(_content);
+ appendChildren(k, H);
+ appendChildren(E, P);
+ appendChildren(P || E, !x && M);
+ appendChildren(M, j);
+ push(R, (() => {
+ B();
+ removeAttr(M, S);
+ removeAttr(M, C);
+ if (elementIsGenerated(j)) {
+ unwrap(j);
}
-
- if (elementIsGenerated(_viewport)) {
- unwrap(_viewport);
+ if (elementIsGenerated(M)) {
+ unwrap(M);
}
-
- if (elementIsGenerated(_padding)) {
- unwrap(_padding);
+ if (elementIsGenerated(P)) {
+ unwrap(P);
}
-
- removePaddingClass();
- removeViewportClass();
- removeContentClass();
- });
-
- if (_nativeScrollbarStyling && !viewportIsTarget) {
- push(destroyFns, removeClass.bind(0, _viewport, classNameViewportScrollbarStyling));
+ V();
+ U();
+ Y();
+ }));
+ if (o && !x) {
+ push(R, removeClass.bind(0, M, T));
}
-
- if (_viewportArrange) {
- insertBefore(_viewport, _viewportArrange);
- push(destroyFns, removeElements.bind(0, _viewportArrange));
+ if (N) {
+ insertBefore(M, N);
+ push(R, removeElements.bind(0, N));
}
-
- return [evaluatedTargetObj, runEach.bind(0, destroyFns)];
+ return [ L, runEach.bind(0, R) ];
};
-const createTrinsicUpdate = (structureSetupElements, state) => {
- const {
- _content
- } = structureSetupElements;
- const [getState] = state;
- return updateHints => {
- const {
- _flexboxGlue
- } = getEnvironment();
- const {
- _heightIntrinsic
- } = getState();
- const {
- _heightIntrinsicChanged
- } = updateHints;
- const heightIntrinsicChanged = (_content || !_flexboxGlue) && _heightIntrinsicChanged;
-
- if (heightIntrinsicChanged) {
- style(_content, {
- height: _heightIntrinsic ? '' : '100%'
+const createTrinsicUpdate = (t, n) => {
+ const {$: o} = t;
+ const [e] = n;
+ return t => {
+ const {M: n} = getEnvironment();
+ const {st: s} = e();
+ const {ct: c} = t;
+ const i = (o || !n) && c;
+ if (i) {
+ style(o, {
+ height: s ? "" : "100%"
});
}
-
return {
- _sizeChanged: heightIntrinsicChanged,
- _contentMutation: heightIntrinsicChanged
+ it: i,
+ rt: i
};
};
};
-const createPaddingUpdate = (structureSetupElements, state) => {
- const [getState, setState] = state;
- const {
- _host,
- _padding,
- _viewport,
- _viewportIsTarget: _isSingleElm
- } = structureSetupElements;
- const [updatePaddingCache, currentPaddingCache] = createCache({
- _equal: equalTRBL,
- _initialValue: topRightBottomLeft()
- }, topRightBottomLeft.bind(0, _host, 'padding', ''));
- return (updateHints, checkOption, force) => {
- let [padding, paddingChanged] = currentPaddingCache(force);
- const {
- _nativeScrollbarStyling,
- _flexboxGlue
- } = getEnvironment();
- const {
- _directionIsRTL
- } = getState();
- const {
- _sizeChanged,
- _contentMutation,
- _directionChanged
- } = updateHints;
- const [paddingAbsolute, paddingAbsoluteChanged] = checkOption('paddingAbsolute');
- const contentMutation = !_flexboxGlue && _contentMutation;
-
- if (_sizeChanged || paddingChanged || contentMutation) {
- [padding, paddingChanged] = updatePaddingCache(force);
+const createPaddingUpdate = (t, n) => {
+ const [o, e] = n;
+ const {V: s, A: c, U: i, nt: r} = t;
+ const [a, l] = createCache({
+ u: equalTRBL,
+ o: topRightBottomLeft()
+ }, topRightBottomLeft.bind(0, s, "padding", ""));
+ return (t, n, s) => {
+ let [u, f] = l(s);
+ const {T: d, M: _} = getEnvironment();
+ const {lt: g} = o();
+ const {it: h, rt: p, ut: v} = t;
+ const [w, b] = n("paddingAbsolute");
+ const y = !_ && p;
+ if (h || f || y) {
+ [u, f] = a(s);
}
-
- const paddingStyleChanged = !_isSingleElm && (paddingAbsoluteChanged || _directionChanged || paddingChanged);
-
- if (paddingStyleChanged) {
- const paddingRelative = !paddingAbsolute || !_padding && !_nativeScrollbarStyling;
- const paddingHorizontal = padding.r + padding.l;
- const paddingVertical = padding.t + padding.b;
- const paddingStyle = {
- marginRight: paddingRelative && !_directionIsRTL ? -paddingHorizontal : 0,
- marginBottom: paddingRelative ? -paddingVertical : 0,
- marginLeft: paddingRelative && _directionIsRTL ? -paddingHorizontal : 0,
- top: paddingRelative ? -padding.t : 0,
- right: paddingRelative ? _directionIsRTL ? -padding.r : 'auto' : 0,
- left: paddingRelative ? _directionIsRTL ? 'auto' : -padding.l : 0,
- width: paddingRelative ? `calc(100% + ${paddingHorizontal}px)` : ''
+ const m = !r && (b || v || f);
+ if (m) {
+ const t = !w || !c && !d;
+ const n = u.r + u.l;
+ const o = u.t + u.b;
+ const s = {
+ marginRight: t && !g ? -n : 0,
+ marginBottom: t ? -o : 0,
+ marginLeft: t && g ? -n : 0,
+ top: t ? -u.t : 0,
+ right: t ? g ? -u.r : "auto" : 0,
+ left: t ? g ? "auto" : -u.l : 0,
+ width: t ? `calc(100% + ${n}px)` : ""
};
- const viewportStyle = {
- paddingTop: paddingRelative ? padding.t : 0,
- paddingRight: paddingRelative ? padding.r : 0,
- paddingBottom: paddingRelative ? padding.b : 0,
- paddingLeft: paddingRelative ? padding.l : 0
+ const r = {
+ paddingTop: t ? u.t : 0,
+ paddingRight: t ? u.r : 0,
+ paddingBottom: t ? u.b : 0,
+ paddingLeft: t ? u.l : 0
};
- style(_padding || _viewport, paddingStyle);
- style(_viewport, viewportStyle);
- setState({
- _padding: padding,
- _paddingAbsolute: !paddingRelative,
- _viewportPaddingStyle: _padding ? viewportStyle : assignDeep({}, paddingStyle, viewportStyle)
+ style(c || i, s);
+ style(i, r);
+ e({
+ A: u,
+ ft: !t,
+ dt: c ? r : assignDeep({}, s, r)
});
}
-
return {
- _paddingStyleChanged: paddingStyleChanged
+ _t: m
};
};
};
-const {
- max
-} = Math;
-const strVisible = 'visible';
-const strHidden = 'hidden';
-const overlaidScrollbarsHideOffset = 42;
-const whCacheOptions = {
- _equal: equalWH,
- _initialValue: {
+const {max: J} = Math;
+
+const K = "visible";
+
+const Q = "hidden";
+
+const Z = 42;
+
+const tt = {
+ u: equalWH,
+ o: {
w: 0,
h: 0
}
};
-const xyCacheOptions = {
- _equal: equalXY,
- _initialValue: {
- x: strHidden,
- y: strHidden
+
+const nt = {
+ u: equalXY,
+ o: {
+ x: Q,
+ y: Q
}
};
-const getOverflowAmount = (viewportScrollSize, viewportClientSize, sizeFraction) => {
- const tollerance = window.devicePixelRatio % 1 !== 0 ? 1 : 0;
- const amount = {
- w: max(0, viewportScrollSize.w - viewportClientSize.w - max(0, sizeFraction.w)),
- h: max(0, viewportScrollSize.h - viewportClientSize.h - max(0, sizeFraction.h))
+const getOverflowAmount = (t, n, o) => {
+ const e = window.devicePixelRatio % 1 !== 0 ? 1 : 0;
+ const s = {
+ w: J(0, t.w - n.w - J(0, o.w)),
+ h: J(0, t.h - n.h - J(0, o.h))
};
return {
- w: amount.w > tollerance ? amount.w : 0,
- h: amount.h > tollerance ? amount.h : 0
+ w: s.w > e ? s.w : 0,
+ h: s.h > e ? s.h : 0
};
};
-const conditionalClass = (elm, classNames, add) => add ? addClass(elm, classNames) : removeClass(elm, classNames);
+const conditionalClass = (t, n, o) => o ? addClass(t, n) : removeClass(t, n);
-const overflowIsVisible = overflowBehavior => overflowBehavior.indexOf(strVisible) === 0;
+const overflowIsVisible = t => 0 === t.indexOf(K);
-const createOverflowUpdate = (structureSetupElements, state) => {
- const [getState, setState] = state;
- const {
- _host,
- _padding,
- _viewport,
- _viewportArrange,
- _viewportIsTarget,
- _viewportAddRemoveClass
- } = structureSetupElements;
- const {
- _nativeScrollbarSize,
- _flexboxGlue,
- _nativeScrollbarStyling,
- _nativeScrollbarIsOverlaid
- } = getEnvironment();
- const doViewportArrange = !_viewportIsTarget && !_nativeScrollbarStyling && (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y);
- const [updateSizeFraction, getCurrentSizeFraction] = createCache(whCacheOptions, fractionalSize.bind(0, _viewport));
- const [updateViewportScrollSizeCache, getCurrentViewportScrollSizeCache] = createCache(whCacheOptions, scrollSize.bind(0, _viewport));
- const [updateOverflowAmountCache, getCurrentOverflowAmountCache] = createCache(whCacheOptions);
- const [updateOverflowStyleCache] = createCache(xyCacheOptions);
-
- const fixFlexboxGlue = (viewportOverflowState, heightIntrinsic) => {
- style(_viewport, {
- height: ''
+const createOverflowUpdate = (t, n) => {
+ const [o, e] = n;
+ const {V: s, A: c, U: i, q: r, nt: a, et: l} = t;
+ const {L: u, M: f, T: d, I: _} = getEnvironment();
+ const g = !a && !d && (_.x || _.y);
+ const [h, p] = createCache(tt, fractionalSize.bind(0, i));
+ const [v, w] = createCache(tt, scrollSize.bind(0, i));
+ const [b, y] = createCache(tt);
+ const [A] = createCache(nt);
+ const fixFlexboxGlue = (t, n) => {
+ style(i, {
+ height: ""
});
-
- if (heightIntrinsic) {
- const {
- _paddingAbsolute,
- _padding: padding
- } = getState();
- const {
- _overflowScroll,
- _scrollbarsHideOffset
- } = viewportOverflowState;
- const fSize = fractionalSize(_host);
- const hostClientSize = clientSize(_host);
- const isContentBox = style(_viewport, 'boxSizing') === 'content-box';
- const paddingVertical = _paddingAbsolute || isContentBox ? padding.b + padding.t : 0;
- const subtractXScrollbar = !(_nativeScrollbarIsOverlaid.x && isContentBox);
- style(_viewport, {
- height: hostClientSize.h + fSize.h + (_overflowScroll.x && subtractXScrollbar ? _scrollbarsHideOffset.x : 0) - paddingVertical
+ if (n) {
+ const {ft: n, A: e} = o();
+ const {gt: c, ht: r} = t;
+ const a = fractionalSize(s);
+ const l = clientSize(s);
+ const u = "content-box" === style(i, "boxSizing");
+ const f = n || u ? e.b + e.t : 0;
+ const d = !(_.x && u);
+ style(i, {
+ height: l.h + a.h + (c.x && d ? r.x : 0) - f
});
}
};
-
- const getViewportOverflowState = (showNativeOverlaidScrollbars, viewportStyleObj) => {
- const arrangeHideOffset = !_nativeScrollbarStyling && !showNativeOverlaidScrollbars ? overlaidScrollbarsHideOffset : 0;
-
- const getStatePerAxis = (styleKey, isOverlaid, nativeScrollbarSize) => {
- const overflowStyle = style(_viewport, styleKey);
- const objectPrefferedOverflowStyle = viewportStyleObj ? viewportStyleObj[styleKey] : overflowStyle;
- const overflowScroll = objectPrefferedOverflowStyle === 'scroll';
- const nonScrollbarStylingHideOffset = isOverlaid ? arrangeHideOffset : nativeScrollbarSize;
- const scrollbarsHideOffset = overflowScroll && !_nativeScrollbarStyling ? nonScrollbarStylingHideOffset : 0;
- const scrollbarsHideOffsetArrange = isOverlaid && !!arrangeHideOffset;
- return [overflowStyle, overflowScroll, scrollbarsHideOffset, scrollbarsHideOffsetArrange];
+ const getViewportOverflowState = (t, n) => {
+ const o = !d && !t ? Z : 0;
+ const getStatePerAxis = (t, e, s) => {
+ const c = style(i, t);
+ const r = n ? n[t] : c;
+ const a = "scroll" === r;
+ const l = e ? o : s;
+ const u = a && !d ? l : 0;
+ const f = e && !!o;
+ return [ c, a, u, f ];
};
-
- const [xOverflowStyle, xOverflowScroll, xScrollbarsHideOffset, xScrollbarsHideOffsetArrange] = getStatePerAxis('overflowX', _nativeScrollbarIsOverlaid.x, _nativeScrollbarSize.x);
- const [yOverflowStyle, yOverflowScroll, yScrollbarsHideOffset, yScrollbarsHideOffsetArrange] = getStatePerAxis('overflowY', _nativeScrollbarIsOverlaid.y, _nativeScrollbarSize.y);
+ const [e, s, c, r] = getStatePerAxis("overflowX", _.x, u.x);
+ const [a, l, f, g] = getStatePerAxis("overflowY", _.y, u.y);
return {
- _overflowStyle: {
- x: xOverflowStyle,
- y: yOverflowStyle
+ vt: {
+ x: e,
+ y: a
},
- _overflowScroll: {
- x: xOverflowScroll,
- y: yOverflowScroll
+ gt: {
+ x: s,
+ y: l
},
- _scrollbarsHideOffset: {
- x: xScrollbarsHideOffset,
- y: yScrollbarsHideOffset
+ ht: {
+ x: c,
+ y: f
},
- _scrollbarsHideOffsetArrange: {
- x: xScrollbarsHideOffsetArrange,
- y: yScrollbarsHideOffsetArrange
+ wt: {
+ x: r,
+ y: g
}
};
};
-
- const setViewportOverflowState = (showNativeOverlaidScrollbars, hasOverflow, overflowOption, viewportStyleObj) => {
- const setAxisOverflowStyle = (behavior, hasOverflowAxis) => {
- const overflowVisible = overflowIsVisible(behavior);
- const overflowVisibleBehavior = hasOverflowAxis && overflowVisible && behavior.replace(`${strVisible}-`, '') || '';
- return [hasOverflowAxis && !overflowVisible ? behavior : '', overflowIsVisible(overflowVisibleBehavior) ? 'hidden' : overflowVisibleBehavior];
+ const setViewportOverflowState = (t, n, o, e) => {
+ const setAxisOverflowStyle = (t, n) => {
+ const o = overflowIsVisible(t);
+ const e = n && o && t.replace(`${K}-`, "") || "";
+ return [ n && !o ? t : "", overflowIsVisible(e) ? "hidden" : e ];
};
-
- const [overflowX, visibleBehaviorX] = setAxisOverflowStyle(overflowOption.x, hasOverflow.x);
- const [overflowY, visibleBehaviorY] = setAxisOverflowStyle(overflowOption.y, hasOverflow.y);
- viewportStyleObj.overflowX = visibleBehaviorX && overflowY ? visibleBehaviorX : overflowX;
- viewportStyleObj.overflowY = visibleBehaviorY && overflowX ? visibleBehaviorY : overflowY;
- return getViewportOverflowState(showNativeOverlaidScrollbars, viewportStyleObj);
+ const [s, c] = setAxisOverflowStyle(o.x, n.x);
+ const [i, r] = setAxisOverflowStyle(o.y, n.y);
+ e.overflowX = c && i ? c : s;
+ e.overflowY = r && s ? r : i;
+ return getViewportOverflowState(t, e);
};
-
- const arrangeViewport = (viewportOverflowState, viewportScrollSize, sizeFraction, directionIsRTL) => {
- if (doViewportArrange) {
- const {
- _viewportPaddingStyle
- } = getState();
- const {
- _scrollbarsHideOffset,
- _scrollbarsHideOffsetArrange
- } = viewportOverflowState;
- const {
- x: arrangeX,
- y: arrangeY
- } = _scrollbarsHideOffsetArrange;
- const {
- x: hideOffsetX,
- y: hideOffsetY
- } = _scrollbarsHideOffset;
- const viewportArrangeHorizontalPaddingKey = directionIsRTL ? 'paddingRight' : 'paddingLeft';
- const viewportArrangeHorizontalPaddingValue = _viewportPaddingStyle[viewportArrangeHorizontalPaddingKey];
- const viewportArrangeVerticalPaddingValue = _viewportPaddingStyle.paddingTop;
- const fractionalContentWidth = viewportScrollSize.w + sizeFraction.w;
- const fractionalContenHeight = viewportScrollSize.h + sizeFraction.h;
- const arrangeSize = {
- w: hideOffsetY && arrangeY ? `${hideOffsetY + fractionalContentWidth - viewportArrangeHorizontalPaddingValue}px` : '',
- h: hideOffsetX && arrangeX ? `${hideOffsetX + fractionalContenHeight - viewportArrangeVerticalPaddingValue}px` : ''
+ const arrangeViewport = (t, n, e, s) => {
+ if (g) {
+ const {dt: c} = o();
+ const {ht: a, wt: l} = t;
+ const {x: u, y: f} = l;
+ const {x: d, y: _} = a;
+ const g = s ? "paddingRight" : "paddingLeft";
+ const h = c[g];
+ const p = c.paddingTop;
+ const v = n.w + e.w;
+ const w = n.h + e.h;
+ const b = {
+ w: _ && f ? `${_ + v - h}px` : "",
+ h: d && u ? `${d + w - p}px` : ""
};
-
- if (_viewportArrange) {
- const {
- sheet
- } = _viewportArrange;
-
- if (sheet) {
- const {
- cssRules
- } = sheet;
-
- if (cssRules) {
- if (!cssRules.length) {
- sheet.insertRule(`#${attr(_viewportArrange, 'id')} + .${classNameViewportArrange}::before {}`, 0);
+ if (r) {
+ const {sheet: t} = r;
+ if (t) {
+ const {cssRules: n} = t;
+ if (n) {
+ if (!n.length) {
+ t.insertRule(`#${attr(r, "id")} + .${L}::before {}`, 0);
}
-
- const ruleStyle = cssRules[0].style;
- ruleStyle.width = arrangeSize.w;
- ruleStyle.height = arrangeSize.h;
+ const o = n[0].style;
+ o.width = b.w;
+ o.height = b.h;
}
}
} else {
- style(_viewport, {
- '--os-vaw': arrangeSize.w,
- '--os-vah': arrangeSize.h
+ style(i, {
+ "--os-vaw": b.w,
+ "--os-vah": b.h
});
}
}
-
- return doViewportArrange;
+ return g;
};
-
- const hideNativeScrollbars = (viewportOverflowState, directionIsRTL, viewportArrange, viewportStyleObj) => {
- const {
- _scrollbarsHideOffset,
- _scrollbarsHideOffsetArrange
- } = viewportOverflowState;
- const {
- x: arrangeX,
- y: arrangeY
- } = _scrollbarsHideOffsetArrange;
- const {
- x: hideOffsetX,
- y: hideOffsetY
- } = _scrollbarsHideOffset;
- const {
- _viewportPaddingStyle: viewportPaddingStyle
- } = getState();
- const horizontalMarginKey = directionIsRTL ? 'marginLeft' : 'marginRight';
- const viewportHorizontalPaddingKey = directionIsRTL ? 'paddingLeft' : 'paddingRight';
- const horizontalMarginValue = viewportPaddingStyle[horizontalMarginKey];
- const verticalMarginValue = viewportPaddingStyle.marginBottom;
- const horizontalPaddingValue = viewportPaddingStyle[viewportHorizontalPaddingKey];
- const verticalPaddingValue = viewportPaddingStyle.paddingBottom;
- viewportStyleObj.width = `calc(100% + ${hideOffsetY + horizontalMarginValue * -1}px)`;
- viewportStyleObj[horizontalMarginKey] = -hideOffsetY + horizontalMarginValue;
- viewportStyleObj.marginBottom = -hideOffsetX + verticalMarginValue;
-
- if (viewportArrange) {
- viewportStyleObj[viewportHorizontalPaddingKey] = horizontalPaddingValue + (arrangeY ? hideOffsetY : 0);
- viewportStyleObj.paddingBottom = verticalPaddingValue + (arrangeX ? hideOffsetX : 0);
+ const hideNativeScrollbars = (t, n, e, s) => {
+ const {ht: c, wt: i} = t;
+ const {x: r, y: a} = i;
+ const {x: l, y: u} = c;
+ const {dt: f} = o();
+ const d = n ? "marginLeft" : "marginRight";
+ const _ = n ? "paddingLeft" : "paddingRight";
+ const g = f[d];
+ const h = f.marginBottom;
+ const p = f[_];
+ const v = f.paddingBottom;
+ s.width = `calc(100% + ${u + -1 * g}px)`;
+ s[d] = -u + g;
+ s.marginBottom = -l + h;
+ if (e) {
+ s[_] = p + (a ? u : 0);
+ s.paddingBottom = v + (r ? l : 0);
}
};
-
- const undoViewportArrange = (showNativeOverlaidScrollbars, directionIsRTL, viewportOverflowState) => {
- if (doViewportArrange) {
- const finalViewportOverflowState = viewportOverflowState || getViewportOverflowState(showNativeOverlaidScrollbars);
- const {
- _viewportPaddingStyle: viewportPaddingStyle
- } = getState();
- const {
- _scrollbarsHideOffsetArrange
- } = finalViewportOverflowState;
- const {
- x: arrangeX,
- y: arrangeY
- } = _scrollbarsHideOffsetArrange;
- const finalPaddingStyle = {};
-
- const assignProps = props => each(props.split(' '), prop => {
- finalPaddingStyle[prop] = viewportPaddingStyle[prop];
- });
-
- if (arrangeX) {
- assignProps('marginBottom paddingTop paddingBottom');
+ const undoViewportArrange = (t, n, e) => {
+ if (g) {
+ const s = e || getViewportOverflowState(t);
+ const {dt: c} = o();
+ const {wt: r} = s;
+ const {x: a, y: l} = r;
+ const u = {};
+ const assignProps = t => each(t.split(" "), (t => {
+ u[t] = c[t];
+ }));
+ if (a) {
+ assignProps("marginBottom paddingTop paddingBottom");
}
-
- if (arrangeY) {
- assignProps('marginLeft marginRight paddingLeft paddingRight');
+ if (l) {
+ assignProps("marginLeft marginRight paddingLeft paddingRight");
}
-
- const prevStyle = style(_viewport, keys(finalPaddingStyle));
- removeClass(_viewport, classNameViewportArrange);
-
- if (!_flexboxGlue) {
- finalPaddingStyle.height = '';
+ const d = style(i, keys(u));
+ removeClass(i, L);
+ if (!f) {
+ u.height = "";
}
-
- style(_viewport, finalPaddingStyle);
- return [() => {
- hideNativeScrollbars(finalViewportOverflowState, directionIsRTL, doViewportArrange, prevStyle);
- style(_viewport, prevStyle);
- addClass(_viewport, classNameViewportArrange);
- }, finalViewportOverflowState];
+ style(i, u);
+ return [ () => {
+ hideNativeScrollbars(s, n, g, d);
+ style(i, d);
+ addClass(i, L);
+ }, s ];
}
-
- return [noop];
+ return [ noop ];
};
-
- return (updateHints, checkOption, force) => {
- const {
- _sizeChanged,
- _hostMutation,
- _contentMutation,
- _paddingStyleChanged,
- _heightIntrinsicChanged,
- _directionChanged
- } = updateHints;
- const {
- _heightIntrinsic,
- _directionIsRTL
- } = getState();
- const [showNativeOverlaidScrollbarsOption, showNativeOverlaidScrollbarsChanged] = checkOption('nativeScrollbarsOverlaid.show');
- const [overflow, overflowChanged] = checkOption('overflow');
- const showNativeOverlaidScrollbars = showNativeOverlaidScrollbarsOption && _nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y;
- const adjustFlexboxGlue = !_viewportIsTarget && !_flexboxGlue && (_sizeChanged || _contentMutation || _hostMutation || showNativeOverlaidScrollbarsChanged || _heightIntrinsicChanged);
- const overflowXVisible = overflowIsVisible(overflow.x);
- const overflowYVisible = overflowIsVisible(overflow.y);
- const overflowVisible = overflowXVisible || overflowYVisible;
- let sizeFractionCache = getCurrentSizeFraction(force);
- let viewportScrollSizeCache = getCurrentViewportScrollSizeCache(force);
- let overflowAmuntCache = getCurrentOverflowAmountCache(force);
- let preMeasureViewportOverflowState;
-
- if (showNativeOverlaidScrollbarsChanged && _nativeScrollbarStyling) {
- _viewportAddRemoveClass(classNameViewportScrollbarStyling, dataValueHostViewportScrollbarStyling, !showNativeOverlaidScrollbars);
+ return (t, n, r) => {
+ const {it: u, bt: g, rt: $, _t: L, ct: I, ut: D} = t;
+ const {st: E, lt: P} = o();
+ const [M, j] = n("nativeScrollbarsOverlaid.show");
+ const [N, R] = n("overflow");
+ const F = M && _.x && _.y;
+ const H = !a && !f && (u || $ || g || j || I);
+ const k = overflowIsVisible(N.x);
+ const B = overflowIsVisible(N.y);
+ const V = k || B;
+ let U = p(r);
+ let Y = w(r);
+ let q = y(r);
+ let G;
+ if (j && d) {
+ l(T, O, !F);
}
-
- if (adjustFlexboxGlue) {
- preMeasureViewportOverflowState = getViewportOverflowState(showNativeOverlaidScrollbars);
- fixFlexboxGlue(preMeasureViewportOverflowState, _heightIntrinsic);
+ if (H) {
+ G = getViewportOverflowState(F);
+ fixFlexboxGlue(G, E);
}
-
- if (_sizeChanged || _paddingStyleChanged || _contentMutation || _directionChanged || showNativeOverlaidScrollbarsChanged) {
- if (overflowVisible) {
- _viewportAddRemoveClass(classNameOverflowVisible, dataValueHostOverflowVisible, false);
+ if (u || L || $ || D || j) {
+ if (V) {
+ l(z, x, false);
}
-
- const [redoViewportArrange, undoViewportArrangeOverflowState] = undoViewportArrange(showNativeOverlaidScrollbars, _directionIsRTL, preMeasureViewportOverflowState);
- const [_sizeFraction, _sizeFractionChanged] = sizeFractionCache = updateSizeFraction(force);
- const [_viewportScrollSize, _viewportScrollSizeChanged] = viewportScrollSizeCache = updateViewportScrollSizeCache(force);
- const viewportclientSize = clientSize(_viewport);
- let arrangedViewportScrollSize = _viewportScrollSize;
- let arrangedViewportClientSize = viewportclientSize;
- redoViewportArrange();
-
- if ((_viewportScrollSizeChanged || _sizeFractionChanged || showNativeOverlaidScrollbarsChanged) && undoViewportArrangeOverflowState && !showNativeOverlaidScrollbars && arrangeViewport(undoViewportArrangeOverflowState, _viewportScrollSize, _sizeFraction, _directionIsRTL)) {
- arrangedViewportClientSize = clientSize(_viewport);
- arrangedViewportScrollSize = scrollSize(_viewport);
+ const [t, n] = undoViewportArrange(F, P, G);
+ const [o, e] = U = h(r);
+ const [s, c] = Y = v(r);
+ const a = clientSize(i);
+ let u = s;
+ let f = a;
+ t();
+ if ((c || e || j) && n && !F && arrangeViewport(n, s, o, P)) {
+ f = clientSize(i);
+ u = scrollSize(i);
}
-
- overflowAmuntCache = updateOverflowAmountCache(getOverflowAmount({
- w: max(_viewportScrollSize.w, arrangedViewportScrollSize.w),
- h: max(_viewportScrollSize.h, arrangedViewportScrollSize.h)
+ q = b(getOverflowAmount({
+ w: J(s.w, u.w),
+ h: J(s.h, u.h)
}, {
- w: arrangedViewportClientSize.w + max(0, viewportclientSize.w - _viewportScrollSize.w),
- h: arrangedViewportClientSize.h + max(0, viewportclientSize.h - _viewportScrollSize.h)
- }, _sizeFraction), force);
+ w: f.w + J(0, a.w - s.w),
+ h: f.h + J(0, a.h - s.h)
+ }, o), r);
}
-
- const [overflowAmount, overflowAmountChanged] = overflowAmuntCache;
- const [viewportScrollSize, viewportScrollSizeChanged] = viewportScrollSizeCache;
- const [sizeFraction, sizeFractionChanged] = sizeFractionCache;
- const hasOverflow = {
- x: overflowAmount.w > 0,
- y: overflowAmount.h > 0
+ const [W, X] = q;
+ const [K, Q] = Y;
+ const [Z, tt] = U;
+ const nt = {
+ x: W.w > 0,
+ y: W.h > 0
};
- const removeClipping = overflowXVisible && overflowYVisible && (hasOverflow.x || hasOverflow.y) || overflowXVisible && hasOverflow.x && !hasOverflow.y || overflowYVisible && hasOverflow.y && !hasOverflow.x;
-
- if (_paddingStyleChanged || _directionChanged || sizeFractionChanged || viewportScrollSizeChanged || overflowAmountChanged || overflowChanged || showNativeOverlaidScrollbarsChanged || adjustFlexboxGlue) {
- const viewportStyle = {
+ const ot = k && B && (nt.x || nt.y) || k && nt.x && !nt.y || B && nt.y && !nt.x;
+ if (L || D || tt || Q || X || R || j || H) {
+ const t = {
marginRight: 0,
marginBottom: 0,
marginLeft: 0,
- width: '',
- overflowY: '',
- overflowX: ''
+ width: "",
+ overflowY: "",
+ overflowX: ""
};
- const viewportOverflowState = setViewportOverflowState(showNativeOverlaidScrollbars, hasOverflow, overflow, viewportStyle);
- const viewportArranged = arrangeViewport(viewportOverflowState, viewportScrollSize, sizeFraction, _directionIsRTL);
-
- if (!_viewportIsTarget) {
- hideNativeScrollbars(viewportOverflowState, _directionIsRTL, viewportArranged, viewportStyle);
+ const n = setViewportOverflowState(F, nt, N, t);
+ const o = arrangeViewport(n, K, Z, P);
+ if (!a) {
+ hideNativeScrollbars(n, P, o, t);
}
-
- if (adjustFlexboxGlue) {
- fixFlexboxGlue(viewportOverflowState, _heightIntrinsic);
+ if (H) {
+ fixFlexboxGlue(n, E);
}
-
- if (_viewportIsTarget) {
- attr(_host, dataAttributeHostOverflowX, viewportStyle.overflowX);
- attr(_host, dataAttributeHostOverflowY, viewportStyle.overflowY);
+ if (a) {
+ attr(s, S, t.overflowX);
+ attr(s, C, t.overflowY);
} else {
- style(_viewport, viewportStyle);
+ style(i, t);
}
}
-
- attrClass(_host, dataAttributeHost, dataValueHostOverflowVisible, removeClipping);
- conditionalClass(_padding, classNameOverflowVisible, removeClipping);
- !_viewportIsTarget && conditionalClass(_viewport, classNameOverflowVisible, overflowVisible);
- const [overflowStyle, overflowStyleChanged] = updateOverflowStyleCache(getViewportOverflowState(showNativeOverlaidScrollbars)._overflowStyle);
- setState({
- _overflowStyle: overflowStyle,
- _overflowAmount: {
- x: overflowAmount.w,
- y: overflowAmount.h
+ attrClass(s, m, x, ot);
+ conditionalClass(c, z, ot);
+ !a && conditionalClass(i, z, V);
+ const [et, st] = A(getViewportOverflowState(F).vt);
+ e({
+ vt: et,
+ yt: {
+ x: W.w,
+ y: W.h
},
- _hasOverflow: hasOverflow
+ St: nt
});
return {
- _overflowStyleChanged: overflowStyleChanged,
- _overflowAmountChanged: overflowAmountChanged
+ Ct: st,
+ xt: X
};
};
};
-const prepareUpdateHints = (leading, adaptive, force) => {
- const result = {};
- const finalAdaptive = adaptive || {};
- const objKeys = keys(leading).concat(keys(finalAdaptive));
- each(objKeys, key => {
- const leadingValue = leading[key];
- const adaptiveValue = finalAdaptive[key];
- result[key] = !!(force || leadingValue || adaptiveValue);
- });
- return result;
+const prepareUpdateHints = (t, n, o) => {
+ const e = {};
+ const s = n || {};
+ const c = keys(t).concat(keys(s));
+ each(c, (n => {
+ const c = t[n];
+ const i = s[n];
+ e[n] = !!(o || c || i);
+ }));
+ return e;
};
-const createStructureSetupUpdate = (structureSetupElements, state) => {
- const {
- _viewport
- } = structureSetupElements;
- const {
- _nativeScrollbarStyling,
- _nativeScrollbarIsOverlaid,
- _flexboxGlue
- } = getEnvironment();
- const doViewportArrange = !_nativeScrollbarStyling && (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y);
- const updateSegments = [createTrinsicUpdate(structureSetupElements, state), createPaddingUpdate(structureSetupElements, state), createOverflowUpdate(structureSetupElements, state)];
- return (checkOption, updateHints, force) => {
- const initialUpdateHints = prepareUpdateHints(assignDeep({
- _sizeChanged: false,
- _paddingStyleChanged: false,
- _directionChanged: false,
- _heightIntrinsicChanged: false,
- _overflowAmountChanged: false,
- _overflowStyleChanged: false,
- _hostMutation: false,
- _contentMutation: false
- }, updateHints), {}, force);
- const adjustScrollOffset = doViewportArrange || !_flexboxGlue;
- const scrollOffsetX = adjustScrollOffset && scrollLeft(_viewport);
- const scrollOffsetY = adjustScrollOffset && scrollTop(_viewport);
- let adaptivedUpdateHints = initialUpdateHints;
- each(updateSegments, updateSegment => {
- adaptivedUpdateHints = prepareUpdateHints(adaptivedUpdateHints, updateSegment(adaptivedUpdateHints, checkOption, !!force) || {}, force);
- });
-
- if (isNumber(scrollOffsetX)) {
- scrollLeft(_viewport, scrollOffsetX);
+const createStructureSetupUpdate = (t, n) => {
+ const {U: o} = t;
+ const {T: e, I: s, M: c} = getEnvironment();
+ const i = !e && (s.x || s.y);
+ const r = [ createTrinsicUpdate(t, n), createPaddingUpdate(t, n), createOverflowUpdate(t, n) ];
+ return (t, n, e) => {
+ const s = prepareUpdateHints(assignDeep({
+ it: false,
+ _t: false,
+ ut: false,
+ ct: false,
+ xt: false,
+ Ct: false,
+ bt: false,
+ rt: false
+ }, n), {}, e);
+ const a = i || !c;
+ const l = a && scrollLeft(o);
+ const u = a && scrollTop(o);
+ let f = s;
+ each(r, (n => {
+ f = prepareUpdateHints(f, n(f, t, !!e) || {}, e);
+ }));
+ if (isNumber(l)) {
+ scrollLeft(o, l);
}
-
- if (isNumber(scrollOffsetY)) {
- scrollTop(_viewport, scrollOffsetY);
+ if (isNumber(u)) {
+ scrollTop(o, u);
}
-
- return adaptivedUpdateHints;
+ return f;
};
};
-const animationStartEventName = 'animationstart';
-const scrollEventName = 'scroll';
-const scrollAmount = 3333333;
+const ot = "animationstart";
-const getElmDirectionIsRTL = elm => style(elm, 'direction') === 'rtl';
+const et = "scroll";
-const domRectHasDimensions = rect => rect && (rect.height || rect.width);
+const st = 3333333;
-const createSizeObserver = (target, onSizeChangedCallback, options) => {
- const {
- _direction: observeDirectionChange = false,
- _appear: observeAppearChange = false
- } = options || {};
- const {
- _rtlScrollBehavior: rtlScrollBehavior
- } = getEnvironment();
- const baseElements = createDOM(``);
- const sizeObserver = baseElements[0];
- const listenerElement = sizeObserver.firstChild;
- const getIsDirectionRTL = getElmDirectionIsRTL.bind(0, sizeObserver);
- const [updateResizeObserverContentRectCache] = createCache({
- _initialValue: undefined,
- _alwaysUpdateValues: true,
- _equal: (currVal, newVal) => !(!currVal || !domRectHasDimensions(currVal) && domRectHasDimensions(newVal))
+const getElmDirectionIsRTL = t => "rtl" === style(t, "direction");
+
+const domRectHasDimensions = t => t && (t.height || t.width);
+
+const createSizeObserver = (t, n, o) => {
+ const {Ot: e = false, At: s = false} = o || {};
+ const {P: c} = getEnvironment();
+ const i = createDOM(``);
+ const r = i[0];
+ const a = r.firstChild;
+ const l = getElmDirectionIsRTL.bind(0, r);
+ const [_] = createCache({
+ o: void 0,
+ _: true,
+ u: (t, n) => !(!t || !domRectHasDimensions(t) && domRectHasDimensions(n))
});
-
- const onSizeChangedCallbackProxy = sizeChangedContext => {
- const isResizeObserverCall = isArray(sizeChangedContext) && sizeChangedContext.length > 0 && isObject(sizeChangedContext[0]);
- const hasDirectionCache = !isResizeObserverCall && isBoolean(sizeChangedContext[0]);
- let skip = false;
- let appear = false;
- let doDirectionScroll = true;
-
- if (isResizeObserverCall) {
- const [currRContentRect,, prevContentRect] = updateResizeObserverContentRectCache(sizeChangedContext.pop().contentRect);
- const hasDimensions = domRectHasDimensions(currRContentRect);
- const hadDimensions = domRectHasDimensions(prevContentRect);
- skip = !prevContentRect || !hasDimensions;
- appear = !hadDimensions && hasDimensions;
- doDirectionScroll = !skip;
- } else if (hasDirectionCache) {
- [, doDirectionScroll] = sizeChangedContext;
+ const onSizeChangedCallbackProxy = t => {
+ const o = isArray(t) && t.length > 0 && isObject(t[0]);
+ const s = !o && isBoolean(t[0]);
+ let i = false;
+ let a = false;
+ let l = true;
+ if (o) {
+ const [n, , o] = _(t.pop().contentRect);
+ const e = domRectHasDimensions(n);
+ const s = domRectHasDimensions(o);
+ i = !o || !e;
+ a = !s && e;
+ l = !i;
+ } else if (s) {
+ [, l] = t;
} else {
- appear = sizeChangedContext === true;
+ a = true === t;
}
-
- if (observeDirectionChange && doDirectionScroll) {
- const rtl = hasDirectionCache ? sizeChangedContext[0] : getElmDirectionIsRTL(sizeObserver);
- scrollLeft(sizeObserver, rtl ? rtlScrollBehavior.n ? -scrollAmount : rtlScrollBehavior.i ? 0 : scrollAmount : scrollAmount);
- scrollTop(sizeObserver, scrollAmount);
+ if (e && l) {
+ const n = s ? t[0] : getElmDirectionIsRTL(r);
+ scrollLeft(r, n ? c.n ? -st : c.i ? 0 : st : st);
+ scrollTop(r, st);
}
-
- if (!skip) {
- onSizeChangedCallback({
- _sizeChanged: !hasDirectionCache,
- _directionIsRTLCache: hasDirectionCache ? sizeChangedContext : undefined,
- _appear: !!appear
+ if (!i) {
+ n({
+ it: !s,
+ $t: s ? t : void 0,
+ At: !!a
});
}
};
-
- const offListeners = [];
- let appearCallback = observeAppearChange ? onSizeChangedCallbackProxy : false;
- let directionIsRTLCache;
-
- if (ResizeObserverConstructor) {
- const resizeObserverInstance = new ResizeObserverConstructor(onSizeChangedCallbackProxy);
- resizeObserverInstance.observe(listenerElement);
- push(offListeners, () => {
- resizeObserverInstance.disconnect();
- });
+ const g = [];
+ let h = s ? onSizeChangedCallbackProxy : false;
+ let p;
+ if (u) {
+ const t = new u(onSizeChangedCallbackProxy);
+ t.observe(a);
+ push(g, (() => {
+ t.disconnect();
+ }));
} else {
- const observerElementChildren = createDOM(``);
- appendChildren(listenerElement, observerElementChildren);
- addClass(listenerElement, classNameSizeObserverListenerScroll);
- const observerElementChildrenRoot = observerElementChildren[0];
- const shrinkElement = observerElementChildrenRoot.lastChild;
- const expandElement = observerElementChildrenRoot.firstChild;
- const expandElementChild = expandElement == null ? void 0 : expandElement.firstChild;
- let cacheSize = offsetSize(observerElementChildrenRoot);
- let currSize = cacheSize;
- let isDirty = false;
- let rAFId;
-
+ const t = createDOM(``);
+ appendChildren(a, t);
+ addClass(a, M);
+ const n = t[0];
+ const o = n.lastChild;
+ const e = n.firstChild;
+ const c = null == e ? void 0 : e.firstChild;
+ let i = offsetSize(n);
+ let r = i;
+ let l = false;
+ let u;
const reset = () => {
- scrollLeft(expandElement, scrollAmount);
- scrollTop(expandElement, scrollAmount);
- scrollLeft(shrinkElement, scrollAmount);
- scrollTop(shrinkElement, scrollAmount);
+ scrollLeft(e, st);
+ scrollTop(e, st);
+ scrollLeft(o, st);
+ scrollTop(o, st);
};
-
- const onResized = appear => {
- rAFId = 0;
-
- if (isDirty) {
- cacheSize = currSize;
- onSizeChangedCallbackProxy(appear === true);
+ const onResized = t => {
+ u = 0;
+ if (l) {
+ i = r;
+ onSizeChangedCallbackProxy(true === t);
}
};
-
- const onScroll = scrollEvent => {
- currSize = offsetSize(observerElementChildrenRoot);
- isDirty = !scrollEvent || !equalWH(currSize, cacheSize);
-
- if (scrollEvent) {
- stopAndPrevent(scrollEvent);
-
- if (isDirty && !rAFId) {
- cAF(rAFId);
- rAFId = rAF(onResized);
+ const onScroll = t => {
+ r = offsetSize(n);
+ l = !t || !equalWH(r, i);
+ if (t) {
+ stopAndPrevent(t);
+ if (l && !u) {
+ f(u);
+ u = d(onResized);
}
} else {
- onResized(scrollEvent === false);
+ onResized(false === t);
}
-
reset();
};
-
- push(offListeners, [on(expandElement, scrollEventName, onScroll), on(shrinkElement, scrollEventName, onScroll)]);
- style(expandElementChild, {
- width: scrollAmount,
- height: scrollAmount
+ push(g, [ on(e, et, onScroll), on(o, et, onScroll) ]);
+ style(c, {
+ width: st,
+ height: st
});
reset();
- appearCallback = observeAppearChange ? onScroll.bind(0, false) : reset;
+ h = s ? onScroll.bind(0, false) : reset;
}
-
- if (observeDirectionChange) {
- directionIsRTLCache = createCache({
- _initialValue: !getIsDirectionRTL()
- }, getIsDirectionRTL);
- const [updateDirectionIsRTLCache] = directionIsRTLCache;
- push(offListeners, on(sizeObserver, scrollEventName, event => {
- const directionIsRTLCacheValues = updateDirectionIsRTLCache();
- const [directionIsRTL, directionIsRTLChanged] = directionIsRTLCacheValues;
-
- if (directionIsRTLChanged) {
- removeClass(listenerElement, 'ltr rtl');
-
- if (directionIsRTL) {
- addClass(listenerElement, 'rtl');
+ if (e) {
+ p = createCache({
+ o: !l()
+ }, l);
+ const [t] = p;
+ push(g, on(r, et, (n => {
+ const o = t();
+ const [e, s] = o;
+ if (s) {
+ removeClass(a, "ltr rtl");
+ if (e) {
+ addClass(a, "rtl");
} else {
- addClass(listenerElement, 'ltr');
+ addClass(a, "ltr");
}
-
- onSizeChangedCallbackProxy(directionIsRTLCacheValues);
+ onSizeChangedCallbackProxy(o);
}
-
- stopAndPrevent(event);
+ stopAndPrevent(n);
+ })));
+ }
+ if (h) {
+ addClass(r, E);
+ push(g, on(r, ot, h, {
+ O: !!u
}));
}
-
- if (appearCallback) {
- addClass(sizeObserver, classNameSizeObserverAppear);
- push(offListeners, on(sizeObserver, animationStartEventName, appearCallback, {
- _once: !!ResizeObserverConstructor
- }));
- }
-
- prependChildren(target, sizeObserver);
+ prependChildren(t, r);
return () => {
- runEach(offListeners);
- removeElements(sizeObserver);
+ runEach(g);
+ removeElements(r);
};
};
-const isHeightIntrinsic = ioEntryOrSize => ioEntryOrSize.h === 0 || ioEntryOrSize.isIntersecting || ioEntryOrSize.intersectionRatio > 0;
+const isHeightIntrinsic = t => 0 === t.h || t.isIntersecting || t.intersectionRatio > 0;
-const createTrinsicObserver = (target, onTrinsicChangedCallback) => {
- const trinsicObserver = createDiv(classNameTrinsicObserver);
- const offListeners = [];
- const [updateHeightIntrinsicCache] = createCache({
- _initialValue: false
+const createTrinsicObserver = (t, n) => {
+ const o = createDiv(R);
+ const e = [];
+ const [s] = createCache({
+ o: false
});
-
- const triggerOnTrinsicChangedCallback = updateValue => {
- if (updateValue) {
- const heightIntrinsic = updateHeightIntrinsicCache(isHeightIntrinsic(updateValue));
- const [, heightIntrinsicChanged] = heightIntrinsic;
-
- if (heightIntrinsicChanged) {
- onTrinsicChangedCallback(heightIntrinsic);
+ const triggerOnTrinsicChangedCallback = t => {
+ if (t) {
+ const o = s(isHeightIntrinsic(t));
+ const [, e] = o;
+ if (e) {
+ n(o);
}
}
};
-
- if (IntersectionObserverConstructor) {
- const intersectionObserverInstance = new IntersectionObserverConstructor(entries => {
- if (entries && entries.length > 0) {
- triggerOnTrinsicChangedCallback(entries.pop());
+ if (l) {
+ const n = new l((t => {
+ if (t && t.length > 0) {
+ triggerOnTrinsicChangedCallback(t.pop());
}
- }, {
- root: target
- });
- intersectionObserverInstance.observe(trinsicObserver);
- push(offListeners, () => {
- intersectionObserverInstance.disconnect();
+ }), {
+ root: t
});
+ n.observe(o);
+ push(e, (() => {
+ n.disconnect();
+ }));
} else {
const onSizeChanged = () => {
- const newSize = offsetSize(trinsicObserver);
- triggerOnTrinsicChangedCallback(newSize);
+ const t = offsetSize(o);
+ triggerOnTrinsicChangedCallback(t);
};
-
- push(offListeners, createSizeObserver(trinsicObserver, onSizeChanged));
+ push(e, createSizeObserver(o, onSizeChanged));
onSizeChanged();
}
-
- prependChildren(target, trinsicObserver);
+ prependChildren(t, o);
return () => {
- runEach(offListeners);
- removeElements(trinsicObserver);
+ runEach(e);
+ removeElements(o);
};
};
-const createEventContentChange = (target, callback, eventContentChange) => {
- let map;
- let destroyed = false;
-
+const createEventContentChange = (t, n, o) => {
+ let e;
+ let s = false;
const destroy = () => {
- destroyed = true;
+ s = true;
};
-
- const updateElements = getElements => {
- if (eventContentChange) {
- const eventElmList = eventContentChange.reduce((arr, item) => {
- if (item) {
- const selector = item[0];
- const eventNames = item[1];
- const elements = eventNames && selector && (getElements ? getElements(selector) : find(selector, target));
-
- if (elements && elements.length && eventNames && isString(eventNames)) {
- push(arr, [elements, eventNames.trim()], true);
+ const updateElements = c => {
+ if (o) {
+ const i = o.reduce(((n, o) => {
+ if (o) {
+ const e = o[0];
+ const s = o[1];
+ const i = s && e && (c ? c(e) : find(e, t));
+ if (i && i.length && s && isString(s)) {
+ push(n, [ i, s.trim() ], true);
}
}
-
- return arr;
- }, []);
- each(eventElmList, item => each(item[0], elm => {
- const eventNames = item[1];
- const entry = map.get(elm);
-
- if (entry) {
- const entryEventNames = entry[0];
- const entryOff = entry[1];
-
- if (entryEventNames === eventNames) {
- entryOff();
+ return n;
+ }), []);
+ each(i, (t => each(t[0], (o => {
+ const c = t[1];
+ const i = e.get(o);
+ if (i) {
+ const t = i[0];
+ const n = i[1];
+ if (t === c) {
+ n();
}
}
-
- const off = on(elm, eventNames, event => {
- if (destroyed) {
- off();
- map.delete(elm);
+ const r = on(o, c, (t => {
+ if (s) {
+ r();
+ e.delete(o);
} else {
- callback(event);
+ n(t);
}
- });
- map.set(elm, [eventNames, off]);
- }));
+ }));
+ e.set(o, [ c, r ]);
+ }))));
}
};
-
- if (eventContentChange) {
- map = new WeakMap();
+ if (o) {
+ e = new WeakMap;
updateElements();
}
-
- return [destroy, updateElements];
+ return [ destroy, updateElements ];
};
-const createDOMObserver = (target, isContentObserver, callback, options) => {
- let isConnected = false;
- const {
- _attributes,
- _styleChangingAttributes,
- _eventContentChange,
- _nestedTargetSelector,
- _ignoreTargetChange,
- _ignoreContentChange
- } = options || {};
- const [destroyEventContentChange, updateEventContentChangeElements] = createEventContentChange(target, debounce(() => {
- if (isConnected) {
- callback(true);
+const createDOMObserver = (t, n, o, e) => {
+ let s = false;
+ const {Lt: c, It: i, Tt: r, zt: l, Dt: u, Et: f} = e || {};
+ const [d, _] = createEventContentChange(t, debounce((() => {
+ if (s) {
+ o(true);
}
- }, {
- _timeout: 33,
- _maxDelay: 99
- }), _eventContentChange);
- const finalAttributes = _attributes || [];
- const finalStyleChangingAttributes = _styleChangingAttributes || [];
- const observedAttributes = finalAttributes.concat(finalStyleChangingAttributes);
-
- const observerCallback = mutations => {
- const ignoreTargetChange = _ignoreTargetChange || noop;
- const ignoreContentChange = _ignoreContentChange || noop;
- const targetChangedAttrs = [];
- const totalAddedNodes = [];
- let targetStyleChanged = false;
- let contentChanged = false;
- let childListChanged = false;
- each(mutations, mutation => {
- const {
- attributeName,
- target: mutationTarget,
- type,
- oldValue,
- addedNodes
- } = mutation;
- const isAttributesType = type === 'attributes';
- const isChildListType = type === 'childList';
- const targetIsMutationTarget = target === mutationTarget;
- const attributeValue = isAttributesType && isString(attributeName) ? attr(mutationTarget, attributeName) : 0;
- const attributeChanged = attributeValue !== 0 && oldValue !== attributeValue;
- const styleChangingAttrChanged = indexOf(finalStyleChangingAttributes, attributeName) > -1 && attributeChanged;
-
- if (isContentObserver && !targetIsMutationTarget) {
- const notOnlyAttrChanged = !isAttributesType;
- const contentAttrChanged = isAttributesType && styleChangingAttrChanged;
- const isNestedTarget = contentAttrChanged && _nestedTargetSelector && is(mutationTarget, _nestedTargetSelector);
- const baseAssertion = isNestedTarget ? !ignoreTargetChange(mutationTarget, attributeName, oldValue, attributeValue) : notOnlyAttrChanged || contentAttrChanged;
- const contentFinalChanged = baseAssertion && !ignoreContentChange(mutation, !!isNestedTarget, target, options);
- push(totalAddedNodes, addedNodes);
- contentChanged = contentChanged || contentFinalChanged;
- childListChanged = childListChanged || isChildListType;
+ }), {
+ g: 33,
+ p: 99
+ }), r);
+ const g = c || [];
+ const h = i || [];
+ const p = g.concat(h);
+ const observerCallback = s => {
+ const c = u || noop;
+ const i = f || noop;
+ const r = [];
+ const a = [];
+ let d = false;
+ let g = false;
+ let p = false;
+ each(s, (o => {
+ const {attributeName: s, target: u, type: f, oldValue: _, addedNodes: v} = o;
+ const w = "attributes" === f;
+ const b = "childList" === f;
+ const y = t === u;
+ const m = w && isString(s) ? attr(u, s) : 0;
+ const S = 0 !== m && _ !== m;
+ const C = indexOf(h, s) > -1 && S;
+ if (n && !y) {
+ const n = !w;
+ const r = w && C;
+ const f = r && l && is(u, l);
+ const d = f ? !c(u, s, _, m) : n || r;
+ const h = d && !i(o, !!f, t, e);
+ push(a, v);
+ g = g || h;
+ p = p || b;
}
-
- if (!isContentObserver && targetIsMutationTarget && attributeChanged && !ignoreTargetChange(mutationTarget, attributeName, oldValue, attributeValue)) {
- push(targetChangedAttrs, attributeName);
- targetStyleChanged = targetStyleChanged || styleChangingAttrChanged;
+ if (!n && y && S && !c(u, s, _, m)) {
+ push(r, s);
+ d = d || C;
}
- });
-
- if (childListChanged && !isEmptyArray(totalAddedNodes)) {
- updateEventContentChangeElements(selector => totalAddedNodes.reduce((arr, node) => {
- push(arr, find(selector, node));
- return is(node, selector) ? push(arr, node) : arr;
- }, []));
+ }));
+ if (p && !isEmptyArray(a)) {
+ _((t => a.reduce(((n, o) => {
+ push(n, find(t, o));
+ return is(o, t) ? push(n, o) : n;
+ }), [])));
}
-
- if (isContentObserver) {
- contentChanged && callback(false);
- } else if (!isEmptyArray(targetChangedAttrs) || targetStyleChanged) {
- callback(targetChangedAttrs, targetStyleChanged);
+ if (n) {
+ g && o(false);
+ } else if (!isEmptyArray(r) || d) {
+ o(r, d);
}
};
-
- const mutationObserver = new MutationObserverConstructor(observerCallback);
- mutationObserver.observe(target, {
+ const v = new a(observerCallback);
+ v.observe(t, {
attributes: true,
attributeOldValue: true,
- attributeFilter: observedAttributes,
- subtree: isContentObserver,
- childList: isContentObserver,
- characterData: isContentObserver
+ attributeFilter: p,
+ subtree: n,
+ childList: n,
+ characterData: n
});
- isConnected = true;
- return [() => {
- if (isConnected) {
- destroyEventContentChange();
- mutationObserver.disconnect();
- isConnected = false;
+ s = true;
+ return [ () => {
+ if (s) {
+ d();
+ v.disconnect();
+ s = false;
}
}, () => {
- if (isConnected) {
- observerCallback(mutationObserver.takeRecords());
+ if (s) {
+ observerCallback(v.takeRecords());
}
- }];
+ } ];
};
-const hostSelector = `[${dataAttributeHost}]`;
-const viewportSelector = `.${classNameViewport}`;
-const viewportAttrsFromTarget = ['tabindex'];
-const baseStyleChangingAttrsTextarea = ['wrap', 'cols', 'rows'];
-const baseStyleChangingAttrs = ['id', 'class', 'style', 'open'];
-const createStructureSetupObservers = (structureSetupElements, state, structureSetupUpdate) => {
- let debounceTimeout;
- let debounceMaxDelay;
- let contentMutationObserver;
- const [, setState] = state;
- const {
- _host,
- _viewport,
- _content,
- _isTextarea,
- _viewportIsTarget,
- _viewportHasClass,
- _viewportAddRemoveClass
- } = structureSetupElements;
- const {
- _nativeScrollbarStyling,
- _flexboxGlue
- } = getEnvironment();
- const [updateContentSizeCache] = createCache({
- _equal: equalWH,
- _initialValue: {
+const ct = `[${m}]`;
+
+const it = `.${$}`;
+
+const rt = [ "tabindex" ];
+
+const at = [ "wrap", "cols", "rows" ];
+
+const lt = [ "id", "class", "style", "open" ];
+
+const createStructureSetupObservers = (t, n, o) => {
+ let e;
+ let s;
+ let c;
+ const [, i] = n;
+ const {V: r, U: a, $: l, K: f, nt: d, ot: _, et: g} = t;
+ const {T: h, M: p} = getEnvironment();
+ const [v] = createCache({
+ u: equalWH,
+ o: {
w: 0,
h: 0
}
- }, () => {
- const has = _viewportHasClass(classNameOverflowVisible, dataValueHostOverflowVisible);
-
- has && _viewportAddRemoveClass(classNameOverflowVisible, dataValueHostOverflowVisible);
- const contentScroll = scrollSize(_content);
- const viewportScroll = scrollSize(_viewport);
- const fractional = fractionalSize(_viewport);
- has && _viewportAddRemoveClass(classNameOverflowVisible, dataValueHostOverflowVisible, true);
+ }, (() => {
+ const t = _(z, x);
+ t && g(z, x);
+ const n = scrollSize(l);
+ const o = scrollSize(a);
+ const e = fractionalSize(a);
+ t && g(z, x, true);
return {
- w: viewportScroll.w + contentScroll.w + fractional.w,
- h: viewportScroll.h + contentScroll.h + fractional.h
+ w: o.w + n.w + e.w,
+ h: o.h + n.h + e.h
};
- });
- const contentMutationObserverAttr = _isTextarea ? baseStyleChangingAttrsTextarea : baseStyleChangingAttrs.concat(baseStyleChangingAttrsTextarea);
- const structureSetupUpdateWithDebouncedAdaptiveUpdateHints = debounce(structureSetupUpdate, {
- _timeout: () => debounceTimeout,
- _maxDelay: () => debounceMaxDelay,
-
- _mergeParams(prev, curr) {
- const [prevObj] = prev;
- const [currObj] = curr;
- return [keys(prevObj).concat(keys(currObj)).reduce((obj, key) => {
- obj[key] = prevObj[key] || currObj[key];
- return obj;
- }, {})];
- }
-
- });
-
- const updateViewportAttrsFromHost = attributes => {
- each(attributes || viewportAttrsFromTarget, attribute => {
- if (indexOf(viewportAttrsFromTarget, attribute) > -1) {
- const hostAttr = attr(_host, attribute);
-
- if (isString(hostAttr)) {
- attr(_viewport, attribute, hostAttr);
- } else {
- removeAttr(_viewport, attribute);
- }
- }
- });
- };
-
- const onTrinsicChanged = heightIntrinsicCache => {
- const [heightIntrinsic, heightIntrinsicChanged] = heightIntrinsicCache;
- setState({
- _heightIntrinsic: heightIntrinsic
- });
- structureSetupUpdate({
- _heightIntrinsicChanged: heightIntrinsicChanged
- });
- };
-
- const onSizeChanged = ({
- _sizeChanged,
- _directionIsRTLCache,
- _appear
- }) => {
- const updateFn = !_sizeChanged || _appear ? structureSetupUpdate : structureSetupUpdateWithDebouncedAdaptiveUpdateHints;
- let directionChanged = false;
-
- if (_directionIsRTLCache) {
- const [directionIsRTL, directionIsRTLChanged] = _directionIsRTLCache;
- directionChanged = directionIsRTLChanged;
- setState({
- _directionIsRTL: directionIsRTL
- });
- }
-
- updateFn({
- _sizeChanged,
- _directionChanged: directionChanged
- });
- };
-
- const onContentMutation = contentChangedTroughEvent => {
- const [, contentSizeChanged] = updateContentSizeCache();
- const updateFn = contentChangedTroughEvent ? structureSetupUpdate : structureSetupUpdateWithDebouncedAdaptiveUpdateHints;
-
- if (contentSizeChanged) {
- updateFn({
- _contentMutation: true
- });
- }
- };
-
- const onHostMutation = (targetChangedAttrs, targetStyleChanged) => {
- if (targetStyleChanged) {
- structureSetupUpdateWithDebouncedAdaptiveUpdateHints({
- _hostMutation: true
- });
- } else if (!_viewportIsTarget) {
- updateViewportAttrsFromHost(targetChangedAttrs);
- }
- };
-
- const destroyTrinsicObserver = (_content || !_flexboxGlue) && createTrinsicObserver(_host, onTrinsicChanged);
- const destroySizeObserver = !_viewportIsTarget && createSizeObserver(_host, onSizeChanged, {
- _appear: true,
- _direction: !_nativeScrollbarStyling
- });
- const [destroyHostMutationObserver] = createDOMObserver(_host, false, onHostMutation, {
- _styleChangingAttributes: baseStyleChangingAttrs,
- _attributes: baseStyleChangingAttrs.concat(viewportAttrsFromTarget)
- });
- const viewportIsTargetResizeObserver = _viewportIsTarget && new ResizeObserverConstructor(onSizeChanged.bind(0, {
- _sizeChanged: true
}));
- viewportIsTargetResizeObserver && viewportIsTargetResizeObserver.observe(_host);
- updateViewportAttrsFromHost();
- return [checkOption => {
- const [ignoreMutation] = checkOption('updating.ignoreMutation');
- const [attributes, attributesChanged] = checkOption('updating.attributes');
- const [elementEvents, elementEventsChanged] = checkOption('updating.elementEvents');
- const [debounceValue, debounceChanged] = checkOption('updating.debounce');
- const updateContentMutationObserver = elementEventsChanged || attributesChanged;
-
- const ignoreMutationFromOptions = mutation => isFunction(ignoreMutation) && ignoreMutation(mutation);
-
- if (updateContentMutationObserver) {
- if (contentMutationObserver) {
- contentMutationObserver[1]();
- contentMutationObserver[0]();
+ const w = f ? at : lt.concat(at);
+ const b = debounce(o, {
+ g: () => e,
+ p: () => s,
+ v(t, n) {
+ const [o] = t;
+ const [e] = n;
+ return [ keys(o).concat(keys(e)).reduce(((t, n) => {
+ t[n] = o[n] || e[n];
+ return t;
+ }), {}) ];
+ }
+ });
+ const updateViewportAttrsFromHost = t => {
+ each(t || rt, (t => {
+ if (indexOf(rt, t) > -1) {
+ const n = attr(r, t);
+ if (isString(n)) {
+ attr(a, t, n);
+ } else {
+ removeAttr(a, t);
+ }
}
-
- contentMutationObserver = createDOMObserver(_content || _viewport, true, onContentMutation, {
- _styleChangingAttributes: contentMutationObserverAttr.concat(attributes || []),
- _attributes: contentMutationObserverAttr.concat(attributes || []),
- _eventContentChange: elementEvents,
- _nestedTargetSelector: hostSelector,
- _ignoreContentChange: (mutation, isNestedTarget) => {
- const {
- target,
- attributeName
- } = mutation;
- const ignore = !isNestedTarget && attributeName ? liesBetween(target, hostSelector, viewportSelector) : false;
- return ignore || !!ignoreMutationFromOptions(mutation);
+ }));
+ };
+ const onTrinsicChanged = t => {
+ const [n, e] = t;
+ i({
+ st: n
+ });
+ o({
+ ct: e
+ });
+ };
+ const onSizeChanged = ({it: t, $t: n, At: e}) => {
+ const s = !t || e ? o : b;
+ let c = false;
+ if (n) {
+ const [t, o] = n;
+ c = o;
+ i({
+ lt: t
+ });
+ }
+ s({
+ it: t,
+ ut: c
+ });
+ };
+ const onContentMutation = t => {
+ const [, n] = v();
+ const e = t ? o : b;
+ if (n) {
+ e({
+ rt: true
+ });
+ }
+ };
+ const onHostMutation = (t, n) => {
+ if (n) {
+ b({
+ bt: true
+ });
+ } else if (!d) {
+ updateViewportAttrsFromHost(t);
+ }
+ };
+ const y = (l || !p) && createTrinsicObserver(r, onTrinsicChanged);
+ const m = !d && createSizeObserver(r, onSizeChanged, {
+ At: true,
+ Ot: !h
+ });
+ const [S] = createDOMObserver(r, false, onHostMutation, {
+ It: lt,
+ Lt: lt.concat(rt)
+ });
+ const C = d && new u(onSizeChanged.bind(0, {
+ it: true
+ }));
+ C && C.observe(r);
+ updateViewportAttrsFromHost();
+ return [ t => {
+ const [n] = t("updating.ignoreMutation");
+ const [o, i] = t("updating.attributes");
+ const [r, u] = t("updating.elementEvents");
+ const [f, d] = t("updating.debounce");
+ const _ = u || i;
+ const ignoreMutationFromOptions = t => isFunction(n) && n(t);
+ if (_) {
+ if (c) {
+ c[1]();
+ c[0]();
+ }
+ c = createDOMObserver(l || a, true, onContentMutation, {
+ It: w.concat(o || []),
+ Lt: w.concat(o || []),
+ Tt: r,
+ zt: ct,
+ Et: (t, n) => {
+ const {target: o, attributeName: e} = t;
+ const s = !n && e ? liesBetween(o, ct, it) : false;
+ return s || !!ignoreMutationFromOptions(t);
}
});
}
-
- if (debounceChanged) {
- structureSetupUpdateWithDebouncedAdaptiveUpdateHints._flush();
-
- if (isArray(debounceValue)) {
- const timeout = debounceValue[0];
- const maxWait = debounceValue[1];
- debounceTimeout = isNumber(timeout) ? timeout : false;
- debounceMaxDelay = isNumber(maxWait) ? maxWait : false;
- } else if (isNumber(debounceValue)) {
- debounceTimeout = debounceValue;
- debounceMaxDelay = false;
+ if (d) {
+ b.m();
+ if (isArray(f)) {
+ const t = f[0];
+ const n = f[1];
+ e = isNumber(t) ? t : false;
+ s = isNumber(n) ? n : false;
+ } else if (isNumber(f)) {
+ e = f;
+ s = false;
} else {
- debounceTimeout = false;
- debounceMaxDelay = false;
+ e = false;
+ s = false;
}
}
}, () => {
- contentMutationObserver && contentMutationObserver[0]();
- destroyTrinsicObserver && destroyTrinsicObserver();
- destroySizeObserver && destroySizeObserver();
- viewportIsTargetResizeObserver && viewportIsTargetResizeObserver.disconnect();
- destroyHostMutationObserver();
- }];
+ c && c[0]();
+ y && y();
+ m && m();
+ C && C.disconnect();
+ S();
+ } ];
};
-const initialStructureSetupUpdateState = {
- _padding: {
+const ut = {
+ A: {
t: 0,
r: 0,
b: 0,
l: 0
},
- _paddingAbsolute: false,
- _viewportPaddingStyle: {
+ ft: false,
+ dt: {
marginRight: 0,
marginBottom: 0,
marginLeft: 0,
@@ -2252,348 +1995,286 @@ const initialStructureSetupUpdateState = {
paddingBottom: 0,
paddingLeft: 0
},
- _overflowAmount: {
+ yt: {
x: 0,
y: 0
},
- _overflowStyle: {
- x: 'hidden',
- y: 'hidden'
+ vt: {
+ x: "hidden",
+ y: "hidden"
},
- _hasOverflow: {
+ St: {
x: false,
y: false
},
- _heightIntrinsic: false,
- _directionIsRTL: false
-};
-const createStructureSetup = (target, options) => {
- const checkOptionsFallback = createOptionCheck(options, {});
- const state = createState(initialStructureSetupUpdateState);
- const onUpdatedListeners = new Set();
- const [getState] = state;
-
- const runOnUpdatedListeners = (updateHints, changedOptions, force) => {
- runEach(onUpdatedListeners, [updateHints, changedOptions || {}, !!force]);
- };
-
- const [elements, destroyElements] = createStructureSetupElements(target);
- const updateStructure = createStructureSetupUpdate(elements, state);
- const [updateObservers, destroyObservers] = createStructureSetupObservers(elements, state, updateHints => {
- runOnUpdatedListeners(updateStructure(checkOptionsFallback, updateHints));
- });
- const structureSetupState = getState.bind(0);
-
- structureSetupState._addOnUpdatedListener = listener => {
- onUpdatedListeners.add(listener);
- };
-
- structureSetupState._elements = elements;
- return [(changedOptions, force) => {
- const checkOption = createOptionCheck(options, changedOptions, force);
- updateObservers(checkOption);
- runOnUpdatedListeners(updateStructure(checkOption, {}, force));
- }, structureSetupState, () => {
- onUpdatedListeners.clear();
- destroyObservers();
- destroyElements();
- }];
+ st: false,
+ lt: false
};
-const generateScrollbarDOM = scrollbarClassName => {
- const scrollbar = createDiv(`${classNameScrollbar} ${scrollbarClassName}`);
- const track = createDiv(classNameScrollbarTrack);
- const handle = createDiv(classNameScrollbarHandle);
- appendChildren(scrollbar, track);
- appendChildren(track, handle);
+const createStructureSetup = (t, n) => {
+ const o = createOptionCheck(n, {});
+ const e = createState(ut);
+ const s = new Set;
+ const [c] = e;
+ const runOnUpdatedListeners = (t, n, o) => {
+ runEach(s, [ t, n || {}, !!o ]);
+ };
+ const [i, r] = createStructureSetupElements(t);
+ const a = createStructureSetupUpdate(i, e);
+ const [l, u] = createStructureSetupObservers(i, e, (t => {
+ runOnUpdatedListeners(a(o, t));
+ }));
+ const f = c.bind(0);
+ f.Pt = t => {
+ s.add(t);
+ };
+ f.Mt = i;
+ return [ (t, o) => {
+ const e = createOptionCheck(n, t, o);
+ l(e);
+ runOnUpdatedListeners(a(e, {}, o));
+ }, f, () => {
+ s.clear();
+ u();
+ r();
+ } ];
+};
+
+const generateScrollbarDOM = t => {
+ const n = createDiv(`${F} ${t}`);
+ const o = createDiv(B);
+ const e = createDiv(V);
+ appendChildren(n, o);
+ appendChildren(o, e);
return {
- _scrollbar: scrollbar,
- _track: track,
- _handle: handle
+ jt: n,
+ Nt: o,
+ Rt: e
};
};
-const createScrollbarsSetupElements = (target, structureSetupElements) => {
- const {
- _getInitializationStrategy
- } = getEnvironment();
-
- const {
- _scrollbarsSlot: environmentScrollbarSlot
- } = _getInitializationStrategy();
-
- const {
- _target,
- _host,
- _viewport,
- _targetIsElm
- } = structureSetupElements;
- const initializationScrollbarSlot = !_targetIsElm && target.scrollbarsSlot;
- const initializationScrollbarSlotResult = isFunction(initializationScrollbarSlot) ? initializationScrollbarSlot(_target, _host, _viewport) : initializationScrollbarSlot;
- const evaluatedScrollbarSlot = initializationScrollbarSlotResult || (isFunction(environmentScrollbarSlot) ? environmentScrollbarSlot(_target, _host, _viewport) : environmentScrollbarSlot) || _host;
- const horizontalScrollbarStructure = generateScrollbarDOM(classNameScrollbarHorizontal);
- const verticalScrollbarStructure = generateScrollbarDOM(classNameScrollbarVertical);
- const {
- _scrollbar: horizontalScrollbar
- } = horizontalScrollbarStructure;
- const {
- _scrollbar: verticalScrollbar
- } = verticalScrollbarStructure;
- appendChildren(evaluatedScrollbarSlot, horizontalScrollbar);
- appendChildren(evaluatedScrollbarSlot, verticalScrollbar);
- return [{
- _horizontalScrollbarStructure: horizontalScrollbarStructure,
- _verticalScrollbarStructure: verticalScrollbarStructure
- }, removeElements.bind(0, [horizontalScrollbar, verticalScrollbar])];
+const createScrollbarsSetupElements = (t, n) => {
+ const {N: o} = getEnvironment();
+ const {Ft: e} = o();
+ const {Y: s, V: c, U: i, tt: r} = n;
+ const a = !r && t.scrollbarsSlot;
+ const l = dynamicInitializationElement([ s, c, i ], (() => c), e, a);
+ const u = generateScrollbarDOM(H);
+ const f = generateScrollbarDOM(k);
+ const {jt: d} = u;
+ const {jt: _} = f;
+ appendChildren(l, d);
+ appendChildren(l, _);
+ return [ {
+ Ht: u,
+ kt: f
+ }, removeElements.bind(0, [ d, _ ]) ];
};
-const createScrollbarsSetup = (target, options, structureSetupElements) => {
- const state = createState({});
- const [getState] = state;
- const [elements, destroyElements] = createScrollbarsSetupElements(target, structureSetupElements);
- const scrollbarsSetupState = getState.bind(0);
- scrollbarsSetupState._elements = elements;
- return [(changedOptions, force) => {
- const checkOption = createOptionCheck(options, changedOptions, force);
- console.log(checkOption);
- }, scrollbarsSetupState, () => {
- destroyElements();
- }];
+const createScrollbarsSetup = (t, n, o) => {
+ const e = createState({});
+ const [s] = e;
+ const [c, i] = createScrollbarsSetupElements(t, o);
+ const r = s.bind(0);
+ r.Mt = c;
+ return [ (t, o) => {
+ const e = createOptionCheck(n, t, o);
+ console.log(e);
+ }, r, () => {
+ i();
+ } ];
};
-const pluginRegistry = {};
-const getPlugins = () => assignDeep({}, pluginRegistry);
-const addPlugin = addedPlugin => each(isArray(addedPlugin) ? addedPlugin : [addedPlugin], plugin => {
- pluginRegistry[plugin[0]] = plugin[1];
-});
+const ft = {};
-const optionsTemplateTypes = {
- boolean: '__TPL_boolean_TYPE__',
- number: '__TPL_number_TYPE__',
- string: '__TPL_string_TYPE__',
- array: '__TPL_array_TYPE__',
- object: '__TPL_object_TYPE__',
- function: '__TPL_function_TYPE__',
- null: '__TPL_null_TYPE__'
+const getPlugins = () => assignDeep({}, ft);
+
+const addPlugin = t => each(isArray(t) ? t : [ t ], (t => {
+ ft[t[0]] = t[1];
+}));
+
+const dt = {
+ boolean: "__TPL_boolean_TYPE__",
+ number: "__TPL_number_TYPE__",
+ string: "__TPL_string_TYPE__",
+ array: "__TPL_array_TYPE__",
+ object: "__TPL_object_TYPE__",
+ function: "__TPL_function_TYPE__",
+ null: "__TPL_null_TYPE__"
};
-const numberAllowedValues = optionsTemplateTypes.number;
-const booleanAllowedValues = optionsTemplateTypes.boolean;
-const arrayNullValues = [optionsTemplateTypes.array, optionsTemplateTypes.null];
-const overflowAllowedValues = 'hidden scroll visible visible-hidden';
-const scrollbarsVisibilityAllowedValues = 'visible hidden auto';
-const scrollbarsAutoHideAllowedValues = 'never scroll leavemove';
+const _t = dt.number;
+
+const gt = dt.boolean;
+
+const ht = [ dt.array, dt.null ];
+
+const pt = "hidden scroll visible visible-hidden";
+
+const vt = "visible hidden auto";
+
+const wt = "never scroll leavemove";
+
({
- paddingAbsolute: booleanAllowedValues,
+ paddingAbsolute: gt,
updating: {
- elementEvents: arrayNullValues,
- attributes: arrayNullValues,
- debounce: [optionsTemplateTypes.number, optionsTemplateTypes.array, optionsTemplateTypes.null],
- ignoreMutation: [optionsTemplateTypes.function, optionsTemplateTypes.null]
+ elementEvents: ht,
+ attributes: ht,
+ debounce: [ dt.number, dt.array, dt.null ],
+ ignoreMutation: [ dt.function, dt.null ]
},
overflow: {
- x: overflowAllowedValues,
- y: overflowAllowedValues
+ x: pt,
+ y: pt
},
scrollbars: {
- visibility: scrollbarsVisibilityAllowedValues,
- autoHide: scrollbarsAutoHideAllowedValues,
- autoHideDelay: numberAllowedValues,
- dragScroll: booleanAllowedValues,
- clickScroll: booleanAllowedValues,
- touch: booleanAllowedValues
+ visibility: vt,
+ autoHide: wt,
+ autoHideDelay: _t,
+ dragScroll: gt,
+ clickScroll: gt,
+ touch: gt
},
nativeScrollbarsOverlaid: {
- show: booleanAllowedValues,
- initialize: booleanAllowedValues
+ show: gt,
+ initialize: gt
}
});
-const optionsValidationPluginName = '__osOptionsValidationPlugin';
-const targets = new Set();
-const targetInstanceMap = new WeakMap();
-const addInstance = (target, osInstance) => {
- targetInstanceMap.set(target, osInstance);
- targets.add(target);
+const bt = "__osOptionsValidationPlugin";
+
+const yt = new Set;
+
+const mt = new WeakMap;
+
+const addInstance = (t, n) => {
+ mt.set(t, n);
+ yt.add(t);
};
-const removeInstance = target => {
- targetInstanceMap.delete(target);
- targets.delete(target);
+
+const removeInstance = t => {
+ mt.delete(t);
+ yt.delete(t);
};
-const getInstance = target => targetInstanceMap.get(target);
-const createOSEventListenerHub = initialEventListeners => createEventListenerHub(initialEventListeners);
+const getInstance = t => mt.get(t);
-const OverlayScrollbars = (target, options, eventListeners) => {
- const {
- _getDefaultOptions,
- _nativeScrollbarIsOverlaid,
- _addListener: addEnvListener
- } = getEnvironment();
- const plugins = getPlugins();
- const instanceTarget = isHTMLElement(target) ? target : target.target;
- const potentialInstance = getInstance(instanceTarget);
-
- if (potentialInstance) {
- return potentialInstance;
+const OverlayScrollbars = (t, n, o) => {
+ const {F: e, I: s, j: c} = getEnvironment();
+ const i = getPlugins();
+ const r = isHTMLElement(t) ? t : t.target;
+ const a = getInstance(r);
+ if (a) {
+ return a;
}
-
- const optionsValidationPlugin = plugins[optionsValidationPluginName];
-
- const validateOptions = newOptions => {
- const opts = newOptions || {};
- const validate = optionsValidationPlugin && optionsValidationPlugin._;
- return validate ? validate(opts, true) : opts;
+ const l = i[bt];
+ const validateOptions = t => {
+ const n = t || {};
+ const o = l && l.Bt;
+ return o ? o(n, true) : n;
};
-
- const currentOptions = assignDeep({}, _getDefaultOptions(), validateOptions(options));
- const [addEvent, removeEvent, triggerEvent] = createOSEventListenerHub(eventListeners);
-
- if (_nativeScrollbarIsOverlaid.x && _nativeScrollbarIsOverlaid.y && !currentOptions.nativeScrollbarsOverlaid.initialize) {
- triggerEvent('initializationWithdrawn');
+ const u = assignDeep({}, e(), validateOptions(n));
+ const [f, d, _] = createEventListenerHub(o);
+ if (s.x && s.y && !u.nativeScrollbarsOverlaid.initialize) {
+ _("initializationWithdrawn");
}
-
- const [updateStructure, structureState, destroyStructure] = createStructureSetup(target, currentOptions);
- const [updateScrollbars,, destroyScrollbars] = createScrollbarsSetup(target, currentOptions, structureState._elements);
-
- const update = (changedOptions, force) => {
- updateStructure(changedOptions, force);
- updateScrollbars(changedOptions, force);
+ const [g, h, p] = createStructureSetup(t, u);
+ const [v, , w] = createScrollbarsSetup(t, u, h.Mt);
+ const update = (t, n) => {
+ g(t, n);
+ v(t, n);
};
-
- const removeEnvListener = addEnvListener(update.bind(0, {}, true));
-
- structureState._addOnUpdatedListener((updateHints, changedOptions, force) => {
- const {
- _sizeChanged,
- _directionChanged,
- _heightIntrinsicChanged,
- _overflowAmountChanged,
- _overflowStyleChanged,
- _contentMutation,
- _hostMutation
- } = updateHints;
- triggerEvent('updated', {
+ const b = c(update.bind(0, {}, true));
+ h.Pt(((t, n, o) => {
+ const {it: e, ut: s, ct: c, xt: i, Ct: r, rt: a, bt: l} = t;
+ _("updated", {
updateHints: {
- sizeChanged: _sizeChanged,
- directionChanged: _directionChanged,
- heightIntrinsicChanged: _heightIntrinsicChanged,
- overflowAmountChanged: _overflowAmountChanged,
- overflowStyleChanged: _overflowStyleChanged,
- contentMutation: _contentMutation,
- hostMutation: _hostMutation
+ sizeChanged: e,
+ directionChanged: s,
+ heightIntrinsicChanged: c,
+ overflowAmountChanged: i,
+ overflowStyleChanged: r,
+ contentMutation: a,
+ hostMutation: l
},
- changedOptions,
- force
+ changedOptions: n,
+ force: o
});
- });
-
- const instance = {
- options(newOptions) {
- if (newOptions) {
- const changedOptions = getOptionsDiff(currentOptions, validateOptions(newOptions));
-
- if (!isEmptyObject(changedOptions)) {
- assignDeep(currentOptions, changedOptions);
- update(changedOptions);
+ }));
+ const y = {
+ options(t) {
+ if (t) {
+ const n = getOptionsDiff(u, validateOptions(t));
+ if (!isEmptyObject(n)) {
+ assignDeep(u, n);
+ update(n);
}
}
-
- return assignDeep({}, currentOptions);
+ return assignDeep({}, u);
},
-
- on: addEvent,
- off: removeEvent,
-
+ on: f,
+ off: d,
state() {
- const {
- _overflowAmount,
- _overflowStyle,
- _hasOverflow,
- _padding,
- _paddingAbsolute
- } = structureState();
+ const {yt: t, vt: n, St: o, A: e, ft: s} = h();
return assignDeep({}, {
- overflowAmount: _overflowAmount,
- overflowStyle: _overflowStyle,
- hasOverflow: _hasOverflow,
- padding: _padding,
- paddingAbsolute: _paddingAbsolute
+ overflowAmount: t,
+ overflowStyle: n,
+ hasOverflow: o,
+ padding: e,
+ paddingAbsolute: s
});
},
-
elements() {
- const {
- _target,
- _host,
- _padding,
- _viewport,
- _content
- } = structureState._elements;
+ const {Y: t, V: n, A: o, U: e, $: s} = h.Mt;
return assignDeep({}, {
- target: _target,
- host: _host,
- padding: _padding || _viewport,
- viewport: _viewport,
- content: _content || _viewport
+ target: t,
+ host: n,
+ padding: o || e,
+ viewport: e,
+ content: s || e
});
},
-
- update(force) {
- update({}, force);
+ update(t) {
+ update({}, t);
},
-
destroy: () => {
- removeInstance(instanceTarget);
- removeEnvListener();
- removeEvent();
- destroyScrollbars();
- destroyStructure();
- triggerEvent('destroyed');
+ removeInstance(r);
+ b();
+ d();
+ w();
+ p();
+ _("destroyed");
}
};
- each(keys(plugins), pluginName => {
- const pluginInstance = plugins[pluginName];
-
- if (isFunction(pluginInstance)) {
- pluginInstance(OverlayScrollbars, instance);
+ each(keys(i), (t => {
+ const n = i[t];
+ if (isFunction(n)) {
+ n(OverlayScrollbars, y);
}
- });
- instance.update(true);
- addInstance(instanceTarget, instance);
- triggerEvent('initialized');
- return instance;
+ }));
+ y.update(true);
+ addInstance(r, y);
+ _("initialized");
+ return y;
};
+
OverlayScrollbars.plugin = addPlugin;
OverlayScrollbars.env = () => {
- const {
- _nativeScrollbarSize,
- _nativeScrollbarIsOverlaid,
- _nativeScrollbarStyling,
- _rtlScrollBehavior,
- _flexboxGlue,
- _cssCustomProperties,
- _defaultInitializationStrategy,
- _defaultDefaultOptions,
- _getInitializationStrategy,
- _setInitializationStrategy,
- _getDefaultOptions,
- _setDefaultOptions
- } = getEnvironment();
+ const {L: t, I: n, T: o, P: e, M: s, D: c, k: i, B: r, N: a, R: l, F: u, H: f} = getEnvironment();
return assignDeep({}, {
- scrollbarSize: _nativeScrollbarSize,
- scrollbarIsOverlaid: _nativeScrollbarIsOverlaid,
- scrollbarStyling: _nativeScrollbarStyling,
- rtlScrollBehavior: _rtlScrollBehavior,
- flexboxGlue: _flexboxGlue,
- cssCustomProperties: _cssCustomProperties,
- defaultInitializationStrategy: _defaultInitializationStrategy,
- defaultDefaultOptions: _defaultDefaultOptions,
- getInitializationStrategy: _getInitializationStrategy,
- setInitializationStrategy: _setInitializationStrategy,
- getDefaultOptions: _getDefaultOptions,
- setDefaultOptions: _setDefaultOptions
+ scrollbarSize: t,
+ scrollbarIsOverlaid: n,
+ scrollbarStyling: o,
+ rtlScrollBehavior: e,
+ flexboxGlue: s,
+ cssCustomProperties: c,
+ defaultInitializationStrategy: i,
+ defaultDefaultOptions: r,
+ getInitializationStrategy: a,
+ setInitializationStrategy: l,
+ getDefaultOptions: u,
+ setDefaultOptions: f
});
};
diff --git a/packages/overlayscrollbars/dist/overlayscrollbars.esm.js.map b/packages/overlayscrollbars/dist/overlayscrollbars.esm.js.map
index 7a7017a..2aa0132 100644
--- a/packages/overlayscrollbars/dist/overlayscrollbars.esm.js.map
+++ b/packages/overlayscrollbars/dist/overlayscrollbars.esm.js.map
@@ -1 +1 @@
-{"version":3,"file":"overlayscrollbars.esm.js","sources":["../src/support/cache.ts","../src/support/utils/types.ts","../src/support/utils/array.ts","../src/support/utils/object.ts","../src/support/dom/attribute.ts","../src/support/dom/traversal.ts","../src/support/dom/manipulation.ts","../src/support/dom/create.ts","../src/support/compatibility/vendors.ts","../src/support/compatibility/apis.ts","../src/support/dom/class.ts","../src/support/utils/equal.ts","../src/support/utils/function.ts","../src/support/dom/style.ts","../src/support/dom/dimensions.ts","../src/support/dom/events.ts","../src/support/dom/offset.ts","../src/support/eventListeners.ts","../src/setups/setups.ts","../src/classnames.ts","../src/options.ts","../src/environment.ts","../src/setups/structureSetup/structureSetup.elements.ts","../src/setups/structureSetup/updateSegments/trinsicUpdateSegment.ts","../src/setups/structureSetup/updateSegments/paddingUpdateSegment.ts","../src/setups/structureSetup/updateSegments/overflowUpdateSegment.ts","../src/setups/structureSetup/structureSetup.update.ts","../src/observers/sizeObserver.ts","../src/observers/trinsicObserver.ts","../src/observers/domObserver.ts","../src/setups/structureSetup/structureSetup.observers.ts","../src/setups/structureSetup/structureSetup.ts","../src/setups/scrollbarsSetup/scrollbarsSetup.elements.ts","../src/setups/scrollbarsSetup/scrollbarsSetup.ts","../src/plugins/plugins.ts","../src/plugins/optionsValidation/validation.ts","../src/plugins/optionsValidation/optionsValidation.ts","../src/instances.ts","../src/eventListeners.ts","../src/overlayscrollbars.ts"],"sourcesContent":["export interface CacheOptions {\r\n // initial value of _value.\r\n _initialValue: Value;\r\n // Custom comparison function if shallow compare isn't enough. Returns true if nothing changed.\r\n _equal?: EqualCachePropFunction;\r\n // If true always updates _value and _previous, otherwise they update only when they changed.\r\n _alwaysUpdateValues?: boolean;\r\n}\r\n\r\nexport type CacheValues = [value: T, changed: boolean, previous?: T];\r\n\r\nexport type EqualCachePropFunction = (currentVal: Value, newVal: Value) => boolean;\r\n\r\nexport type CacheUpdater = (current: Value, previous?: Value) => Value;\r\n\r\nexport type UpdateCacheContextual = (newValue: Value, force?: boolean) => CacheValues;\r\n\r\nexport type UpdateCache = (force?: boolean) => CacheValues;\r\n\r\nexport type GetCurrentCache = (force?: boolean) => CacheValues;\r\n\r\nexport type Cache = [UpdateCache, GetCurrentCache];\r\n\r\nexport type CacheContextual = [UpdateCacheContextual, GetCurrentCache];\r\n\r\nexport function createCache(options: CacheOptions): CacheContextual;\r\nexport function createCache(\r\n options: CacheOptions,\r\n update: CacheUpdater\r\n): Cache;\r\nexport function createCache(\r\n options: CacheOptions,\r\n update?: CacheUpdater\r\n): CacheContextual | Cache {\r\n const { _initialValue, _equal, _alwaysUpdateValues } = options;\r\n let _value: Value = _initialValue;\r\n let _previous: Value | undefined;\r\n\r\n const cacheUpdateContextual: UpdateCacheContextual = (newValue, force?) => {\r\n const curr = _value;\r\n\r\n const newVal = newValue;\r\n const changed = force || (_equal ? !_equal(curr, newVal) : curr !== newVal);\r\n\r\n if (changed || _alwaysUpdateValues) {\r\n _value = newVal;\r\n _previous = curr;\r\n }\r\n\r\n return [_value, changed, _previous];\r\n };\r\n const cacheUpdateIsolated: UpdateCache = (force?) =>\r\n cacheUpdateContextual(update!(_value, _previous), force);\r\n\r\n const getCurrentCache: GetCurrentCache = (force?: boolean) => [\r\n _value,\r\n !!force, // changed\r\n _previous,\r\n ];\r\n\r\n return [update ? cacheUpdateIsolated : cacheUpdateContextual, getCurrentCache] as\r\n | CacheContextual\r\n | Cache;\r\n}\r\n","import { PlainObject } from 'typings';\r\n\r\nconst ElementNodeType = Node.ELEMENT_NODE;\r\nconst { toString, hasOwnProperty } = Object.prototype;\r\n\r\nexport function isUndefined(obj: any): obj is undefined {\r\n return obj === undefined;\r\n}\r\n\r\nexport function isNull(obj: any): obj is null {\r\n return obj === null;\r\n}\r\n\r\nexport const type: (obj: any) => string = (obj) =>\r\n isUndefined(obj) || isNull(obj)\r\n ? `${obj}`\r\n : toString\r\n .call(obj)\r\n .replace(/^\\[object (.+)\\]$/, '$1')\r\n .toLowerCase();\r\n\r\nexport function isNumber(obj: any): obj is number {\r\n return typeof obj === 'number';\r\n}\r\n\r\nexport function isString(obj: any): obj is string {\r\n return typeof obj === 'string';\r\n}\r\n\r\nexport function isBoolean(obj: any): obj is boolean {\r\n return typeof obj === 'boolean';\r\n}\r\n\r\nexport function isFunction(obj: any): obj is (...args: any[]) => any {\r\n return typeof obj === 'function';\r\n}\r\n\r\nexport function isArray(obj: any): obj is Array {\r\n return Array.isArray(obj);\r\n}\r\n\r\nexport function isObject(obj: any): boolean {\r\n return typeof obj === 'object' && !isArray(obj) && !isNull(obj);\r\n}\r\n\r\n/**\r\n * Returns true if the given object is array like, false otherwise.\r\n * @param obj The Object\r\n */\r\nexport function isArrayLike(obj: any): obj is ArrayLike {\r\n const length = !!obj && obj.length;\r\n const lengthCorrectFormat = isNumber(length) && length > -1 && length % 1 == 0; // eslint-disable-line eqeqeq\r\n\r\n return isArray(obj) || (!isFunction(obj) && lengthCorrectFormat)\r\n ? length > 0 && isObject(obj)\r\n ? length - 1 in obj\r\n : true\r\n : false;\r\n}\r\n\r\n/**\r\n * Returns true if the given object is a \"plain\" (e.g. { key: value }) object, false otherwise.\r\n * @param obj The Object.\r\n */\r\nexport function isPlainObject(obj: any): obj is PlainObject {\r\n if (!obj || !isObject(obj) || type(obj) !== 'object') return false;\r\n\r\n let key;\r\n const cstr = 'constructor';\r\n const ctor = obj[cstr];\r\n const ctorProto = ctor && ctor.prototype;\r\n const hasOwnConstructor = hasOwnProperty.call(obj, cstr);\r\n const hasIsPrototypeOf = ctorProto && hasOwnProperty.call(ctorProto, 'isPrototypeOf');\r\n\r\n if (ctor && !hasOwnConstructor && !hasIsPrototypeOf) {\r\n return false;\r\n }\r\n\r\n /* eslint-disable no-restricted-syntax */\r\n for (key in obj) {\r\n /**/\r\n }\r\n /* eslint-enable */\r\n\r\n return isUndefined(key) || hasOwnProperty.call(obj, key);\r\n}\r\n\r\n/**\r\n * Checks whether the given object is a HTMLElement.\r\n * @param obj The object which shall be checked.\r\n */\r\nexport function isHTMLElement(obj: any): obj is HTMLElement {\r\n const instanceofObj = window.HTMLElement;\r\n return obj\r\n ? instanceofObj\r\n ? obj instanceof instanceofObj\r\n : obj.nodeType === ElementNodeType\r\n : false;\r\n}\r\n\r\n/**\r\n * Checks whether the given object is a Element.\r\n * @param obj The object which shall be checked.\r\n */\r\nexport function isElement(obj: any): obj is Element {\r\n const instanceofObj = window.Element;\r\n return obj\r\n ? instanceofObj\r\n ? obj instanceof instanceofObj\r\n : obj.nodeType === ElementNodeType\r\n : false;\r\n}\r\n","import { isArrayLike, isString } from 'support/utils/types';\r\nimport { PlainObject } from 'typings';\r\n\r\ntype RunEachItem = ((...args: any) => any | any[]) | null | undefined;\r\n\r\n/**\r\n * Iterates through a array or object\r\n * @param arrayLikeOrObject The array or object through which shall be iterated.\r\n * @param callback The function which is responsible for the iteration.\r\n * If the function returns true its treated like a \"continue\" statement.\r\n * If the function returns false its treated like a \"break\" statement.\r\n */\r\nexport function each(\r\n array: Array | ReadonlyArray,\r\n callback: (value: T, indexOrKey: number, source: Array) => boolean | unknown\r\n): Array | ReadonlyArray;\r\nexport function each(\r\n array: Array | ReadonlyArray | null | undefined,\r\n callback: (value: T, indexOrKey: number, source: Array) => boolean | unknown\r\n): Array | ReadonlyArray | null | undefined;\r\nexport function each(\r\n arrayLikeObject: ArrayLike,\r\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | unknown\r\n): ArrayLike;\r\nexport function each(\r\n arrayLikeObject: ArrayLike | null | undefined,\r\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | unknown\r\n): ArrayLike | null | undefined;\r\nexport function each(\r\n obj: PlainObject,\r\n callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | unknown\r\n): PlainObject;\r\nexport function each(\r\n obj: PlainObject | null | undefined,\r\n callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | unknown\r\n): PlainObject | null | undefined;\r\nexport function each(\r\n source: ArrayLike | PlainObject | null | undefined,\r\n callback: (value: T, indexOrKey: any, source: any) => boolean | unknown\r\n): Array | ReadonlyArray | ArrayLike | PlainObject | null | undefined {\r\n if (isArrayLike(source)) {\r\n for (let i = 0; i < source.length; i++) {\r\n if (callback(source[i], i, source) === false) {\r\n break;\r\n }\r\n }\r\n } else if (source) {\r\n each(Object.keys(source), (key) => callback(source[key], key, source));\r\n }\r\n return source;\r\n}\r\n\r\n/**\r\n * Returns the index of the given inside the given array or -1 if the given item isn't part of the given array.\r\n * @param arr The array.\r\n * @param item The item.\r\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\r\n */\r\nexport const indexOf = (arr: T[], item: T, fromIndex?: number): number =>\r\n arr.indexOf(item, fromIndex);\r\n\r\n/**\r\n * Pushesh all given items into the given array and returns it.\r\n * @param array The array the items shall be pushed into.\r\n * @param items The items which shall be pushed into the array.\r\n */\r\nexport const push = (array: T[], items: T | ArrayLike, arrayIsSingleItem?: boolean): T[] => {\r\n !arrayIsSingleItem && !isString(items) && isArrayLike(items)\r\n ? Array.prototype.push.apply(array, items as T[])\r\n : array.push(items as T);\r\n return array;\r\n};\r\n\r\n/**\r\n * Creates a shallow-copied Array instance from an array-like or iterable object.\r\n * @param arr The object from which the array instance shall be created.\r\n */\r\nexport const from = (arr?: ArrayLike | Set) => {\r\n if (Array.from && arr) {\r\n return Array.from(arr);\r\n }\r\n const result: T[] = [];\r\n\r\n if (arr instanceof Set) {\r\n arr.forEach((value) => {\r\n push(result, value);\r\n });\r\n } else {\r\n each(arr, (elm) => {\r\n push(result, elm);\r\n });\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * Check whether the passed array is empty.\r\n * @param array The array which shall be checked.\r\n */\r\nexport const isEmptyArray = (array: any[] | null | undefined): boolean =>\r\n !!array && array.length === 0;\r\n\r\n/**\r\n * Calls all functions in the passed array/set of functions.\r\n * @param arr The array filled with function which shall be called.\r\n * @param p1 The first param.\r\n */\r\nexport const runEach = (arr: ArrayLike | Set, args?: any[]): void => {\r\n // eslint-disable-next-line prefer-spread\r\n const runFn = (fn: RunEachItem) => fn && fn.apply(undefined, args || []);\r\n if (arr instanceof Set) {\r\n arr.forEach(runFn);\r\n } else {\r\n each(arr, runFn);\r\n }\r\n};\r\n","import { isArray, isFunction, isPlainObject, isNull } from 'support/utils/types';\r\nimport { each } from 'support/utils/array';\r\n\r\n/**\r\n * Determines whether the passed object has a property with the passed name.\r\n * @param obj The object.\r\n * @param prop The name of the property.\r\n */\r\nexport const hasOwnProperty = (obj: any, prop: string | number | symbol): boolean =>\r\n Object.prototype.hasOwnProperty.call(obj, prop);\r\n\r\n/**\r\n * Returns the names of the enumerable string properties and methods of an object.\r\n * @param obj The object of which the properties shall be returned.\r\n */\r\nexport const keys = (obj: any): Array => (obj ? Object.keys(obj) : []);\r\n\r\n// https://github.com/jquery/jquery/blob/master/src/core.js#L116\r\nexport function assignDeep(target: T, object1: U): T & U;\r\nexport function assignDeep(target: T, object1: U, object2: V): T & U & V;\r\nexport function assignDeep(\r\n target: T,\r\n object1: U,\r\n object2: V,\r\n object3: W\r\n): T & U & V & W;\r\nexport function assignDeep(\r\n target: T,\r\n object1: U,\r\n object2: V,\r\n object3: W,\r\n object4: X\r\n): T & U & V & W & X;\r\nexport function assignDeep(\r\n target: T,\r\n object1: U,\r\n object2: V,\r\n object3: W,\r\n object4: X,\r\n object5: Y\r\n): T & U & V & W & X & Y;\r\nexport function assignDeep(\r\n target: T,\r\n object1?: U,\r\n object2?: V,\r\n object3?: W,\r\n object4?: X,\r\n object5?: Y,\r\n object6?: Z\r\n): T & U & V & W & X & Y & Z {\r\n const sources: Array = [object1, object2, object3, object4, object5, object6];\r\n\r\n // Handle case when target is a string or something (possible in deep copy)\r\n if ((typeof target !== 'object' || isNull(target)) && !isFunction(target)) {\r\n target = {} as T;\r\n }\r\n\r\n each(sources, (source) => {\r\n // Extend the base object\r\n each(keys(source), (key) => {\r\n const copy: any = source[key];\r\n\r\n // Prevent Object.prototype pollution\r\n // Prevent never-ending loop\r\n if (target === copy) {\r\n return true;\r\n }\r\n\r\n const copyIsArray = isArray(copy);\r\n\r\n // Recurse if we're merging plain objects or arrays\r\n if (copy && (isPlainObject(copy) || copyIsArray)) {\r\n const src = target[key];\r\n let clone: any = src;\r\n\r\n // Ensure proper type for the source value\r\n if (copyIsArray && !isArray(src)) {\r\n clone = [];\r\n } else if (!copyIsArray && !isPlainObject(src)) {\r\n clone = {};\r\n }\r\n\r\n // Never move original objects, clone them\r\n target[key] = assignDeep(clone, copy) as any;\r\n } else {\r\n target[key] = copy;\r\n }\r\n });\r\n });\r\n\r\n // Return the modified object\r\n return target as any;\r\n}\r\n\r\n/**\r\n * Returns true if the given object is empty, false otherwise.\r\n * @param obj The Object.\r\n */\r\nexport function isEmptyObject(obj: any): boolean {\r\n /* eslint-disable no-restricted-syntax, guard-for-in */\r\n for (const name in obj) return false;\r\n return true;\r\n /* eslint-enable */\r\n}\r\n","import { from } from 'support/utils/array';\r\nimport { isUndefined } from 'support/utils/types';\r\n\r\ntype GetSetPropName = 'scrollLeft' | 'scrollTop' | 'value';\r\n\r\nfunction getSetProp(\r\n topLeft: GetSetPropName,\r\n fallback: number | string,\r\n elm: HTMLElement | HTMLInputElement | false | null | undefined,\r\n value?: number | string\r\n): number | string | void {\r\n if (isUndefined(value)) {\r\n return elm ? elm[topLeft] : fallback;\r\n }\r\n elm && (elm[topLeft] = value);\r\n}\r\n\r\n/**\r\n * Gets or sets a attribute with the given attribute of the given element depending whether the value attribute is given.\r\n * Returns null if the element has no attribute with the given name.\r\n * @param elm The element of which the attribute shall be get or set.\r\n * @param attrName The attribute name which shall be get or set.\r\n * @param value The value of the attribute which shall be set.\r\n */\r\nexport function attr(elm: HTMLElement | false | null | undefined, attrName: string): string | null;\r\nexport function attr(\r\n elm: HTMLElement | false | null | undefined,\r\n attrName: string,\r\n value: string\r\n): void;\r\nexport function attr(\r\n elm: HTMLElement | false | null | undefined,\r\n attrName: string,\r\n value?: string\r\n): string | null | void {\r\n if (isUndefined(value)) {\r\n return elm ? elm.getAttribute(attrName) : null;\r\n }\r\n elm && elm.setAttribute(attrName, value);\r\n}\r\n\r\nexport const attrClass = (\r\n elm: HTMLElement | false | null | undefined,\r\n attrName: string,\r\n value: string,\r\n add?: boolean\r\n) => {\r\n const currValues = attr(elm, attrName) || '';\r\n const currValuesSet = new Set(currValues.split(' '));\r\n currValuesSet[add ? 'add' : 'delete'](value);\r\n\r\n attr(elm, attrName, from(currValuesSet).join(' ').trim());\r\n};\r\n\r\nexport const hasAttrClass = (\r\n elm: HTMLElement | false | null | undefined,\r\n attrName: string,\r\n value: string\r\n) => {\r\n const currValues = attr(elm, attrName) || '';\r\n const currValuesSet = new Set(currValues.split(' '));\r\n return currValuesSet.has(value);\r\n};\r\n\r\n/**\r\n * Removes the given attribute from the given element.\r\n * @param elm The element of which the attribute shall be removed.\r\n * @param attrName The attribute name.\r\n */\r\nexport const removeAttr = (elm: Element | false | null | undefined, attrName: string): void => {\r\n elm && elm.removeAttribute(attrName);\r\n};\r\n\r\n/**\r\n * Gets or sets the scrollLeft value of the given element depending whether the value attribute is given.\r\n * @param elm The element of which the scrollLeft value shall be get or set.\r\n * @param value The scrollLeft value which shall be set.\r\n */\r\nexport function scrollLeft(elm: HTMLElement | false | null | undefined): number;\r\nexport function scrollLeft(elm: HTMLElement | false | null | undefined, value: number): void;\r\nexport function scrollLeft(\r\n elm: HTMLElement | false | null | undefined,\r\n value?: number\r\n): number | void {\r\n return getSetProp('scrollLeft', 0, elm, value) as number;\r\n}\r\n\r\n/**\r\n * Gets or sets the scrollTop value of the given element depending whether the value attribute is given.\r\n * @param elm The element of which the scrollTop value shall be get or set.\r\n * @param value The scrollTop value which shall be set.\r\n */\r\nexport function scrollTop(elm: HTMLElement | false | null | undefined): number;\r\nexport function scrollTop(elm: HTMLElement | false | null | undefined, value: number): void;\r\nexport function scrollTop(\r\n elm: HTMLElement | false | null | undefined,\r\n value?: number\r\n): number | void {\r\n return getSetProp('scrollTop', 0, elm, value) as number;\r\n}\r\n\r\n/**\r\n * Gets or sets the value of the given input element depending whether the value attribute is given.\r\n * @param elm The input element of which the value shall be get or set.\r\n * @param value The value which shall be set.\r\n */\r\nexport function val(elm: HTMLInputElement | false | null | undefined): string;\r\nexport function val(elm: HTMLInputElement | false | null | undefined, value: string): void;\r\nexport function val(\r\n elm: HTMLInputElement | false | null | undefined,\r\n value?: string\r\n): string | void {\r\n return getSetProp('value', '', elm, value) as string;\r\n}\r\n","import { isElement } from 'support/utils/types';\r\nimport { push, from } from 'support/utils/array';\r\n\r\ntype InputElementType = Element | Node | false | null | undefined;\r\ntype OutputElementType = Element | null;\r\n\r\nconst elmPrototype = Element.prototype;\r\n\r\n/**\r\n * Find all elements with the passed selector, outgoing (and including) the passed element or the document if no element was provided.\r\n * @param selector The selector which has to be searched by.\r\n * @param elm The element from which the search shall be outgoing.\r\n */\r\nconst find = (selector: string, elm?: InputElementType): Element[] => {\r\n const arr: Array = [];\r\n const rootElm = elm ? (isElement(elm) ? elm : null) : document;\r\n\r\n return rootElm ? push(arr, rootElm.querySelectorAll(selector)) : arr;\r\n};\r\n\r\n/**\r\n * Find the first element with the passed selector, outgoing (and including) the passed element or the document if no element was provided.\r\n * @param selector The selector which has to be searched by.\r\n * @param elm The element from which the search shall be outgoing.\r\n */\r\nconst findFirst = (selector: string, elm?: InputElementType): OutputElementType => {\r\n const rootElm = elm ? (isElement(elm) ? elm : null) : document;\r\n\r\n return rootElm ? rootElm.querySelector(selector) : null;\r\n};\r\n\r\n/**\r\n * Determines whether the passed element is matching with the passed selector.\r\n * @param elm The element which has to be compared with the passed selector.\r\n * @param selector The selector which has to be compared with the passed element. Additional selectors: ':visible' and ':hidden'.\r\n */\r\nconst is = (elm: InputElementType, selector: string): boolean => {\r\n if (isElement(elm)) {\r\n /* istanbul ignore next */\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n const fn: (...args: any) => boolean = elmPrototype.matches || elmPrototype.msMatchesSelector;\r\n return fn.call(elm, selector);\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Returns the children (no text-nodes or comments) of the passed element which are matching the passed selector. An empty array is returned if the passed element is null.\r\n * @param elm The element of which the children shall be returned.\r\n * @param selector The selector which must match with the children elements.\r\n */\r\nconst children = (elm: InputElementType, selector?: string): ReadonlyArray => {\r\n const childs: Array = [];\r\n\r\n return isElement(elm)\r\n ? push(\r\n childs,\r\n from(elm.children).filter((child) => (selector ? is(child, selector) : child))\r\n )\r\n : childs;\r\n};\r\n\r\n/**\r\n * Returns the childNodes (incl. text-nodes or comments etc.) of the passed element. An empty array is returned if the passed element is null.\r\n * @param elm The element of which the childNodes shall be returned.\r\n */\r\nconst contents = (elm: InputElementType): ReadonlyArray =>\r\n elm ? from(elm.childNodes) : [];\r\n\r\n/**\r\n * Returns the parent element of the passed element, or null if the passed element is null.\r\n * @param elm The element of which the parent element shall be returned.\r\n */\r\nconst parent = (elm: InputElementType): OutputElementType => (elm ? elm.parentElement : null);\r\n\r\nconst closest = (elm: InputElementType, selector: string): OutputElementType => {\r\n if (isElement(elm)) {\r\n const closestFn = elmPrototype.closest;\r\n if (closestFn) {\r\n return closestFn.call(elm, selector);\r\n }\r\n\r\n do {\r\n if (is(elm, selector)) {\r\n return elm as Element;\r\n }\r\n elm = parent(elm);\r\n } while (elm);\r\n }\r\n\r\n return null;\r\n};\r\n\r\n/**\r\n * Determines whether the given element lies between two selectors in the DOM.\r\n * @param elm The element.\r\n * @param highBoundarySelector The high boundary selector.\r\n * @param deepBoundarySelector The deep boundary selector.\r\n */\r\nconst liesBetween = (\r\n elm: InputElementType,\r\n highBoundarySelector: string,\r\n deepBoundarySelector: string\r\n): boolean => {\r\n const closestHighBoundaryElm = elm && closest(elm, highBoundarySelector);\r\n const closestDeepBoundaryElm = elm && findFirst(deepBoundarySelector, closestHighBoundaryElm);\r\n\r\n return closestHighBoundaryElm && closestDeepBoundaryElm\r\n ? closestHighBoundaryElm === elm ||\r\n closestDeepBoundaryElm === elm ||\r\n closest(closest(elm, deepBoundarySelector), highBoundarySelector) !== closestHighBoundaryElm\r\n : false;\r\n};\r\n\r\nexport { find, findFirst, is, children, contents, parent, liesBetween };\r\n","import { isArrayLike } from 'support/utils/types';\r\nimport { each, from } from 'support/utils/array';\r\nimport { parent } from 'support/dom/traversal';\r\n\r\ntype NodeCollection = ArrayLike | Node | false | null | undefined;\r\n\r\n/**\r\n * Inserts Nodes before the given preferredAnchor element.\r\n * @param parentElm The parent of the preferredAnchor element or the element which shall be the parent of the inserted Nodes.\r\n * @param preferredAnchor The element before which the Nodes shall be inserted or null if the elements shall be appended at the end.\r\n * @param insertedElms The Nodes which shall be inserted.\r\n */\r\nconst before = (\r\n parentElm: Node | false | null | undefined,\r\n preferredAnchor: Node | null | undefined,\r\n insertedElms: NodeCollection\r\n): void => {\r\n if (insertedElms) {\r\n let anchor: Node | null | undefined = preferredAnchor;\r\n let fragment: DocumentFragment | Node | null | undefined;\r\n\r\n // parent must be defined\r\n if (parentElm) {\r\n if (isArrayLike(insertedElms)) {\r\n fragment = document.createDocumentFragment();\r\n\r\n // append all insertedElms to the fragment and if one of these is the anchor, change the anchor\r\n each(insertedElms, (insertedElm) => {\r\n if (insertedElm === anchor) {\r\n anchor = insertedElm.previousSibling;\r\n }\r\n fragment!.appendChild(insertedElm);\r\n });\r\n } else {\r\n fragment = insertedElms;\r\n }\r\n\r\n // if the preferred anchor isn't null set it to a valid anchor\r\n if (preferredAnchor) {\r\n if (!anchor) {\r\n anchor = parentElm.firstChild;\r\n } else if (anchor !== preferredAnchor) {\r\n anchor = anchor.nextSibling;\r\n }\r\n }\r\n\r\n parentElm.insertBefore(fragment, anchor || null);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Appends the given children at the end of the given Node.\r\n * @param node The Node to which the children shall be appended.\r\n * @param children The Nodes which shall be appended.\r\n */\r\nexport const appendChildren = (node: Node | null | undefined, children: NodeCollection): void => {\r\n before(node, null, children);\r\n};\r\n\r\n/**\r\n * Prepends the given children at the start of the given Node.\r\n * @param node The Node to which the children shall be prepended.\r\n * @param children The Nodes which shall be prepended.\r\n */\r\nexport const prependChildren = (node: Node | null | undefined, children: NodeCollection): void => {\r\n before(node, node && node.firstChild, children);\r\n};\r\n\r\n/**\r\n * Inserts the given Nodes before the given Node.\r\n * @param node The Node before which the given Nodes shall be inserted.\r\n * @param insertedNodes The Nodes which shall be inserted.\r\n */\r\nexport const insertBefore = (\r\n node: Node | null | undefined,\r\n insertedNodes: NodeCollection\r\n): void => {\r\n before(parent(node), node, insertedNodes);\r\n};\r\n\r\n/**\r\n * Inserts the given Nodes after the given Node.\r\n * @param node The Node after which the given Nodes shall be inserted.\r\n * @param insertedNodes The Nodes which shall be inserted.\r\n */\r\nexport const insertAfter = (node: Node | null | undefined, insertedNodes: NodeCollection): void => {\r\n before(parent(node), node && node.nextSibling, insertedNodes);\r\n};\r\n\r\n/**\r\n * Removes the given Nodes from their parent.\r\n * @param nodes The Nodes which shall be removed.\r\n */\r\nexport const removeElements = (nodes: NodeCollection): void => {\r\n if (isArrayLike(nodes)) {\r\n each(from(nodes), (e) => removeElements(e));\r\n } else if (nodes) {\r\n const parentElm = parent(nodes);\r\n if (parentElm) {\r\n parentElm.removeChild(nodes);\r\n }\r\n }\r\n};\r\n","import { each } from 'support/utils/array';\r\nimport { attr } from 'support/dom/attribute';\r\nimport { contents } from 'support/dom/traversal';\r\nimport { removeElements } from 'support/dom/manipulation';\r\n\r\n/**\r\n * Creates a div DOM node.\r\n */\r\nexport const createDiv = (classNames?: string): HTMLDivElement => {\r\n const div = document.createElement('div');\r\n if (classNames) {\r\n attr(div, 'class', classNames);\r\n }\r\n return div;\r\n};\r\n\r\n/**\r\n * Creates DOM nodes modeled after the passed html string and returns the root dom nodes as a array.\r\n * @param html The html string after which the DOM nodes shall be created.\r\n */\r\nexport const createDOM = (html: string): ReadonlyArray => {\r\n const createdDiv = createDiv();\r\n createdDiv.innerHTML = html.trim();\r\n\r\n return each(contents(createdDiv), (elm) => removeElements(elm));\r\n};\r\n","import { each } from 'support/utils/array';\r\nimport { hasOwnProperty } from 'support/utils/object';\r\nimport { createDiv } from 'support/dom/create';\r\n\r\nconst firstLetterToUpper = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1);\r\nconst getDummyStyle = (): CSSStyleDeclaration => createDiv().style;\r\n\r\n// https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix\r\n\r\nexport const cssPrefixes: ReadonlyArray = ['-webkit-', '-moz-', '-o-', '-ms-'];\r\nexport const jsPrefixes: ReadonlyArray = [\r\n 'WebKit',\r\n 'Moz',\r\n 'O',\r\n 'MS',\r\n 'webkit',\r\n 'moz',\r\n 'o',\r\n 'ms',\r\n];\r\n\r\nexport const jsCache: { [key: string]: any } = {};\r\nexport const cssCache: { [key: string]: string } = {};\r\n\r\n/**\r\n * Gets the name of the given CSS property with vendor prefix if it isn't supported without it, or and empty string if unsupported.\r\n * @param name The name of the CSS property which shall be get.\r\n */\r\nexport const cssProperty = (name: string): string => {\r\n let result: string | undefined = cssCache[name];\r\n\r\n if (hasOwnProperty(cssCache, name)) {\r\n return result;\r\n }\r\n\r\n const uppercasedName: string = firstLetterToUpper(name);\r\n const elmStyle: CSSStyleDeclaration = getDummyStyle();\r\n\r\n each(cssPrefixes, (prefix: string) => {\r\n const prefixWithoutDashes: string = prefix.replace(/-/g, '');\r\n const resultPossibilities: Array = [\r\n name, // transition\r\n prefix + name, // -webkit-transition\r\n prefixWithoutDashes + uppercasedName, // webkitTransition\r\n firstLetterToUpper(prefixWithoutDashes) + uppercasedName, // WebkitTransition\r\n ];\r\n\r\n // eslint-disable-next-line no-return-assign\r\n return !(result = resultPossibilities.find(\r\n (resultPossibility: string) => elmStyle[resultPossibility] !== undefined\r\n ));\r\n });\r\n\r\n // eslint-disable-next-line no-return-assign\r\n return (cssCache[name] = result || '');\r\n};\r\n\r\n/**\r\n * Get the name of the given CSS property value(s), with vendor prefix if it isn't supported without it, or an empty string if no value is supported.\r\n * @param property The CSS property to which the CSS property value(s) belong.\r\n * @param values The value(s) separated by spaces which shall be get.\r\n * @param suffix A suffix which is added to each value in case the value is a function or something else more advanced.\r\n */\r\nexport const cssPropertyValue = (property: string, values: string, suffix?: string): string => {\r\n const name = `${property} ${values}`;\r\n let result: string | undefined = cssCache[name];\r\n\r\n if (hasOwnProperty(cssCache, name)) {\r\n return result;\r\n }\r\n\r\n const dummyStyle: CSSStyleDeclaration = getDummyStyle();\r\n const possbleValues: Array = values.split(' ');\r\n const preparedSuffix: string = suffix || '';\r\n const cssPrefixesWithFirstEmpty = [''].concat(cssPrefixes);\r\n\r\n each(possbleValues, (possibleValue: string) => {\r\n each(cssPrefixesWithFirstEmpty, (prefix: string) => {\r\n const prop = prefix + possibleValue;\r\n dummyStyle.cssText = `${property}:${prop}${preparedSuffix}`;\r\n if (dummyStyle.length) {\r\n result = prop;\r\n return false;\r\n }\r\n });\r\n return !result;\r\n });\r\n\r\n // eslint-disable-next-line no-return-assign\r\n return (cssCache[name] = result || '');\r\n};\r\n\r\n/**\r\n * Get the requested JS function, object or constructor with vendor prefix if it isn't supported without or undefined if unsupported.\r\n * @param name The name of the JS function, object or constructor.\r\n */\r\nexport const jsAPI = (name: string): T | undefined => {\r\n let result: any = jsCache[name] || window[name];\r\n\r\n if (hasOwnProperty(jsCache, name)) {\r\n return result;\r\n }\r\n\r\n each(jsPrefixes, (prefix: string) => {\r\n result = result || window[prefix + firstLetterToUpper(name)];\r\n return !result;\r\n });\r\n\r\n jsCache[name] = result;\r\n return result;\r\n};\r\n","import { jsAPI } from 'support/compatibility/vendors';\r\n\r\nexport const MutationObserverConstructor = jsAPI('MutationObserver');\r\nexport const IntersectionObserverConstructor = jsAPI(\r\n 'IntersectionObserver'\r\n);\r\nexport const ResizeObserverConstructor = jsAPI('ResizeObserver');\r\nexport const cAF = jsAPI('cancelAnimationFrame');\r\nexport const rAF = jsAPI('requestAnimationFrame');\r\n","import { isString } from 'support/utils/types';\r\nimport { each } from 'support/utils/array';\r\nimport { keys } from 'support/utils/object';\r\n\r\nconst rnothtmlwhite = /[^\\x20\\t\\r\\n\\f]+/g;\r\nconst classListAction = (\r\n elm: Element | false | null | undefined,\r\n className: string | false | null | undefined,\r\n action: (elmClassList: DOMTokenList, clazz: string) => boolean | void\r\n): boolean => {\r\n let clazz: string;\r\n let i = 0;\r\n let result = false;\r\n\r\n if (elm && className && isString(className)) {\r\n const classes: Array = className.match(rnothtmlwhite) || [];\r\n result = classes.length > 0;\r\n while ((clazz = classes[i++])) {\r\n result = !!action(elm.classList, clazz) && result;\r\n }\r\n }\r\n return result;\r\n};\r\n\r\n/**\r\n * Check whether the given element has the given class name(s).\r\n * @param elm The element.\r\n * @param className The class name(s).\r\n */\r\nexport const hasClass = (\r\n elm: Element | false | null | undefined,\r\n className: string | false | null | undefined\r\n): boolean => classListAction(elm, className, (classList, clazz) => classList.contains(clazz));\r\n\r\n/**\r\n * Removes the given class name(s) from the given element.\r\n * @param elm The element.\r\n * @param className The class name(s) which shall be removed. (separated by spaces)\r\n */\r\nexport const removeClass = (\r\n elm: Element | false | null | undefined,\r\n className: string | false | null | undefined\r\n): void => {\r\n classListAction(elm, className, (classList, clazz) => classList.remove(clazz));\r\n};\r\n\r\n/**\r\n * Adds the given class name(s) to the given element.\r\n * @param elm The element.\r\n * @param className The class name(s) which shall be added. (separated by spaces)\r\n * @returns A function which removes the added class name(s).\r\n */\r\nexport const addClass = (\r\n elm: Element | false | null | undefined,\r\n className: string | false | null | undefined\r\n): (() => void) => {\r\n classListAction(elm, className, (classList, clazz) => classList.add(clazz));\r\n return removeClass.bind(0, elm, className);\r\n};\r\n\r\n/**\r\n * Takes two className strings, compares them and returns the difference as array.\r\n * @param classNameA ClassName A.\r\n * @param classNameB ClassName B.\r\n */\r\nexport const diffClass = (\r\n classNameA: string | null | undefined,\r\n classNameB: string | null | undefined\r\n) => {\r\n const classNameASplit = classNameA && classNameA.split(' ');\r\n const classNameBSplit = classNameB && classNameB.split(' ');\r\n const tempObj = {};\r\n\r\n each(classNameASplit, (className) => {\r\n tempObj[className] = 1;\r\n });\r\n each(classNameBSplit, (className) => {\r\n if (tempObj[className]) {\r\n delete tempObj[className];\r\n } else {\r\n tempObj[className] = 1;\r\n }\r\n });\r\n\r\n return keys(tempObj);\r\n};\r\n","import { each } from 'support/utils/array';\r\nimport { WH, XY, TRBL } from 'support/dom';\r\nimport { PlainObject } from 'typings';\r\n\r\n/**\r\n * Compares two objects and returns true if all values of the passed prop names are identical, false otherwise or if one of the two object is falsy.\r\n * @param a Object a.\r\n * @param b Object b.\r\n * @param props The props which shall be compared.\r\n */\r\nexport const equal = (\r\n a: T | undefined,\r\n b: T | undefined,\r\n props: Array,\r\n propMutation?: ((value: any) => any) | null | false\r\n): boolean => {\r\n if (a && b) {\r\n let result = true;\r\n each(props, (prop) => {\r\n const compareA = propMutation ? propMutation(a[prop]) : a[prop];\r\n const compareB = propMutation ? propMutation(b[prop]) : b[prop];\r\n if (compareA !== compareB) {\r\n result = false;\r\n }\r\n });\r\n return result;\r\n }\r\n return false;\r\n};\r\n\r\n/**\r\n * Compares object a with object b and returns true if both have the same property values, false otherwise.\r\n * Also returns false if one of the objects is undefined or null.\r\n * @param a Object a.\r\n * @param b Object b.\r\n */\r\nexport const equalWH = (a?: WH, b?: WH) => equal>(a, b, ['w', 'h']);\r\n\r\n/**\r\n * Compares object a with object b and returns true if both have the same property values, false otherwise.\r\n * Also returns false if one of the objects is undefined or null.\r\n * @param a Object a.\r\n * @param b Object b.\r\n */\r\nexport const equalXY = (a?: XY, b?: XY) => equal>(a, b, ['x', 'y']);\r\n\r\n/**\r\n * Compares object a with object b and returns true if both have the same property values, false otherwise.\r\n * Also returns false if one of the objects is undefined or null.\r\n * @param a Object a.\r\n * @param b Object b.\r\n */\r\nexport const equalTRBL = (a?: TRBL, b?: TRBL) => equal(a, b, ['t', 'r', 'b', 'l']);\r\n\r\n/**\r\n * Compares two DOM Rects for their equality of their width and height properties\r\n * Also returns false if one of the DOM Rects is undefined or null.\r\n * @param a DOM Rect a.\r\n * @param b DOM Rect b.\r\n * @param round Whether the values should be rounded.\r\n */\r\nexport const equalBCRWH = (a?: DOMRect, b?: DOMRect, round?: boolean) =>\r\n equal(a, b, ['width', 'height'], round && ((value) => Math.round(value)));\r\n","import { isNumber, isFunction } from 'support/utils/types';\r\nimport { from } from 'support/utils/array';\r\nimport { rAF, cAF } from 'support/compatibility/apis';\r\n\r\nconst clearTimeouts = (id: number | undefined) => {\r\n id && window.clearTimeout(id);\r\n id && cAF!(id);\r\n};\r\n\r\ntype DebounceTiming = number | false | null | undefined;\r\n\r\nexport interface DebounceOptions any> {\r\n /**\r\n * The timeout for debouncing. If null, no debounce is applied.\r\n */\r\n _timeout?: DebounceTiming | (() => DebounceTiming);\r\n /**\r\n * A maximum amount of ms. before the function will be called even with debounce.\r\n */\r\n _maxDelay?: DebounceTiming | (() => DebounceTiming);\r\n /**\r\n * Function which merges parameters for each canceled debounce.\r\n * If parameters can't be merged the function will return null, otherwise it returns the merged parameters.\r\n */\r\n _mergeParams?: (\r\n prev: Parameters,\r\n curr: Parameters\r\n ) => Parameters | false | null | undefined;\r\n}\r\n\r\nexport interface Debounced any> {\r\n (...args: Parameters): ReturnType;\r\n _flush(): void;\r\n}\r\n\r\nexport const noop = () => {}; // eslint-disable-line\r\n\r\n/**\r\n * Debounces the given function either with a timeout or a animation frame.\r\n * @param functionToDebounce The function which shall be debounced.\r\n * @param options Options for debouncing.\r\n */\r\nexport const debounce = any>(\r\n functionToDebounce: FunctionToDebounce,\r\n options?: DebounceOptions\r\n): Debounced => {\r\n let timeoutId: number | undefined;\r\n let maxTimeoutId: number | undefined;\r\n let prevArguments: Parameters | null | undefined;\r\n let latestArguments: Parameters | null | undefined;\r\n const { _timeout, _maxDelay, _mergeParams } = options || {};\r\n const setT = window.setTimeout;\r\n\r\n const invokeFunctionToDebounce = function (args: IArguments) {\r\n clearTimeouts(timeoutId);\r\n clearTimeouts(maxTimeoutId);\r\n maxTimeoutId = timeoutId = prevArguments = undefined;\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n functionToDebounce.apply(this, args);\r\n };\r\n\r\n const mergeParms = (\r\n curr: Parameters\r\n ): Parameters | false | null | undefined =>\r\n _mergeParams && prevArguments ? _mergeParams(prevArguments, curr) : curr;\r\n\r\n const flush = () => {\r\n /* istanbul ignore next */\r\n if (timeoutId) {\r\n invokeFunctionToDebounce(mergeParms(latestArguments!) || latestArguments!);\r\n }\r\n };\r\n\r\n const debouncedFn = function () {\r\n // eslint-disable-next-line prefer-rest-params\r\n const args: Parameters = from(arguments) as Parameters;\r\n const finalTimeout = isFunction(_timeout) ? _timeout() : _timeout;\r\n const hasTimeout = isNumber(finalTimeout) && finalTimeout >= 0;\r\n\r\n if (hasTimeout) {\r\n const finalMaxWait = isFunction(_maxDelay) ? _maxDelay() : _maxDelay;\r\n const hasMaxWait = isNumber(finalMaxWait) && finalMaxWait >= 0;\r\n const setTimeoutFn = finalTimeout > 0 ? setT : rAF!;\r\n const mergeParamsResult = mergeParms(args);\r\n const invokedArgs = mergeParamsResult || args;\r\n const boundInvoke = invokeFunctionToDebounce.bind(0, invokedArgs);\r\n\r\n // if (!mergeParamsResult) {\r\n // invokeFunctionToDebounce(prevArguments || args);\r\n // }\r\n\r\n clearTimeouts(timeoutId);\r\n // @ts-ignore\r\n timeoutId = setTimeoutFn(boundInvoke, finalTimeout as number) as number;\r\n\r\n if (hasMaxWait && !maxTimeoutId) {\r\n maxTimeoutId = setT(flush, finalMaxWait as number);\r\n }\r\n\r\n prevArguments = latestArguments = invokedArgs;\r\n } else {\r\n invokeFunctionToDebounce(args);\r\n }\r\n };\r\n debouncedFn._flush = flush;\r\n\r\n return debouncedFn as Debounced;\r\n};\r\n","import { each, keys } from 'support/utils';\r\nimport { isString, isNumber, isArray, isUndefined } from 'support/utils/types';\r\nimport { PlainObject, StyleObject } from 'typings';\r\n\r\nexport interface TRBL {\r\n t: number;\r\n r: number;\r\n b: number;\r\n l: number;\r\n}\r\n\r\nconst cssNumber = {\r\n // animationiterationcount: 1,\r\n // columncount: 1,\r\n // fillopacity: 1,\r\n // flexgrow: 1,\r\n // flexshrink: 1,\r\n // fontweight: 1,\r\n // lineheight: 1,\r\n // order: 1,\r\n // orphans: 1,\r\n // widows: 1,\r\n // zoom: 1,\r\n opacity: 1,\r\n zindex: 1,\r\n};\r\n\r\nconst parseToZeroOrNumber = (value: string, toFloat?: boolean): number => {\r\n /* istanbul ignore next */\r\n const num = toFloat ? parseFloat(value) : parseInt(value, 10);\r\n /* istanbul ignore next */\r\n return Number.isNaN(num) ? 0 : num;\r\n};\r\nconst adaptCSSVal = (prop: string, val: string | number): string | number =>\r\n !cssNumber[prop.toLowerCase()] && isNumber(val) ? `${val}px` : val;\r\nconst getCSSVal = (elm: HTMLElement, computedStyle: CSSStyleDeclaration, prop: string): string =>\r\n /* istanbul ignore next */\r\n computedStyle != null\r\n ? computedStyle[prop] || computedStyle.getPropertyValue(prop)\r\n : elm.style[prop];\r\nconst setCSSVal = (\r\n elm: HTMLElement | false | null | undefined,\r\n prop: string,\r\n val: string | number\r\n): void => {\r\n try {\r\n if (elm) {\r\n const { style: elmStyle } = elm;\r\n if (!isUndefined(elmStyle[prop])) {\r\n elmStyle[prop] = adaptCSSVal(prop, val);\r\n } else {\r\n elmStyle.setProperty(prop, val as string);\r\n }\r\n }\r\n } catch (e) {}\r\n};\r\n\r\n/**\r\n * Gets or sets the passed styles to the passed element.\r\n * @param elm The element to which the styles shall be applied to / be read from.\r\n * @param styles The styles which shall be set or read.\r\n */\r\nexport function style(\r\n elm: HTMLElement | false | null | undefined,\r\n styles: StyleObject\r\n): void;\r\nexport function style(\r\n elm: HTMLElement | false | null | undefined,\r\n styles: string\r\n): string;\r\nexport function style(\r\n elm: HTMLElement | false | null | undefined,\r\n styles: Array | string\r\n): { [key: string]: string };\r\nexport function style(\r\n elm: HTMLElement | false | null | undefined,\r\n styles: StyleObject | Array | string\r\n): { [key: string]: string } | string | void {\r\n const getSingleStyle = isString(styles);\r\n const getStyles = isArray(styles) || getSingleStyle;\r\n\r\n if (getStyles) {\r\n let getStylesResult: string | PlainObject = getSingleStyle ? '' : {};\r\n if (elm) {\r\n const computedStyle: CSSStyleDeclaration = window.getComputedStyle(elm, null);\r\n getStylesResult = getSingleStyle\r\n ? getCSSVal(elm, computedStyle, styles as string)\r\n : (styles as Array).reduce((result, key) => {\r\n result[key] = getCSSVal(elm, computedStyle, key as string);\r\n return result;\r\n }, getStylesResult);\r\n }\r\n return getStylesResult;\r\n }\r\n each(keys(styles), (key) => setCSSVal(elm, key, styles[key]));\r\n}\r\n\r\n/**\r\n * Hides the passed element (display: none).\r\n * @param elm The element which shall be hidden.\r\n */\r\nexport const hide = (elm: HTMLElement | false | null | undefined): void => {\r\n style(elm, { display: 'none' });\r\n};\r\n\r\n/**\r\n * Shows the passed element (display: block).\r\n * @param elm The element which shall be shown.\r\n */\r\nexport const show = (elm: HTMLElement | false | null | undefined): void => {\r\n style(elm, { display: 'block' });\r\n};\r\n\r\n/**\r\n * Returns the top right bottom left values of the passed css property.\r\n * @param elm The element of which the values shall be returned.\r\n * @param propertyPrefix The css property prefix. (e.g. \"border\")\r\n * @param propertySuffix The css property suffix. (e.g. \"width\")\r\n */\r\nexport const topRightBottomLeft = (\r\n elm?: HTMLElement | false | null | undefined,\r\n propertyPrefix?: string,\r\n propertySuffix?: string\r\n): TRBL => {\r\n const finalPrefix = propertyPrefix ? `${propertyPrefix}-` : '';\r\n const finalSuffix = propertySuffix ? `-${propertySuffix}` : '';\r\n const top = `${finalPrefix}top${finalSuffix}`;\r\n const right = `${finalPrefix}right${finalSuffix}`;\r\n const bottom = `${finalPrefix}bottom${finalSuffix}`;\r\n const left = `${finalPrefix}left${finalSuffix}`;\r\n const result = style(elm, [top, right, bottom, left]);\r\n return {\r\n t: parseToZeroOrNumber(result[top]),\r\n r: parseToZeroOrNumber(result[right]),\r\n b: parseToZeroOrNumber(result[bottom]),\r\n l: parseToZeroOrNumber(result[left]),\r\n };\r\n};\r\n","import { style } from 'support/dom/style';\r\n\r\nexport interface WH {\r\n w: T;\r\n h: T;\r\n}\r\n\r\nconst elementHasDimensions = (elm: HTMLElement): boolean =>\r\n !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);\r\nconst zeroObj: WH = {\r\n w: 0,\r\n h: 0,\r\n};\r\n\r\n/**\r\n * Returns the window inner- width and height.\r\n */\r\nexport const windowSize = (): WH => ({\r\n w: window.innerWidth,\r\n h: window.innerHeight,\r\n});\r\n\r\n/**\r\n * Returns the scroll- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the scroll- width and height shall be returned.\r\n */\r\nexport const offsetSize = (elm: HTMLElement | null | undefined): WH =>\r\n elm\r\n ? {\r\n w: elm.offsetWidth,\r\n h: elm.offsetHeight,\r\n }\r\n : zeroObj;\r\n\r\n/**\r\n * Returns the client- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the client- width and height shall be returned.\r\n */\r\nexport const clientSize = (elm: HTMLElement | false | null | undefined): WH =>\r\n elm\r\n ? {\r\n w: elm.clientWidth,\r\n h: elm.clientHeight,\r\n }\r\n : zeroObj;\r\n\r\n/**\r\n * Returns the client- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the client- width and height shall be returned.\r\n */\r\nexport const scrollSize = (elm: HTMLElement | false | null | undefined): WH =>\r\n elm\r\n ? {\r\n w: elm.scrollWidth,\r\n h: elm.scrollHeight,\r\n }\r\n : zeroObj;\r\n\r\n/**\r\n * Returns the fractional- width and height of the passed element. If the element is null the width and height values are 0.\r\n * @param elm The element of which the fractional- width and height shall be returned.\r\n */\r\nexport const fractionalSize = (elm: HTMLElement | false | null | undefined): WH => {\r\n const cssHeight = parseFloat(style(elm, 'height')) || 0;\r\n const cssWidth = parseFloat(style(elm, 'height')) || 0;\r\n return {\r\n w: cssWidth - Math.round(cssWidth),\r\n h: cssHeight - Math.round(cssHeight),\r\n };\r\n};\r\n\r\n/**\r\n * Returns the BoundingClientRect of the passed element.\r\n * @param elm The element of which the BoundingClientRect shall be returned.\r\n */\r\nexport const getBoundingClientRect = (elm: HTMLElement): DOMRect => elm.getBoundingClientRect();\r\n\r\n/**\r\n * Determines whether the passed element has any dimensions.\r\n * @param elm The element.\r\n */\r\nexport const hasDimensions = (elm: HTMLElement | false | null | undefined): boolean =>\r\n elm ? elementHasDimensions(elm as HTMLElement) : false;\r\n","import { isUndefined } from 'support/utils/types';\r\nimport { each, push, runEach } from 'support/utils/array';\r\n\r\nlet passiveEventsSupport: boolean;\r\nconst supportPassiveEvents = (): boolean => {\r\n if (isUndefined(passiveEventsSupport)) {\r\n passiveEventsSupport = false;\r\n try {\r\n /* eslint-disable */\r\n // @ts-ignore\r\n window.addEventListener(\r\n 'test',\r\n null,\r\n Object.defineProperty({}, 'passive', {\r\n get: function () {\r\n passiveEventsSupport = true;\r\n },\r\n })\r\n );\r\n /* eslint-enable */\r\n } catch (e) {}\r\n }\r\n return passiveEventsSupport;\r\n};\r\nconst splitEventNames = (eventNames: string) => eventNames.split(' ');\r\n\r\nexport interface OnOptions {\r\n _capture?: boolean;\r\n _passive?: boolean;\r\n _once?: boolean;\r\n}\r\n\r\n/**\r\n * Removes the passed event listener for the passed events with the passed options.\r\n * @param target The element from which the listener shall be removed.\r\n * @param eventNames The eventsnames for which the listener shall be removed.\r\n * @param listener The listener which shall be removed.\r\n * @param capture The options of the removed listener.\r\n */\r\nexport const off = (\r\n target: EventTarget,\r\n eventNames: string,\r\n listener: (event: T) => any,\r\n capture?: boolean\r\n): void => {\r\n each(splitEventNames(eventNames), (eventName) => {\r\n target.removeEventListener(eventName, listener as EventListener, capture);\r\n });\r\n};\r\n\r\n/**\r\n * Adds the passed event listener for the passed eventnames with the passed options.\r\n * @param target The element to which the listener shall be added.\r\n * @param eventNames The eventsnames for which the listener shall be called.\r\n * @param listener The listener which is called on the eventnames.\r\n * @param options The options of the added listener.\r\n */\r\nexport const on = (\r\n target: EventTarget,\r\n eventNames: string,\r\n listener: (event: T) => any,\r\n options?: OnOptions\r\n): (() => void) => {\r\n const doSupportPassiveEvents = supportPassiveEvents();\r\n const passive = (doSupportPassiveEvents && options && options._passive) || false;\r\n const capture = (options && options._capture) || false;\r\n const once = (options && options._once) || false;\r\n const offListeners: (() => void)[] = [];\r\n const nativeOptions: AddEventListenerOptions | boolean = doSupportPassiveEvents\r\n ? {\r\n passive,\r\n capture,\r\n }\r\n : capture;\r\n\r\n each(splitEventNames(eventNames), (eventName) => {\r\n const finalListener = (once\r\n ? (evt: T) => {\r\n target.removeEventListener(eventName, finalListener, capture);\r\n listener && listener(evt);\r\n }\r\n : listener) as EventListener;\r\n\r\n push(offListeners, off.bind(null, target, eventName, finalListener, capture));\r\n target.addEventListener(eventName, finalListener, nativeOptions);\r\n });\r\n\r\n return runEach.bind(0, offListeners);\r\n};\r\n\r\n/**\r\n * Shorthand for the stopPropagation event Method.\r\n * @param evt The event of which the stopPropagation method shall be called.\r\n */\r\nexport const stopPropagation = (evt: Event): void => evt.stopPropagation();\r\n\r\n/**\r\n * Shorthand for the preventDefault event Method.\r\n * @param evt The event of which the preventDefault method shall be called.\r\n */\r\nexport const preventDefault = (evt: Event): void => evt.preventDefault();\r\n\r\n/**\r\n * Shorthand for the stopPropagation and preventDefault event Method.\r\n * @param evt The event of which the stopPropagation and preventDefault methods shall be called.\r\n */\r\nexport const stopAndPrevent = (evt: Event): void =>\r\n (stopPropagation(evt) as undefined) || (preventDefault(evt) as undefined);\r\n","import { getBoundingClientRect } from 'support/dom/dimensions';\r\n\r\nexport interface XY {\r\n x: T;\r\n y: T;\r\n}\r\n\r\nconst zeroObj: XY = {\r\n x: 0,\r\n y: 0,\r\n};\r\n\r\n/**\r\n * Returns the offset- left and top coordinates of the passed element relative to the document. If the element is null the top and left values are 0.\r\n * @param elm The element of which the offset- top and left coordinates shall be returned.\r\n */\r\nexport const absoluteCoordinates = (elm: HTMLElement | null | undefined): XY => {\r\n const rect = elm ? getBoundingClientRect(elm) : 0;\r\n return rect\r\n ? {\r\n x: rect.left + window.pageYOffset,\r\n y: rect.top + window.pageXOffset,\r\n }\r\n : zeroObj;\r\n};\r\n\r\n/**\r\n * Returns the offset- left and top coordinates of the passed element. If the element is null the top and left values are 0.\r\n * @param elm The element of which the offset- top and left coordinates shall be returned.\r\n */\r\nexport const offsetCoordinates = (elm: HTMLElement | null | undefined): XY =>\r\n elm\r\n ? {\r\n x: elm.offsetLeft,\r\n y: elm.offsetTop,\r\n }\r\n : zeroObj;\r\n","import { isArray } from 'support/utils/types';\r\nimport { keys } from 'support/utils/object';\r\nimport { each, from } from 'support/utils/array';\r\n\r\nexport type EventListener<\r\n NameArgsMap extends Record,\r\n Name extends Extract = Extract\r\n> = (...args: NameArgsMap[Name] extends undefined ? [] : [args: NameArgsMap[Name]]) => void;\r\n\r\nexport type EventListenerGroup<\r\n NameArgsMap extends Record,\r\n Name extends Extract = Extract\r\n> = EventListener | EventListener[];\r\n\r\nexport type AddEventListener> = <\r\n Name extends Extract\r\n>(\r\n name: Name,\r\n listener: EventListenerGroup\r\n) => () => void;\r\n\r\nexport type RemoveEventListener> = <\r\n Name extends Extract\r\n>(\r\n name?: Name,\r\n listener?: EventListenerGroup\r\n) => void;\r\n\r\nexport type TriggerEventListener> = <\r\n Name extends Extract\r\n>(\r\n name: Name,\r\n ...args: NameArgsMap[Name] extends undefined ? [] : [args: NameArgsMap[Name]]\r\n) => void;\r\n\r\nexport type InitialEventListeners> = {\r\n [K in Extract]?: EventListenerGroup;\r\n};\r\n\r\nconst manageListener = >(\r\n callback: (listener?: EventListener) => void,\r\n listener?: EventListener | EventListener[]\r\n) => {\r\n each(isArray(listener) ? listener : [listener], callback);\r\n};\r\n\r\nexport const createEventListenerHub = >(\r\n initialEventListeners?: InitialEventListeners\r\n): [\r\n AddEventListener,\r\n RemoveEventListener,\r\n TriggerEventListener\r\n] => {\r\n const events = new Map, Set>>();\r\n const removeEvent: RemoveEventListener = (name?, listener?) => {\r\n if (name) {\r\n const eventSet = events.get(name);\r\n manageListener((currListener) => {\r\n if (eventSet) {\r\n eventSet[currListener ? 'delete' : 'clear'](currListener!);\r\n }\r\n }, listener as EventListenerGroup | undefined);\r\n } else {\r\n events.forEach((eventSet) => {\r\n eventSet.clear();\r\n });\r\n events.clear();\r\n }\r\n };\r\n const addEvent: AddEventListener = (name, listener) => {\r\n const eventSet = events.get(name) || new Set();\r\n events.set(name, eventSet);\r\n\r\n manageListener((currListener) => {\r\n currListener && eventSet.add(currListener);\r\n }, listener as EventListenerGroup);\r\n\r\n return removeEvent.bind(0, name as any, listener as EventListenerGroup);\r\n };\r\n const triggerEvent: TriggerEventListener = (name, args?) => {\r\n const eventSet = events.get(name);\r\n\r\n each(from(eventSet), (event) => {\r\n if (args) {\r\n (event as (args: NameArgsMap[Extract]) => void)(args as any);\r\n } else {\r\n (event as () => void)();\r\n }\r\n });\r\n };\r\n\r\n const initialListenerKeys = keys(initialEventListeners) as Extract[];\r\n each(initialListenerKeys, (key) => {\r\n addEvent(key, initialEventListeners![key] as any);\r\n });\r\n\r\n return [addEvent, removeEvent, triggerEvent];\r\n};\r\n","import { assignDeep, hasOwnProperty } from 'support';\r\nimport type { OSOptions, ReadonlyOSOptions } from 'options';\r\nimport type { PartialOptions } from 'typings';\r\n\r\nexport type SetupElements> = [elements: T, destroy: () => void];\r\n\r\nexport type SetupUpdate = (\r\n changedOptions: PartialOptions,\r\n force?: boolean\r\n) => T;\r\n\r\nexport type SetupUpdateCheckOption = (path: string) => [value: T, changed: boolean];\r\n\r\nexport type SetupUpdateSegment> = (\r\n updateHints: Hints,\r\n checkOption: SetupUpdateCheckOption,\r\n force: boolean\r\n) => Partial | void;\r\n\r\nexport type SetupState> = [\r\n get: () => T,\r\n set: (newState: Partial) => void\r\n];\r\n\r\nexport type Setup = Record> = [\r\n update: SetupUpdate,\r\n state: (() => DynamicState) & StaticState,\r\n destroy: () => void\r\n];\r\n\r\nconst getPropByPath = (obj: any, path: string): T =>\r\n obj\r\n ? path.split('.').reduce((o, prop) => (o && hasOwnProperty(o, prop) ? o[prop] : undefined), obj)\r\n : undefined;\r\n\r\nexport const createOptionCheck =\r\n (\r\n options: ReadonlyOSOptions,\r\n changedOptions: PartialOptions,\r\n force?: boolean\r\n ): SetupUpdateCheckOption =>\r\n (path: string) =>\r\n [getPropByPath(options, path), force || getPropByPath(changedOptions, path) !== undefined];\r\n\r\nexport const createState = (initialState: S): SetupState => {\r\n let state: S = initialState;\r\n return [\r\n () => state,\r\n (newState: Partial) => {\r\n state = assignDeep({}, state, newState);\r\n },\r\n ];\r\n};\r\n","export const classNameEnvironment = 'os-environment';\r\nexport const classNameEnvironmentFlexboxGlue = `${classNameEnvironment}-flexbox-glue`;\r\nexport const classNameEnvironmentFlexboxGlueMax = `${classNameEnvironmentFlexboxGlue}-max`;\r\n\r\nexport const dataAttributeHost = 'data-overlayscrollbars';\r\nexport const dataAttributeHostOverflowX = `${dataAttributeHost}-overflow-x`;\r\nexport const dataAttributeHostOverflowY = `${dataAttributeHost}-overflow-y`;\r\nexport const dataValueHostOverflowVisible = 'overflowVisible';\r\nexport const dataValueHostViewportScrollbarStyling = 'viewportStyled';\r\nexport const classNamePadding = 'os-padding';\r\nexport const classNameViewport = 'os-viewport';\r\nexport const classNameViewportArrange = `${classNameViewport}-arrange`;\r\nexport const classNameContent = 'os-content';\r\nexport const classNameViewportScrollbarStyling = `${classNameViewport}-scrollbar-styled`;\r\nexport const classNameOverflowVisible = `os-overflow-visible`;\r\n\r\nexport const classNameSizeObserver = 'os-size-observer';\r\nexport const classNameSizeObserverAppear = `${classNameSizeObserver}-appear`;\r\nexport const classNameSizeObserverListener = `${classNameSizeObserver}-listener`;\r\nexport const classNameSizeObserverListenerScroll = `${classNameSizeObserverListener}-scroll`;\r\nexport const classNameSizeObserverListenerItem = `${classNameSizeObserverListener}-item`;\r\nexport const classNameSizeObserverListenerItemFinal = `${classNameSizeObserverListenerItem}-final`;\r\n\r\nexport const classNameTrinsicObserver = 'os-trinsic-observer';\r\n\r\nexport const classNameScrollbar = 'os-scrollbar';\r\nexport const classNameScrollbarHorizontal = `${classNameScrollbar}-horizontal`;\r\nexport const classNameScrollbarVertical = `${classNameScrollbar}-vertical`;\r\nexport const classNameScrollbarTrack = 'os-scrollbar-track';\r\nexport const classNameScrollbarHandle = 'os-scrollbar-handle';\r\n","import { assignDeep, each, isObject, keys, isArray, hasOwnProperty, isFunction } from 'support';\r\nimport { PartialOptions, ReadonlyOptions } from 'typings';\r\n\r\nconst stringify = (value: any) =>\r\n JSON.stringify(value, (_, val) => {\r\n if (isFunction(val)) {\r\n throw new Error();\r\n }\r\n return val;\r\n });\r\n\r\nexport type ResizeBehavior = 'none' | 'both' | 'horizontal' | 'vertical';\r\n\r\nexport type OverflowBehavior =\r\n | 'hidden'\r\n | 'scroll'\r\n | 'visible'\r\n | 'visible-hidden'\r\n | 'visible-scroll';\r\n\r\nexport type VisibilityBehavior = 'visible' | 'hidden' | 'auto';\r\n\r\nexport type AutoHideBehavior = 'never' | 'scroll' | 'leave' | 'move';\r\n\r\nexport type ScrollBehavior = 'always' | 'ifneeded' | 'never';\r\n\r\nexport type BasicEventCallback = (this: any) => void;\r\n\r\nexport type ScrollEventCallback = (this: any, args?: UIEvent) => void;\r\n\r\nexport type OverflowChangedCallback = (this: any, args?: OverflowChangedArgs) => void;\r\n\r\nexport type OverflowAmountChangedCallback = (this: any, args?: OverflowAmountChangedArgs) => void;\r\n\r\nexport type DirectionChangedCallback = (this: any, args?: DirectionChangedArgs) => void;\r\n\r\nexport type SizeChangedCallback = (this: any, args?: SizeChangedArgs) => void;\r\n\r\nexport type UpdatedCallback = (this: any, args?: UpdatedArgs) => void;\r\n\r\nexport interface OSOptions {\r\n paddingAbsolute: boolean;\r\n updating: {\r\n elementEvents: Array<[elementSelector: string, eventNames: string]> | null;\r\n attributes: string[] | null;\r\n debounce: [timeout: number, maxWait: number] | number | null; // (if tuple: [timeout: 0, maxWait: 33], if number: [timeout: number, maxWait: false]) debounce for content Changes\r\n ignoreMutation: ((mutation: MutationRecord) => any) | null;\r\n };\r\n overflow: {\r\n x: OverflowBehavior;\r\n y: OverflowBehavior;\r\n };\r\n scrollbars: {\r\n visibility: VisibilityBehavior;\r\n autoHide: AutoHideBehavior;\r\n autoHideDelay: number;\r\n dragScroll: boolean;\r\n clickScroll: boolean;\r\n touch: boolean;\r\n };\r\n nativeScrollbarsOverlaid: {\r\n show: boolean;\r\n initialize: boolean;\r\n };\r\n}\r\n\r\nexport type ReadonlyOSOptions = ReadonlyOptions;\r\n\r\nexport interface OverflowChangedArgs {\r\n x: boolean;\r\n y: boolean;\r\n xScrollable: boolean;\r\n yScrollable: boolean;\r\n clipped: boolean;\r\n}\r\n\r\nexport interface OverflowAmountChangedArgs {\r\n x: number;\r\n y: number;\r\n}\r\n\r\nexport interface DirectionChangedArgs {\r\n isRTL: number;\r\n dir: string;\r\n}\r\n\r\nexport interface SizeChangedArgs {\r\n width: number;\r\n height: number;\r\n}\r\n\r\nexport interface UpdatedArgs {\r\n forced: boolean;\r\n}\r\n\r\nexport const defaultOptions: OSOptions = {\r\n // resize: 'none', // none || both || horizontal || vertical || n || b || h || v\r\n paddingAbsolute: false, // true || false\r\n updating: {\r\n elementEvents: [['img', 'load']], // array of tuples || null\r\n debounce: [0, 33], // number || number array || null\r\n attributes: null, // string array || null\r\n ignoreMutation: null, // () => any || null\r\n },\r\n overflow: {\r\n x: 'scroll', // visible-hidden || visible-scroll || hidden || scroll || v-h || v-s || h || s\r\n y: 'scroll', // visible-hidden || visible-scroll || hidden || scroll || v-h || v-s || h || s\r\n },\r\n nativeScrollbarsOverlaid: {\r\n show: false, // true || false\r\n initialize: false, // true || false\r\n },\r\n scrollbars: {\r\n visibility: 'auto', // visible || hidden || auto || v || h || a\r\n autoHide: 'never', // never || scroll || leave || move || n || s || l || m\r\n autoHideDelay: 800, // number\r\n dragScroll: true, // true || false\r\n clickScroll: false, // true || false\r\n touch: true, // true || false\r\n },\r\n /*\r\n textarea: {\r\n dynWidth: false, // true || false\r\n dynHeight: false, // true || false\r\n inheritedAttrs: ['style', 'class'], // string || array || null\r\n },\r\n */\r\n};\r\n\r\nexport const getOptionsDiff = (\r\n currOptions: T,\r\n newOptions: PartialOptions\r\n): PartialOptions => {\r\n const diff: PartialOptions = {};\r\n const optionsKeys = keys(newOptions).concat(keys(currOptions));\r\n\r\n each(optionsKeys, (optionKey) => {\r\n const currOptionValue = currOptions[optionKey];\r\n const newOptionValue = newOptions[optionKey];\r\n\r\n if (isObject(currOptionValue) && isObject(newOptionValue)) {\r\n assignDeep((diff[optionKey] = {}), getOptionsDiff(currOptionValue, newOptionValue));\r\n } else if (hasOwnProperty(newOptions, optionKey) && newOptionValue !== currOptionValue) {\r\n let isDiff = true;\r\n\r\n if (isArray(currOptionValue) || isArray(newOptionValue)) {\r\n try {\r\n if (stringify(currOptionValue) === stringify(newOptionValue)) {\r\n isDiff = false;\r\n }\r\n } catch {}\r\n }\r\n\r\n if (isDiff) {\r\n diff[optionKey] = newOptionValue;\r\n }\r\n }\r\n });\r\n\r\n return diff;\r\n};\r\n","import {\r\n createDOM,\r\n addClass,\r\n style,\r\n appendChildren,\r\n fractionalSize,\r\n clientSize,\r\n absoluteCoordinates,\r\n offsetSize,\r\n scrollLeft,\r\n XY,\r\n removeAttr,\r\n removeElements,\r\n windowSize,\r\n equalBCRWH,\r\n getBoundingClientRect,\r\n assignDeep,\r\n cssProperty,\r\n createCache,\r\n equalXY,\r\n createEventListenerHub,\r\n EventListener,\r\n} from 'support';\r\nimport {\r\n classNameEnvironment,\r\n classNameEnvironmentFlexboxGlue,\r\n classNameEnvironmentFlexboxGlueMax,\r\n classNameViewportScrollbarStyling,\r\n} from 'classnames';\r\nimport { OSOptions, defaultOptions } from 'options';\r\nimport { OSTargetElement, PartialOptions } from 'typings';\r\n\r\ntype StructureInitializationStrategyElementFn =\r\n | ((target: OSTargetElement) => HTMLElement | T)\r\n | T;\r\n\r\ntype ScrollbarsInitializationStrategyElementFn =\r\n | ((target: OSTargetElement, host: HTMLElement, viewport: HTMLElement) => HTMLElement | T)\r\n | T;\r\n\r\n/**\r\n * A Static element is an element which MUST be generated.\r\n * If null or undefined (or the returned result is null or undefined), the initialization function is generatig the element, otherwise\r\n * the element returned by the function acts as the generated element.\r\n */\r\nexport type StructureInitializationStrategyStaticElement = StructureInitializationStrategyElementFn<\r\n null | undefined\r\n>;\r\n\r\n/**\r\n * A Dynamic element is an element which CAN be generated.\r\n * If boolean (or the returned result is boolean), the generation of the element is forced (or not).\r\n * If the function returns and element, the element returned by the function acts as the generated element.\r\n */\r\nexport type StructureInitializationStrategyDynamicElement =\r\n StructureInitializationStrategyElementFn;\r\n\r\nexport interface StructureInitializationStrategy {\r\n _host: StructureInitializationStrategyStaticElement;\r\n _viewport: StructureInitializationStrategyStaticElement;\r\n _padding: StructureInitializationStrategyDynamicElement;\r\n _content: StructureInitializationStrategyDynamicElement;\r\n}\r\n\r\nexport interface ScrollbarsInitializationStrategy {\r\n /**\r\n * The scrollbars slot. If null or undefined (or the returned result is null or undefined), the initialization function is deciding the element, otherwise\r\n * the element returned by the function acts as the scrollbars slot.\r\n */\r\n _scrollbarsSlot: ScrollbarsInitializationStrategyElementFn;\r\n}\r\n\r\nexport interface InitializationStrategy\r\n extends StructureInitializationStrategy,\r\n ScrollbarsInitializationStrategy {}\r\n\r\nexport type DefaultInitializationStrategy = {\r\n [K in keyof InitializationStrategy]: Extract<\r\n InitializationStrategy[K],\r\n boolean | null | undefined\r\n >;\r\n};\r\n\r\nexport interface EnvironmentListenersNameArgsMap {\r\n _: undefined;\r\n}\r\n\r\nexport interface Environment {\r\n readonly _nativeScrollbarSize: XY;\r\n readonly _nativeScrollbarIsOverlaid: XY;\r\n readonly _nativeScrollbarStyling: boolean;\r\n readonly _rtlScrollBehavior: { n: boolean; i: boolean };\r\n readonly _flexboxGlue: boolean;\r\n readonly _cssCustomProperties: boolean;\r\n readonly _defaultInitializationStrategy: DefaultInitializationStrategy;\r\n readonly _defaultDefaultOptions: OSOptions;\r\n _addListener(listener: EventListener): () => void;\r\n _getInitializationStrategy(): InitializationStrategy;\r\n _setInitializationStrategy(newInitializationStrategy: Partial): void;\r\n _getDefaultOptions(): OSOptions;\r\n _setDefaultOptions(newDefaultOptions: PartialOptions): void;\r\n}\r\n\r\nlet environmentInstance: Environment;\r\nconst { abs, round } = Math;\r\n\r\nconst diffBiggerThanOne = (valOne: number, valTwo: number): boolean => {\r\n const absValOne = abs(valOne);\r\n const absValTwo = abs(valTwo);\r\n return !(absValOne === absValTwo || absValOne + 1 === absValTwo || absValOne - 1 === absValTwo);\r\n};\r\n\r\nconst getNativeScrollbarSize = (\r\n body: HTMLElement,\r\n measureElm: HTMLElement,\r\n measureElmChild: HTMLElement\r\n): XY => {\r\n appendChildren(body, measureElm);\r\n\r\n const cSize = clientSize(measureElm);\r\n const oSize = offsetSize(measureElm);\r\n const fSize = fractionalSize(measureElmChild);\r\n\r\n return {\r\n x: oSize.h - cSize.h + fSize.h,\r\n y: oSize.w - cSize.w + fSize.w,\r\n };\r\n};\r\n\r\nconst getNativeScrollbarStyling = (testElm: HTMLElement): boolean => {\r\n let result = false;\r\n const revertClass = addClass(testElm, classNameViewportScrollbarStyling);\r\n try {\r\n result =\r\n style(testElm, cssProperty('scrollbar-width')) === 'none' ||\r\n window.getComputedStyle(testElm, '::-webkit-scrollbar').getPropertyValue('display') ===\r\n 'none';\r\n } catch (ex) {}\r\n revertClass();\r\n return result;\r\n};\r\n\r\nconst getRtlScrollBehavior = (\r\n parentElm: HTMLElement,\r\n childElm: HTMLElement\r\n): { i: boolean; n: boolean } => {\r\n const strHidden = 'hidden';\r\n style(parentElm, { overflowX: strHidden, overflowY: strHidden, direction: 'rtl' });\r\n scrollLeft(parentElm, 0);\r\n\r\n const parentOffset = absoluteCoordinates(parentElm);\r\n const childOffset = absoluteCoordinates(childElm);\r\n scrollLeft(parentElm, -999); // https://github.com/KingSora/OverlayScrollbars/issues/187\r\n const childOffsetAfterScroll = absoluteCoordinates(childElm);\r\n return {\r\n /**\r\n * origin direction = determines if the zero scroll position is on the left or right side\r\n * 'i' means 'invert' (i === true means that the axis must be inverted to be correct)\r\n * true = on the left side\r\n * false = on the right side\r\n */\r\n i: parentOffset.x === childOffset.x,\r\n /**\r\n * negative = determines if the maximum scroll is positive or negative\r\n * 'n' means 'negate' (n === true means that the axis must be negated to be correct)\r\n * true = negative\r\n * false = positive\r\n */\r\n n: childOffset.x !== childOffsetAfterScroll.x,\r\n };\r\n};\r\n\r\nconst getFlexboxGlue = (parentElm: HTMLElement, childElm: HTMLElement): boolean => {\r\n const revertFbxGlue = addClass(parentElm, classNameEnvironmentFlexboxGlue);\r\n const minOffsetsizeParent = getBoundingClientRect(parentElm);\r\n const minOffsetsize = getBoundingClientRect(childElm);\r\n const supportsMin = equalBCRWH(minOffsetsize, minOffsetsizeParent, true);\r\n\r\n const revertFbxGlueMax = addClass(parentElm, classNameEnvironmentFlexboxGlueMax);\r\n const maxOffsetsizeParent = getBoundingClientRect(parentElm);\r\n const maxOffsetsize = getBoundingClientRect(childElm);\r\n const supportsMax = equalBCRWH(maxOffsetsize, maxOffsetsizeParent, true);\r\n\r\n revertFbxGlue();\r\n revertFbxGlueMax();\r\n\r\n return supportsMin && supportsMax;\r\n};\r\n\r\nconst getWindowDPR = (): number => {\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n const dDPI = window.screen.deviceXDPI || 0;\r\n // eslint-disable-next-line\r\n // @ts-ignore\r\n const sDPI = window.screen.logicalXDPI || 1;\r\n return window.devicePixelRatio || dDPI / sDPI;\r\n};\r\n\r\nconst getDefaultInitializationStrategy = (\r\n nativeScrollbarStyling: boolean\r\n): DefaultInitializationStrategy => ({\r\n _host: null,\r\n _viewport: null,\r\n _padding: !nativeScrollbarStyling,\r\n _content: false,\r\n _scrollbarsSlot: null,\r\n});\r\n\r\nconst createEnvironment = (): Environment => {\r\n const { body } = document;\r\n const envDOM = createDOM(``);\r\n const envElm = envDOM[0] as HTMLElement;\r\n const envChildElm = envElm.firstChild as HTMLElement;\r\n const [addEvent, , triggerEvent] = createEventListenerHub();\r\n const [updateNativeScrollbarSizeCache, getNativeScrollbarSizeCache] = createCache({\r\n _initialValue: getNativeScrollbarSize(body, envElm, envChildElm),\r\n _equal: equalXY,\r\n });\r\n const [nativeScrollbarSize] = getNativeScrollbarSizeCache();\r\n const nativeScrollbarStyling = getNativeScrollbarStyling(envElm);\r\n const nativeScrollbarIsOverlaid = {\r\n x: nativeScrollbarSize.x === 0,\r\n y: nativeScrollbarSize.y === 0,\r\n };\r\n const initializationStrategy = getDefaultInitializationStrategy(nativeScrollbarStyling);\r\n const defaultDefaultOptions = assignDeep({}, defaultOptions);\r\n\r\n const env: Environment = {\r\n _nativeScrollbarSize: nativeScrollbarSize,\r\n _nativeScrollbarIsOverlaid: nativeScrollbarIsOverlaid,\r\n _nativeScrollbarStyling: nativeScrollbarStyling,\r\n _cssCustomProperties: style(envElm, 'zIndex') === '-1',\r\n _rtlScrollBehavior: getRtlScrollBehavior(envElm, envChildElm),\r\n _flexboxGlue: getFlexboxGlue(envElm, envChildElm),\r\n _addListener: (listener) => addEvent('_', listener),\r\n _getInitializationStrategy: assignDeep.bind(\r\n 0,\r\n {} as InitializationStrategy,\r\n initializationStrategy\r\n ),\r\n _setInitializationStrategy(newInitializationStrategy) {\r\n assignDeep(initializationStrategy, newInitializationStrategy);\r\n },\r\n _getDefaultOptions: assignDeep.bind(\r\n 0,\r\n {} as OSOptions,\r\n defaultDefaultOptions\r\n ),\r\n _setDefaultOptions(newDefaultOptions) {\r\n assignDeep(defaultDefaultOptions, newDefaultOptions);\r\n },\r\n _defaultInitializationStrategy: assignDeep({}, initializationStrategy),\r\n _defaultDefaultOptions: assignDeep({}, defaultDefaultOptions),\r\n };\r\n\r\n removeAttr(envElm, 'style');\r\n removeElements(envElm);\r\n\r\n if (!nativeScrollbarStyling && (!nativeScrollbarIsOverlaid.x || !nativeScrollbarIsOverlaid.y)) {\r\n let size = windowSize();\r\n let dpr = getWindowDPR();\r\n\r\n window.addEventListener('resize', () => {\r\n const sizeNew = windowSize();\r\n const deltaSize = {\r\n w: sizeNew.w - size.w,\r\n h: sizeNew.h - size.h,\r\n };\r\n\r\n if (deltaSize.w === 0 && deltaSize.h === 0) return;\r\n\r\n const deltaAbsSize = {\r\n w: abs(deltaSize.w),\r\n h: abs(deltaSize.h),\r\n };\r\n const deltaAbsRatio = {\r\n w: abs(round(sizeNew.w / (size.w / 100.0))),\r\n h: abs(round(sizeNew.h / (size.h / 100.0))),\r\n };\r\n const dprNew = getWindowDPR();\r\n const deltaIsBigger = deltaAbsSize.w > 2 && deltaAbsSize.h > 2;\r\n const difference = !diffBiggerThanOne(deltaAbsRatio.w, deltaAbsRatio.h);\r\n const dprChanged = dprNew !== dpr && dpr > 0;\r\n const isZoom = deltaIsBigger && difference && dprChanged;\r\n\r\n if (isZoom) {\r\n const [scrollbarSize, scrollbarSizeChanged] = updateNativeScrollbarSizeCache(\r\n getNativeScrollbarSize(body, envElm, envChildElm)\r\n );\r\n\r\n assignDeep(environmentInstance._nativeScrollbarSize, scrollbarSize); // keep the object same!\r\n removeElements(envElm);\r\n\r\n if (scrollbarSizeChanged) {\r\n triggerEvent('_');\r\n }\r\n }\r\n\r\n size = sizeNew;\r\n dpr = dprNew;\r\n });\r\n }\r\n\r\n return env;\r\n};\r\n\r\nexport const getEnvironment = (): Environment => {\r\n if (!environmentInstance) {\r\n environmentInstance = createEnvironment();\r\n }\r\n return environmentInstance;\r\n};\r\n","import {\r\n isHTMLElement,\r\n appendChildren,\r\n is,\r\n createDiv,\r\n contents,\r\n insertAfter,\r\n addClass,\r\n parent,\r\n indexOf,\r\n removeElements,\r\n removeClass,\r\n hasClass,\r\n push,\r\n runEach,\r\n insertBefore,\r\n attr,\r\n isBoolean,\r\n isFunction,\r\n keys,\r\n removeAttr,\r\n attrClass,\r\n hasAttrClass,\r\n ResizeObserverConstructor,\r\n} from 'support';\r\nimport {\r\n dataAttributeHost,\r\n dataAttributeHostOverflowX,\r\n dataAttributeHostOverflowY,\r\n classNamePadding,\r\n classNameViewport,\r\n classNameViewportArrange,\r\n classNameContent,\r\n classNameViewportScrollbarStyling,\r\n} from 'classnames';\r\nimport {\r\n getEnvironment,\r\n StructureInitializationStrategyStaticElement,\r\n StructureInitializationStrategyDynamicElement,\r\n} from 'environment';\r\nimport { OSTarget, OSTargetElement, StructureInitialization } from 'typings';\r\n\r\nexport type StructureSetupElements = [targetObj: StructureSetupElementsObj, destroy: () => void];\r\n\r\nexport interface StructureSetupElementsObj {\r\n _target: OSTargetElement;\r\n _host: HTMLElement;\r\n _viewport: HTMLElement;\r\n _padding: HTMLElement | false;\r\n _content: HTMLElement | false;\r\n _viewportArrange: HTMLStyleElement | false;\r\n // ctx ----\r\n _isTextarea: boolean;\r\n _isBody: boolean;\r\n _htmlElm: HTMLHtmlElement;\r\n _bodyElm: HTMLBodyElement;\r\n _windowElm: Window;\r\n _documentElm: Document;\r\n _targetIsElm: boolean;\r\n _viewportIsTarget: boolean;\r\n _viewportHasClass: (className: string, attributeClassName: string) => boolean;\r\n _viewportAddRemoveClass: (className: string, attributeClassName: string, add?: boolean) => void;\r\n}\r\n\r\nlet contentArrangeCounter = 0;\r\n\r\nconst unwrap = (elm: HTMLElement | false | null | undefined) => {\r\n appendChildren(parent(elm), contents(elm));\r\n removeElements(elm);\r\n};\r\n\r\nconst createUniqueViewportArrangeElement = (): HTMLStyleElement | false => {\r\n const { _nativeScrollbarStyling, _nativeScrollbarIsOverlaid, _cssCustomProperties } =\r\n getEnvironment();\r\n /* istanbul ignore next */\r\n const create =\r\n !_cssCustomProperties &&\r\n !_nativeScrollbarStyling &&\r\n (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y);\r\n const result = create ? document.createElement('style') : false;\r\n\r\n if (result) {\r\n attr(result, 'id', `${classNameViewportArrange}-${contentArrangeCounter}`);\r\n contentArrangeCounter++;\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst staticCreationFromStrategy = (\r\n target: OSTargetElement,\r\n initializationValue?: HTMLElement | undefined,\r\n strategy?: StructureInitializationStrategyStaticElement\r\n): HTMLElement => {\r\n const result =\r\n initializationValue ||\r\n (isFunction(strategy) ? strategy(target) : (strategy as null | undefined));\r\n return result || createDiv();\r\n};\r\n\r\nconst dynamicCreationFromStrategy = (\r\n target: OSTargetElement,\r\n initializationValue: HTMLElement | boolean | undefined,\r\n strategy: StructureInitializationStrategyDynamicElement\r\n): HTMLElement | false => {\r\n const takeInitializationValue = isBoolean(initializationValue) || initializationValue;\r\n const result = takeInitializationValue\r\n ? (initializationValue as boolean | HTMLElement)\r\n : isFunction(strategy)\r\n ? strategy(target)\r\n : strategy;\r\n\r\n return result === true ? createDiv() : result;\r\n};\r\n\r\nconst addDataAttrHost = (elm: HTMLElement, value?: string | false | null | undefined) => {\r\n attr(elm, dataAttributeHost, value || '');\r\n return removeAttr.bind(0, elm, dataAttributeHost);\r\n};\r\n\r\nexport const createStructureSetupElements = (target: OSTarget): StructureSetupElements => {\r\n const { _getInitializationStrategy, _nativeScrollbarStyling } = getEnvironment();\r\n const {\r\n _host: hostInitializationStrategy,\r\n _viewport: viewportInitializationStrategy,\r\n _padding: paddingInitializationStrategy,\r\n _content: contentInitializationStrategy,\r\n } = _getInitializationStrategy();\r\n const targetIsElm = isHTMLElement(target);\r\n const targetStructureInitialization = target as StructureInitialization;\r\n const targetElement = targetIsElm\r\n ? (target as OSTargetElement)\r\n : targetStructureInitialization.target;\r\n const isTextarea = is(targetElement, 'textarea');\r\n const isBody = !isTextarea && is(targetElement, 'body');\r\n const ownerDocument = targetElement!.ownerDocument;\r\n const bodyElm = ownerDocument.body as HTMLBodyElement;\r\n const wnd = ownerDocument.defaultView as Window;\r\n const singleElmSupport = !!ResizeObserverConstructor && _nativeScrollbarStyling;\r\n const potentialViewportElement = staticCreationFromStrategy(\r\n targetElement,\r\n targetStructureInitialization.viewport,\r\n viewportInitializationStrategy\r\n );\r\n const potentiallySingleElm = potentialViewportElement === targetElement;\r\n const viewportIsTarget = singleElmSupport && potentiallySingleElm;\r\n const viewportElement =\r\n potentiallySingleElm && !viewportIsTarget\r\n ? staticCreationFromStrategy(targetElement)\r\n : potentialViewportElement;\r\n const evaluatedTargetObj: StructureSetupElementsObj = {\r\n _target: targetElement,\r\n _host: isTextarea\r\n ? staticCreationFromStrategy(\r\n targetElement,\r\n targetStructureInitialization.host,\r\n hostInitializationStrategy\r\n )\r\n : (targetElement as HTMLElement),\r\n _viewport: viewportElement,\r\n _padding: dynamicCreationFromStrategy(\r\n targetElement,\r\n targetStructureInitialization.padding,\r\n paddingInitializationStrategy\r\n ),\r\n _content: dynamicCreationFromStrategy(\r\n targetElement,\r\n targetStructureInitialization.content,\r\n contentInitializationStrategy\r\n ),\r\n _viewportArrange: !viewportIsTarget && createUniqueViewportArrangeElement(),\r\n _windowElm: wnd,\r\n _documentElm: ownerDocument,\r\n _htmlElm: parent(bodyElm) as HTMLHtmlElement,\r\n _bodyElm: bodyElm,\r\n _isTextarea: isTextarea,\r\n _isBody: isBody,\r\n _targetIsElm: targetIsElm,\r\n _viewportIsTarget: viewportIsTarget,\r\n _viewportHasClass: (className: string, attributeClassName: string) =>\r\n viewportIsTarget\r\n ? hasAttrClass(viewportElement, dataAttributeHost, attributeClassName)\r\n : hasClass(viewportElement, className),\r\n _viewportAddRemoveClass: (className: string, attributeClassName: string, add?: boolean) =>\r\n viewportIsTarget\r\n ? attrClass(viewportElement, dataAttributeHost, attributeClassName, add)\r\n : (add ? addClass : removeClass)(viewportElement, className),\r\n };\r\n const generatedElements = keys(evaluatedTargetObj).reduce((arr, key: string) => {\r\n const value = evaluatedTargetObj[key];\r\n return push(arr, value && !parent(value) ? value : false);\r\n }, [] as HTMLElement[]);\r\n const elementIsGenerated = (elm: HTMLElement | false) =>\r\n elm ? indexOf(generatedElements, elm) > -1 : null;\r\n const { _target, _host, _padding, _viewport, _content, _viewportArrange } = evaluatedTargetObj;\r\n const destroyFns: (() => any)[] = [];\r\n const isTextareaHostGenerated = isTextarea && elementIsGenerated(_host);\r\n const targetContents = isTextarea\r\n ? _target\r\n : contents(\r\n [_content, _viewport, _padding, _host, _target].find(\r\n (elm) => elementIsGenerated(elm) === false\r\n )\r\n );\r\n const contentSlot = _content || _viewport;\r\n const removeHostDataAttr = addDataAttrHost(_host, viewportIsTarget ? 'viewport' : 'host');\r\n const removePaddingClass = addClass(_padding, classNamePadding);\r\n const removeViewportClass = addClass(_viewport, !viewportIsTarget && classNameViewport);\r\n const removeContentClass = addClass(_content, classNameContent);\r\n\r\n // only insert host for textarea after target if it was generated\r\n if (isTextareaHostGenerated) {\r\n insertAfter(_target, _host);\r\n\r\n push(destroyFns, () => {\r\n insertAfter(_host, _target);\r\n removeElements(_host);\r\n });\r\n }\r\n\r\n appendChildren(contentSlot, targetContents);\r\n appendChildren(_host, _padding);\r\n appendChildren(_padding || _host, !viewportIsTarget && _viewport);\r\n appendChildren(_viewport, _content);\r\n\r\n push(destroyFns, () => {\r\n removeHostDataAttr();\r\n removeAttr(_viewport, dataAttributeHostOverflowX);\r\n removeAttr(_viewport, dataAttributeHostOverflowY);\r\n\r\n if (elementIsGenerated(_content)) {\r\n unwrap(_content);\r\n }\r\n if (elementIsGenerated(_viewport)) {\r\n unwrap(_viewport);\r\n }\r\n if (elementIsGenerated(_padding)) {\r\n unwrap(_padding);\r\n }\r\n removePaddingClass();\r\n removeViewportClass();\r\n removeContentClass();\r\n });\r\n\r\n if (_nativeScrollbarStyling && !viewportIsTarget) {\r\n push(destroyFns, removeClass.bind(0, _viewport, classNameViewportScrollbarStyling));\r\n }\r\n if (_viewportArrange) {\r\n insertBefore(_viewport, _viewportArrange);\r\n push(destroyFns, removeElements.bind(0, _viewportArrange));\r\n }\r\n\r\n return [evaluatedTargetObj, runEach.bind(0, destroyFns)];\r\n};\r\n","import { style } from 'support';\r\nimport { getEnvironment } from 'environment';\r\nimport type { CreateStructureUpdateSegment } from 'setups/structureSetup/structureSetup.update';\r\n\r\n/**\r\n * Lifecycle with the responsibility to adjust the trinsic behavior of the content element.\r\n * @param structureUpdateHub\r\n * @returns\r\n */\r\nexport const createTrinsicUpdate: CreateStructureUpdateSegment = (\r\n structureSetupElements,\r\n state\r\n) => {\r\n const { _content } = structureSetupElements;\r\n const [getState] = state;\r\n\r\n return (updateHints) => {\r\n const { _flexboxGlue } = getEnvironment();\r\n const { _heightIntrinsic } = getState();\r\n const { _heightIntrinsicChanged } = updateHints;\r\n const heightIntrinsicChanged = (_content || !_flexboxGlue) && _heightIntrinsicChanged;\r\n\r\n if (heightIntrinsicChanged) {\r\n style(_content, {\r\n height: _heightIntrinsic ? '' : '100%',\r\n });\r\n }\r\n\r\n return {\r\n _sizeChanged: heightIntrinsicChanged,\r\n _contentMutation: heightIntrinsicChanged,\r\n };\r\n };\r\n};\r\n","import { createCache, topRightBottomLeft, equalTRBL, style, assignDeep } from 'support';\r\nimport { StyleObject } from 'typings';\r\nimport { getEnvironment } from 'environment';\r\nimport type { CreateStructureUpdateSegment } from 'setups/structureSetup/structureSetup.update';\r\n\r\n/**\r\n * Lifecycle with the responsibility to adjust the padding styling of the padding and viewport element.\r\n * @param structureUpdateHub\r\n * @returns\r\n */\r\nexport const createPaddingUpdate: CreateStructureUpdateSegment = (\r\n structureSetupElements,\r\n state\r\n) => {\r\n const [getState, setState] = state;\r\n const { _host, _padding, _viewport, _viewportIsTarget: _isSingleElm } = structureSetupElements;\r\n const [updatePaddingCache, currentPaddingCache] = createCache(\r\n {\r\n _equal: equalTRBL,\r\n _initialValue: topRightBottomLeft(),\r\n },\r\n topRightBottomLeft.bind(0, _host, 'padding', '')\r\n );\r\n\r\n return (updateHints, checkOption, force) => {\r\n let [padding, paddingChanged] = currentPaddingCache(force);\r\n const { _nativeScrollbarStyling, _flexboxGlue } = getEnvironment();\r\n const { _directionIsRTL } = getState();\r\n const { _sizeChanged, _contentMutation, _directionChanged } = updateHints;\r\n const [paddingAbsolute, paddingAbsoluteChanged] = checkOption('paddingAbsolute');\r\n const contentMutation = !_flexboxGlue && _contentMutation;\r\n\r\n if (_sizeChanged || paddingChanged || contentMutation) {\r\n [padding, paddingChanged] = updatePaddingCache(force);\r\n }\r\n\r\n const paddingStyleChanged =\r\n !_isSingleElm && (paddingAbsoluteChanged || _directionChanged || paddingChanged);\r\n\r\n if (paddingStyleChanged) {\r\n // if there is no padding element and no scrollbar styling, paddingAbsolute isn't supported\r\n const paddingRelative = !paddingAbsolute || (!_padding && !_nativeScrollbarStyling);\r\n const paddingHorizontal = padding.r + padding.l;\r\n const paddingVertical = padding.t + padding.b;\r\n\r\n const paddingStyle: StyleObject = {\r\n marginRight: paddingRelative && !_directionIsRTL ? -paddingHorizontal : 0,\r\n marginBottom: paddingRelative ? -paddingVertical : 0,\r\n marginLeft: paddingRelative && _directionIsRTL ? -paddingHorizontal : 0,\r\n top: paddingRelative ? -padding.t : 0,\r\n right: paddingRelative ? (_directionIsRTL ? -padding.r : 'auto') : 0,\r\n left: paddingRelative ? (_directionIsRTL ? 'auto' : -padding.l) : 0,\r\n width: paddingRelative ? `calc(100% + ${paddingHorizontal}px)` : '',\r\n };\r\n const viewportStyle: StyleObject = {\r\n paddingTop: paddingRelative ? padding.t : 0,\r\n paddingRight: paddingRelative ? padding.r : 0,\r\n paddingBottom: paddingRelative ? padding.b : 0,\r\n paddingLeft: paddingRelative ? padding.l : 0,\r\n };\r\n\r\n // if there is no padding element apply the style to the viewport element instead\r\n style(_padding || _viewport, paddingStyle);\r\n style(_viewport, viewportStyle);\r\n\r\n setState({\r\n _padding: padding,\r\n _paddingAbsolute: !paddingRelative,\r\n _viewportPaddingStyle: _padding\r\n ? viewportStyle\r\n : assignDeep({}, paddingStyle, viewportStyle),\r\n });\r\n }\r\n\r\n return {\r\n _paddingStyleChanged: paddingStyleChanged,\r\n };\r\n };\r\n};\r\n","import {\r\n createCache,\r\n keys,\r\n attr,\r\n WH,\r\n XY,\r\n style,\r\n scrollSize,\r\n fractionalSize,\r\n equalWH,\r\n addClass,\r\n removeClass,\r\n clientSize,\r\n noop,\r\n each,\r\n equalXY,\r\n attrClass,\r\n} from 'support';\r\nimport { getEnvironment } from 'environment';\r\nimport {\r\n classNameViewportArrange,\r\n classNameViewportScrollbarStyling,\r\n classNameOverflowVisible,\r\n dataAttributeHost,\r\n dataAttributeHostOverflowX,\r\n dataAttributeHostOverflowY,\r\n dataValueHostViewportScrollbarStyling,\r\n dataValueHostOverflowVisible,\r\n} from 'classnames';\r\nimport type { StyleObject, OverflowStyle } from 'typings';\r\nimport type { OverflowBehavior } from 'options';\r\nimport type { CreateStructureUpdateSegment } from 'setups/structureSetup/structureSetup.update';\r\n\r\ninterface ViewportOverflowState {\r\n _scrollbarsHideOffset: XY;\r\n _scrollbarsHideOffsetArrange: XY;\r\n _overflowScroll: XY;\r\n _overflowStyle: XY;\r\n}\r\n\r\ntype UndoViewportArrangeResult = [\r\n redoViewportArrange: () => void,\r\n overflowState?: ViewportOverflowState\r\n];\r\n\r\nconst { max } = Math;\r\nconst strVisible = 'visible';\r\nconst strHidden = 'hidden';\r\nconst overlaidScrollbarsHideOffset = 42;\r\nconst whCacheOptions = {\r\n _equal: equalWH,\r\n _initialValue: { w: 0, h: 0 },\r\n};\r\nconst xyCacheOptions = {\r\n _equal: equalXY,\r\n _initialValue: { x: strHidden, y: strHidden } as XY,\r\n};\r\n\r\nconst getOverflowAmount = (\r\n viewportScrollSize: WH,\r\n viewportClientSize: WH,\r\n sizeFraction: WH\r\n) => {\r\n const tollerance = window.devicePixelRatio % 1 !== 0 ? 1 : 0;\r\n const amount = {\r\n w: max(0, viewportScrollSize.w - viewportClientSize.w - max(0, sizeFraction.w)),\r\n h: max(0, viewportScrollSize.h - viewportClientSize.h - max(0, sizeFraction.h)),\r\n };\r\n\r\n return {\r\n w: amount.w > tollerance ? amount.w : 0,\r\n h: amount.h > tollerance ? amount.h : 0,\r\n };\r\n};\r\n\r\nconst conditionalClass = (\r\n elm: Element | false | null | undefined,\r\n classNames: string,\r\n add: boolean\r\n) => (add ? addClass(elm, classNames) : removeClass(elm, classNames));\r\n\r\nconst overflowIsVisible = (overflowBehavior: string) => overflowBehavior.indexOf(strVisible) === 0;\r\n\r\n/**\r\n * Lifecycle with the responsibility to set the correct overflow and scrollbar hiding styles of the viewport element.\r\n * @param structureUpdateHub\r\n * @returns\r\n */\r\nexport const createOverflowUpdate: CreateStructureUpdateSegment = (\r\n structureSetupElements,\r\n state\r\n) => {\r\n const [getState, setState] = state;\r\n const {\r\n _host,\r\n _padding,\r\n _viewport,\r\n _viewportArrange,\r\n _viewportIsTarget,\r\n _viewportAddRemoveClass,\r\n } = structureSetupElements;\r\n const {\r\n _nativeScrollbarSize,\r\n _flexboxGlue,\r\n _nativeScrollbarStyling,\r\n _nativeScrollbarIsOverlaid,\r\n } = getEnvironment();\r\n const doViewportArrange =\r\n !_viewportIsTarget &&\r\n !_nativeScrollbarStyling &&\r\n (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y);\r\n\r\n const [updateSizeFraction, getCurrentSizeFraction] = createCache>(\r\n whCacheOptions,\r\n fractionalSize.bind(0, _viewport)\r\n );\r\n\r\n const [updateViewportScrollSizeCache, getCurrentViewportScrollSizeCache] = createCache<\r\n WH\r\n >(whCacheOptions, scrollSize.bind(0, _viewport));\r\n\r\n const [updateOverflowAmountCache, getCurrentOverflowAmountCache] =\r\n createCache>(whCacheOptions);\r\n\r\n const [updateOverflowStyleCache] = createCache>(xyCacheOptions);\r\n\r\n /**\r\n * Applies a fixed height to the viewport so it can't overflow or underflow the host element.\r\n * @param viewportOverflowState The current overflow state.\r\n * @param heightIntrinsic Whether the host height is intrinsic or not.\r\n */\r\n const fixFlexboxGlue = (\r\n viewportOverflowState: ViewportOverflowState,\r\n heightIntrinsic: boolean\r\n ) => {\r\n style(_viewport, {\r\n height: '',\r\n });\r\n\r\n if (heightIntrinsic) {\r\n const { _paddingAbsolute, _padding: padding } = getState();\r\n const { _overflowScroll, _scrollbarsHideOffset } = viewportOverflowState;\r\n const fSize = fractionalSize(_host);\r\n const hostClientSize = clientSize(_host);\r\n\r\n // padding subtraction is only needed if padding is absolute or if viewport is content-box\r\n const isContentBox = style(_viewport, 'boxSizing') === 'content-box';\r\n const paddingVertical = _paddingAbsolute || isContentBox ? padding.b + padding.t : 0;\r\n const subtractXScrollbar = !(_nativeScrollbarIsOverlaid.x && isContentBox);\r\n\r\n style(_viewport, {\r\n height:\r\n hostClientSize.h +\r\n fSize.h +\r\n (_overflowScroll.x && subtractXScrollbar ? _scrollbarsHideOffset.x : 0) -\r\n paddingVertical,\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Gets the current overflow state of the viewport.\r\n * @param showNativeOverlaidScrollbars Whether native overlaid scrollbars are shown instead of hidden.\r\n * @param viewportStyleObj The viewport style object where the overflow scroll property can be read of, or undefined if shall be determined.\r\n * @returns A object which contains informations about the current overflow state.\r\n */\r\n const getViewportOverflowState = (\r\n showNativeOverlaidScrollbars: boolean,\r\n viewportStyleObj?: StyleObject\r\n ): ViewportOverflowState => {\r\n const arrangeHideOffset =\r\n !_nativeScrollbarStyling && !showNativeOverlaidScrollbars ? overlaidScrollbarsHideOffset : 0;\r\n const getStatePerAxis = (\r\n styleKey: string,\r\n isOverlaid: boolean,\r\n nativeScrollbarSize: number\r\n ) => {\r\n const overflowStyle = style(_viewport, styleKey);\r\n // can't do something like \"viewportStyleObj && viewportStyleObj[styleKey] || overflowStyle\" here!\r\n const objectPrefferedOverflowStyle = viewportStyleObj\r\n ? viewportStyleObj[styleKey]\r\n : overflowStyle;\r\n const overflowScroll = objectPrefferedOverflowStyle === 'scroll';\r\n const nonScrollbarStylingHideOffset = isOverlaid ? arrangeHideOffset : nativeScrollbarSize;\r\n const scrollbarsHideOffset =\r\n overflowScroll && !_nativeScrollbarStyling ? nonScrollbarStylingHideOffset : 0;\r\n const scrollbarsHideOffsetArrange = isOverlaid && !!arrangeHideOffset;\r\n\r\n return [overflowStyle, overflowScroll, scrollbarsHideOffset, scrollbarsHideOffsetArrange] as [\r\n overflowStyle: OverflowStyle,\r\n overflowScroll: boolean,\r\n scrollbarsHideOffset: number,\r\n scrollbarsHideOffsetArrange: boolean\r\n ];\r\n };\r\n\r\n const [xOverflowStyle, xOverflowScroll, xScrollbarsHideOffset, xScrollbarsHideOffsetArrange] =\r\n getStatePerAxis('overflowX', _nativeScrollbarIsOverlaid.x, _nativeScrollbarSize.x);\r\n const [yOverflowStyle, yOverflowScroll, yScrollbarsHideOffset, yScrollbarsHideOffsetArrange] =\r\n getStatePerAxis('overflowY', _nativeScrollbarIsOverlaid.y, _nativeScrollbarSize.y);\r\n\r\n return {\r\n _overflowStyle: {\r\n x: xOverflowStyle,\r\n y: yOverflowStyle,\r\n },\r\n _overflowScroll: {\r\n x: xOverflowScroll,\r\n y: yOverflowScroll,\r\n },\r\n _scrollbarsHideOffset: {\r\n x: xScrollbarsHideOffset,\r\n y: yScrollbarsHideOffset,\r\n },\r\n _scrollbarsHideOffsetArrange: {\r\n x: xScrollbarsHideOffsetArrange,\r\n y: yScrollbarsHideOffsetArrange,\r\n },\r\n };\r\n };\r\n\r\n /**\r\n * Sets the overflow property of the viewport and calculates the a overflow state according to the new parameters.\r\n * @param showNativeOverlaidScrollbars Whether to show natively overlaid scrollbars.\r\n * @param overflowAmount The overflow amount.\r\n * @param overflow The overflow behavior according to the options.\r\n * @param viewportStyleObj The viewport style object to which the overflow style shall be applied.\r\n * @returns A object which represents the newly set overflow state.\r\n */\r\n const setViewportOverflowState = (\r\n showNativeOverlaidScrollbars: boolean,\r\n hasOverflow: XY,\r\n overflowOption: XY,\r\n viewportStyleObj: StyleObject\r\n ): ViewportOverflowState => {\r\n const setAxisOverflowStyle = (behavior: OverflowBehavior, hasOverflowAxis: boolean) => {\r\n const overflowVisible = overflowIsVisible(behavior);\r\n const overflowVisibleBehavior =\r\n (hasOverflowAxis && overflowVisible && behavior.replace(`${strVisible}-`, '')) || '';\r\n return [\r\n hasOverflowAxis && !overflowVisible ? behavior : '',\r\n overflowIsVisible(overflowVisibleBehavior) ? 'hidden' : overflowVisibleBehavior,\r\n ];\r\n };\r\n\r\n const [overflowX, visibleBehaviorX] = setAxisOverflowStyle(overflowOption.x, hasOverflow.x);\r\n const [overflowY, visibleBehaviorY] = setAxisOverflowStyle(overflowOption.y, hasOverflow.y);\r\n\r\n viewportStyleObj.overflowX = visibleBehaviorX && overflowY ? visibleBehaviorX : overflowX;\r\n viewportStyleObj.overflowY = visibleBehaviorY && overflowX ? visibleBehaviorY : overflowY;\r\n\r\n return getViewportOverflowState(showNativeOverlaidScrollbars, viewportStyleObj);\r\n };\r\n\r\n /**\r\n * Sets the styles of the viewport arrange element.\r\n * @param viewportOverflowState The viewport overflow state according to which the scrollbars shall be hidden.\r\n * @param viewportScrollSize The content scroll size.\r\n * @param directionIsRTL Whether the direction is RTL or not.\r\n * @returns A boolean which indicates whether the viewport arrange element was adjusted.\r\n */\r\n const arrangeViewport = (\r\n viewportOverflowState: ViewportOverflowState,\r\n viewportScrollSize: WH,\r\n sizeFraction: WH,\r\n directionIsRTL: boolean\r\n ) => {\r\n if (doViewportArrange) {\r\n const { _viewportPaddingStyle } = getState();\r\n const { _scrollbarsHideOffset, _scrollbarsHideOffsetArrange } = viewportOverflowState;\r\n const { x: arrangeX, y: arrangeY } = _scrollbarsHideOffsetArrange;\r\n const { x: hideOffsetX, y: hideOffsetY } = _scrollbarsHideOffset;\r\n const viewportArrangeHorizontalPaddingKey: keyof StyleObject = directionIsRTL\r\n ? 'paddingRight'\r\n : 'paddingLeft';\r\n const viewportArrangeHorizontalPaddingValue = _viewportPaddingStyle[\r\n viewportArrangeHorizontalPaddingKey\r\n ] as number;\r\n const viewportArrangeVerticalPaddingValue = _viewportPaddingStyle.paddingTop as number;\r\n const fractionalContentWidth = viewportScrollSize.w + sizeFraction.w;\r\n const fractionalContenHeight = viewportScrollSize.h + sizeFraction.h;\r\n const arrangeSize = {\r\n w:\r\n hideOffsetY && arrangeY\r\n ? `${hideOffsetY + fractionalContentWidth - viewportArrangeHorizontalPaddingValue}px`\r\n : '',\r\n h:\r\n hideOffsetX && arrangeX\r\n ? `${hideOffsetX + fractionalContenHeight - viewportArrangeVerticalPaddingValue}px`\r\n : '',\r\n };\r\n\r\n // adjust content arrange / before element\r\n if (_viewportArrange) {\r\n const { sheet } = _viewportArrange;\r\n if (sheet) {\r\n const { cssRules } = sheet;\r\n if (cssRules) {\r\n if (!cssRules.length) {\r\n sheet.insertRule(\r\n `#${attr(_viewportArrange, 'id')} + .${classNameViewportArrange}::before {}`,\r\n 0\r\n );\r\n }\r\n\r\n // @ts-ignore\r\n const ruleStyle = cssRules[0].style;\r\n\r\n ruleStyle.width = arrangeSize.w;\r\n ruleStyle.height = arrangeSize.h;\r\n }\r\n }\r\n } else {\r\n style<'--os-vaw' | '--os-vah'>(_viewport, {\r\n '--os-vaw': arrangeSize.w,\r\n '--os-vah': arrangeSize.h,\r\n });\r\n }\r\n }\r\n\r\n return doViewportArrange;\r\n };\r\n\r\n /**\r\n * Hides the native scrollbars according to the passed parameters.\r\n * @param viewportOverflowState The viewport overflow state.\r\n * @param directionIsRTL Whether the direction is RTL or not.\r\n * @param viewportArrange Whether special styles related to the viewport arrange strategy shall be applied.\r\n * @param viewportStyleObj The viewport style object to which the needed styles shall be applied.\r\n */\r\n const hideNativeScrollbars = (\r\n viewportOverflowState: ViewportOverflowState,\r\n directionIsRTL: boolean,\r\n viewportArrange: boolean,\r\n viewportStyleObj: StyleObject\r\n ) => {\r\n const { _scrollbarsHideOffset, _scrollbarsHideOffsetArrange } = viewportOverflowState;\r\n const { x: arrangeX, y: arrangeY } = _scrollbarsHideOffsetArrange;\r\n const { x: hideOffsetX, y: hideOffsetY } = _scrollbarsHideOffset;\r\n const { _viewportPaddingStyle: viewportPaddingStyle } = getState();\r\n const horizontalMarginKey: keyof StyleObject = directionIsRTL ? 'marginLeft' : 'marginRight';\r\n const viewportHorizontalPaddingKey: keyof StyleObject = directionIsRTL\r\n ? 'paddingLeft'\r\n : 'paddingRight';\r\n const horizontalMarginValue = viewportPaddingStyle[horizontalMarginKey] as number;\r\n const verticalMarginValue = viewportPaddingStyle.marginBottom as number;\r\n const horizontalPaddingValue = viewportPaddingStyle[viewportHorizontalPaddingKey] as number;\r\n const verticalPaddingValue = viewportPaddingStyle.paddingBottom as number;\r\n\r\n // horizontal\r\n viewportStyleObj.width = `calc(100% + ${hideOffsetY + horizontalMarginValue * -1}px)`;\r\n viewportStyleObj[horizontalMarginKey] = -hideOffsetY + horizontalMarginValue;\r\n\r\n // vertical\r\n viewportStyleObj.marginBottom = -hideOffsetX + verticalMarginValue;\r\n\r\n // viewport arrange additional styles\r\n if (viewportArrange) {\r\n viewportStyleObj[viewportHorizontalPaddingKey] =\r\n horizontalPaddingValue + (arrangeY ? hideOffsetY : 0);\r\n viewportStyleObj.paddingBottom = verticalPaddingValue + (arrangeX ? hideOffsetX : 0);\r\n }\r\n };\r\n\r\n /**\r\n * Removes all styles applied because of the viewport arrange strategy.\r\n * @param showNativeOverlaidScrollbars Whether native overlaid scrollbars are shown instead of hidden.\r\n * @param directionIsRTL Whether the direction is RTL or not.\r\n * @param viewportOverflowState The currentviewport overflow state or undefined if it has to be determined.\r\n * @returns A object with a function which applies all the removed styles and the determined viewport vverflow state.\r\n */\r\n const undoViewportArrange = (\r\n showNativeOverlaidScrollbars: boolean,\r\n directionIsRTL: boolean,\r\n viewportOverflowState?: ViewportOverflowState\r\n ): UndoViewportArrangeResult => {\r\n if (doViewportArrange) {\r\n const finalViewportOverflowState =\r\n viewportOverflowState || getViewportOverflowState(showNativeOverlaidScrollbars);\r\n const { _viewportPaddingStyle: viewportPaddingStyle } = getState();\r\n const { _scrollbarsHideOffsetArrange } = finalViewportOverflowState;\r\n const { x: arrangeX, y: arrangeY } = _scrollbarsHideOffsetArrange;\r\n const finalPaddingStyle: StyleObject = {};\r\n const assignProps = (props: string) =>\r\n each(props.split(' '), (prop) => {\r\n finalPaddingStyle[prop] = viewportPaddingStyle[prop];\r\n });\r\n\r\n if (arrangeX) {\r\n assignProps('marginBottom paddingTop paddingBottom');\r\n }\r\n\r\n if (arrangeY) {\r\n assignProps('marginLeft marginRight paddingLeft paddingRight');\r\n }\r\n\r\n const prevStyle = style(_viewport, keys(finalPaddingStyle));\r\n\r\n removeClass(_viewport, classNameViewportArrange);\r\n\r\n if (!_flexboxGlue) {\r\n finalPaddingStyle.height = '';\r\n }\r\n\r\n style(_viewport, finalPaddingStyle);\r\n\r\n return [\r\n () => {\r\n hideNativeScrollbars(\r\n finalViewportOverflowState,\r\n directionIsRTL,\r\n doViewportArrange,\r\n prevStyle\r\n );\r\n style(_viewport, prevStyle);\r\n addClass(_viewport, classNameViewportArrange);\r\n },\r\n finalViewportOverflowState,\r\n ];\r\n }\r\n return [noop];\r\n };\r\n\r\n return (updateHints, checkOption, force) => {\r\n const {\r\n _sizeChanged,\r\n _hostMutation,\r\n _contentMutation,\r\n _paddingStyleChanged,\r\n _heightIntrinsicChanged,\r\n _directionChanged,\r\n } = updateHints;\r\n const { _heightIntrinsic, _directionIsRTL } = getState();\r\n const [showNativeOverlaidScrollbarsOption, showNativeOverlaidScrollbarsChanged] =\r\n checkOption('nativeScrollbarsOverlaid.show');\r\n const [overflow, overflowChanged] = checkOption>('overflow');\r\n\r\n const showNativeOverlaidScrollbars =\r\n showNativeOverlaidScrollbarsOption &&\r\n _nativeScrollbarIsOverlaid.x &&\r\n _nativeScrollbarIsOverlaid.y;\r\n const adjustFlexboxGlue =\r\n !_viewportIsTarget &&\r\n !_flexboxGlue &&\r\n (_sizeChanged ||\r\n _contentMutation ||\r\n _hostMutation ||\r\n showNativeOverlaidScrollbarsChanged ||\r\n _heightIntrinsicChanged);\r\n const overflowXVisible = overflowIsVisible(overflow.x);\r\n const overflowYVisible = overflowIsVisible(overflow.y);\r\n const overflowVisible = overflowXVisible || overflowYVisible;\r\n\r\n let sizeFractionCache = getCurrentSizeFraction(force);\r\n let viewportScrollSizeCache = getCurrentViewportScrollSizeCache(force);\r\n let overflowAmuntCache = getCurrentOverflowAmountCache(force);\r\n\r\n let preMeasureViewportOverflowState: ViewportOverflowState | undefined;\r\n\r\n if (showNativeOverlaidScrollbarsChanged && _nativeScrollbarStyling) {\r\n _viewportAddRemoveClass(\r\n classNameViewportScrollbarStyling,\r\n dataValueHostViewportScrollbarStyling,\r\n !showNativeOverlaidScrollbars\r\n );\r\n }\r\n\r\n if (adjustFlexboxGlue) {\r\n preMeasureViewportOverflowState = getViewportOverflowState(showNativeOverlaidScrollbars);\r\n fixFlexboxGlue(preMeasureViewportOverflowState, _heightIntrinsic);\r\n }\r\n\r\n if (\r\n _sizeChanged ||\r\n _paddingStyleChanged ||\r\n _contentMutation ||\r\n _directionChanged ||\r\n showNativeOverlaidScrollbarsChanged\r\n ) {\r\n if (overflowVisible) {\r\n _viewportAddRemoveClass(classNameOverflowVisible, dataValueHostOverflowVisible, false);\r\n }\r\n\r\n const [redoViewportArrange, undoViewportArrangeOverflowState] = undoViewportArrange(\r\n showNativeOverlaidScrollbars,\r\n _directionIsRTL,\r\n preMeasureViewportOverflowState\r\n );\r\n const [sizeFraction, sizeFractionChanged] = (sizeFractionCache = updateSizeFraction(force));\r\n const [viewportScrollSize, viewportScrollSizeChanged] = (viewportScrollSizeCache =\r\n updateViewportScrollSizeCache(force));\r\n const viewportclientSize = clientSize(_viewport);\r\n let arrangedViewportScrollSize = viewportScrollSize;\r\n let arrangedViewportClientSize = viewportclientSize;\r\n\r\n redoViewportArrange();\r\n\r\n // if re measure is required (only required if content arrange strategy is used)\r\n if (\r\n (viewportScrollSizeChanged || sizeFractionChanged || showNativeOverlaidScrollbarsChanged) &&\r\n undoViewportArrangeOverflowState &&\r\n !showNativeOverlaidScrollbars &&\r\n arrangeViewport(\r\n undoViewportArrangeOverflowState,\r\n viewportScrollSize,\r\n sizeFraction,\r\n _directionIsRTL\r\n )\r\n ) {\r\n arrangedViewportClientSize = clientSize(_viewport);\r\n arrangedViewportScrollSize = scrollSize(_viewport);\r\n }\r\n\r\n overflowAmuntCache = updateOverflowAmountCache(\r\n getOverflowAmount(\r\n {\r\n w: max(viewportScrollSize.w, arrangedViewportScrollSize.w),\r\n h: max(viewportScrollSize.h, arrangedViewportScrollSize.h),\r\n }, // scroll size\r\n {\r\n w: arrangedViewportClientSize.w + max(0, viewportclientSize.w - viewportScrollSize.w),\r\n h: arrangedViewportClientSize.h + max(0, viewportclientSize.h - viewportScrollSize.h),\r\n }, // client size\r\n sizeFraction\r\n ),\r\n force\r\n );\r\n }\r\n\r\n const [overflowAmount, overflowAmountChanged] = overflowAmuntCache;\r\n const [viewportScrollSize, viewportScrollSizeChanged] = viewportScrollSizeCache;\r\n const [sizeFraction, sizeFractionChanged] = sizeFractionCache;\r\n const hasOverflow = {\r\n x: overflowAmount.w > 0,\r\n y: overflowAmount.h > 0,\r\n };\r\n const removeClipping =\r\n (overflowXVisible && overflowYVisible && (hasOverflow.x || hasOverflow.y)) ||\r\n (overflowXVisible && hasOverflow.x && !hasOverflow.y) ||\r\n (overflowYVisible && hasOverflow.y && !hasOverflow.x);\r\n\r\n if (\r\n _paddingStyleChanged ||\r\n _directionChanged ||\r\n sizeFractionChanged ||\r\n viewportScrollSizeChanged ||\r\n overflowAmountChanged ||\r\n overflowChanged ||\r\n showNativeOverlaidScrollbarsChanged ||\r\n adjustFlexboxGlue\r\n ) {\r\n const viewportStyle: StyleObject = {\r\n marginRight: 0,\r\n marginBottom: 0,\r\n marginLeft: 0,\r\n width: '',\r\n overflowY: '',\r\n overflowX: '',\r\n };\r\n const viewportOverflowState = setViewportOverflowState(\r\n showNativeOverlaidScrollbars,\r\n hasOverflow,\r\n overflow,\r\n viewportStyle\r\n );\r\n const viewportArranged = arrangeViewport(\r\n viewportOverflowState,\r\n viewportScrollSize,\r\n sizeFraction,\r\n _directionIsRTL\r\n );\r\n\r\n if (!_viewportIsTarget) {\r\n hideNativeScrollbars(\r\n viewportOverflowState,\r\n _directionIsRTL,\r\n viewportArranged,\r\n viewportStyle\r\n );\r\n }\r\n\r\n if (adjustFlexboxGlue) {\r\n fixFlexboxGlue(viewportOverflowState, _heightIntrinsic);\r\n }\r\n\r\n if (_viewportIsTarget) {\r\n attr(_host, dataAttributeHostOverflowX, viewportStyle.overflowX as string);\r\n attr(_host, dataAttributeHostOverflowY, viewportStyle.overflowY as string);\r\n } else {\r\n style(_viewport, viewportStyle);\r\n }\r\n }\r\n\r\n attrClass(_host, dataAttributeHost, dataValueHostOverflowVisible, removeClipping);\r\n conditionalClass(_padding, classNameOverflowVisible, removeClipping);\r\n !_viewportIsTarget && conditionalClass(_viewport, classNameOverflowVisible, overflowVisible);\r\n\r\n const [overflowStyle, overflowStyleChanged] = updateOverflowStyleCache(\r\n getViewportOverflowState(showNativeOverlaidScrollbars)._overflowStyle\r\n );\r\n\r\n setState({\r\n _overflowStyle: overflowStyle,\r\n _overflowAmount: {\r\n x: overflowAmount.w,\r\n y: overflowAmount.h,\r\n },\r\n _hasOverflow: hasOverflow,\r\n });\r\n\r\n return {\r\n _overflowStyleChanged: overflowStyleChanged,\r\n _overflowAmountChanged: overflowAmountChanged,\r\n };\r\n };\r\n};\r\n","import { each, isNumber, scrollLeft, scrollTop, assignDeep, keys } from 'support';\r\nimport { getEnvironment } from 'environment';\r\nimport {\r\n createTrinsicUpdate,\r\n createPaddingUpdate,\r\n createOverflowUpdate,\r\n} from 'setups/structureSetup/updateSegments';\r\nimport type { SetupState, SetupUpdateSegment, SetupUpdateCheckOption } from 'setups';\r\nimport type { StructureSetupState } from 'setups/structureSetup';\r\nimport type { StructureSetupElementsObj } from 'setups/structureSetup/structureSetup.elements';\r\n\r\nexport type CreateStructureUpdateSegment = (\r\n structureSetupElements: StructureSetupElementsObj,\r\n state: SetupState\r\n) => StructureSetupUpdateSegment;\r\n\r\nexport type StructureSetupUpdateSegment = SetupUpdateSegment;\r\n\r\nexport type StructureSetupUpdate = (\r\n checkOption: SetupUpdateCheckOption,\r\n updateHints: Partial,\r\n force?: boolean\r\n) => StructureSetupUpdateHints;\r\n\r\nexport interface StructureSetupUpdateHints {\r\n _sizeChanged: boolean;\r\n _directionChanged: boolean;\r\n _heightIntrinsicChanged: boolean;\r\n _overflowAmountChanged: boolean;\r\n _overflowStyleChanged: boolean;\r\n _paddingStyleChanged: boolean;\r\n _hostMutation: boolean;\r\n _contentMutation: boolean;\r\n}\r\n\r\nconst prepareUpdateHints = (\r\n leading: Required,\r\n adaptive?: Partial,\r\n force?: boolean\r\n): Required => {\r\n const result = {};\r\n const finalAdaptive = adaptive || {};\r\n const objKeys = keys(leading).concat(keys(finalAdaptive));\r\n\r\n each(objKeys, (key) => {\r\n const leadingValue = leading[key];\r\n const adaptiveValue = finalAdaptive[key];\r\n result[key] = !!(force || leadingValue || adaptiveValue);\r\n });\r\n\r\n return result as Required;\r\n};\r\n\r\nexport const createStructureSetupUpdate = (\r\n structureSetupElements: StructureSetupElementsObj,\r\n state: SetupState\r\n): StructureSetupUpdate => {\r\n const { _viewport } = structureSetupElements;\r\n const { _nativeScrollbarStyling, _nativeScrollbarIsOverlaid, _flexboxGlue } = getEnvironment();\r\n const doViewportArrange =\r\n !_nativeScrollbarStyling && (_nativeScrollbarIsOverlaid.x || _nativeScrollbarIsOverlaid.y);\r\n\r\n const updateSegments: StructureSetupUpdateSegment[] = [\r\n createTrinsicUpdate(structureSetupElements, state),\r\n createPaddingUpdate(structureSetupElements, state),\r\n createOverflowUpdate(structureSetupElements, state),\r\n ];\r\n\r\n return (\r\n checkOption: SetupUpdateCheckOption,\r\n updateHints: Partial,\r\n force?: boolean\r\n ) => {\r\n const initialUpdateHints = prepareUpdateHints(\r\n assignDeep(\r\n {\r\n _sizeChanged: false,\r\n _paddingStyleChanged: false,\r\n _directionChanged: false,\r\n _heightIntrinsicChanged: false,\r\n _overflowAmountChanged: false,\r\n _overflowStyleChanged: false,\r\n _hostMutation: false,\r\n _contentMutation: false,\r\n },\r\n updateHints\r\n ),\r\n {},\r\n force\r\n );\r\n const adjustScrollOffset = doViewportArrange || !_flexboxGlue;\r\n const scrollOffsetX = adjustScrollOffset && scrollLeft(_viewport);\r\n const scrollOffsetY = adjustScrollOffset && scrollTop(_viewport);\r\n\r\n let adaptivedUpdateHints: Required = initialUpdateHints;\r\n each(updateSegments, (updateSegment) => {\r\n adaptivedUpdateHints = prepareUpdateHints(\r\n adaptivedUpdateHints,\r\n updateSegment(adaptivedUpdateHints, checkOption, !!force) || {},\r\n force\r\n );\r\n });\r\n\r\n if (isNumber(scrollOffsetX)) {\r\n scrollLeft(_viewport, scrollOffsetX);\r\n }\r\n if (isNumber(scrollOffsetY)) {\r\n scrollTop(_viewport, scrollOffsetY);\r\n }\r\n\r\n return adaptivedUpdateHints;\r\n };\r\n};\r\n","import {\r\n Cache,\r\n CacheValues,\r\n createCache,\r\n createDOM,\r\n style,\r\n appendChildren,\r\n offsetSize,\r\n scrollLeft,\r\n scrollTop,\r\n runEach,\r\n prependChildren,\r\n removeElements,\r\n on,\r\n stopAndPrevent,\r\n addClass,\r\n equalWH,\r\n push,\r\n cAF,\r\n rAF,\r\n ResizeObserverConstructor,\r\n isArray,\r\n isBoolean,\r\n removeClass,\r\n isObject,\r\n} from 'support';\r\nimport { getEnvironment } from 'environment';\r\nimport {\r\n classNameSizeObserver,\r\n classNameSizeObserverAppear,\r\n classNameSizeObserverListener,\r\n classNameSizeObserverListenerScroll,\r\n classNameSizeObserverListenerItem,\r\n classNameSizeObserverListenerItemFinal,\r\n} from 'classnames';\r\n\r\nexport interface SizeObserverOptions {\r\n _direction?: boolean;\r\n _appear?: boolean;\r\n}\r\n\r\nexport interface SizeObserverCallbackParams {\r\n _sizeChanged: boolean;\r\n _directionIsRTLCache?: CacheValues;\r\n _appear?: boolean;\r\n}\r\n\r\nexport type DestroySizeObserver = () => void;\r\n\r\nconst animationStartEventName = 'animationstart';\r\nconst scrollEventName = 'scroll';\r\nconst scrollAmount = 3333333;\r\nconst getElmDirectionIsRTL = (elm: HTMLElement): boolean => style(elm, 'direction') === 'rtl';\r\nconst domRectHasDimensions = (rect?: DOMRectReadOnly) => rect && (rect.height || rect.width);\r\n\r\n/**\r\n * Creates a size observer which observes any size, padding, border, margin and box-sizing changes of the target element. Depending on the options also direction and appear can be observed.\r\n * @param target The target element which shall be observed.\r\n * @param onSizeChangedCallback The callback which gets called after a size change was detected.\r\n * @param options The options for size detection, whether to observe also direction and appear.\r\n * @returns A object which represents the instance of the size observer.\r\n */\r\nexport const createSizeObserver = (\r\n target: HTMLElement,\r\n onSizeChangedCallback: (params: SizeObserverCallbackParams) => any,\r\n options?: SizeObserverOptions\r\n): DestroySizeObserver => {\r\n const { _direction: observeDirectionChange = false, _appear: observeAppearChange = false } =\r\n options || {};\r\n const { _rtlScrollBehavior: rtlScrollBehavior } = getEnvironment();\r\n const baseElements = createDOM(\r\n ``\r\n );\r\n const sizeObserver = baseElements[0] as HTMLElement;\r\n const listenerElement = sizeObserver.firstChild as HTMLElement;\r\n const getIsDirectionRTL = getElmDirectionIsRTL.bind(0, sizeObserver);\r\n const [updateResizeObserverContentRectCache] = createCache({\r\n _initialValue: undefined,\r\n _alwaysUpdateValues: true,\r\n _equal: (currVal, newVal) =>\r\n !(\r\n !currVal || // if no initial value\r\n // if from display: none to display: block\r\n (!domRectHasDimensions(currVal) && domRectHasDimensions(newVal))\r\n ),\r\n });\r\n const onSizeChangedCallbackProxy = (\r\n sizeChangedContext?: CacheValues | ResizeObserverEntry[] | Event | boolean\r\n ) => {\r\n const isResizeObserverCall =\r\n isArray(sizeChangedContext) &&\r\n sizeChangedContext.length > 0 &&\r\n isObject(sizeChangedContext[0]);\r\n\r\n const hasDirectionCache =\r\n !isResizeObserverCall && isBoolean((sizeChangedContext as CacheValues)[0]);\r\n\r\n let skip = false;\r\n let appear: boolean | number | undefined = false;\r\n let doDirectionScroll = true; // always true if sizeChangedContext is Event (appear callback or RO. Polyfill)\r\n\r\n // if triggered from RO.\r\n if (isResizeObserverCall) {\r\n const [currRContentRect, , prevContentRect] = updateResizeObserverContentRectCache(\r\n (sizeChangedContext as ResizeObserverEntry[]).pop()!.contentRect\r\n );\r\n const hasDimensions = domRectHasDimensions(currRContentRect);\r\n const hadDimensions = domRectHasDimensions(prevContentRect);\r\n skip = !prevContentRect || !hasDimensions; // skip on initial RO. call or if display is none\r\n appear = !hadDimensions && hasDimensions;\r\n\r\n doDirectionScroll = !skip; // direction scroll when not skipping\r\n }\r\n // else if its triggered with DirectionCache\r\n else if (hasDirectionCache) {\r\n [, doDirectionScroll] = sizeChangedContext as CacheValues; // direction scroll when DirectionCache changed, false otherwise\r\n }\r\n // else if it triggered with appear from polyfill\r\n else {\r\n appear = sizeChangedContext === true;\r\n }\r\n\r\n if (observeDirectionChange && doDirectionScroll) {\r\n const rtl = hasDirectionCache\r\n ? (sizeChangedContext as CacheValues)[0]\r\n : getElmDirectionIsRTL(sizeObserver);\r\n scrollLeft(\r\n sizeObserver,\r\n rtl\r\n ? rtlScrollBehavior.n\r\n ? -scrollAmount\r\n : rtlScrollBehavior.i\r\n ? 0\r\n : scrollAmount\r\n : scrollAmount\r\n );\r\n scrollTop(sizeObserver, scrollAmount);\r\n }\r\n\r\n if (!skip) {\r\n onSizeChangedCallback({\r\n _sizeChanged: !hasDirectionCache,\r\n _directionIsRTLCache: hasDirectionCache\r\n ? (sizeChangedContext as CacheValues)\r\n : undefined,\r\n _appear: !!appear,\r\n });\r\n }\r\n };\r\n const offListeners: (() => void)[] = [];\r\n let appearCallback: ((...args: any) => any) | false = observeAppearChange\r\n ? onSizeChangedCallbackProxy\r\n : false;\r\n let directionIsRTLCache: Cache | undefined;\r\n\r\n if (ResizeObserverConstructor) {\r\n const resizeObserverInstance = new ResizeObserverConstructor(onSizeChangedCallbackProxy);\r\n resizeObserverInstance.observe(listenerElement);\r\n push(offListeners, () => {\r\n resizeObserverInstance.disconnect();\r\n });\r\n } else {\r\n const observerElementChildren = createDOM(\r\n ``\r\n );\r\n appendChildren(listenerElement, observerElementChildren);\r\n addClass(listenerElement, classNameSizeObserverListenerScroll);\r\n const observerElementChildrenRoot = observerElementChildren[0] as HTMLElement;\r\n const shrinkElement = observerElementChildrenRoot.lastChild as HTMLElement;\r\n const expandElement = observerElementChildrenRoot.firstChild as HTMLElement;\r\n const expandElementChild = expandElement?.firstChild as HTMLElement;\r\n\r\n let cacheSize = offsetSize(observerElementChildrenRoot);\r\n let currSize = cacheSize;\r\n let isDirty = false;\r\n let rAFId: number;\r\n\r\n const reset = () => {\r\n scrollLeft(expandElement, scrollAmount);\r\n scrollTop(expandElement, scrollAmount);\r\n scrollLeft(shrinkElement, scrollAmount);\r\n scrollTop(shrinkElement, scrollAmount);\r\n };\r\n const onResized = (appear?: unknown) => {\r\n rAFId = 0;\r\n if (isDirty) {\r\n cacheSize = currSize;\r\n onSizeChangedCallbackProxy(appear === true);\r\n }\r\n };\r\n const onScroll = (scrollEvent?: Event | false) => {\r\n currSize = offsetSize(observerElementChildrenRoot);\r\n isDirty = !scrollEvent || !equalWH(currSize, cacheSize);\r\n\r\n if (scrollEvent) {\r\n stopAndPrevent(scrollEvent);\r\n\r\n if (isDirty && !rAFId) {\r\n cAF!(rAFId);\r\n rAFId = rAF!(onResized);\r\n }\r\n } else {\r\n onResized(scrollEvent === false);\r\n }\r\n\r\n reset();\r\n };\r\n\r\n push(offListeners, [\r\n on(expandElement, scrollEventName, onScroll),\r\n on(shrinkElement, scrollEventName, onScroll),\r\n ]);\r\n\r\n // lets assume that the divs will never be that large and a constant value is enough\r\n style(expandElementChild, {\r\n width: scrollAmount,\r\n height: scrollAmount,\r\n });\r\n\r\n reset();\r\n\r\n appearCallback = observeAppearChange ? onScroll.bind(0, false) : reset;\r\n }\r\n\r\n if (observeDirectionChange) {\r\n directionIsRTLCache = createCache(\r\n {\r\n _initialValue: !getIsDirectionRTL(), // invert current value to trigger initial change\r\n },\r\n getIsDirectionRTL\r\n );\r\n const [updateDirectionIsRTLCache] = directionIsRTLCache;\r\n\r\n push(\r\n offListeners,\r\n on(sizeObserver, scrollEventName, (event: Event) => {\r\n const directionIsRTLCacheValues = updateDirectionIsRTLCache();\r\n const [directionIsRTL, directionIsRTLChanged] = directionIsRTLCacheValues;\r\n\r\n if (directionIsRTLChanged) {\r\n removeClass(listenerElement, 'ltr rtl');\r\n if (directionIsRTL) {\r\n addClass(listenerElement, 'rtl');\r\n } else {\r\n addClass(listenerElement, 'ltr');\r\n }\r\n onSizeChangedCallbackProxy(directionIsRTLCacheValues);\r\n }\r\n\r\n stopAndPrevent(event);\r\n })\r\n );\r\n }\r\n\r\n // appearCallback is always needed on scroll-observer strategy to reset it\r\n if (appearCallback) {\r\n addClass(sizeObserver, classNameSizeObserverAppear);\r\n push(\r\n offListeners,\r\n on(sizeObserver, animationStartEventName, appearCallback, {\r\n // Fire only once for \"CSS is ready\" event if ResizeObserver strategy is used\r\n _once: !!ResizeObserverConstructor,\r\n })\r\n );\r\n }\r\n\r\n prependChildren(target, sizeObserver);\r\n\r\n return () => {\r\n runEach(offListeners);\r\n removeElements(sizeObserver);\r\n };\r\n};\r\n","import {\r\n WH,\r\n CacheValues,\r\n createDiv,\r\n offsetSize,\r\n runEach,\r\n prependChildren,\r\n removeElements,\r\n createCache,\r\n push,\r\n IntersectionObserverConstructor,\r\n} from 'support';\r\nimport { createSizeObserver } from 'observers/sizeObserver';\r\nimport { classNameTrinsicObserver } from 'classnames';\r\n\r\nexport type DestroyTrinsicObserver = () => void;\r\n\r\nconst isHeightIntrinsic = (ioEntryOrSize: IntersectionObserverEntry | WH): boolean =>\r\n (ioEntryOrSize as WH).h === 0 ||\r\n (ioEntryOrSize as IntersectionObserverEntry).isIntersecting ||\r\n (ioEntryOrSize as IntersectionObserverEntry).intersectionRatio > 0;\r\n\r\n/**\r\n * Creates a trinsic observer which observes changes to intrinsic or extrinsic sizing for the height of the target element.\r\n * @param target The element which shall be observed.\r\n * @param onTrinsicChangedCallback The callback which gets called after a change was detected.\r\n * @returns A object which represents the instance of the trinsic observer.\r\n */\r\nexport const createTrinsicObserver = (\r\n target: HTMLElement,\r\n onTrinsicChangedCallback: (heightIntrinsic: CacheValues) => any\r\n): DestroyTrinsicObserver => {\r\n const trinsicObserver = createDiv(classNameTrinsicObserver);\r\n const offListeners: (() => void)[] = [];\r\n const [updateHeightIntrinsicCache] = createCache({\r\n _initialValue: false,\r\n });\r\n\r\n const triggerOnTrinsicChangedCallback = (\r\n updateValue?: IntersectionObserverEntry | WH\r\n ) => {\r\n if (updateValue) {\r\n const heightIntrinsic = updateHeightIntrinsicCache(isHeightIntrinsic(updateValue));\r\n const [, heightIntrinsicChanged] = heightIntrinsic;\r\n\r\n if (heightIntrinsicChanged) {\r\n onTrinsicChangedCallback(heightIntrinsic);\r\n }\r\n }\r\n };\r\n\r\n if (IntersectionObserverConstructor) {\r\n const intersectionObserverInstance: IntersectionObserver = new IntersectionObserverConstructor(\r\n (entries: IntersectionObserverEntry[]) => {\r\n if (entries && entries.length > 0) {\r\n triggerOnTrinsicChangedCallback(entries.pop());\r\n }\r\n },\r\n { root: target }\r\n );\r\n intersectionObserverInstance.observe(trinsicObserver);\r\n push(offListeners, () => {\r\n intersectionObserverInstance.disconnect();\r\n });\r\n } else {\r\n const onSizeChanged = () => {\r\n const newSize = offsetSize(trinsicObserver);\r\n triggerOnTrinsicChangedCallback(newSize);\r\n };\r\n push(offListeners, createSizeObserver(trinsicObserver, onSizeChanged));\r\n onSizeChanged();\r\n }\r\n\r\n prependChildren(target, trinsicObserver);\r\n\r\n return () => {\r\n runEach(offListeners);\r\n removeElements(trinsicObserver);\r\n };\r\n};\r\n","import {\r\n each,\r\n noop,\r\n debounce,\r\n indexOf,\r\n isString,\r\n MutationObserverConstructor,\r\n isEmptyArray,\r\n on,\r\n attr,\r\n is,\r\n find,\r\n push,\r\n} from 'support';\r\n\r\ntype DOMContentObserverCallback = (contentChangedTroughEvent: boolean) => any;\r\n\r\ntype DOMTargetObserverCallback = (targetChangedAttrs: string[], targetStyleChanged: boolean) => any;\r\n\r\ninterface DOMObserverOptionsBase {\r\n _attributes?: string[];\r\n _styleChangingAttributes?: string[];\r\n /**\r\n * A function which can ignore a changed attribute if it returns true.\r\n * for DOMTargetObserver this applies to the changes to the observed target\r\n * for DOMContentObserver this applies to changes to nested targets -> nested targets are elements which match the \"_nestedTargetSelector\" selector\r\n */\r\n _ignoreTargetChange?: DOMObserverIgnoreTargetChange;\r\n}\r\n\r\ninterface DOMContentObserverOptions extends DOMObserverOptionsBase {\r\n _eventContentChange?: DOMObserverEventContentChange; // [selector, eventname(s) | function returning eventname(s)] -> eventnames divided by whitespaces\r\n _nestedTargetSelector?: string;\r\n _ignoreContentChange?: DOMObserverIgnoreContentChange; // function which will prevent marking certain dom changes as content change if it returns true\r\n}\r\n\r\ntype DOMTargetObserverOptions = DOMObserverOptionsBase;\r\n\r\ntype ContentChangeArrayItem = [selector?: string, eventNames?: string] | null | undefined;\r\n\r\nexport type DOMObserverEventContentChange =\r\n | Array\r\n | false\r\n | null\r\n | undefined;\r\n\r\nexport type DOMObserverIgnoreContentChange = (\r\n mutation: MutationRecord,\r\n isNestedTarget: boolean,\r\n domObserverTarget: HTMLElement,\r\n domObserverOptions?: DOMContentObserverOptions\r\n) => boolean;\r\n\r\nexport type DOMObserverIgnoreTargetChange = (\r\n target: Node,\r\n attributeName: string,\r\n oldAttributeValue: string | null,\r\n newAttributeValue: string | null\r\n) => boolean;\r\n\r\nexport type DOMObserverCallback = ContentObserver extends true\r\n ? DOMContentObserverCallback\r\n : DOMTargetObserverCallback;\r\n\r\nexport type DOMObserverOptions = ContentObserver extends true\r\n ? DOMContentObserverOptions\r\n : DOMTargetObserverOptions;\r\n\r\nexport type DOMObserver = [destroy: () => void, update: () => void];\r\n\r\ntype EventContentChangeUpdateElement = (getElements?: (selector: string) => Node[]) => void;\r\ntype EventContentChange = [destroy: () => void, updateElements: EventContentChangeUpdateElement];\r\n\r\n/**\r\n * Creates a set of helper functions to observe events of elements inside the target element.\r\n * @param target The target element of which the children elements shall be observed. (not only direct children but also nested ones)\r\n * @param eventContentChange The event content change array. (array of tuples: selector and eventname(s))\r\n * @param callback Callback which is called if one of the elements emits the corresponding event.\r\n * @returns A object which contains a set of helper functions to destroy and update the observation of elements.\r\n */\r\nconst createEventContentChange = (\r\n target: Element,\r\n callback: (...args: any) => any,\r\n eventContentChange?: DOMObserverEventContentChange\r\n): EventContentChange => {\r\n let map: WeakMap