\
\
- '), a, b, c];
+ '
+ ),
+ a,
+ b,
+ c,
+ ];
};
export default index;
diff --git a/packages/overlayscrollbars/dist/overlayscrollbars.esm.js.map b/packages/overlayscrollbars/dist/overlayscrollbars.esm.js.map
index cceb4c1..5975614 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/core/utils/types.ts","../src/core/utils/object.ts","../src/core/utils/array.ts","../src/core/dom/traversal.ts","../src/core/dom/manipulation.ts","../src/core/dom/create.ts","../src/index.ts"],"sourcesContent":["import { PlainObject } from 'core/typings';\n\nexport const type: (obj: any) => string = (obj) => {\n if (obj === undefined) return `${obj}`;\n if (obj === null) return `${obj}`;\n return Object.prototype.toString\n .call(obj)\n .replace(/^\\[object (.+)\\]$/, '$1')\n .toLowerCase();\n};\n\nexport function isNumber(obj: any): obj is number {\n return typeof obj === 'number';\n}\n\nexport function isString(obj: any): obj is string {\n return typeof obj === 'string';\n}\n\nexport function isBoolean(obj: any): obj is boolean {\n return typeof obj === 'boolean';\n}\n\nexport function isFunction(obj: any): obj is (...args: Array) => unknown {\n return typeof obj === 'function';\n}\n\nexport function isUndefined(obj: any): obj is undefined {\n return obj === undefined;\n}\n\nexport function isNull(obj: any): obj is null {\n return obj === null;\n}\n\nexport function isArray(obj: any): obj is Array {\n return Array.isArray(obj);\n}\n\nexport function isObject(obj: any): boolean {\n return typeof obj === 'object' && !isArray(obj) && !isNull(obj);\n}\n\n/**\n * Returns true if the given object is array like, false otherwise.\n * @param obj The Object\n */\nexport function isArrayLike(obj: any): obj is ArrayLike {\n const length = !!obj && obj.length;\n return isArray(obj) || (!isFunction(obj) && isNumber(length) && length > -1 && length % 1 == 0); // eslint-disable-line eqeqeq\n}\n\n/**\n * Returns true if the given object is a \"plain\" (e.g. { key: value }) object, false otherwise.\n * @param obj The Object.\n */\nexport function isPlainObject(obj: any): obj is PlainObject {\n if (!obj || !isObject(obj) || type(obj) !== 'object') return false;\n\n let key;\n const proto = 'prototype';\n const { hasOwnProperty } = Object[proto];\n const hasOwnConstructor = hasOwnProperty.call(obj, 'constructor');\n const hasIsPrototypeOf = obj.constructor && obj.constructor[proto] && hasOwnProperty.call(obj.constructor[proto], 'isPrototypeOf');\n\n if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {\n return false;\n }\n\n /* eslint-disable no-restricted-syntax */\n for (key in obj) {\n /**/\n }\n /* eslint-enable */\n\n return isUndefined(key) || hasOwnProperty.call(obj, key);\n}\n\n/**\n * Checks whether the given object is a HTMLElement.\n * @param obj The object which shall be checked.\n */\nexport function isHTMLElement(obj: any): obj is HTMLElement {\n const instaceOfRightHandSide = window.HTMLElement;\n const doInstanceOf = isObject(instaceOfRightHandSide) || isFunction(instaceOfRightHandSide);\n return !!(doInstanceOf ? obj instanceof instaceOfRightHandSide : obj && isObject(obj) && obj.nodeType === 1 && isString(obj.nodeName));\n}\n\n/**\n * Returns true if the given object is empty, false otherwise.\n * @param obj The Object.\n */\nexport function isEmptyObject(obj: any): boolean {\n /* eslint-disable no-restricted-syntax, guard-for-in */\n for (const name in obj) return false;\n return true;\n /* eslint-enable */\n}\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 = (obj: any, prop: string | number | symbol) =>\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: any) => (obj ? Object.keys(obj) : []);\r\n","import { keys } from 'core/utils/object';\nimport { isArrayLike } from 'core/utils/types';\nimport { PlainObject } from 'core/typings';\n\n/**\n * Iterates through a array or object\n * @param arrayLikeOrObject The array or object through which shall be iterated.\n * @param callback The function which is responsible for the iteration.\n * If the function returns true its treated like a \"continue\" statement.\n * If the function returns false its treated like a \"break\" statement.\n */\nexport function each(\n array: Array | ReadonlyArray,\n callback: (value: T, indexOrKey: number, source: Array) => boolean | void,\n): Array | ReadonlyArray;\nexport function each(\n array: Array | ReadonlyArray | null,\n callback: (value: T, indexOrKey: number, source: Array) => boolean | void,\n): Array | ReadonlyArray | null;\nexport function each(\n arrayLikeObject: ArrayLike,\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\n): ArrayLike;\nexport function each(\n arrayLikeObject: ArrayLike | null,\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\n): ArrayLike | null;\nexport function each(obj: PlainObject, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject;\nexport function each(obj: PlainObject | null, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject | null;\nexport function each(\n source: ArrayLike | PlainObject | null,\n callback: (value: T | any, indexOrKey: any, source: any) => boolean | void,\n): Array | ReadonlyArray | ArrayLike | PlainObject | null {\n if (isArrayLike(source)) {\n for (let i = 0; i < source.length; i++) {\n if (callback(source[i], i, source) === false) {\n break;\n }\n }\n } else if (source) {\n each(keys(source), (key) => callback(source[key], key, source));\n }\n return source;\n}\n\n/**\n * Returns the index of the given inside the given array or -1 if the given item isn't part of the given array.\n * @param arr The array.\n * @param item The item.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\nexport const indexOf: (arr: Array, item: T, fromIndex?: number) => number = (arr, item, fromIndex) => arr.indexOf(item, fromIndex);\n","import { each } from 'core/utils/array';\n\nconst elementIsVisible: (elm: HTMLElement) => boolean = (elm) => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);\n\nexport const find: (selector: string, elm?: Element | null) => ReadonlyArray = (selector, elm?) => {\n const arr: Array = [];\n\n each((elm || document).querySelectorAll(selector), (e: Element) => {\n arr.push(e);\n });\n\n return arr;\n};\n\nexport const findFirst: (selector: string, elm?: Element | null) => Element | null = (selector, elm?) => (elm || document).querySelector(selector);\n\nexport const is: (elm: Element | null, selector: string) => boolean = (elm, selector) => {\n if (elm) {\n if (selector === ':visible') {\n return elementIsVisible(elm as HTMLElement);\n }\n if (selector === ':hidden') {\n return !elementIsVisible(elm as HTMLElement);\n }\n if (elm.matches(selector)) {\n return true;\n }\n }\n return false;\n};\n\nexport const children: (elm: Element | null, selector?: string) => ReadonlyArray = (elm, selector?) => {\n const childs: Array = [];\n\n each(elm && elm.children, (child: Element) => {\n if (selector) {\n if (child.matches(selector)) {\n childs.push(child);\n }\n } else {\n childs.push(child);\n }\n });\n\n return childs;\n};\n\nexport const contents: (elm: Element | null) => ReadonlyArray = (elm) => (elm ? Array.from(elm.childNodes) : []);\n\nexport const parent: (elm: Node | null) => Node | null = (elm) => (elm ? elm.parentElement : null);\n","import { isArrayLike } from 'core/utils/types';\nimport { each } from 'core/utils/array';\nimport { parent } from 'core/dom/traversal';\n\ntype NodeCollection = ArrayLike | Node | undefined | null;\n\n/**\n * Inserts Nodes before the given preferredAnchor element.\n * @param parentElm The parent of the preferredAnchor element or the element which shall be the parent of the inserted Nodes.\n * @param preferredAnchor The element before which the Nodes shall be inserted or null if the elements shall be appended at the end.\n * @param insertedElms The Nodes which shall be inserted.\n */\nconst before: (parentElm: Node | null, preferredAnchor: Node | null, insertedElms: NodeCollection) => void = (\n parentElm,\n preferredAnchor,\n insertedElms,\n) => {\n if (insertedElms) {\n let anchor: Node | null = preferredAnchor;\n let fragment: DocumentFragment | Node | undefined | null;\n\n // parent must be defined\n if (parentElm) {\n if (isArrayLike(insertedElms)) {\n fragment = document.createDocumentFragment();\n\n // append all insertedElms to the fragment and if one of these is the anchor, change the anchor\n each(insertedElms, (insertedElm) => {\n if (insertedElm === anchor) {\n anchor = insertedElm.previousSibling;\n }\n fragment!.appendChild(insertedElm);\n });\n } else {\n fragment = insertedElms;\n }\n\n // if the preferred anchor isn't null set it to a valid anchor\n if (preferredAnchor) {\n if (!anchor) {\n anchor = parentElm.firstChild;\n } else if (anchor !== preferredAnchor) {\n anchor = anchor.nextSibling;\n }\n }\n\n parentElm.insertBefore(fragment, anchor);\n }\n }\n};\n\n/**\n * Appends the given children at the end of the given Node.\n * @param node The Node to which the children shall be appended.\n * @param children The Nodes which shall be appended.\n */\nexport const appendChildren: (node: Node | null, children: NodeCollection) => void = (node, children) => {\n before(node, null, children);\n};\n\n/**\n * Prepends the given children at the start of the given Node.\n * @param node The Node to which the children shall be prepended.\n * @param children The Nodes which shall be prepended.\n */\nexport const prependChildren: (node: Node | null, children: NodeCollection) => void = (node, children) => {\n before(node, node && node.firstChild, children);\n};\n\n/**\n * Inserts the given Nodes before the given Node.\n * @param node The Node before which the given Nodes shall be inserted.\n * @param insertedNodes The Nodes which shall be inserted.\n */\nexport const insertBefore: (node: Node | null, insertedNodes: NodeCollection) => void = (node, insertedNodes) => {\n before(parent(node), node, insertedNodes);\n};\n\n/**\n * Inserts the given Nodes after the given Node.\n * @param node The Node after which the given Nodes shall be inserted.\n * @param insertedNodes The Nodes which shall be inserted.\n */\nexport const insertAfter: (node: Node | null, insertedNodes: NodeCollection) => void = (node, insertedNodes) => {\n before(parent(node), node && node.nextSibling, insertedNodes);\n};\n\n/**\n * Removes the given Nodes from their parent.\n * @param nodes The Nodes which shall be removed.\n */\nexport const removeElements: (nodes: NodeCollection) => void = (nodes) => {\n if (isArrayLike(nodes)) {\n each(Array.from(nodes), (e) => removeElements(e));\n } else if (nodes) {\n const { parentNode } = nodes;\n if (parentNode) {\n parentNode.removeChild(nodes);\n }\n }\n};\n","import { each } from 'core/utils/array';\nimport { contents } from 'core/dom/traversal';\nimport { removeElements } from 'core/dom/manipulation';\n\nexport const createDiv: () => HTMLDivElement = () => document.createElement('div');\n\nexport const createDOM: (html: string) => ReadonlyArray = (html) => {\n const createdDiv = createDiv();\n createdDiv.innerHTML = html.trim();\n\n return each(contents(createdDiv), (elm) => removeElements(elm));\n};\n","import { createDOM } from 'core/dom';\n\n/*\nexport * from 'core/compatibility';\nexport * from 'core/utils';\nexport * from 'core/dom';\nexport * from 'core/options';\nexport * from 'instances';\n*/\n\nconst abc = {\n a: 1,\n b: 1,\n c: 1,\n};\n\nexport default () => {\n const { a, b, c } = abc;\n return [\n createDOM(\n '\\\n
\\\n \\\n
\\\n
\\\n
\\\n fdfhdfgh\\\n
\\\n
\\\n
\\\n
\\\n
\\\n \\\n
\\\n
\\\n
\\\n
\\\n \\\n
\\\n
\\\n \\\n
'\n ),\n a,\n b,\n c,\n ];\n};\n"],"names":["isNumber","obj","isFunction","isArray","Array","isArrayLike","length","keys","Object","each","source","callback","i","key","contents","elm","from","childNodes","removeElements","nodes","e","parentNode","removeChild","createDiv","document","createElement","createDOM","html","createdDiv","innerHTML","trim","abc","a","b","c"],"mappings":"SAWgBA,SAASC;AACvB,SAAO,OAAOA,GAAP,KAAe,QAAtB;AACD;;SAUeC,WAAWD;AACzB,SAAO,OAAOA,GAAP,KAAe,UAAtB;AACD;;SAUeE,QAAQF;AACtB,SAAOG,KAAK,CAACD,OAAN,CAAcF,GAAd,CAAP;AACD;;SAUeI,YAAyCJ;AACvD,QAAMK,MAAM,GAAG,CAAC,CAACL,GAAF,IAASA,GAAG,CAACK,MAA5B;AACA,SAAOH,OAAO,CAACF,GAAD,CAAP,IAAiB,CAACC,UAAU,CAACD,GAAD,CAAX,IAAoBD,QAAQ,CAACM,MAAD,CAA5B,IAAwCA,MAAM,GAAG,CAAC,CAAlD,IAAuDA,MAAM,GAAG,CAAT,IAAc,CAA7F;;;ACrCK,MAAMC,IAAI,GAAiCN,GAAD,IAAeA,GAAG,GAAGO,MAAM,CAACD,IAAP,CAAYN,GAAZ,CAAH,GAAsB,EAAlF;;SCiBSQ,KACdC,QACAC;AAEA,MAAIN,WAAW,CAACK,MAAD,CAAf,EAAyB;AACvB,SAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,MAAM,CAACJ,MAA3B,EAAmCM,CAAC,EAApC,EAAwC;AACtC,UAAID,QAAQ,CAACD,MAAM,CAACE,CAAD,CAAP,EAAYA,CAAZ,EAAeF,MAAf,CAAR,KAAmC,KAAvC,EAA8C;AAC5C;AACD;AACF;AACF,GAND,MAMO,IAAIA,MAAJ,EAAY;AACjBD,IAAAA,IAAI,CAACF,IAAI,CAACG,MAAD,CAAL,EAAgBG,GAAD,IAASF,QAAQ,CAACD,MAAM,CAACG,GAAD,CAAP,EAAcA,GAAd,EAAmBH,MAAnB,CAAhC,CAAJ;AACD;;AACD,SAAOA,MAAP;;;ACKK,MAAMI,QAAQ,GAAuDC,GAAD,IAAUA,GAAG,GAAGX,KAAK,CAACY,IAAN,CAAsBD,GAAG,CAACE,UAA1B,CAAH,GAA2C,EAA5H;;AC4CA,MAAMC,cAAc,GAAqCC,KAAD;AAC7D,MAAId,WAAW,CAACc,KAAD,CAAf,EAAwB;AACtBV,IAAAA,IAAI,CAACL,KAAK,CAACY,IAAN,CAAWG,KAAX,CAAD,EAAqBC,CAAD,IAAOF,cAAc,CAACE,CAAD,CAAzC,CAAJ;AACD,GAFD,MAEO,IAAID,KAAJ,EAAW;AAChB,UAAM;AAAEE,MAAAA;AAAF,QAAiBF,KAAvB;;AACA,QAAIE,UAAJ,EAAgB;AACdA,MAAAA,UAAU,CAACC,WAAX,CAAuBH,KAAvB;AACD;AACF;AACF,CATM;;ACvFA,MAAMI,SAAS,GAAyB,MAAMC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAA9C;;AAEA,MAAMC,SAAS,GAA2CC,IAAD;AAC9D,QAAMC,UAAU,GAAGL,SAAS,EAA5B;AACAK,EAAAA,UAAU,CAACC,SAAX,GAAuBF,IAAI,CAACG,IAAL,EAAvB;AAEA,SAAOrB,IAAI,CAACK,QAAQ,CAACc,UAAD,CAAT,EAAwBb,GAAD,IAASG,cAAc,CAACH,GAAD,CAA9C,CAAX;AACD,CALM;;ACIP,MAAMgB,GAAG,GAAG;AACVC,EAAAA,CAAC,EAAE,CADO;AAEVC,EAAAA,CAAC,EAAE,CAFO;AAGVC,EAAAA,CAAC,EAAE;AAHO,CAAZ;;AAMA,YAAe;AACb,QAAM;AAAEF,IAAAA,CAAF;AAAKC,IAAAA,CAAL;AAAQC,IAAAA;AAAR,MAAcH,GAApB;AACA,SAAO,CACLL,SAAS,CACP;;;;;;;;;;;;;;;;;;;;;WADO,CADJ,EAyBLM,CAzBK,EA0BLC,CA1BK,EA2BLC,CA3BK,CAAP;AA6BD,CA/BD;;"}
\ No newline at end of file
+{"version":3,"file":"overlayscrollbars.esm.js","sources":["../src/support/utils/types.ts","../src/support/utils/object.ts","../src/support/utils/array.ts","../src/support/dom/traversal.ts","../src/support/dom/manipulation.ts","../src/support/dom/create.ts","../src/index.ts"],"sourcesContent":["import { PlainObject } from 'typings';\r\n\r\nexport const type: (obj: any) => string = (obj) => {\r\n if (obj === undefined) return `${obj}`;\r\n if (obj === null) return `${obj}`;\r\n return Object.prototype.toString\r\n .call(obj)\r\n .replace(/^\\[object (.+)\\]$/, '$1')\r\n .toLowerCase();\r\n};\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: Array) => unknown {\r\n return typeof obj === 'function';\r\n}\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 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 return isArray(obj) || (!isFunction(obj) && isNumber(length) && length > -1 && length % 1 == 0); // eslint-disable-line eqeqeq\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 proto = 'prototype';\r\n const { hasOwnProperty } = Object[proto];\r\n const hasOwnConstructor = hasOwnProperty.call(obj, 'constructor');\r\n const hasIsPrototypeOf = obj.constructor && obj.constructor[proto] && hasOwnProperty.call(obj.constructor[proto], 'isPrototypeOf');\r\n\r\n if (obj.constructor && !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 instaceOfRightHandSide = window.HTMLElement;\r\n const doInstanceOf = isObject(instaceOfRightHandSide) || isFunction(instaceOfRightHandSide);\r\n return !!(doInstanceOf ? obj instanceof instaceOfRightHandSide : obj && isObject(obj) && obj.nodeType === 1 && isString(obj.nodeName));\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","/**\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","import { keys } from 'support/utils/object';\r\nimport { isArrayLike } from 'support/utils/types';\r\nimport { PlainObject } from 'typings';\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 | void,\r\n): Array | ReadonlyArray;\r\nexport function each(\r\n array: Array | ReadonlyArray | null,\r\n callback: (value: T, indexOrKey: number, source: Array) => boolean | void,\r\n): Array | ReadonlyArray | null;\r\nexport function each(\r\n arrayLikeObject: ArrayLike,\r\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\r\n): ArrayLike;\r\nexport function each(\r\n arrayLikeObject: ArrayLike | null,\r\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\r\n): ArrayLike | null;\r\nexport function each(obj: PlainObject, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject;\r\nexport function each(obj: PlainObject | null, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject | null;\r\nexport function each(\r\n source: ArrayLike | PlainObject | null,\r\n callback: (value: T | any, indexOrKey: any, source: any) => boolean | void,\r\n): Array | ReadonlyArray | ArrayLike | PlainObject | null {\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(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: Array, item: T, fromIndex?: number): number => arr.indexOf(item, fromIndex);\r\n","import { each } from 'support/utils/array';\r\n\r\nconst elementIsVisible = (elm: HTMLElement): boolean => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);\r\n\r\nexport const find = (selector: string, elm?: Element | null): ReadonlyArray => {\r\n const arr: Array = [];\r\n\r\n each((elm || document).querySelectorAll(selector), (e: Element) => {\r\n arr.push(e);\r\n });\r\n\r\n return arr;\r\n};\r\n\r\nexport const findFirst = (selector: string, elm?: Element | null): Element | null => (elm || document).querySelector(selector);\r\n\r\nexport const is = (elm: Element | null, selector: string): boolean => {\r\n if (elm) {\r\n if (selector === ':visible') {\r\n return elementIsVisible(elm as HTMLElement);\r\n }\r\n if (selector === ':hidden') {\r\n return !elementIsVisible(elm as HTMLElement);\r\n }\r\n if (elm.matches(selector)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n\r\nexport const children = (elm: Element | null, selector?: string): ReadonlyArray => {\r\n const childs: Array = [];\r\n\r\n each(elm && elm.children, (child: Element) => {\r\n if (selector) {\r\n if (child.matches(selector)) {\r\n childs.push(child);\r\n }\r\n } else {\r\n childs.push(child);\r\n }\r\n });\r\n\r\n return childs;\r\n};\r\n\r\nexport const contents = (elm: Element | null): ReadonlyArray => (elm ? Array.from(elm.childNodes) : []);\r\n\r\nexport const parent = (elm: Node | null): Node | null => (elm ? elm.parentElement : null);\r\n","import { isArrayLike } from 'support/utils/types';\r\nimport { each } from 'support/utils/array';\r\nimport { parent } from 'support/dom/traversal';\r\n\r\ntype NodeCollection = ArrayLike | Node | undefined | null;\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 = (parentElm: Node | null, preferredAnchor: Node | null, insertedElms: NodeCollection): void => {\r\n if (insertedElms) {\r\n let anchor: Node | null = preferredAnchor;\r\n let fragment: DocumentFragment | Node | undefined | null;\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);\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, 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, 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 = (node: Node | null, insertedNodes: NodeCollection): 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, 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(Array.from(nodes), (e) => removeElements(e));\r\n } else if (nodes) {\r\n const { parentNode } = nodes;\r\n if (parentNode) {\r\n parentNode.removeChild(nodes);\r\n }\r\n }\r\n};\r\n","import { each } from 'support/utils/array';\r\nimport { contents } from 'support/dom/traversal';\r\nimport { removeElements } from 'support/dom/manipulation';\r\n\r\nexport const createDiv = (): HTMLDivElement => document.createElement('div');\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 { createDOM } from 'support/dom';\r\n\r\nconst abc = {\r\n a: 1,\r\n b: 1,\r\n c: 1,\r\n};\r\n\r\nexport default () => {\r\n const { a, b, c } = abc;\r\n return [\r\n createDOM(\r\n '\\\r\n
\
\
- '), a, b, c];
+ '
+ ),
+ a,
+ b,
+ c,
+ ];
};
- var _default = index;
- _exports.default = _default;
+ return index;
});
//# sourceMappingURL=overlayscrollbars.js.map
diff --git a/packages/overlayscrollbars/dist/overlayscrollbars.js.map b/packages/overlayscrollbars/dist/overlayscrollbars.js.map
index d61b41a..c02f08b 100644
--- a/packages/overlayscrollbars/dist/overlayscrollbars.js.map
+++ b/packages/overlayscrollbars/dist/overlayscrollbars.js.map
@@ -1 +1 @@
-{"version":3,"file":"overlayscrollbars.js","sources":["../src/core/utils/types.ts","../src/core/utils/object.ts","../src/core/utils/array.ts","../src/core/dom/traversal.ts","../src/core/dom/manipulation.ts","../src/core/dom/create.ts","../src/index.ts"],"sourcesContent":["import { PlainObject } from 'core/typings';\n\nexport const type: (obj: any) => string = (obj) => {\n if (obj === undefined) return `${obj}`;\n if (obj === null) return `${obj}`;\n return Object.prototype.toString\n .call(obj)\n .replace(/^\\[object (.+)\\]$/, '$1')\n .toLowerCase();\n};\n\nexport function isNumber(obj: any): obj is number {\n return typeof obj === 'number';\n}\n\nexport function isString(obj: any): obj is string {\n return typeof obj === 'string';\n}\n\nexport function isBoolean(obj: any): obj is boolean {\n return typeof obj === 'boolean';\n}\n\nexport function isFunction(obj: any): obj is (...args: Array) => unknown {\n return typeof obj === 'function';\n}\n\nexport function isUndefined(obj: any): obj is undefined {\n return obj === undefined;\n}\n\nexport function isNull(obj: any): obj is null {\n return obj === null;\n}\n\nexport function isArray(obj: any): obj is Array {\n return Array.isArray(obj);\n}\n\nexport function isObject(obj: any): boolean {\n return typeof obj === 'object' && !isArray(obj) && !isNull(obj);\n}\n\n/**\n * Returns true if the given object is array like, false otherwise.\n * @param obj The Object\n */\nexport function isArrayLike(obj: any): obj is ArrayLike {\n const length = !!obj && obj.length;\n return isArray(obj) || (!isFunction(obj) && isNumber(length) && length > -1 && length % 1 == 0); // eslint-disable-line eqeqeq\n}\n\n/**\n * Returns true if the given object is a \"plain\" (e.g. { key: value }) object, false otherwise.\n * @param obj The Object.\n */\nexport function isPlainObject(obj: any): obj is PlainObject {\n if (!obj || !isObject(obj) || type(obj) !== 'object') return false;\n\n let key;\n const proto = 'prototype';\n const { hasOwnProperty } = Object[proto];\n const hasOwnConstructor = hasOwnProperty.call(obj, 'constructor');\n const hasIsPrototypeOf = obj.constructor && obj.constructor[proto] && hasOwnProperty.call(obj.constructor[proto], 'isPrototypeOf');\n\n if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {\n return false;\n }\n\n /* eslint-disable no-restricted-syntax */\n for (key in obj) {\n /**/\n }\n /* eslint-enable */\n\n return isUndefined(key) || hasOwnProperty.call(obj, key);\n}\n\n/**\n * Checks whether the given object is a HTMLElement.\n * @param obj The object which shall be checked.\n */\nexport function isHTMLElement(obj: any): obj is HTMLElement {\n const instaceOfRightHandSide = window.HTMLElement;\n const doInstanceOf = isObject(instaceOfRightHandSide) || isFunction(instaceOfRightHandSide);\n return !!(doInstanceOf ? obj instanceof instaceOfRightHandSide : obj && isObject(obj) && obj.nodeType === 1 && isString(obj.nodeName));\n}\n\n/**\n * Returns true if the given object is empty, false otherwise.\n * @param obj The Object.\n */\nexport function isEmptyObject(obj: any): boolean {\n /* eslint-disable no-restricted-syntax, guard-for-in */\n for (const name in obj) return false;\n return true;\n /* eslint-enable */\n}\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 = (obj: any, prop: string | number | symbol) =>\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: any) => (obj ? Object.keys(obj) : []);\r\n","import { keys } from 'core/utils/object';\nimport { isArrayLike } from 'core/utils/types';\nimport { PlainObject } from 'core/typings';\n\n/**\n * Iterates through a array or object\n * @param arrayLikeOrObject The array or object through which shall be iterated.\n * @param callback The function which is responsible for the iteration.\n * If the function returns true its treated like a \"continue\" statement.\n * If the function returns false its treated like a \"break\" statement.\n */\nexport function each(\n array: Array | ReadonlyArray,\n callback: (value: T, indexOrKey: number, source: Array) => boolean | void,\n): Array | ReadonlyArray;\nexport function each(\n array: Array | ReadonlyArray | null,\n callback: (value: T, indexOrKey: number, source: Array) => boolean | void,\n): Array | ReadonlyArray | null;\nexport function each(\n arrayLikeObject: ArrayLike,\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\n): ArrayLike;\nexport function each(\n arrayLikeObject: ArrayLike | null,\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\n): ArrayLike | null;\nexport function each(obj: PlainObject, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject;\nexport function each(obj: PlainObject | null, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject | null;\nexport function each(\n source: ArrayLike | PlainObject | null,\n callback: (value: T | any, indexOrKey: any, source: any) => boolean | void,\n): Array | ReadonlyArray | ArrayLike | PlainObject | null {\n if (isArrayLike(source)) {\n for (let i = 0; i < source.length; i++) {\n if (callback(source[i], i, source) === false) {\n break;\n }\n }\n } else if (source) {\n each(keys(source), (key) => callback(source[key], key, source));\n }\n return source;\n}\n\n/**\n * Returns the index of the given inside the given array or -1 if the given item isn't part of the given array.\n * @param arr The array.\n * @param item The item.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\nexport const indexOf: (arr: Array, item: T, fromIndex?: number) => number = (arr, item, fromIndex) => arr.indexOf(item, fromIndex);\n","import { each } from 'core/utils/array';\n\nconst elementIsVisible: (elm: HTMLElement) => boolean = (elm) => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);\n\nexport const find: (selector: string, elm?: Element | null) => ReadonlyArray = (selector, elm?) => {\n const arr: Array = [];\n\n each((elm || document).querySelectorAll(selector), (e: Element) => {\n arr.push(e);\n });\n\n return arr;\n};\n\nexport const findFirst: (selector: string, elm?: Element | null) => Element | null = (selector, elm?) => (elm || document).querySelector(selector);\n\nexport const is: (elm: Element | null, selector: string) => boolean = (elm, selector) => {\n if (elm) {\n if (selector === ':visible') {\n return elementIsVisible(elm as HTMLElement);\n }\n if (selector === ':hidden') {\n return !elementIsVisible(elm as HTMLElement);\n }\n if (elm.matches(selector)) {\n return true;\n }\n }\n return false;\n};\n\nexport const children: (elm: Element | null, selector?: string) => ReadonlyArray = (elm, selector?) => {\n const childs: Array = [];\n\n each(elm && elm.children, (child: Element) => {\n if (selector) {\n if (child.matches(selector)) {\n childs.push(child);\n }\n } else {\n childs.push(child);\n }\n });\n\n return childs;\n};\n\nexport const contents: (elm: Element | null) => ReadonlyArray = (elm) => (elm ? Array.from(elm.childNodes) : []);\n\nexport const parent: (elm: Node | null) => Node | null = (elm) => (elm ? elm.parentElement : null);\n","import { isArrayLike } from 'core/utils/types';\nimport { each } from 'core/utils/array';\nimport { parent } from 'core/dom/traversal';\n\ntype NodeCollection = ArrayLike | Node | undefined | null;\n\n/**\n * Inserts Nodes before the given preferredAnchor element.\n * @param parentElm The parent of the preferredAnchor element or the element which shall be the parent of the inserted Nodes.\n * @param preferredAnchor The element before which the Nodes shall be inserted or null if the elements shall be appended at the end.\n * @param insertedElms The Nodes which shall be inserted.\n */\nconst before: (parentElm: Node | null, preferredAnchor: Node | null, insertedElms: NodeCollection) => void = (\n parentElm,\n preferredAnchor,\n insertedElms,\n) => {\n if (insertedElms) {\n let anchor: Node | null = preferredAnchor;\n let fragment: DocumentFragment | Node | undefined | null;\n\n // parent must be defined\n if (parentElm) {\n if (isArrayLike(insertedElms)) {\n fragment = document.createDocumentFragment();\n\n // append all insertedElms to the fragment and if one of these is the anchor, change the anchor\n each(insertedElms, (insertedElm) => {\n if (insertedElm === anchor) {\n anchor = insertedElm.previousSibling;\n }\n fragment!.appendChild(insertedElm);\n });\n } else {\n fragment = insertedElms;\n }\n\n // if the preferred anchor isn't null set it to a valid anchor\n if (preferredAnchor) {\n if (!anchor) {\n anchor = parentElm.firstChild;\n } else if (anchor !== preferredAnchor) {\n anchor = anchor.nextSibling;\n }\n }\n\n parentElm.insertBefore(fragment, anchor);\n }\n }\n};\n\n/**\n * Appends the given children at the end of the given Node.\n * @param node The Node to which the children shall be appended.\n * @param children The Nodes which shall be appended.\n */\nexport const appendChildren: (node: Node | null, children: NodeCollection) => void = (node, children) => {\n before(node, null, children);\n};\n\n/**\n * Prepends the given children at the start of the given Node.\n * @param node The Node to which the children shall be prepended.\n * @param children The Nodes which shall be prepended.\n */\nexport const prependChildren: (node: Node | null, children: NodeCollection) => void = (node, children) => {\n before(node, node && node.firstChild, children);\n};\n\n/**\n * Inserts the given Nodes before the given Node.\n * @param node The Node before which the given Nodes shall be inserted.\n * @param insertedNodes The Nodes which shall be inserted.\n */\nexport const insertBefore: (node: Node | null, insertedNodes: NodeCollection) => void = (node, insertedNodes) => {\n before(parent(node), node, insertedNodes);\n};\n\n/**\n * Inserts the given Nodes after the given Node.\n * @param node The Node after which the given Nodes shall be inserted.\n * @param insertedNodes The Nodes which shall be inserted.\n */\nexport const insertAfter: (node: Node | null, insertedNodes: NodeCollection) => void = (node, insertedNodes) => {\n before(parent(node), node && node.nextSibling, insertedNodes);\n};\n\n/**\n * Removes the given Nodes from their parent.\n * @param nodes The Nodes which shall be removed.\n */\nexport const removeElements: (nodes: NodeCollection) => void = (nodes) => {\n if (isArrayLike(nodes)) {\n each(Array.from(nodes), (e) => removeElements(e));\n } else if (nodes) {\n const { parentNode } = nodes;\n if (parentNode) {\n parentNode.removeChild(nodes);\n }\n }\n};\n","import { each } from 'core/utils/array';\nimport { contents } from 'core/dom/traversal';\nimport { removeElements } from 'core/dom/manipulation';\n\nexport const createDiv: () => HTMLDivElement = () => document.createElement('div');\n\nexport const createDOM: (html: string) => ReadonlyArray = (html) => {\n const createdDiv = createDiv();\n createdDiv.innerHTML = html.trim();\n\n return each(contents(createdDiv), (elm) => removeElements(elm));\n};\n","import { createDOM } from 'core/dom';\n\n/*\nexport * from 'core/compatibility';\nexport * from 'core/utils';\nexport * from 'core/dom';\nexport * from 'core/options';\nexport * from 'instances';\n*/\n\nconst abc = {\n a: 1,\n b: 1,\n c: 1,\n};\n\nexport default () => {\n const { a, b, c } = abc;\n return [\n createDOM(\n '\\\n
\\\n \\\n
\\\n
\\\n
\\\n fdfhdfgh\\\n
\\\n
\\\n
\\\n
\\\n
\\\n \\\n
\\\n
\\\n
\\\n
\\\n \\\n
\\\n
\\\n \\\n
'\n ),\n a,\n b,\n c,\n ];\n};\n"],"names":["isNumber","obj","isFunction","isArray","Array","isArrayLike","length","keys","Object","each","source","callback","i","key","contents","elm","from","childNodes","removeElements","nodes","e","parentNode","removeChild","createDiv","document","createElement","createDOM","html","createdDiv","innerHTML","trim","abc","a","b","c"],"mappings":";;;;;;;;;;;;;;;;;;;;WAWgBA,SAASC;AACvB,WAAO,OAAOA,GAAP,KAAe,QAAtB;AACD;;WAUeC,WAAWD;AACzB,WAAO,OAAOA,GAAP,KAAe,UAAtB;AACD;;WAUeE,QAAQF;AACtB,WAAOG,KAAK,CAACD,OAAN,CAAcF,GAAd,CAAP;AACD;;WAUeI,YAAyCJ;AACvD,QAAMK,MAAM,GAAG,CAAC,CAACL,GAAF,IAASA,GAAG,CAACK,MAA5B;AACA,WAAOH,OAAO,CAACF,GAAD,CAAP,IAAiB,CAACC,UAAU,CAACD,GAAD,CAAX,IAAoBD,QAAQ,CAACM,MAAD,CAA5B,IAAwCA,MAAM,GAAG,CAAC,CAAlD,IAAuDA,MAAM,GAAG,CAAT,IAAc,CAA7F;;;ACrCK,MAAMC,IAAI,GAAgC,SAApCA,IAAoC,CAACN,GAAD;AAAA,WAAeA,GAAG,GAAGO,MAAM,CAACD,IAAP,CAAYN,GAAZ,CAAH,GAAsB,EAAxC;AAAA,GAA1C;;WCiBSQ,KACdC,QACAC;AAEA,QAAIN,WAAW,CAACK,MAAD,CAAf,EAAyB;AACvB,WAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,MAAM,CAACJ,MAA3B,EAAmCM,CAAC,EAApC,EAAwC;AACtC,YAAID,QAAQ,CAACD,MAAM,CAACE,CAAD,CAAP,EAAYA,CAAZ,EAAeF,MAAf,CAAR,KAAmC,KAAvC,EAA8C;AAC5C;AACD;AACF;AACF,KAND,MAMO,IAAIA,MAAJ,EAAY;AACjBD,MAAAA,IAAI,CAACF,IAAI,CAACG,MAAD,CAAL,EAAe,UAACG,GAAD;AAAA,eAASF,QAAQ,CAACD,MAAM,CAACG,GAAD,CAAP,EAAcA,GAAd,EAAmBH,MAAnB,CAAjB;AAAA,OAAf,CAAJ;AACD;;AACD,WAAOA,MAAP;;;ACKK,MAAMI,QAAQ,GAAsD,SAA9DA,QAA8D,CAACC,GAAD;AAAA,WAAUA,GAAG,GAAGX,KAAK,CAACY,IAAN,CAAsBD,GAAG,CAACE,UAA1B,CAAH,GAA2C,EAAxD;AAAA,GAApE;;AC4CA,MAAMC,cAAc,GAAoC,SAAlDA,cAAkD,CAACC,KAAD;AAC7D,QAAId,WAAW,CAACc,KAAD,CAAf,EAAwB;AACtBV,MAAAA,IAAI,CAACL,KAAK,CAACY,IAAN,CAAWG,KAAX,CAAD,EAAoB,UAACC,CAAD;AAAA,eAAOF,cAAc,CAACE,CAAD,CAArB;AAAA,OAApB,CAAJ;AACD,KAFD,MAEO,IAAID,KAAJ,EAAW;AAAA,UACRE,UADQ,GACOF,KADP,CACRE,UADQ;;AAEhB,UAAIA,UAAJ,EAAgB;AACdA,QAAAA,UAAU,CAACC,WAAX,CAAuBH,KAAvB;AACD;AACF;AACF,GATM;;ACvFA,MAAMI,SAAS,GAAyB,SAAlCA,SAAkC;AAAA,WAAMC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAN;AAAA,GAAxC;;AAEA,MAAMC,SAAS,GAA0C,SAAnDA,SAAmD,CAACC,IAAD;AAC9D,QAAMC,UAAU,GAAGL,SAAS,EAA5B;AACAK,IAAAA,UAAU,CAACC,SAAX,GAAuBF,IAAI,CAACG,IAAL,EAAvB;AAEA,WAAOrB,IAAI,CAACK,QAAQ,CAACc,UAAD,CAAT,EAAuB,UAACb,GAAD;AAAA,aAASG,cAAc,CAACH,GAAD,CAAvB;AAAA,KAAvB,CAAX;AACD,GALM;;ACIP,MAAMgB,GAAG,GAAG;AACVC,IAAAA,CAAC,EAAE,CADO;AAEVC,IAAAA,CAAC,EAAE,CAFO;AAGVC,IAAAA,CAAC,EAAE;AAHO,GAAZ;;AAMA,cAAe,cAAA;QACLF,IAAYD,IAAZC;QAAGC,IAASF,IAATE;QAAGC,IAAMH,IAANG;AACd,WAAO,CACLR,SAAS,CACP;;;;;;;;;;;;;;;;;;;;;WADO,CADJ,EAyBLM,CAzBK,EA0BLC,CA1BK,EA2BLC,CA3BK,CAAP;AA6BD,GA/BD;;"}
\ No newline at end of file
+{"version":3,"file":"overlayscrollbars.js","sources":["../src/support/utils/types.ts","../src/support/utils/object.ts","../src/support/utils/array.ts","../src/support/dom/traversal.ts","../src/support/dom/manipulation.ts","../src/support/dom/create.ts","../src/index.ts"],"sourcesContent":["import { PlainObject } from 'typings';\r\n\r\nexport const type: (obj: any) => string = (obj) => {\r\n if (obj === undefined) return `${obj}`;\r\n if (obj === null) return `${obj}`;\r\n return Object.prototype.toString\r\n .call(obj)\r\n .replace(/^\\[object (.+)\\]$/, '$1')\r\n .toLowerCase();\r\n};\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: Array) => unknown {\r\n return typeof obj === 'function';\r\n}\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 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 return isArray(obj) || (!isFunction(obj) && isNumber(length) && length > -1 && length % 1 == 0); // eslint-disable-line eqeqeq\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 proto = 'prototype';\r\n const { hasOwnProperty } = Object[proto];\r\n const hasOwnConstructor = hasOwnProperty.call(obj, 'constructor');\r\n const hasIsPrototypeOf = obj.constructor && obj.constructor[proto] && hasOwnProperty.call(obj.constructor[proto], 'isPrototypeOf');\r\n\r\n if (obj.constructor && !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 instaceOfRightHandSide = window.HTMLElement;\r\n const doInstanceOf = isObject(instaceOfRightHandSide) || isFunction(instaceOfRightHandSide);\r\n return !!(doInstanceOf ? obj instanceof instaceOfRightHandSide : obj && isObject(obj) && obj.nodeType === 1 && isString(obj.nodeName));\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","/**\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","import { keys } from 'support/utils/object';\r\nimport { isArrayLike } from 'support/utils/types';\r\nimport { PlainObject } from 'typings';\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 | void,\r\n): Array | ReadonlyArray;\r\nexport function each(\r\n array: Array | ReadonlyArray | null,\r\n callback: (value: T, indexOrKey: number, source: Array) => boolean | void,\r\n): Array | ReadonlyArray | null;\r\nexport function each(\r\n arrayLikeObject: ArrayLike,\r\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\r\n): ArrayLike;\r\nexport function each(\r\n arrayLikeObject: ArrayLike | null,\r\n callback: (value: T, indexOrKey: number, source: ArrayLike) => boolean | void,\r\n): ArrayLike | null;\r\nexport function each(obj: PlainObject, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject;\r\nexport function each(obj: PlainObject | null, callback: (value: any, indexOrKey: string, source: PlainObject) => boolean | void): PlainObject | null;\r\nexport function each(\r\n source: ArrayLike | PlainObject | null,\r\n callback: (value: T | any, indexOrKey: any, source: any) => boolean | void,\r\n): Array | ReadonlyArray | ArrayLike | PlainObject | null {\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(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: Array, item: T, fromIndex?: number): number => arr.indexOf(item, fromIndex);\r\n","import { each } from 'support/utils/array';\r\n\r\nconst elementIsVisible = (elm: HTMLElement): boolean => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);\r\n\r\nexport const find = (selector: string, elm?: Element | null): ReadonlyArray => {\r\n const arr: Array = [];\r\n\r\n each((elm || document).querySelectorAll(selector), (e: Element) => {\r\n arr.push(e);\r\n });\r\n\r\n return arr;\r\n};\r\n\r\nexport const findFirst = (selector: string, elm?: Element | null): Element | null => (elm || document).querySelector(selector);\r\n\r\nexport const is = (elm: Element | null, selector: string): boolean => {\r\n if (elm) {\r\n if (selector === ':visible') {\r\n return elementIsVisible(elm as HTMLElement);\r\n }\r\n if (selector === ':hidden') {\r\n return !elementIsVisible(elm as HTMLElement);\r\n }\r\n if (elm.matches(selector)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n\r\nexport const children = (elm: Element | null, selector?: string): ReadonlyArray => {\r\n const childs: Array = [];\r\n\r\n each(elm && elm.children, (child: Element) => {\r\n if (selector) {\r\n if (child.matches(selector)) {\r\n childs.push(child);\r\n }\r\n } else {\r\n childs.push(child);\r\n }\r\n });\r\n\r\n return childs;\r\n};\r\n\r\nexport const contents = (elm: Element | null): ReadonlyArray => (elm ? Array.from(elm.childNodes) : []);\r\n\r\nexport const parent = (elm: Node | null): Node | null => (elm ? elm.parentElement : null);\r\n","import { isArrayLike } from 'support/utils/types';\r\nimport { each } from 'support/utils/array';\r\nimport { parent } from 'support/dom/traversal';\r\n\r\ntype NodeCollection = ArrayLike | Node | undefined | null;\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 = (parentElm: Node | null, preferredAnchor: Node | null, insertedElms: NodeCollection): void => {\r\n if (insertedElms) {\r\n let anchor: Node | null = preferredAnchor;\r\n let fragment: DocumentFragment | Node | undefined | null;\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);\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, 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, 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 = (node: Node | null, insertedNodes: NodeCollection): 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, 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(Array.from(nodes), (e) => removeElements(e));\r\n } else if (nodes) {\r\n const { parentNode } = nodes;\r\n if (parentNode) {\r\n parentNode.removeChild(nodes);\r\n }\r\n }\r\n};\r\n","import { each } from 'support/utils/array';\r\nimport { contents } from 'support/dom/traversal';\r\nimport { removeElements } from 'support/dom/manipulation';\r\n\r\nexport const createDiv = (): HTMLDivElement => document.createElement('div');\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 { createDOM } from 'support/dom';\r\n\r\nconst abc = {\r\n a: 1,\r\n b: 1,\r\n c: 1,\r\n};\r\n\r\nexport default () => {\r\n const { a, b, c } = abc;\r\n return [\r\n createDOM(\r\n '\\\r\n
\\\r\n \\\r\n
\\\r\n
\\\r\n
\\\r\n fdfhdfgh\\\r\n
\\\r\n
\\\r\n
\\\r\n
\\\r\n
\\\r\n \\\r\n
\\\r\n
\\\r\n
\\\r\n
\\\r\n \\\r\n
\\\r\n
\\\r\n \\\r\n
'\r\n ),\r\n a,\r\n b,\r\n c,\r\n ];\r\n};\r\n"],"names":["isNumber","obj","isFunction","isArray","Array","isArrayLike","length","keys","Object","each","source","callback","i","key","contents","elm","from","childNodes","removeElements","nodes","e","parentNode","removeChild","createDiv","document","createElement","createDOM","html","createdDiv","innerHTML","trim","abc","a","b","c"],"mappings":";;;;;;;;;WAWgBA,SAASC;AACvB,WAAO,OAAOA,GAAP,KAAe,QAAtB;AACD;;WAUeC,WAAWD;AACzB,WAAO,OAAOA,GAAP,KAAe,UAAtB;AACD;;WAUeE,QAAQF;AACtB,WAAOG,KAAK,CAACD,OAAN,CAAcF,GAAd,CAAP;AACD;;WAUeI,YAAyCJ;AACvD,QAAMK,MAAM,GAAG,CAAC,CAACL,GAAF,IAASA,GAAG,CAACK,MAA5B;AACA,WAAOH,OAAO,CAACF,GAAD,CAAP,KAAiB,CAACC,UAAU,CAACD,GAAD,CAAX,IAAoBD,QAAQ,CAACM,MAAD,CAA5B,IAAwCA,MAAM,GAAG,CAAC,CAAlD,IAAuDA,MAAM,GAAG,CAAT,IAAc,EAA7F;;;ACrCK,MAAMC,IAAI,GAAG,SAAPA,IAAO,CAACN,GAAD;AAAA,WAA8BA,GAAG,GAAGO,MAAM,CAACD,IAAP,CAAYN,GAAZ,CAAH,GAAsB,EAAvD;AAAA,GAAb;;WCiBSQ,KACdC,QACAC;AAEA,QAAIN,WAAW,CAACK,MAAD,CAAf,EAAyB;AACvB,WAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,MAAM,CAACJ,MAA3B,EAAmCM,CAAC,EAApC,EAAwC;AACtC,YAAID,QAAQ,CAACD,MAAM,CAACE,CAAD,CAAP,EAAYA,CAAZ,EAAeF,MAAf,CAAR,KAAmC,KAAvC,EAA8C;AAC5C;AACD;AACF;AACF,KAND,MAMO,IAAIA,MAAJ,EAAY;AACjBD,MAAAA,IAAI,CAACF,IAAI,CAACG,MAAD,CAAL,EAAe,UAACG,GAAD;AAAA,eAASF,QAAQ,CAACD,MAAM,CAACG,GAAD,CAAP,EAAcA,GAAd,EAAmBH,MAAnB,CAAjB;AAAA,OAAf,CAAJ;AACD;;AACD,WAAOA,MAAP;;;ACKK,MAAMI,QAAQ,GAAG,SAAXA,QAAW,CAACC,GAAD;AAAA,WAAoDA,GAAG,GAAGX,KAAK,CAACY,IAAN,CAAsBD,GAAG,CAACE,UAA1B,CAAH,GAA2C,EAAlG;AAAA,GAAjB;;ACwCA,MAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,KAAD;AAC5B,QAAId,WAAW,CAACc,KAAD,CAAf,EAAwB;AACtBV,MAAAA,IAAI,CAACL,KAAK,CAACY,IAAN,CAAWG,KAAX,CAAD,EAAoB,UAACC,CAAD;AAAA,eAAOF,cAAc,CAACE,CAAD,CAArB;AAAA,OAApB,CAAJ;AACD,KAFD,MAEO,IAAID,KAAJ,EAAW;AAAA,UACRE,UADQ,GACOF,KADP,CACRE,UADQ;;AAEhB,UAAIA,UAAJ,EAAgB;AACdA,QAAAA,UAAU,CAACC,WAAX,CAAuBH,KAAvB;AACD;AACF;AACF,GATM;;ACnFA,MAAMI,SAAS,GAAG,SAAZA,SAAY;AAAA,WAAsBC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAtB;AAAA,GAAlB;;AAEA,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,IAAD;AACvB,QAAMC,UAAU,GAAGL,SAAS,EAA5B;AACAK,IAAAA,UAAU,CAACC,SAAX,GAAuBF,IAAI,CAACG,IAAL,EAAvB;AAEA,WAAOrB,IAAI,CAACK,QAAQ,CAACc,UAAD,CAAT,EAAuB,UAACb,GAAD;AAAA,aAASG,cAAc,CAACH,GAAD,CAAvB;AAAA,KAAvB,CAAX;AACD,GALM;;ACJP,MAAMgB,GAAG,GAAG;AACVC,IAAAA,CAAC,EAAE,CADO;AAEVC,IAAAA,CAAC,EAAE,CAFO;AAGVC,IAAAA,CAAC,EAAE;AAHO,GAAZ;;cAMe,cAAA;QACLF,IAAYD,IAAZC;MAAGC,IAASF,IAATE;MAAGC,IAAMH,IAANG;AACd,WAAO;MACLR,SAAS;QACP;;;;;;;;;;;;;;;;;;;;;;MADO,CADJ;MAyBLM,CAzBK;MA0BLC,CA1BK;MA2BLC;IA3BK,CAAP;AA6BD;;;;"}
\ No newline at end of file
diff --git a/packages/overlayscrollbars/dist/overlayscrollbars.min.js b/packages/overlayscrollbars/dist/overlayscrollbars.min.js
index 7363e02..9ad2e66 100644
--- a/packages/overlayscrollbars/dist/overlayscrollbars.min.js
+++ b/packages/overlayscrollbars/dist/overlayscrollbars.min.js
@@ -1 +1 @@
-!function(r,e){if("function"==typeof define&&define.amd)define("OverlayScrollbars",["exports"],e);else if("undefined"!=typeof exports)e(exports);else{var o={exports:{}};e(o.exports),r.OverlayScrollbars=o.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(r){function e(r){var e=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(e)&&e>-1&&e%1==0}Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;function o(r,s){if(e(r))for(var i=0;i
fdfhdfgh
'),r,e,o]};r.default=t}));
\ No newline at end of file
+!function(r,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(r=r||self).OverlayScrollbars=o()}(this,(function(){"use strict";function r(r){var o=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(o)&&o>-1&&o%1==0}function o(s,e){if(r(s))for(var n=0;n
fdfhdfgh
'),r,o,t]}}));
\ No newline at end of file
diff --git a/packages/overlayscrollbars/src/core/compatibility/index.ts b/packages/overlayscrollbars/src/core/compatibility/index.ts
deleted file mode 100644
index 3b8d5e2..0000000
--- a/packages/overlayscrollbars/src/core/compatibility/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from 'core/compatibility/vendors';
-export * from 'core/compatibility/apis';
-export * from 'core/compatibility/events';
diff --git a/packages/overlayscrollbars/src/core/dom/attribute.ts b/packages/overlayscrollbars/src/core/dom/attribute.ts
deleted file mode 100644
index 036a409..0000000
--- a/packages/overlayscrollbars/src/core/dom/attribute.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Gets or sets a attribute with the given attribute of the given element depending whether the value attribute is given.
- * Returns null if the element has no attribute with the given name.
- * @param elm The element of which the attribute shall be get or set.
- * @param attrName The attribute name which shall be get or set.
- * @param value The value of the attribute which shall be set.
- */
-export const attr = (elm: Element, attrName: string, value?: string): string | null | void => {
- if (value === undefined) {
- return elm.getAttribute(attrName);
- }
- elm.setAttribute(attrName, value);
-};
-
-/**
- * Removes the given attribute from the given element.
- * @param elm The element of which the attribute shall be removed.
- * @param attrName The attribute name.
- */
-export const removeAttr = (elm: Element, attrName: string): void => {
- elm.removeAttribute(attrName);
-};
-
-/**
- * Gets or sets the scrollLeft value of the given element depending whether the value attribute is given.
- * @param elm The element of which the scrollLeft value shall be get or set.
- * @param value The scrollLeft value which shall be set.
- */
-export const scrollLeft = (elm: HTMLElement, value?: number): number | void => {
- if (value === undefined) {
- return elm.scrollLeft;
- }
- elm.scrollLeft = value;
-};
-
-/**
- * Gets or sets the scrollTop value of the given element depending whether the value attribute is given.
- * @param elm The element of which the scrollTop value shall be get or set.
- * @param value The scrollTop value which shall be set.
- */
-export const scrollTop = (elm: HTMLElement, value?: number): number | void => {
- if (value === undefined) {
- return elm.scrollTop;
- }
- elm.scrollTop = value;
-};
-
-/**
- * Gets or sets the value of the given input element depending whether the value attribute is given.
- * @param elm The input element of which the value shall be get or set.
- * @param value The value which shall be set.
- */
-export const val = (elm: HTMLInputElement, value?: string): string | void => {
- if (value === undefined) {
- return elm.value;
- }
- elm.value = value;
-};
diff --git a/packages/overlayscrollbars/src/core/dom/class.ts b/packages/overlayscrollbars/src/core/dom/class.ts
deleted file mode 100644
index c00cd62..0000000
--- a/packages/overlayscrollbars/src/core/dom/class.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { isString } from 'core/utils/types';
-
-const rnothtmlwhite = /[^\x20\t\r\n\f]+/g;
-
-/**
- * Check whether the given element has the given class name.
- * @param elm The element.
- * @param className The class name.
- */
-export const hasClass = (elm: Element, className: string): boolean => elm.classList.contains(className);
-
-/**
- * Adds the given class name(s) to the given element.
- * @param elm The element.
- * @param className The class name(s) which shall be added. (separated by spaces)
- */
-export const addClass = (elm: Element, className: string): void => {
- let clazz: string;
- let i = 0;
-
- if (isString(className)) {
- const classes: Array = className.match(rnothtmlwhite) || [];
- while ((clazz = classes[i++])) {
- elm.classList.add(clazz);
- }
- }
-};
-
-/**
- * Removes the given class name(s) from the given element.
- * @param elm The element.
- * @param className The class name(s) which shall be removed. (separated by spaces)
- */
-export const removeClass = (elm: Element, className: string): void => {
- let clazz: string;
- let i = 0;
-
- if (isString(className)) {
- const classes: Array = className.match(rnothtmlwhite) || [];
- while ((clazz = classes[i++])) {
- elm.classList.remove(clazz);
- }
- }
-};
-
-/**
- * Adds or removes the given class name(s) from the given element depending on the given condition.
- * Condition true means add class name(s), false means remove class name(s).
- * @param elm The element.
- * @param className The class name(s) which shall be added or removed. (separated by spaces)
- */
-export const conditionalClass = (elm: Element, className: string, condition: boolean): void => {
- if (condition) {
- addClass(elm, className);
- } else {
- removeClass(elm, className);
- }
-};
diff --git a/packages/overlayscrollbars/src/core/dom/index.ts b/packages/overlayscrollbars/src/core/dom/index.ts
deleted file mode 100644
index e8eb32f..0000000
--- a/packages/overlayscrollbars/src/core/dom/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export * from 'core/dom/attribute';
-export * from 'core/dom/class';
-export * from 'core/dom/create';
-export * from 'core/dom/style';
-export * from 'core/dom/manipulation';
-export * from 'core/dom/offset';
-export * from 'core/dom/traversal';
diff --git a/packages/overlayscrollbars/src/core/dom/offset.ts b/packages/overlayscrollbars/src/core/dom/offset.ts
deleted file mode 100644
index b7dae8d..0000000
--- a/packages/overlayscrollbars/src/core/dom/offset.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const offset = (elm: HTMLElement) => {
- const rect = elm.getBoundingClientRect();
- return {
- top: rect.top + window.pageXOffset,
- left: rect.left + window.pageYOffset,
- };
-};
-
-export const position = (elm: HTMLElement) => ({
- top: elm.offsetTop,
- left: elm.offsetLeft,
-});
diff --git a/packages/overlayscrollbars/src/core/dom/style.ts b/packages/overlayscrollbars/src/core/dom/style.ts
deleted file mode 100644
index 1588bbb..0000000
--- a/packages/overlayscrollbars/src/core/dom/style.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { each, keys } from 'core/utils';
-import { isString, isNumber, isUndefined } from 'core/utils/types';
-
-type cssStyleObj = { [key: string]: string | number };
-
-const cssNumber = {
- animationIterationCount: true,
- columnCount: true,
- fillOpacity: true,
- flexGrow: true,
- flexShrink: true,
- fontWeight: true,
- lineHeight: true,
- opacity: true,
- order: true,
- orphans: true,
- widows: true,
- zIndex: true,
- zoom: true,
-};
-
-const parseCSSVal = (prop: string, val: string | number): string | number =>
- !cssNumber[prop.toLowerCase()] && isNumber(val) ? `${val}px` : val;
-
-const setCSSVal = (elm: HTMLElement, prop: string, val: string | number): void => {
- try {
- if (elm.style[prop] !== undefined) {
- elm.style[prop] = parseCSSVal(prop, val);
- }
- } catch (e) {}
-};
-
-export function style(elm: HTMLElement, styles: string | cssStyleObj): string;
-export function style(elm: HTMLElement, styles: string | cssStyleObj, val: string | number): void;
-export function style(elm: HTMLElement, styles: string | cssStyleObj, val?: string | number): string | void {
- const getCptStyle = window.getComputedStyle;
-
- if (isString(styles)) {
- if (isUndefined(val)) {
- const cptStyle: CSSStyleDeclaration = getCptStyle(elm, null);
-
- // https://bugzilla.mozilla.org/show_bug.cgi?id=548397 can be null sometimes if iframe with display: none (firefox only!)
- return cptStyle != null ? cptStyle.getPropertyValue(styles) : elm.style[styles];
- }
- setCSSVal(elm, styles, val);
- } else {
- each(keys(styles), (key) => setCSSVal(elm, key, styles[key]));
- }
-}
-
-export const hide = (elm: HTMLElement): void => {
- elm.style.display = 'none';
-};
-
-export const show = (elm: HTMLElement): void => {
- elm.style.display = 'block';
-};
diff --git a/packages/overlayscrollbars/src/core/options/index.ts b/packages/overlayscrollbars/src/core/options/index.ts
deleted file mode 100644
index 9bb9056..0000000
--- a/packages/overlayscrollbars/src/core/options/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from 'core/options/validation';
-export * from 'core/options/transformation';
diff --git a/packages/overlayscrollbars/src/core/utils/index.ts b/packages/overlayscrollbars/src/core/utils/index.ts
deleted file mode 100644
index db59a3a..0000000
--- a/packages/overlayscrollbars/src/core/utils/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from 'core/utils/array';
-export * from 'core/utils/object';
-export * from 'core/utils/extend';
-export * from 'core/utils/types';
diff --git a/packages/overlayscrollbars/src/index.ts b/packages/overlayscrollbars/src/index.ts
index bd35943..4e2649e 100644
--- a/packages/overlayscrollbars/src/index.ts
+++ b/packages/overlayscrollbars/src/index.ts
@@ -1,12 +1,4 @@
-import { createDOM } from 'core/dom';
-
-/*
-export * from 'core/compatibility';
-export * from 'core/utils';
-export * from 'core/dom';
-export * from 'core/options';
-export * from 'instances';
-*/
+import { createDOM } from 'support/dom';
const abc = {
a: 1,
diff --git a/packages/overlayscrollbars/src/options/index.ts b/packages/overlayscrollbars/src/options/index.ts
new file mode 100644
index 0000000..d4f6692
--- /dev/null
+++ b/packages/overlayscrollbars/src/options/index.ts
@@ -0,0 +1,100 @@
+export * from 'options/options';
+
+export type ResizeBehavior = 'none' | 'both' | 'horizontal' | 'vertical';
+
+export type OverflowBehavior = 'hidden' | 'scroll' | 'visible-hidden' | 'visible-scroll';
+
+export type VisibilityBehavior = 'visible' | 'hidden' | 'auto';
+
+export type AutoHideBehavior = 'never' | 'scroll' | 'leave' | 'move';
+
+export type ScrollBehavior = 'always' | 'ifneeded' | 'never';
+
+export type BasicEventCallback = (this: any) => void;
+
+export type ScrollEventCallback = (this: any, args?: UIEvent) => void;
+
+export type OverflowChangedCallback = (this: any, args?: OverflowChangedArgs) => void;
+
+export type OverflowAmountChangedCallback = (this: any, args?: OverflowAmountChangedArgs) => void;
+
+export type DirectionChangedCallback = (this: any, args?: DirectionChangedArgs) => void;
+
+export type SizeChangedCallback = (this: any, args?: SizeChangedArgs) => void;
+
+export type UpdatedCallback = (this: any, args?: UpdatedArgs) => void;
+
+export interface Options {
+ className?: string | null;
+ resize?: ResizeBehavior;
+ sizeAutoCapable?: boolean;
+ clipAlways?: boolean;
+ normalizeRTL?: boolean;
+ paddingAbsolute?: boolean;
+ autoUpdate?: boolean | null;
+ autoUpdateInterval?: number;
+ updateOnLoad?: string | ReadonlyArray | null;
+ nativeScrollbarsOverlaid?: {
+ showNativeScrollbars?: boolean;
+ initialize?: boolean;
+ };
+ overflowBehavior?: {
+ x?: OverflowBehavior;
+ y?: OverflowBehavior;
+ };
+ scrollbars?: {
+ visibility?: VisibilityBehavior;
+ autoHide?: AutoHideBehavior;
+ autoHideDelay?: number;
+ dragScrolling?: boolean;
+ clickScrolling?: boolean;
+ touchSupport?: boolean;
+ snapHandle?: boolean;
+ };
+ textarea?: {
+ dynWidth?: boolean;
+ dynHeight?: boolean;
+ inheritedAttrs?: string | ReadonlyArray | null;
+ };
+ callbacks?: {
+ onInitialized?: BasicEventCallback | null;
+ onInitializationWithdrawn?: BasicEventCallback | null;
+ onDestroyed?: BasicEventCallback | null;
+ onScrollStart?: ScrollEventCallback | null;
+ onScroll?: ScrollEventCallback | null;
+ onScrollStop?: ScrollEventCallback | null;
+ onOverflowChanged?: OverflowChangedCallback | null;
+ onOverflowAmountChanged?: OverflowAmountChangedCallback | null;
+ onDirectionChanged?: DirectionChangedCallback | null;
+ onContentSizeChanged?: SizeChangedCallback | null;
+ onHostSizeChanged?: SizeChangedCallback | null;
+ onUpdated?: UpdatedCallback | null;
+ };
+}
+
+export interface OverflowChangedArgs {
+ x: boolean;
+ y: boolean;
+ xScrollable: boolean;
+ yScrollable: boolean;
+ clipped: boolean;
+}
+
+export interface OverflowAmountChangedArgs {
+ x: number;
+ y: number;
+}
+
+export interface DirectionChangedArgs {
+ isRTL: number;
+ dir: string;
+}
+
+export interface SizeChangedArgs {
+ width: number;
+ height: number;
+}
+
+export interface UpdatedArgs {
+ forced: boolean;
+}
diff --git a/packages/overlayscrollbars/src/options.ts b/packages/overlayscrollbars/src/options/options.ts
similarity index 94%
rename from packages/overlayscrollbars/src/options.ts
rename to packages/overlayscrollbars/src/options/options.ts
index 84922be..60a9266 100644
--- a/packages/overlayscrollbars/src/options.ts
+++ b/packages/overlayscrollbars/src/options/options.ts
@@ -1,6 +1,13 @@
-import { OptionsTemplate, OptionsTemplateValue, OptionsAndOptionsTemplateValue, OptionsAndOptionsTemplate, Func } from 'core/typings';
-import { optionsTemplateTypes as oTypes, transform } from 'core/options';
-import { ResizeBehavior, OverflowBehavior, VisibilityBehavior, AutoHideBehavior, Options } from 'typings';
+import {
+ optionsTemplateTypes as oTypes,
+ transform,
+ OptionsTemplate,
+ OptionsTemplateValue,
+ OptionsAndOptionsTemplateValue,
+ OptionsAndOptionsTemplate,
+ Func,
+} from 'support/options';
+import { ResizeBehavior, OverflowBehavior, VisibilityBehavior, AutoHideBehavior, Options } from 'options';
const classNameAllowedValues: OptionsTemplateValue = [oTypes.string, oTypes.null];
const numberAllowedValues: OptionsTemplateValue = oTypes.number;
diff --git a/packages/overlayscrollbars/src/core/compatibility/apis.ts b/packages/overlayscrollbars/src/support/compatibility/apis.ts
similarity index 57%
rename from packages/overlayscrollbars/src/core/compatibility/apis.ts
rename to packages/overlayscrollbars/src/support/compatibility/apis.ts
index a624940..3724de2 100644
--- a/packages/overlayscrollbars/src/core/compatibility/apis.ts
+++ b/packages/overlayscrollbars/src/support/compatibility/apis.ts
@@ -1,3 +1,3 @@
-import { jsAPI } from 'core/compatibility/vendors';
+import { jsAPI } from 'support/compatibility/vendors';
export const resizeObserver: any | undefined = jsAPI('ResizeObserver');
diff --git a/packages/overlayscrollbars/src/core/compatibility/events.ts b/packages/overlayscrollbars/src/support/compatibility/events.ts
similarity index 100%
rename from packages/overlayscrollbars/src/core/compatibility/events.ts
rename to packages/overlayscrollbars/src/support/compatibility/events.ts
diff --git a/packages/overlayscrollbars/src/support/compatibility/index.ts b/packages/overlayscrollbars/src/support/compatibility/index.ts
new file mode 100644
index 0000000..1bdf704
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/compatibility/index.ts
@@ -0,0 +1,3 @@
+export * from 'support/compatibility/vendors';
+export * from 'support/compatibility/apis';
+export * from 'support/compatibility/events';
diff --git a/packages/overlayscrollbars/src/core/compatibility/vendors.ts b/packages/overlayscrollbars/src/support/compatibility/vendors.ts
similarity index 97%
rename from packages/overlayscrollbars/src/core/compatibility/vendors.ts
rename to packages/overlayscrollbars/src/support/compatibility/vendors.ts
index aa6d729..c7f3d6c 100644
--- a/packages/overlayscrollbars/src/core/compatibility/vendors.ts
+++ b/packages/overlayscrollbars/src/support/compatibility/vendors.ts
@@ -1,5 +1,5 @@
-import { each, hasOwnProperty } from 'core/utils';
-import { createDiv } from 'core/dom';
+import { each, hasOwnProperty } from 'support/utils';
+import { createDiv } from 'support/dom';
const firstLetterToUpper = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1);
const getDummyStyle = (): CSSStyleDeclaration => createDiv().style;
diff --git a/packages/overlayscrollbars/src/support/dom/attribute.ts b/packages/overlayscrollbars/src/support/dom/attribute.ts
new file mode 100644
index 0000000..a95491d
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/dom/attribute.ts
@@ -0,0 +1,73 @@
+import { isUndefined } from 'support/utils/types';
+
+type GetSetPropName = 'scrollLeft' | 'scrollTop' | 'value';
+
+function getSetProp(
+ topLeft: GetSetPropName,
+ fallback: number | string,
+ elm: HTMLElement | HTMLInputElement | null,
+ value?: number | string
+): number | string | void {
+ if (isUndefined(value)) {
+ return elm ? elm[topLeft] : fallback;
+ }
+ elm && (elm[topLeft] = value);
+}
+
+/**
+ * Gets or sets a attribute with the given attribute of the given element depending whether the value attribute is given.
+ * Returns null if the element has no attribute with the given name.
+ * @param elm The element of which the attribute shall be get or set.
+ * @param attrName The attribute name which shall be get or set.
+ * @param value The value of the attribute which shall be set.
+ */
+export function attr(elm: HTMLElement | null, attrName: string): string | null;
+export function attr(elm: HTMLElement | null, attrName: string, value: string): void;
+export function attr(elm: HTMLElement | null, attrName: string, value?: string): string | null | void {
+ if (isUndefined(value)) {
+ return elm ? elm.getAttribute(attrName) : null;
+ }
+ elm && elm.setAttribute(attrName, value);
+}
+
+/**
+ * Removes the given attribute from the given element.
+ * @param elm The element of which the attribute shall be removed.
+ * @param attrName The attribute name.
+ */
+export const removeAttr = (elm: Element | null, attrName: string): void => {
+ elm?.removeAttribute(attrName);
+};
+
+/**
+ * Gets or sets the scrollLeft value of the given element depending whether the value attribute is given.
+ * @param elm The element of which the scrollLeft value shall be get or set.
+ * @param value The scrollLeft value which shall be set.
+ */
+export function scrollLeft(elm: HTMLElement | null): number;
+export function scrollLeft(elm: HTMLElement | null, value: number): void;
+export function scrollLeft(elm: HTMLElement | null, value?: number): number | void {
+ return getSetProp('scrollLeft', 0, elm, value) as number;
+}
+
+/**
+ * Gets or sets the scrollTop value of the given element depending whether the value attribute is given.
+ * @param elm The element of which the scrollTop value shall be get or set.
+ * @param value The scrollTop value which shall be set.
+ */
+export function scrollTop(elm: HTMLElement | null): number;
+export function scrollTop(elm: HTMLElement | null, value: number): void;
+export function scrollTop(elm: HTMLElement | null, value?: number): number | void {
+ return getSetProp('scrollTop', 0, elm, value) as number;
+}
+
+/**
+ * Gets or sets the value of the given input element depending whether the value attribute is given.
+ * @param elm The input element of which the value shall be get or set.
+ * @param value The value which shall be set.
+ */
+export function val(elm: HTMLInputElement | null): string;
+export function val(elm: HTMLInputElement | null, value: string): void;
+export function val(elm: HTMLInputElement | null, value?: string): string | void {
+ return getSetProp('value', '', elm, value) as string;
+}
diff --git a/packages/overlayscrollbars/src/support/dom/class.ts b/packages/overlayscrollbars/src/support/dom/class.ts
new file mode 100644
index 0000000..022d7d5
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/dom/class.ts
@@ -0,0 +1,43 @@
+import { isString } from 'support/utils/types';
+
+const rnothtmlwhite = /[^\x20\t\r\n\f]+/g;
+const classListAction = (elm: Element | null, className: string, action: (elmClassList: DOMTokenList, clazz: string) => boolean | void): boolean => {
+ let clazz: string;
+ let i = 0;
+ let result = false;
+
+ if (elm && isString(className)) {
+ const classes: Array = className.match(rnothtmlwhite) || [];
+ result = classes.length > 0;
+ while ((clazz = classes[i++])) {
+ result = (action(elm.classList, clazz) as boolean) && result;
+ }
+ }
+ return result;
+};
+
+/**
+ * Check whether the given element has the given class name(s).
+ * @param elm The element.
+ * @param className The class name(s).
+ */
+export const hasClass = (elm: Element | null, className: string): boolean =>
+ classListAction(elm, className, (classList, clazz) => classList.contains(clazz));
+
+/**
+ * Adds the given class name(s) to the given element.
+ * @param elm The element.
+ * @param className The class name(s) which shall be added. (separated by spaces)
+ */
+export const addClass = (elm: Element | null, className: string): void => {
+ classListAction(elm, className, (classList, clazz) => classList.add(clazz));
+};
+
+/**
+ * Removes the given class name(s) from the given element.
+ * @param elm The element.
+ * @param className The class name(s) which shall be removed. (separated by spaces)
+ */
+export const removeClass = (elm: Element | null, className: string): void => {
+ classListAction(elm, className, (classList, clazz) => classList.remove(clazz));
+};
diff --git a/packages/overlayscrollbars/src/core/dom/create.ts b/packages/overlayscrollbars/src/support/dom/create.ts
similarity index 65%
rename from packages/overlayscrollbars/src/core/dom/create.ts
rename to packages/overlayscrollbars/src/support/dom/create.ts
index e15e617..d39c5fc 100644
--- a/packages/overlayscrollbars/src/core/dom/create.ts
+++ b/packages/overlayscrollbars/src/support/dom/create.ts
@@ -1,6 +1,6 @@
-import { each } from 'core/utils/array';
-import { contents } from 'core/dom/traversal';
-import { removeElements } from 'core/dom/manipulation';
+import { each } from 'support/utils/array';
+import { contents } from 'support/dom/traversal';
+import { removeElements } from 'support/dom/manipulation';
export const createDiv = (): HTMLDivElement => document.createElement('div');
diff --git a/packages/overlayscrollbars/src/support/dom/events.ts b/packages/overlayscrollbars/src/support/dom/events.ts
new file mode 100644
index 0000000..1e5578f
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/dom/events.ts
@@ -0,0 +1,6 @@
+export const on = (target: EventTarget, type: string, listener: EventListenerOrEventListenerObject | null, options: AddEventListenerOptions): void => {
+
+
+
+ target.addEventListener(type, listener, options);
+};
\ No newline at end of file
diff --git a/packages/overlayscrollbars/src/support/dom/index.ts b/packages/overlayscrollbars/src/support/dom/index.ts
new file mode 100644
index 0000000..9dccb22
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/dom/index.ts
@@ -0,0 +1,7 @@
+export * from 'support/dom/attribute';
+export * from 'support/dom/class';
+export * from 'support/dom/create';
+export * from 'support/dom/style';
+export * from 'support/dom/manipulation';
+export * from 'support/dom/offset';
+export * from 'support/dom/traversal';
diff --git a/packages/overlayscrollbars/src/core/dom/manipulation.ts b/packages/overlayscrollbars/src/support/dom/manipulation.ts
similarity index 95%
rename from packages/overlayscrollbars/src/core/dom/manipulation.ts
rename to packages/overlayscrollbars/src/support/dom/manipulation.ts
index c396860..05a17e0 100644
--- a/packages/overlayscrollbars/src/core/dom/manipulation.ts
+++ b/packages/overlayscrollbars/src/support/dom/manipulation.ts
@@ -1,6 +1,6 @@
-import { isArrayLike } from 'core/utils/types';
-import { each } from 'core/utils/array';
-import { parent } from 'core/dom/traversal';
+import { isArrayLike } from 'support/utils/types';
+import { each } from 'support/utils/array';
+import { parent } from 'support/dom/traversal';
type NodeCollection = ArrayLike | Node | undefined | null;
diff --git a/packages/overlayscrollbars/src/support/dom/offset.ts b/packages/overlayscrollbars/src/support/dom/offset.ts
new file mode 100644
index 0000000..a7ffc84
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/dom/offset.ts
@@ -0,0 +1,22 @@
+const zeroObj = {
+ left: 0,
+ top: 0,
+};
+
+export const offset = (elm: HTMLElement | null) => {
+ const rect = elm ? elm.getBoundingClientRect() : 0;
+ return rect
+ ? {
+ left: rect.left + window.pageYOffset,
+ top: rect.top + window.pageXOffset,
+ }
+ : zeroObj;
+};
+
+export const position = (elm: HTMLElement | null) =>
+ elm
+ ? {
+ left: elm.offsetLeft,
+ top: elm.offsetTop,
+ }
+ : zeroObj;
diff --git a/packages/overlayscrollbars/src/support/dom/style.ts b/packages/overlayscrollbars/src/support/dom/style.ts
new file mode 100644
index 0000000..cc00b06
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/dom/style.ts
@@ -0,0 +1,63 @@
+import { each, keys } from 'support/utils';
+import { isString, isNumber, isArray } from 'support/utils/types';
+import { PlainObject } from 'typings';
+
+type CssStyles = { [key: string]: string | number };
+const cssNumber = {
+ animationiterationcount: 1,
+ columncount: 1,
+ fillopacity: 1,
+ flexgrow: 1,
+ flexshrink: 1,
+ fontweight: 1,
+ lineheight: 1,
+ opacity: 1,
+ order: 1,
+ orphans: 1,
+ widows: 1,
+ zindex: 1,
+ zoom: 1,
+};
+
+const adaptCSSVal = (prop: string, val: string | number): string | number => (!cssNumber[prop.toLowerCase()] && isNumber(val) ? `${val}px` : val);
+const getCSSVal = (elm: HTMLElement, computedStyle: CSSStyleDeclaration, prop: string): string =>
+ /* istanbul ignore next */
+ computedStyle != null ? computedStyle.getPropertyValue(prop) : elm.style[prop];
+const setCSSVal = (elm: HTMLElement | null, prop: string, val: string | number): void => {
+ try {
+ if (elm && elm.style[prop] !== undefined) {
+ elm.style[prop] = adaptCSSVal(prop, val);
+ }
+ } catch (e) {}
+};
+
+export function style(elm: HTMLElement | null, styles: CssStyles): void;
+export function style(elm: HTMLElement | null, styles: string): string;
+export function style(elm: HTMLElement | null, styles: Array | string): { [key: string]: string };
+export function style(elm: HTMLElement | null, styles: CssStyles | Array | string): { [key: string]: string } | string | void {
+ const getSingleStyle = isString(styles);
+ const getStyles = isArray(styles) || getSingleStyle;
+
+ if (getStyles) {
+ let getStylesResult: string | PlainObject = getSingleStyle ? '' : {};
+ if (elm) {
+ const computedStyle: CSSStyleDeclaration = window.getComputedStyle(elm, null);
+ getStylesResult = getSingleStyle
+ ? getCSSVal(elm, computedStyle, styles as string)
+ : (styles as Array).reduce((result, key) => {
+ result[key] = getCSSVal(elm, computedStyle, key as string);
+ return result;
+ }, getStylesResult);
+ }
+ return getStylesResult;
+ }
+ each(keys(styles), (key) => setCSSVal(elm, key, styles[key]));
+}
+
+export const hide = (elm: HTMLElement | null): void => {
+ style(elm, { display: 'none' });
+};
+
+export const show = (elm: HTMLElement | null): void => {
+ style(elm, { display: 'block' });
+};
diff --git a/packages/overlayscrollbars/src/core/dom/traversal.ts b/packages/overlayscrollbars/src/support/dom/traversal.ts
similarity index 96%
rename from packages/overlayscrollbars/src/core/dom/traversal.ts
rename to packages/overlayscrollbars/src/support/dom/traversal.ts
index 7c82178..8f190e2 100644
--- a/packages/overlayscrollbars/src/core/dom/traversal.ts
+++ b/packages/overlayscrollbars/src/support/dom/traversal.ts
@@ -1,4 +1,4 @@
-import { each } from 'core/utils/array';
+import { each } from 'support/utils/array';
const elementIsVisible = (elm: HTMLElement): boolean => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);
diff --git a/packages/overlayscrollbars/src/support/index.ts b/packages/overlayscrollbars/src/support/index.ts
new file mode 100644
index 0000000..25ec35a
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/index.ts
@@ -0,0 +1,4 @@
+export * from 'support/compatibility';
+export * from 'support/dom';
+export * from 'support/options';
+export * from 'support/utils';
diff --git a/packages/overlayscrollbars/src/core/typings.ts b/packages/overlayscrollbars/src/support/options/index.ts
similarity index 90%
rename from packages/overlayscrollbars/src/core/typings.ts
rename to packages/overlayscrollbars/src/support/options/index.ts
index 4cdb18d..56a4c5b 100644
--- a/packages/overlayscrollbars/src/core/typings.ts
+++ b/packages/overlayscrollbars/src/support/options/index.ts
@@ -1,6 +1,8 @@
-export type PlainObject = { [name: string]: T };
+import { PlainObject } from 'typings';
+
+export * from 'support/options/validation';
+export * from 'support/options/transformation';
-// Options Template Typings:
export type Func = (this: any, ...args: any[]) => any;
export type OptionsTemplateType = ExtractPropsKey;
export type OptionsTemplateTypes = keyof OptionsTemplateTypeMap;
@@ -42,9 +44,9 @@ type OptionsTemplateTypeMap = {
__TPL_null_TYPE__: null;
__TPL_object_TYPE__: object; // eslint-disable-line @typescript-eslint/ban-types
};
-type ExtractPropsKey = {
- [P in keyof T]: TProps extends T[P] ? P : never;
-}[keyof T];
type OptionsTemplateValueNonEnum =
| OptionsTemplateType
| [OptionsTemplateType, ...Array];
+type ExtractPropsKey = {
+ [P in keyof T]: TProps extends T[P] ? P : never;
+}[keyof T];
\ No newline at end of file
diff --git a/packages/overlayscrollbars/src/core/options/transformation.ts b/packages/overlayscrollbars/src/support/options/transformation.ts
similarity index 80%
rename from packages/overlayscrollbars/src/core/options/transformation.ts
rename to packages/overlayscrollbars/src/support/options/transformation.ts
index bc40cc7..5e6df38 100644
--- a/packages/overlayscrollbars/src/core/options/transformation.ts
+++ b/packages/overlayscrollbars/src/support/options/transformation.ts
@@ -1,6 +1,7 @@
-import { OptionsTemplate, OptionsAndOptionsTemplate, PlainObject, OptionsTemplateTypes } from 'core/typings';
-import { isArray, isObject } from 'core/utils/types';
-import { each, keys } from 'core/utils';
+import { OptionsTemplate, OptionsAndOptionsTemplate, OptionsTemplateTypes } from 'support/options';
+import { PlainObject } from 'typings';
+import { isArray, isObject } from 'support/utils/types';
+import { each, keys } from 'support/utils';
/**
* Transforms the given OptionsAndOptionsTemplate object to its corresponding generic (T) Object or its corresponding Template object.
@@ -10,11 +11,11 @@ import { each, keys } from 'core/utils';
export function transform>(optionsWithOptionsTemplate: OptionsAndOptionsTemplate): T;
export function transform>(
optionsWithOptionsTemplate: OptionsAndOptionsTemplate,
- toTemplate: true | void,
+ toTemplate: true | void
): OptionsTemplate;
export function transform>(
optionsWithOptionsTemplate: OptionsAndOptionsTemplate,
- toTemplate?: true | void,
+ toTemplate?: true | void
): OptionsTemplate | T {
const result: any = {};
diff --git a/packages/overlayscrollbars/src/core/options/validation.ts b/packages/overlayscrollbars/src/support/options/validation.ts
similarity index 94%
rename from packages/overlayscrollbars/src/core/options/validation.ts
rename to packages/overlayscrollbars/src/support/options/validation.ts
index 24f6ed3..b64ab61 100644
--- a/packages/overlayscrollbars/src/core/options/validation.ts
+++ b/packages/overlayscrollbars/src/support/options/validation.ts
@@ -1,14 +1,7 @@
-import { each, indexOf, hasOwnProperty, keys } from 'core/utils';
-import { type, isArray, isUndefined, isEmptyObject, isPlainObject, isString } from 'core/utils/types';
-import {
- PlainObject,
- OptionsTemplate,
- OptionsTemplateTypes,
- OptionsTemplateType,
- OptionsValidated,
- Func,
- OptionsValidatedResult,
-} from 'core/typings';
+import { each, indexOf, hasOwnProperty, keys } from 'support/utils';
+import { type, isArray, isUndefined, isEmptyObject, isPlainObject, isString } from 'support/utils/types';
+import { OptionsTemplate, OptionsTemplateTypes, OptionsTemplateType, OptionsValidated, Func, OptionsValidatedResult } from 'support/options';
+import { PlainObject } from 'typings';
const { stringify } = JSON;
@@ -26,7 +19,7 @@ const optionsTemplateTypes: OptionsTemplateTypesDictionary = ['boolean', 'number
result[item] = templateTypePrefixSuffix[0] + item + templateTypePrefixSuffix[1];
return result;
},
- {} as OptionsTemplateTypesDictionary,
+ {} as OptionsTemplateTypesDictionary
);
/**
@@ -52,7 +45,7 @@ const validateRecursive = (
template: OptionsTemplate>,
optionsDiff: OptionsValidated,
doWriteErrors?: boolean,
- propPath?: string,
+ propPath?: string
): OptionsValidatedResult => {
const validatedOptions: OptionsValidated = {};
const optionsCopy: T = { ...options };
@@ -116,7 +109,7 @@ const validateRecursive = (
`${
`The option "${propPrefix}${prop}" wasn't set, because it doesn't accept the type [ ${optionsValueType.toUpperCase()} ] with the value of "${optionsValue}".\r\n` +
`Accepted types are: [ ${errorPossibleTypes.join(', ').toUpperCase()} ].\r\n`
- }${errorEnumStrings.length > 0 ? `\r\nValid strings are: [ ${errorEnumStrings.join(', ')} ].` : ''}`,
+ }${errorEnumStrings.length > 0 ? `\r\nValid strings are: [ ${errorEnumStrings.join(', ')} ].` : ''}`
);
}
@@ -151,7 +144,7 @@ const validate = (
options: T,
template: OptionsTemplate>,
optionsDiff?: OptionsValidated,
- doWriteErrors?: boolean,
+ doWriteErrors?: boolean
): OptionsValidatedResult => {
/*
if (!isEmptyObject(foreign) && doWriteErrors)
diff --git a/packages/overlayscrollbars/src/core/utils/array.ts b/packages/overlayscrollbars/src/support/utils/array.ts
similarity index 94%
rename from packages/overlayscrollbars/src/core/utils/array.ts
rename to packages/overlayscrollbars/src/support/utils/array.ts
index c7a4e7a..e19e9b7 100644
--- a/packages/overlayscrollbars/src/core/utils/array.ts
+++ b/packages/overlayscrollbars/src/support/utils/array.ts
@@ -1,6 +1,6 @@
-import { keys } from 'core/utils/object';
-import { isArrayLike } from 'core/utils/types';
-import { PlainObject } from 'core/typings';
+import { keys } from 'support/utils/object';
+import { isArrayLike } from 'support/utils/types';
+import { PlainObject } from 'typings';
/**
* Iterates through a array or object
diff --git a/packages/overlayscrollbars/src/core/utils/extend.ts b/packages/overlayscrollbars/src/support/utils/extend.ts
similarity index 92%
rename from packages/overlayscrollbars/src/core/utils/extend.ts
rename to packages/overlayscrollbars/src/support/utils/extend.ts
index a3ae067..406841d 100644
--- a/packages/overlayscrollbars/src/core/utils/extend.ts
+++ b/packages/overlayscrollbars/src/support/utils/extend.ts
@@ -1,6 +1,6 @@
-import { isArray, isFunction, isPlainObject, isNull } from 'core/utils/types';
-import { each } from 'core/utils/array';
-import { keys } from 'core/utils/object';
+import { isArray, isFunction, isPlainObject, isNull } from 'support/utils/types';
+import { each } from 'support/utils/array';
+import { keys } from 'support/utils/object';
// https://github.com/jquery/jquery/blob/master/src/core.js#L116
export function extend(target: T, object1: U): T & U;
diff --git a/packages/overlayscrollbars/src/support/utils/index.ts b/packages/overlayscrollbars/src/support/utils/index.ts
new file mode 100644
index 0000000..e275e87
--- /dev/null
+++ b/packages/overlayscrollbars/src/support/utils/index.ts
@@ -0,0 +1,4 @@
+export * from 'support/utils/array';
+export * from 'support/utils/object';
+export * from 'support/utils/extend';
+export * from 'support/utils/types';
diff --git a/packages/overlayscrollbars/src/core/utils/object.ts b/packages/overlayscrollbars/src/support/utils/object.ts
similarity index 100%
rename from packages/overlayscrollbars/src/core/utils/object.ts
rename to packages/overlayscrollbars/src/support/utils/object.ts
diff --git a/packages/overlayscrollbars/src/core/utils/types.ts b/packages/overlayscrollbars/src/support/utils/types.ts
similarity index 98%
rename from packages/overlayscrollbars/src/core/utils/types.ts
rename to packages/overlayscrollbars/src/support/utils/types.ts
index ff6334a..74c2813 100644
--- a/packages/overlayscrollbars/src/core/utils/types.ts
+++ b/packages/overlayscrollbars/src/support/utils/types.ts
@@ -1,4 +1,4 @@
-import { PlainObject } from 'core/typings';
+import { PlainObject } from 'typings';
export const type: (obj: any) => string = (obj) => {
if (obj === undefined) return `${obj}`;
diff --git a/packages/overlayscrollbars/src/typings.ts b/packages/overlayscrollbars/src/typings.ts
index 3307426..74f20e0 100644
--- a/packages/overlayscrollbars/src/typings.ts
+++ b/packages/overlayscrollbars/src/typings.ts
@@ -1,101 +1,4 @@
-export type ResizeBehavior = 'none' | 'both' | 'horizontal' | 'vertical';
-
-export type OverflowBehavior = 'hidden' | 'scroll' | 'visible-hidden' | 'visible-scroll';
-
-export type VisibilityBehavior = 'visible' | 'hidden' | 'auto';
-
-export type AutoHideBehavior = 'never' | 'scroll' | 'leave' | 'move';
-
-export type ScrollBehavior = 'always' | 'ifneeded' | 'never';
-
-export type BasicEventCallback = (this: any) => void;
-
-export type ScrollEventCallback = (this: any, args?: UIEvent) => void;
-
-export type OverflowChangedCallback = (this: any, args?: OverflowChangedArgs) => void;
-
-export type OverflowAmountChangedCallback = (this: any, args?: OverflowAmountChangedArgs) => void;
-
-export type DirectionChangedCallback = (this: any, args?: DirectionChangedArgs) => void;
-
-export type SizeChangedCallback = (this: any, args?: SizeChangedArgs) => void;
-
-export type UpdatedCallback = (this: any, args?: UpdatedArgs) => void;
-
-export interface Options {
- className?: string | null;
- resize?: ResizeBehavior;
- sizeAutoCapable?: boolean;
- clipAlways?: boolean;
- normalizeRTL?: boolean;
- paddingAbsolute?: boolean;
- autoUpdate?: boolean | null;
- autoUpdateInterval?: number;
- updateOnLoad?: string | ReadonlyArray | null;
- nativeScrollbarsOverlaid?: {
- showNativeScrollbars?: boolean;
- initialize?: boolean;
- };
- overflowBehavior?: {
- x?: OverflowBehavior;
- y?: OverflowBehavior;
- };
- scrollbars?: {
- visibility?: VisibilityBehavior;
- autoHide?: AutoHideBehavior;
- autoHideDelay?: number;
- dragScrolling?: boolean;
- clickScrolling?: boolean;
- touchSupport?: boolean;
- snapHandle?: boolean;
- };
- textarea?: {
- dynWidth?: boolean;
- dynHeight?: boolean;
- inheritedAttrs?: string | ReadonlyArray | null;
- };
- callbacks?: {
- onInitialized?: BasicEventCallback | null;
- onInitializationWithdrawn?: BasicEventCallback | null;
- onDestroyed?: BasicEventCallback | null;
- onScrollStart?: ScrollEventCallback | null;
- onScroll?: ScrollEventCallback | null;
- onScrollStop?: ScrollEventCallback | null;
- onOverflowChanged?: OverflowChangedCallback | null;
- onOverflowAmountChanged?: OverflowAmountChangedCallback | null;
- onDirectionChanged?: DirectionChangedCallback | null;
- onContentSizeChanged?: SizeChangedCallback | null;
- onHostSizeChanged?: SizeChangedCallback | null;
- onUpdated?: UpdatedCallback | null;
- };
-}
-
-export interface OverflowChangedArgs {
- x: boolean;
- y: boolean;
- xScrollable: boolean;
- yScrollable: boolean;
- clipped: boolean;
-}
-
-export interface OverflowAmountChangedArgs {
- x: number;
- y: number;
-}
-
-export interface DirectionChangedArgs {
- isRTL: number;
- dir: string;
-}
-
-export interface SizeChangedArgs {
- width: number;
- height: number;
-}
-
-export interface UpdatedArgs {
- forced: boolean;
-}
+export type PlainObject = { [name: string]: T };
/*
export namespace OverlayScrollbars {
diff --git a/packages/overlayscrollbars/tests/core/dom/classes.test.ts b/packages/overlayscrollbars/tests/core/dom/classes.test.ts
deleted file mode 100644
index a3af435..0000000
--- a/packages/overlayscrollbars/tests/core/dom/classes.test.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { addClass, removeClass, hasClass, conditionalClass } from 'core/dom/class';
-
-const testElm = document.body;
-const removeAllClassNames = () => {
- while (testElm.classList.length > 0) {
- const classToRemove = testElm.classList.item(0);
- if (classToRemove) {
- testElm.classList.remove(classToRemove);
- }
- }
-};
-const hasClassName = (className: string) => testElm.classList.contains(className);
-
-describe('dom class names', () => {
- afterEach(() => {
- removeAllClassNames();
- });
-
- test('add none', () => {
- addClass(testElm, '');
- // @ts-ignore
- addClass(testElm, null);
- // @ts-ignore
- addClass(testElm, 2);
- expect(testElm.classList.length).toBe(0);
- });
-
- test('add single', () => {
- addClass(testElm, 'test-class');
- expect(hasClassName('test-class')).toBe(true);
- });
-
- test('add multiple', () => {
- addClass(testElm, 'test-class test-class2');
- expect(hasClassName('test-class')).toBe(true);
- expect(hasClassName('test-class2')).toBe(true);
- });
-
- test('remove none', () => {
- addClass(testElm, 'test-class');
- removeClass(testElm, '');
- // @ts-ignore
- removeClass(testElm, null);
- // @ts-ignore
- removeClass(testElm, 2);
- expect(testElm.classList.length).toBe(1);
- });
-
- test('remove single', () => {
- addClass(testElm, 'test-class');
- expect(hasClassName('test-class')).toBe(true);
- removeClass(testElm, 'test-class');
- expect(hasClassName('test-class')).toBe(false);
- });
-
- test('remove multiple', () => {
- addClass(testElm, 'test-class test-class2');
- removeClass(testElm, 'test-class test-class2');
- expect(hasClassName('test-class')).toBe(false);
- expect(hasClassName('test-class2')).toBe(false);
- });
-
- test('has', () => {
- addClass(testElm, 'test-class');
- expect(hasClass(testElm, 'test-class')).toBe(true);
- });
-
- test('conditional single', () => {
- conditionalClass(testElm, 'test-class', true);
- expect(hasClass(testElm, 'test-class')).toBe(true);
- conditionalClass(testElm, 'test-class', false);
- expect(hasClass(testElm, 'test-class')).toBe(false);
- });
-
- test('conditional multiple', () => {
- conditionalClass(testElm, 'test-class test-class2', true);
- expect(hasClass(testElm, 'test-class')).toBe(true);
- expect(hasClass(testElm, 'test-class2')).toBe(true);
- conditionalClass(testElm, 'test-class test-class2', false);
- expect(hasClass(testElm, 'test-class')).toBe(false);
- expect(hasClass(testElm, 'test-class2')).toBe(false);
- });
-});
diff --git a/packages/overlayscrollbars/tests/options.test.ts b/packages/overlayscrollbars/tests/options.test.ts
index 458ab29..fba6972 100644
--- a/packages/overlayscrollbars/tests/options.test.ts
+++ b/packages/overlayscrollbars/tests/options.test.ts
@@ -1,4 +1,4 @@
-import { validate } from 'core/options';
+import { validate } from 'support/options';
import { defaultOptions, optionsTemplate } from 'options';
describe('options', () => {
diff --git a/packages/overlayscrollbars/tests/core/compatibility/vendors.test.ts b/packages/overlayscrollbars/tests/support/compatibility/vendors.test.ts
similarity index 96%
rename from packages/overlayscrollbars/tests/core/compatibility/vendors.test.ts
rename to packages/overlayscrollbars/tests/support/compatibility/vendors.test.ts
index 9a37ef9..8c1a017 100644
--- a/packages/overlayscrollbars/tests/core/compatibility/vendors.test.ts
+++ b/packages/overlayscrollbars/tests/support/compatibility/vendors.test.ts
@@ -1,4 +1,4 @@
-import { jsAPI, cssProperty, cssPropertyValue } from 'core/compatibility/vendors';
+import { jsAPI, cssProperty, cssPropertyValue } from 'support/compatibility/vendors';
describe('vendors', () => {
describe('jsAPI', () => {
diff --git a/packages/overlayscrollbars/tests/core/dom/attributes.test.ts b/packages/overlayscrollbars/tests/support/dom/attribute.test.ts
similarity index 68%
rename from packages/overlayscrollbars/tests/core/dom/attributes.test.ts
rename to packages/overlayscrollbars/tests/support/dom/attribute.test.ts
index d8c9324..cbc0b8e 100644
--- a/packages/overlayscrollbars/tests/core/dom/attributes.test.ts
+++ b/packages/overlayscrollbars/tests/support/dom/attribute.test.ts
@@ -1,4 +1,4 @@
-import { attr, removeAttr, val, scrollLeft, scrollTop } from 'core/dom/attribute';
+import { attr, removeAttr, val, scrollLeft, scrollTop } from 'support/dom/attribute';
const testElm = document.body;
const setAttribute = (name: string, value: string) => {
@@ -39,6 +39,11 @@ describe('dom attributes', () => {
removeAttribute(attrName);
});
+
+ test('null', () => {
+ expect(attr(null, 'hi')).toBe(null);
+ expect(attr(null, 'hi', '123')).toBe(undefined);
+ });
});
describe('scrollLeft', () => {
@@ -53,6 +58,11 @@ describe('dom attributes', () => {
expect(scrollLeft(testElm)).toBe(100);
setScrollLeft(0);
});
+
+ test('null', () => {
+ expect(scrollLeft(null)).toBe(0);
+ expect(scrollLeft(null, 0)).toBe(undefined);
+ });
});
describe('scrollTop', () => {
@@ -67,6 +77,11 @@ describe('dom attributes', () => {
expect(scrollTop(testElm)).toBe(100);
setScrollTop(0);
});
+
+ test('null', () => {
+ expect(scrollTop(null)).toBe(0);
+ expect(scrollTop(null, 0)).toBe(undefined);
+ });
});
describe('val', () => {
@@ -84,14 +99,25 @@ describe('dom attributes', () => {
val(input, '');
expect(val(input)).toBe('');
});
+
+ test('null', () => {
+ expect(val(null)).toBe('');
+ expect(val(null, '123')).toBe(undefined);
+ });
});
- test('remove attribute', () => {
- const attrName = 'data-test-remove';
+ describe('remove attribute', () => {
+ test('normal', () => {
+ const attrName = 'data-test-remove';
- setAttribute(attrName, '123');
- removeAttr(testElm, attrName);
+ setAttribute(attrName, '123');
+ removeAttr(testElm, attrName);
- expect(attr(testElm, attrName)).toBeNull();
+ expect(attr(testElm, attrName)).toBeNull();
+ });
+
+ test('null', () => {
+ expect(removeAttr(null, 'hi')).toBe(undefined);
+ });
});
});
diff --git a/packages/overlayscrollbars/tests/support/dom/class.test.ts b/packages/overlayscrollbars/tests/support/dom/class.test.ts
new file mode 100644
index 0000000..ab19a4f
--- /dev/null
+++ b/packages/overlayscrollbars/tests/support/dom/class.test.ts
@@ -0,0 +1,95 @@
+import { addClass, removeClass, hasClass } from 'support/dom/class';
+
+const testElm = document.body;
+const removeAllClassNames = () => {
+ while (testElm.classList.length > 0) {
+ const classToRemove = testElm.classList.item(0);
+ if (classToRemove) {
+ testElm.classList.remove(classToRemove);
+ }
+ }
+};
+const hasClassName = (className: string) => testElm.classList.contains(className);
+
+describe('dom class names', () => {
+ afterEach(() => {
+ removeAllClassNames();
+ });
+
+ describe('add', () => {
+ test('none', () => {
+ addClass(testElm, '');
+ // @ts-ignore
+ addClass(testElm, null);
+ // @ts-ignore
+ addClass(testElm, 2);
+ expect(testElm.classList.length).toBe(0);
+ });
+
+ test('single', () => {
+ addClass(testElm, 'test-class');
+ expect(hasClassName('test-class')).toBe(true);
+ });
+
+ test('multiple', () => {
+ addClass(testElm, 'test-class test-class2');
+ expect(hasClassName('test-class')).toBe(true);
+ expect(hasClassName('test-class2')).toBe(true);
+ });
+
+ test('null', () => {
+ expect(addClass(null, 'abc')).toBe(undefined);
+ });
+ });
+
+ describe('remove', () => {
+ test('none', () => {
+ addClass(testElm, 'test-class');
+ removeClass(testElm, '');
+ // @ts-ignore
+ removeClass(testElm, null);
+ // @ts-ignore
+ removeClass(testElm, 2);
+ expect(testElm.classList.length).toBe(1);
+ });
+
+ test('single', () => {
+ addClass(testElm, 'test-class');
+ expect(hasClassName('test-class')).toBe(true);
+ removeClass(testElm, 'test-class');
+ expect(hasClassName('test-class')).toBe(false);
+ });
+
+ test('multiple', () => {
+ addClass(testElm, 'test-class test-class2');
+ removeClass(testElm, 'test-class test-class2');
+ expect(hasClassName('test-class')).toBe(false);
+ expect(hasClassName('test-class2')).toBe(false);
+ });
+
+ test('null', () => {
+ expect(removeClass(null, 'abc')).toBe(undefined);
+ });
+ });
+
+ describe('has', () => {
+ test('none', () => {
+ expect(hasClass(testElm, '')).toBe(false);
+ });
+
+ test('single', () => {
+ addClass(testElm, 'test-class');
+ expect(hasClass(testElm, 'test-class')).toBe(true);
+ });
+
+ test('multiple', () => {
+ addClass(testElm, 'test-class test-class2');
+ expect(hasClass(testElm, 'test-class test-class2')).toBe(true);
+ expect(hasClass(testElm, 'test-class test-class2 test-class3')).toBe(false);
+ });
+
+ test('null', () => {
+ expect(hasClass(null, 'abc')).toBe(false);
+ });
+ });
+});
diff --git a/packages/overlayscrollbars/tests/core/dom/create.test.ts b/packages/overlayscrollbars/tests/support/dom/create.test.ts
similarity index 95%
rename from packages/overlayscrollbars/tests/core/dom/create.test.ts
rename to packages/overlayscrollbars/tests/support/dom/create.test.ts
index f390c9e..1890d80 100644
--- a/packages/overlayscrollbars/tests/core/dom/create.test.ts
+++ b/packages/overlayscrollbars/tests/support/dom/create.test.ts
@@ -1,5 +1,5 @@
-import { each } from 'core/utils';
-import { createDiv, createDOM } from 'core/dom/create';
+import { each } from 'support/utils';
+import { createDiv, createDOM } from 'support/dom/create';
const slotElm = document.body;
const testHTML =
diff --git a/packages/overlayscrollbars/tests/core/dom/manipulation.test.ts b/packages/overlayscrollbars/tests/support/dom/manipulation.test.ts
similarity index 98%
rename from packages/overlayscrollbars/tests/core/dom/manipulation.test.ts
rename to packages/overlayscrollbars/tests/support/dom/manipulation.test.ts
index 4205bd4..8c3c02c 100644
--- a/packages/overlayscrollbars/tests/core/dom/manipulation.test.ts
+++ b/packages/overlayscrollbars/tests/support/dom/manipulation.test.ts
@@ -1,5 +1,5 @@
-import { createDiv, contents, appendChildren, prependChildren, insertBefore, insertAfter, removeElements } from 'core/dom';
-import { each, isArray, isHTMLElement } from 'core/utils';
+import { createDiv, contents, appendChildren, prependChildren, insertBefore, insertAfter, removeElements } from 'support/dom';
+import { each, isArray, isHTMLElement } from 'support/utils';
const slotElm = document.body;
const fillSlotElm = () => {
diff --git a/packages/overlayscrollbars/tests/support/dom/offset.test.ts b/packages/overlayscrollbars/tests/support/dom/offset.test.ts
new file mode 100644
index 0000000..df6960e
--- /dev/null
+++ b/packages/overlayscrollbars/tests/support/dom/offset.test.ts
@@ -0,0 +1,36 @@
+import { isNumber, isPlainObject } from 'support/utils/types';
+import { offset, position } from 'support/dom/offset';
+
+describe('dom offset', () => {
+ describe('offset', () => {
+ test('returns correct object with DOM element', () => {
+ const result = offset(document.body);
+ expect(isPlainObject(result)).toBe(true);
+ expect(isNumber(result.left)).toBe(true);
+ expect(isNumber(result.top)).toBe(true);
+ });
+
+ test('returns correct object with null', () => {
+ const result = offset(null);
+ expect(isPlainObject(result)).toBe(true);
+ expect(result.left).toBe(0);
+ expect(result.top).toBe(0);
+ });
+ });
+
+ describe('position', () => {
+ test('returns correct object with DOM element', () => {
+ const result = position(document.body);
+ expect(isPlainObject(result)).toBe(true);
+ expect(isNumber(result.left)).toBe(true);
+ expect(isNumber(result.top)).toBe(true);
+ });
+
+ test('returns correct object with null', () => {
+ const result = position(null);
+ expect(isPlainObject(result)).toBe(true);
+ expect(result.left).toBe(0);
+ expect(result.top).toBe(0);
+ });
+ });
+});
diff --git a/packages/overlayscrollbars/tests/support/dom/style.test.ts b/packages/overlayscrollbars/tests/support/dom/style.test.ts
new file mode 100644
index 0000000..f0d2891
--- /dev/null
+++ b/packages/overlayscrollbars/tests/support/dom/style.test.ts
@@ -0,0 +1,93 @@
+import { isString, isPlainObject, isEmptyObject } from 'support/utils/types';
+import { style, hide, show } from 'support/dom/style';
+
+describe('dom style', () => {
+ afterEach(() => {
+ document.body.removeAttribute('style');
+ });
+
+ describe('style', () => {
+ describe('get', () => {
+ test('single', () => {
+ expect(isString(style(document.body, 'width'))).toBe(true);
+ });
+
+ test('multiple', () => {
+ const widthHeight = style(document.body, ['width', 'height']);
+ expect(isPlainObject(widthHeight)).toBe(true);
+ expect(isString(widthHeight.width)).toBe(true);
+ expect(isString(widthHeight.height)).toBe(true);
+ });
+
+ test('null', () => {
+ expect(style(null, 'width')).toBe('');
+
+ const widthHeight = style(null, ['width', 'height']);
+ expect(isPlainObject(widthHeight)).toBe(true);
+ expect(isEmptyObject(widthHeight)).toBe(true);
+ });
+ });
+
+ describe('set', () => {
+ test('single', () => {
+ expect(document.body.style.width).toBe('');
+ style(document.body, { width: '123px' });
+ expect(document.body.style.width).toBe('123px');
+ });
+
+ test('single add px', () => {
+ expect(document.body.style.width).toBe('');
+ style(document.body, { width: 123 });
+ expect(document.body.style.width).toBe('123px');
+ });
+
+ test('single dont add px', () => {
+ expect(document.body.style.opacity).toBe('');
+ style(document.body, { opacity: 0.5 });
+ expect(document.body.style.opacity).toBe('0.5');
+ });
+
+ test('multiple', () => {
+ expect(document.body.style.width).toBe('');
+ expect(document.body.style.height).toBe('');
+ expect(document.body.style.opacity).toBe('');
+ expect(document.body.style.zIndex).toBe('');
+ expect(document.body.style.lineHeight).toBe('');
+ style(document.body, { width: '123px', height: 321, opacity: '0.5', zIndex: 1 });
+ expect(document.body.style.width).toBe('123px');
+ expect(document.body.style.height).toBe('321px');
+ expect(document.body.style.opacity).toBe('0.5');
+ expect(document.body.style.zIndex).toBe('1');
+ });
+
+ test('null', () => {
+ expect(style(null, { width: '123px' })).toBe(undefined);
+ expect(style(null, { width: '123px', height: '321px' })).toBe(undefined);
+ });
+ });
+ });
+
+ describe('hide', () => {
+ test('normal', () => {
+ expect(document.body.style.display).toBe('');
+ hide(document.body);
+ expect(document.body.style.display).toBe('none');
+ });
+
+ test('null', () => {
+ expect(hide(null)).toBe(undefined);
+ });
+ });
+
+ describe('show', () => {
+ test('normal', () => {
+ expect(document.body.style.display).toBe('');
+ show(document.body);
+ expect(document.body.style.display).toBe('block');
+ });
+
+ test('null', () => {
+ expect(show(null)).toBe(undefined);
+ });
+ });
+});
diff --git a/packages/overlayscrollbars/tests/core/dom/traversal.test.ts b/packages/overlayscrollbars/tests/support/dom/traversal.test.ts
similarity index 98%
rename from packages/overlayscrollbars/tests/core/dom/traversal.test.ts
rename to packages/overlayscrollbars/tests/support/dom/traversal.test.ts
index e9116a3..f7b64ed 100644
--- a/packages/overlayscrollbars/tests/core/dom/traversal.test.ts
+++ b/packages/overlayscrollbars/tests/support/dom/traversal.test.ts
@@ -1,4 +1,4 @@
-import { find, findFirst, is, children, contents, parent, createDiv } from 'core/dom';
+import { find, findFirst, is, children, contents, parent, createDiv } from 'support/dom';
const slotElm = document.body;
const testHTML = '