change arrow functions style

This commit is contained in:
Rene
2020-08-02 11:54:55 +02:00
parent f935a23185
commit a9203c8850
24 changed files with 127 additions and 84 deletions
@@ -1,24 +1,48 @@
var OverlayScrollbars = function (exports, not_png, j) {
'use strict';
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define("OverlayScrollbars", ["exports", "dir/not.png", "jquery"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("dir/not.png"), require("jquery"));
} else {
var mod = {
exports: {}
};
factory(mod.exports, global.not, global.jQuery);
global.OverlayScrollbars = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _not, _jquery) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
Object.defineProperty(_exports, "not", {
enumerable: true,
get: function get() {
return _not.default;
}
});
_exports.file = _exports.c = _exports.b = _exports.abc = _exports.a = _exports.default = void 0;
_not = _interopRequireDefault(_not);
_jquery = _interopRequireDefault(_jquery);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
not_png = not_png && Object.prototype.hasOwnProperty.call(not_png, 'default') ? not_png['default'] : not_png;
j = j && Object.prototype.hasOwnProperty.call(j, 'default') ? j['default'] : j;
var abc = 'abc';
_exports.abc = abc;
var a = 1 + 1;
var file = {
a: a
};
_exports.file = file;
var a$1 = 'a';
_exports.a = a$1;
var b = 'b';
_exports.b = b;
var c = 'c';
var index = j('div');
exports.not = not_png;
exports.a = a$1;
exports.abc = abc;
exports.b = b;
exports.c = c;
exports.default = index;
exports.file = file;
return exports;
}({}, not_png, jQuery);
_exports.c = c;
var index = (0, _jquery.default)('div');
var _default = index;
_exports.default = _default;
});
//# sourceMappingURL=overlayscrollbars-jquery.js.map
@@ -1 +1 @@
{"version":3,"file":"overlayscrollbars-jquery.js","sources":["../src/dir/abc.js","../src/file.js","../src/test.js","../src/index.js"],"sourcesContent":["export default 'abc';\n","const a = 1 + 1;\nexport default {\n a,\n};\n","export const a = 'a';\nexport const b = 'b';\nexport const c = 'c';\n","import abc from 'dir/abc';\nimport not from 'dir/not.png';\nimport file from 'file';\nimport j from 'jquery';\nimport { a, b, c } from 'test';\n\nexport default j('div');\nexport { a, b, c, file, abc, not };\n"],"names":["a","b","c","j"],"mappings":";;;;;YAAe;ACAf,MAAMA,CAAC,GAAG,IAAI,CAAd;aACe;AACbA,IAAAA,CAAC,EAADA;AADa;MCDFA,GAAC,GAAG;MACJC,CAAC,GAAG;MACJC,CAAC,GAAG;cCIFC,CAAC,CAAC,KAAD;;;;;;;;;"}
{"version":3,"file":"overlayscrollbars-jquery.js","sources":["../src/dir/abc.js","../src/file.js","../src/test.js","../src/index.js"],"sourcesContent":["export default 'abc';\n","const a = 1 + 1;\nexport default {\n a,\n};\n","export const a = 'a';\nexport const b = 'b';\nexport const c = 'c';\n","import abc from 'dir/abc';\nimport not from 'dir/not.png';\nimport file from 'file';\nimport j from 'jquery';\nimport { a, b, c } from 'test';\n\nexport default j('div');\nexport { a, b, c, file, abc, not };\n"],"names":["a","b","c"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAe,KAAf;;ACAA,MAAMA,CAAC,GAAG,IAAI,CAAd;AACA,aAAe;AACbA,IAAAA,CAAC,EAADA;AADa,GAAf;;ACDY,MAACA,GAAC,GAAG,GAAL;;AACA,MAACC,CAAC,GAAG,GAAL;;AACA,MAACC,CAAC,GAAG,GAAL;;ACIZ,cAAe,qBAAE,KAAF,CAAf;"}
@@ -1 +1 @@
var OverlayScrollbars=function(t,a,e){"use strict";a=a&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a;var r={a:2},l=(e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e)("div");return t.not=a,t.a="a",t.abc="abc",t.b="b",t.c="c",t.default=l,t.file=r,t}({},not_png,jQuery);
!function(e,r){if("function"==typeof define&&define.amd)define("OverlayScrollbars",["exports","dir/not.png","jquery"],r);else if("undefined"!=typeof exports)r(exports,require("dir/not.png"),require("jquery"));else{var t={exports:{}};r(t.exports,e.not,e.jQuery),e.OverlayScrollbars=t.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e,r,t){function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"not",{enumerable:!0,get:function(){return r.default}}),e.file=e.c=e.b=e.abc=e.a=e.default=void 0,r=n(r),t=n(t);e.abc="abc";var f={a:2};e.file=f;e.a="a";e.b="b";e.c="c";var o=(0,t.default)("div");e.default=o}));
@@ -91,7 +91,5 @@ var index = () => {
</div>'), a, b, c];
};
const a = 1;
export default index;
export { a };
//# sourceMappingURL=overlayscrollbars.esm.js.map
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
function r(r){const s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function s(o,c){if(r(o))for(let r=0;r<o.length&&!1!==c(o[r],r,o);r++);else o&&s((i=o)?Object.keys(i):[],r=>c(o[r],r,o));var i;return o}const o=c=>{if(r(c))s(Array.from(c),r=>o(r));else if(c){const{parentNode:r}=c;r&&r.removeChild(c)}},c=r=>{const c=document.createElement("div");return c.innerHTML=r.trim(),s((i=c)?Array.from(i.childNodes):[],r=>o(r));var i},i={a:1,b:1,c:1};const e=1;export default()=>{const{a:r,b:s,c:o}=i;return[c(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]};export{e as a};
function r(r){const s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function s(o,i){if(r(o))for(let r=0;r<o.length&&!1!==i(o[r],r,o);r++);else o&&s((c=o)?Object.keys(c):[],r=>i(o[r],r,o));var c;return o}const o=i=>{if(r(i))s(Array.from(i),r=>o(r));else if(i){const{parentNode:r}=i;r&&r.removeChild(i)}},i=r=>{const i=document.createElement("div");return i.innerHTML=r.trim(),s((c=i)?Array.from(c.childNodes):[],r=>o(r));var c},c={a:1,b:1,c:1};export default()=>{const{a:r,b:s,c:o}=c;return[i(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]};
+22 -7
View File
@@ -1,5 +1,22 @@
var OverlayScrollbars = function (exports) {
'use strict';
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define("OverlayScrollbars", ["exports"], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.OverlayScrollbars = mod.exports;
}
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
function isNumber(obj) {
return typeof obj === 'number';
@@ -102,9 +119,7 @@ var OverlayScrollbars = function (exports) {
</div>'), a, b, c];
};
var a = 1;
exports.a = a;
exports.default = index;
return exports;
}({});
var _default = index;
_exports.default = _default;
});
//# sourceMappingURL=overlayscrollbars.js.map
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
var OverlayScrollbars=function(r){"use strict";function s(r){var s=!!r&&r.length;return function(r){return Array.isArray(r)}(r)||!function(r){return"function"==typeof r}(r)&&function(r){return"number"==typeof r}(s)&&s>-1&&s%1==0}function o(r,i){if(s(r))for(var n=0;n<r.length&&!1!==i(r[n],n,r);n++);else r&&o((a=r)?Object.keys(a):[],(function(s){return i(r[s],s,r)}));var a;return r}var i=function(r){var i,n=document.createElement("div");return n.innerHTML=r.trim(),o((i=n)?Array.from(i.childNodes):[],(function(r){return function r(i){if(s(i))o(Array.from(i),(function(s){return r(s)}));else if(i){var n=i.parentNode;n&&n.removeChild(i)}}(r)}))},n=1,a=1,e=1;return r.a=1,r.default=function(){var r=n,s=a,o=e;return[i(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,s,o]},r}({});
!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<r.length&&!1!==s(r[i],i,r);i++);else r&&o((n=r)?Object.keys(n):[],(function(e){return s(r[e],e,r)}));var n;return r}var s=function(r){var s,i=document.createElement("div");return i.innerHTML=r.trim(),o((s=i)?Array.from(s.childNodes):[],(function(r){return function r(s){if(e(s))o(Array.from(s),(function(e){return r(e)}));else if(s){var i=s.parentNode;i&&i.removeChild(s)}}(r)}))},i=1,n=1,l=1,t=function(){var r=i,e=n,o=l;return[s(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>'),r,e,o]};r.default=t}));
@@ -1,4 +1,4 @@
export const mouseButton: (event: MouseEvent) => number = (event) => {
export const mouseButton = (event: MouseEvent): number => {
const { button } = event;
if (!event.which && button !== undefined) {
return button & 1 ? 1 : button & 2 ? 3 : button & 4 ? 2 : 0; // eslint-disable-line no-bitwise
@@ -1,8 +1,8 @@
import { each, hasOwnProperty } from 'core/utils';
import { createDiv } from 'core/dom';
const firstLetterToUpper: (str: string) => string = (str) => str.charAt(0).toUpperCase() + str.slice(1);
const getDummyStyle: () => CSSStyleDeclaration = () => createDiv().style;
const firstLetterToUpper = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1);
const getDummyStyle = (): CSSStyleDeclaration => createDiv().style;
// https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix
@@ -16,7 +16,7 @@ export const cssCache: { [key: string]: string } = {};
* Gets the name of the given CSS property with vendor prefix if it isn't supported without, or undefined if unsupported.
* @param name The name of the CSS property which shall be get.
*/
export const cssProperty: (name: string) => string | undefined = (name) => {
export const cssProperty = (name: string): string | undefined => {
let result: string | undefined = cssCache[name];
if (hasOwnProperty(cssCache, name)) {
@@ -48,7 +48,7 @@ export const cssProperty: (name: string) => string | undefined = (name) => {
* @param values The value(s) separated by spaces which shall be get.
* @param suffix A suffix which is added to each value in case the value is a function or something else more advanced.
*/
export const cssPropertyValue: (property: string, values: string, suffix?: string) => string | undefined = (property, values, suffix) => {
export const cssPropertyValue = (property: string, values: string, suffix?: string): string | undefined => {
const name = `${property} ${values}`;
let result: string | undefined = cssCache[name];
@@ -81,7 +81,7 @@ export const cssPropertyValue: (property: string, values: string, suffix?: strin
* Get the requested JS function, object or constructor with vendor prefix if it isn't supported without or undefined if unsupported.
* @param name The name of the JS function, object or constructor.
*/
export const jsAPI: (name: string) => any = (name) => {
export const jsAPI = (name: string): any => {
let result: any = jsCache[name] || window[name];
if (hasOwnProperty(jsCache, name)) {
@@ -5,7 +5,7 @@
* @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 = (elm, attrName, value) => {
export const attr = (elm: Element, attrName: string, value?: string): string | null | void => {
if (value === undefined) {
return elm.getAttribute(attrName);
}
@@ -17,7 +17,7 @@ export const attr: (elm: Element, attrName: string, value?: string) => string |
* @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, attrName) => {
export const removeAttr = (elm: Element, attrName: string): void => {
elm.removeAttribute(attrName);
};
@@ -26,7 +26,7 @@ export const removeAttr: (elm: Element, attrName: string) => void = (elm, attrNa
* @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 = (elm, value) => {
export const scrollLeft = (elm: HTMLElement, value?: number): number | void => {
if (value === undefined) {
return elm.scrollLeft;
}
@@ -38,7 +38,7 @@ export const scrollLeft: (elm: HTMLElement, value?: number) => number | void = (
* @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 = (elm, value) => {
export const scrollTop = (elm: HTMLElement, value?: number): number | void => {
if (value === undefined) {
return elm.scrollTop;
}
@@ -50,7 +50,7 @@ export const scrollTop: (elm: HTMLElement, value?: number) => number | void = (e
* @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 = (elm, value) => {
export const val = (elm: HTMLInputElement, value?: string): string | void => {
if (value === undefined) {
return elm.value;
}
@@ -7,14 +7,14 @@ const rnothtmlwhite = /[^\x20\t\r\n\f]+/g;
* @param elm The element.
* @param className The class name.
*/
export const hasClass: (elm: Element, className: string) => boolean = (elm, className) => elm.classList.contains(className);
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 = (elm, className) => {
export const addClass = (elm: Element, className: string): void => {
let clazz: string;
let i = 0;
@@ -31,7 +31,7 @@ export const addClass: (elm: Element, className: string) => void = (elm, classNa
* @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 = (elm, className) => {
export const removeClass = (elm: Element, className: string): void => {
let clazz: string;
let i = 0;
@@ -49,7 +49,7 @@ export const removeClass: (elm: Element, className: string) => void = (elm, clas
* @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 = (elm, className, condition) => {
export const conditionalClass = (elm: Element, className: string, condition: boolean): void => {
if (condition) {
addClass(elm, className);
} else {
@@ -2,9 +2,9 @@ import { each } from 'core/utils/array';
import { contents } from 'core/dom/traversal';
import { removeElements } from 'core/dom/manipulation';
export const createDiv: () => HTMLDivElement = () => document.createElement('div');
export const createDiv = (): HTMLDivElement => document.createElement('div');
export const createDOM: (html: string) => ReadonlyArray<Node> = (html) => {
export const createDOM = (html: string): ReadonlyArray<Node> => {
const createdDiv = createDiv();
createdDiv.innerHTML = html.trim();
@@ -10,11 +10,7 @@ type NodeCollection = ArrayLike<Node> | Node | undefined | null;
* @param preferredAnchor The element before which the Nodes shall be inserted or null if the elements shall be appended at the end.
* @param insertedElms The Nodes which shall be inserted.
*/
const before: (parentElm: Node | null, preferredAnchor: Node | null, insertedElms: NodeCollection) => void = (
parentElm,
preferredAnchor,
insertedElms,
) => {
const before = (parentElm: Node | null, preferredAnchor: Node | null, insertedElms: NodeCollection): void => {
if (insertedElms) {
let anchor: Node | null = preferredAnchor;
let fragment: DocumentFragment | Node | undefined | null;
@@ -54,7 +50,7 @@ const before: (parentElm: Node | null, preferredAnchor: Node | null, insertedElm
* @param node The Node to which the children shall be appended.
* @param children The Nodes which shall be appended.
*/
export const appendChildren: (node: Node | null, children: NodeCollection) => void = (node, children) => {
export const appendChildren = (node: Node | null, children: NodeCollection): void => {
before(node, null, children);
};
@@ -63,7 +59,7 @@ export const appendChildren: (node: Node | null, children: NodeCollection) => vo
* @param node The Node to which the children shall be prepended.
* @param children The Nodes which shall be prepended.
*/
export const prependChildren: (node: Node | null, children: NodeCollection) => void = (node, children) => {
export const prependChildren = (node: Node | null, children: NodeCollection): void => {
before(node, node && node.firstChild, children);
};
@@ -72,7 +68,7 @@ export const prependChildren: (node: Node | null, children: NodeCollection) => v
* @param node The Node before which the given Nodes shall be inserted.
* @param insertedNodes The Nodes which shall be inserted.
*/
export const insertBefore: (node: Node | null, insertedNodes: NodeCollection) => void = (node, insertedNodes) => {
export const insertBefore = (node: Node | null, insertedNodes: NodeCollection): void => {
before(parent(node), node, insertedNodes);
};
@@ -81,7 +77,7 @@ export const insertBefore: (node: Node | null, insertedNodes: NodeCollection) =>
* @param node The Node after which the given Nodes shall be inserted.
* @param insertedNodes The Nodes which shall be inserted.
*/
export const insertAfter: (node: Node | null, insertedNodes: NodeCollection) => void = (node, insertedNodes) => {
export const insertAfter = (node: Node | null, insertedNodes: NodeCollection): void => {
before(parent(node), node && node.nextSibling, insertedNodes);
};
@@ -89,7 +85,7 @@ export const insertAfter: (node: Node | null, insertedNodes: NodeCollection) =>
* Removes the given Nodes from their parent.
* @param nodes The Nodes which shall be removed.
*/
export const removeElements: (nodes: NodeCollection) => void = (nodes) => {
export const removeElements = (nodes: NodeCollection): void => {
if (isArrayLike(nodes)) {
each(Array.from(nodes), (e) => removeElements(e));
} else if (nodes) {
@@ -19,10 +19,10 @@ const cssNumber = {
zoom: true,
};
const parseCSSVal: (prop: string, val: string | number) => string | number = (prop, val) =>
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 = (elm, prop, val) => {
const setCSSVal = (elm: HTMLElement, prop: string, val: string | number): void => {
try {
if (elm.style[prop] !== undefined) {
elm.style[prop] = parseCSSVal(prop, val);
@@ -48,10 +48,10 @@ export function style(elm: HTMLElement, styles: string | cssStyleObj, val?: stri
}
}
export const hide: (elm: HTMLElement) => void = (elm) => {
export const hide = (elm: HTMLElement): void => {
elm.style.display = 'none';
};
export const show: (elm: HTMLElement) => void = (elm) => {
export const show = (elm: HTMLElement): void => {
elm.style.display = 'block';
};
@@ -1,8 +1,8 @@
import { each } from 'core/utils/array';
const elementIsVisible: (elm: HTMLElement) => boolean = (elm) => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);
const elementIsVisible = (elm: HTMLElement): boolean => !!(elm.offsetWidth || elm.offsetHeight || elm.getClientRects().length);
export const find: (selector: string, elm?: Element | null) => ReadonlyArray<Element> = (selector, elm?) => {
export const find = (selector: string, elm?: Element | null): ReadonlyArray<Element> => {
const arr: Array<Element> = [];
each((elm || document).querySelectorAll(selector), (e: Element) => {
@@ -12,9 +12,9 @@ export const find: (selector: string, elm?: Element | null) => ReadonlyArray<Ele
return arr;
};
export const findFirst: (selector: string, elm?: Element | null) => Element | null = (selector, elm?) => (elm || document).querySelector(selector);
export const findFirst = (selector: string, elm?: Element | null): Element | null => (elm || document).querySelector(selector);
export const is: (elm: Element | null, selector: string) => boolean = (elm, selector) => {
export const is = (elm: Element | null, selector: string): boolean => {
if (elm) {
if (selector === ':visible') {
return elementIsVisible(elm as HTMLElement);
@@ -29,7 +29,7 @@ export const is: (elm: Element | null, selector: string) => boolean = (elm, sele
return false;
};
export const children: (elm: Element | null, selector?: string) => ReadonlyArray<Element> = (elm, selector?) => {
export const children = (elm: Element | null, selector?: string): ReadonlyArray<Element> => {
const childs: Array<Element> = [];
each(elm && elm.children, (child: Element) => {
@@ -45,6 +45,6 @@ export const children: (elm: Element | null, selector?: string) => ReadonlyArray
return childs;
};
export const contents: (elm: Element | null) => ReadonlyArray<ChildNode> = (elm) => (elm ? Array.from<ChildNode>(elm.childNodes) : []);
export const contents = (elm: Element | null): ReadonlyArray<ChildNode> => (elm ? Array.from<ChildNode>(elm.childNodes) : []);
export const parent: (elm: Node | null) => Node | null = (elm) => (elm ? elm.parentElement : null);
export const parent = (elm: Node | null): Node | null => (elm ? elm.parentElement : null);
@@ -47,13 +47,13 @@ const optionsTemplateTypes: OptionsTemplateTypesDictionary = ['boolean', 'number
* @param doWriteErrors True if errors shall be logged into the console, false otherwise.
* @param propPath The propertyPath which lead to this object. (used for error logging)
*/
const validateRecursive = function <T extends PlainObject>(
const validateRecursive = <T extends PlainObject>(
options: T,
template: OptionsTemplate<Required<T>>,
optionsDiff: OptionsValidated<T>,
doWriteErrors?: boolean,
propPath?: string,
): OptionsValidatedResult<T> {
): OptionsValidatedResult<T> => {
const validatedOptions: OptionsValidated<T> = {};
const optionsCopy: T = { ...options };
const props = keys(template).filter((prop) => hasOwnProperty(options, prop));
@@ -147,12 +147,12 @@ const validateRecursive = function <T extends PlainObject>(
* Without the optionsDiff object the returned validated object would be: { a: 'a', b: 'b', c: 'c' }
* @param doWriteErrors True if errors shall be logged into the console, false otherwise.
*/
const validate = function <T extends PlainObject>(
const validate = <T extends PlainObject>(
options: T,
template: OptionsTemplate<Required<T>>,
optionsDiff?: OptionsValidated<T>,
doWriteErrors?: boolean,
): OptionsValidatedResult<T> {
): OptionsValidatedResult<T> => {
/*
if (!isEmptyObject(foreign) && doWriteErrors)
console.warn(`The following options are discarded due to invalidity:\r\n ${window.JSON.stringify(foreign, null, 2)}`);
@@ -49,4 +49,4 @@ export function each<T>(
* @param item The item.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
export const indexOf: <T = any>(arr: Array<T>, item: T, fromIndex?: number) => number = (arr, item, fromIndex) => arr.indexOf(item, fromIndex);
export const indexOf = <T = any>(arr: Array<T>, item: T, fromIndex?: number): number => arr.indexOf(item, fromIndex);
@@ -3,11 +3,11 @@
* @param obj The object.
* @param prop The name of the property.
*/
export const hasOwnProperty: (obj: any, prop: string | number | symbol) => boolean = (obj: any, prop: string | number | symbol) =>
export const hasOwnProperty = (obj: any, prop: string | number | symbol): boolean =>
Object.prototype.hasOwnProperty.call(obj, prop);
/**
* Returns the names of the enumerable string properties and methods of an object.
* @param obj The object of which the properties shall be returned.
*/
export const keys: (obj: any) => Array<string> = (obj: any) => (obj ? Object.keys(obj) : []);
export const keys = (obj: any): Array<string> => (obj ? Object.keys(obj) : []);
+1 -3
View File
@@ -39,12 +39,10 @@ export default () => {
</div>\
</div>\
<div class="os-scrollbar-corner"></div>\
</div>',
</div>'
),
a,
b,
c,
];
};
export const a = 1;
+4 -4
View File
@@ -6,7 +6,7 @@ const targetInstanceMap: WeakMap<Element, any> = new WeakMap();
* @param target The element which is the target of the OverlayScrollbars instance.
* @param osInstance The OverlayScrollbars instance.
*/
export const addInstance: (target: Element, osInstance: any) => void = (target, osInstance) => {
export const addInstance = (target: Element, osInstance: any): void => {
targetInstanceMap.set(target, osInstance);
targets.add(target);
};
@@ -15,7 +15,7 @@ export const addInstance: (target: Element, osInstance: any) => void = (target,
* Removes a OverlayScrollbars instance from the given element.
* @param target The element from which its OverlayScrollbars instance shall be removed.
*/
export const removeInstance: (target: Element) => void = (target) => {
export const removeInstance = (target: Element): void => {
targetInstanceMap.delete(target);
targets.delete(target);
};
@@ -24,13 +24,13 @@ export const removeInstance: (target: Element) => void = (target) => {
* Gets the OverlayScrollbars from the given element or undefined if it doesn't have one.
* @param target The element of which its OverlayScrollbars instance shall be get.
*/
export const getInstance: (target: Element) => any = (target) => targetInstanceMap.get(target);
export const getInstance = (target: Element): any => targetInstanceMap.get(target);
/**
* Gets a Map which represents all active OverayScrollbars instances.
* The Key is the ekement and the value is the instance.
*/
export const allInstances: () => ReadonlyMap<Element, any> = () => {
export const allInstances = (): ReadonlyMap<Element, any> => {
const validTargetInstanceMap: Map<Element, any> = new Map();
targets.forEach((target: Element) => {
-1
View File
@@ -1,3 +1,2 @@
declare const _default: () => (number | readonly Node[])[];
export default _default;
export declare const a = 1;
+15 -2
View File
@@ -70,13 +70,26 @@ export default async (config) => {
const mainOutputArray = [
{
format: 'iife',
format: 'esm',
name,
globals,
exports,
file: path.resolve(distPath, `${project}.js`),
sourcemap: legacySourceMap,
plugins: [rollupBabelOutputPlugin(legacyOutputBabelConfig)],
plugins: [
rollupBabelOutputPlugin({
...legacyOutputBabelConfig,
plugins: [
[
'@babel/plugin-transform-modules-umd',
{
moduleId: name,
globals,
},
],
],
}),
],
},
{
format: 'esm',