@webalternatif/js-core 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/dom.d.ts CHANGED
@@ -2,7 +2,8 @@ export function isWindow(o: any): boolean;
2
2
  export function isDocument(o: any): boolean;
3
3
  export function isDomElement(o: any): boolean;
4
4
  export function getStyle(el: Element, cssRule: string): string;
5
- declare namespace _default {
5
+ export default dom;
6
+ declare namespace dom {
6
7
  /**
7
8
  * @param {Element} el
8
9
  * @param {string} [selector]
@@ -16,31 +17,31 @@ declare namespace _default {
16
17
  */
17
18
  function child(el: Element, selector?: string): Element | null;
18
19
  /**
19
- * @param {Element|Document} refEl
20
- * @param {string|Element|NodeList|Array<Element>} [selector]
21
- * @returns {Element|null}
20
+ * @param {Element|Document|string} refEl
21
+ * @param {string|Element|NodeList|Array<Element>} selector
22
+ * @returns {Element}
22
23
  */
23
- function findOne(refEl: Element | Document, selector?: string | Element | NodeList | Array<Element>): Element | null;
24
+ function findOne(refEl: Element | Document | string, selector: string | Element | NodeList | Array<Element>): Element;
24
25
  /**
25
- * @param {Element|Document} refEl
26
+ * @param {Element|Document|string} refEl
26
27
  * @param {string|Element|NodeList|Array<Element>} selector
27
28
  * @returns {Array<Element>}
28
29
  */
29
- function find(refEl: Element | Document, selector: string | Element | NodeList | Array<Element>): Array<Element>;
30
+ function find(refEl: Element | Document | string, selector: string | Element | NodeList | Array<Element>): Array<Element>;
30
31
  /**
31
- * @param {Element} el
32
+ * @param {Element|string} el
32
33
  * @param {string} data
33
- * @param {string} value
34
+ * @param {string} [value]
34
35
  * @returns {Element|null}
35
36
  */
36
- function findOneByData(el: Element, data: string, value: string): Element | null;
37
+ function findOneByData(el: Element | string, data: string, value?: string): Element | null;
37
38
  /**
38
- * @param {Element} el
39
+ * @param {Element|string} el
39
40
  * @param {string} data
40
- * @param {string} value
41
+ * @param {string} [value]
41
42
  * @returns {Element[]}
42
43
  */
43
- function findByData(el: Element, data: string, value: string): Element[];
44
+ function findByData(el: Element | string, data: string, value?: string): Element[];
44
45
  /**
45
46
  * @param {Element|NodeList|Array<Element>} el
46
47
  * @param {string} className
@@ -85,10 +86,10 @@ declare namespace _default {
85
86
  function remove(...els: Element | NodeList | Array<Element> | string): void;
86
87
  /**
87
88
  * @param {Element} el
88
- * @param {string|Element} selector
89
+ * @param {string|Element} [selector]
89
90
  * @returns {Element|null}
90
91
  */
91
- function closest(el: Element, selector: string | Element): Element | null;
92
+ function closest(el: Element, selector?: string | Element): Element | null;
92
93
  /**
93
94
  * @param {Element} el
94
95
  * @param {string} [selector]
@@ -198,13 +199,13 @@ declare namespace _default {
198
199
  function on(el: Element | Document | Window, events: string, selector: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
199
200
  /**
200
201
  * @param {Element|Document|Window} el
201
- * @param {string} events
202
- * @param {string|Element|function} selector
202
+ * @param {string} [events]
203
+ * @param {string|Element|function} [selector]
203
204
  * @param {function|AddEventListenerOptions|boolean} [handler]
204
205
  * @param {AddEventListenerOptions|boolean} [options]
205
206
  * @returns {Element}
206
207
  */
207
- function off(el: Element | Document | Window, events: string, selector: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
208
+ function off(el: Element | Document | Window, events?: string, selector?: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
208
209
  /**
209
210
  * @param {HTMLElement} el
210
211
  * @param {Object<string, string>|string} style
@@ -218,9 +219,9 @@ declare namespace _default {
218
219
  * @param {Element} el
219
220
  * @param {string} selectorClosest
220
221
  * @param {string} selectorFind
221
- * @returns {NodeList|null}
222
+ * @returns {Array<Element>}
222
223
  */
223
- function closestFind(el: Element, selectorClosest: string, selectorFind: string): NodeList | null;
224
+ function closestFind(el: Element, selectorClosest: string, selectorFind: string): Array<Element>;
224
225
  /**
225
226
  * @param {Element} el
226
227
  * @param {string} selectorClosest
@@ -240,9 +241,9 @@ declare namespace _default {
240
241
  function last(nodeList: NodeList | Array<Element>): Element | null;
241
242
  /**
242
243
  * @param {string} html
243
- * @returns {Element|null}
244
+ * @returns {Element|DocumentFragment|null}
244
245
  */
245
- function create(html: string): Element | null;
246
+ function create(html: string): Element | DocumentFragment | null;
246
247
  /**
247
248
  * @param {NodeList|Array<Element>} nodeList
248
249
  * @param {number} [index=0]
@@ -267,11 +268,11 @@ declare namespace _default {
267
268
  */
268
269
  function empty(el: Element): Element;
269
270
  /**
270
- * @param {Element|NodeList} el
271
+ * @param {Element|NodeList|Array<Element>} el
271
272
  * @param {string|Element} selector
272
- * @return {Element[]}
273
+ * @return {Array<Element>}
273
274
  */
274
- function not(el: Element | NodeList, selector: string | Element): Element[];
275
+ function not(el: Element | NodeList | Array<Element>, selector: string | Element): Array<Element>;
275
276
  /**
276
277
  * @param {Element} elem1
277
278
  * @param {Element} elem2
@@ -291,10 +292,10 @@ declare namespace _default {
291
292
  function replaceChild(el: Element, child: Element, oldChild: Element): Element;
292
293
  /**
293
294
  * @param {Element} el
294
- * @param {Element[]} children
295
+ * @param {NodeList|Array<Element>|string[]} children
295
296
  * @returns {Element}
296
297
  */
297
- function replaceChildren(el: Element, ...children: Element[]): Element;
298
+ function replaceChildren(el: Element, ...children: NodeList | Array<Element> | string[]): Element;
298
299
  /**
299
300
  * @param {Element|Document|Window} el
300
301
  * @returns {{top: number, left: number}}
@@ -304,4 +305,3 @@ declare namespace _default {
304
305
  left: number;
305
306
  };
306
307
  }
307
- export default _default;
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export default webf;
2
2
  declare const webf: {
3
3
  eventDispatcher: {
4
- "__#1@#listeners": {};
4
+ "__#3@#listeners": {};
5
5
  addListener(eventsName: any, callback: any, context: any, ...args: any[]): /*elided*/ any;
6
6
  addListenerOnce(eventsName: any, callback: any, context: any, ...listenerArgs: any[]): /*elided*/ any;
7
7
  dispatch(eventsName: any, ...args: any[]): /*elided*/ any;
@@ -10,10 +10,8 @@ declare const webf: {
10
10
  getListeners(eventName: any): any;
11
11
  reset(): void;
12
12
  };
13
- translate: (lang: any, ns: any, label: any) => any;
14
- _: (lang: any, ns: any, label: any) => any;
15
- getLang: () => any;
16
- setLang: (lang: any) => void;
13
+ Mouse: typeof Mouse;
14
+ default: typeof i18n.default;
17
15
  equals: (o1: any, o2: any, seen?: WeakMap<WeakKey, any>) => any;
18
16
  noop: () => void;
19
17
  sizeOf: (o: any) => number;
@@ -31,10 +29,10 @@ declare const webf: {
31
29
  dom: {
32
30
  children(el: Element, selector?: string): NodeList;
33
31
  child(el: Element, selector?: string): Element | null;
34
- findOne(refEl: Element | Document, selector?: string | Element | NodeList | Array<Element>): Element | null;
35
- find(refEl: Element | Document, selector: string | Element | NodeList | Array<Element>): Array<Element>;
36
- findOneByData(el: Element, data: string, value: string): Element | null;
37
- findByData(el: Element, data: string, value: string): Element[];
32
+ findOne(refEl: Element | Document | string, selector: string | Element | NodeList | Array<Element>): Element;
33
+ find(refEl: Element | Document | string, selector: string | Element | NodeList | Array<Element>): Array<Element>;
34
+ findOneByData(el: Element | string, data: string, value?: string): Element | null;
35
+ findByData(el: Element | string, data: string, value?: string): Element[];
38
36
  addClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
39
37
  removeClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
40
38
  toggleClass(el: Element, classNames: string, force?: boolean): Element;
@@ -42,7 +40,7 @@ declare const webf: {
42
40
  append(node: Node, ...children: (Node | string)[]): Node;
43
41
  prepend(node: Node, ...children: (Node | string)[]): Node;
44
42
  remove(...els: Element | NodeList | Array<Element> | string): void;
45
- closest(el: Element, selector: string | Element): Element | null;
43
+ closest(el: Element, selector?: string | Element): Element | null;
46
44
  next(el: Element, selector?: string): Element | null;
47
45
  prev(el: Element, selector?: string | null): Element | null;
48
46
  nextAll(el: Element, selector?: string): Element[];
@@ -62,24 +60,24 @@ declare const webf: {
62
60
  } | string, value?: string): Element | DOMStringMap;
63
61
  removeData(el: Element, name: string): Element | any;
64
62
  on(el: Element | Document | Window, events: string, selector: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
65
- off(el: Element | Document | Window, events: string, selector: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
63
+ off(el: Element | Document | Window, events?: string, selector?: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
66
64
  css(el: HTMLElement, style: {
67
65
  [x: string]: string;
68
66
  } | string, value?: string): Element;
69
- closestFind(el: Element, selectorClosest: string, selectorFind: string): NodeList | null;
67
+ closestFind(el: Element, selectorClosest: string, selectorFind: string): Array<Element>;
70
68
  closestFindOne(el: Element, selectorClosest: string, selectorFindOne: string): Element | null;
71
69
  first(nodeList: NodeList | Element | Array<Element>): Element | null;
72
70
  last(nodeList: NodeList | Array<Element>): Element | null;
73
- create(html: string): Element | null;
71
+ create(html: string): Element | DocumentFragment | null;
74
72
  eq(nodeList: NodeList | Array<Element>, index?: number): Element | null;
75
73
  after(el: Element, newEl: Element | string): Element | null;
76
74
  before(el: Element, newEl: Element | string): Element | null;
77
75
  empty(el: Element): Element;
78
- not(el: Element | NodeList, selector: string | Element): Element[];
76
+ not(el: Element | NodeList | Array<Element>, selector: string | Element): Array<Element>;
79
77
  collide(elem1: Element, elem2: Element): boolean;
80
78
  matches(el: Element, selector: string | Element): boolean;
81
79
  replaceChild(el: Element, child: Element, oldChild: Element): Element;
82
- replaceChildren(el: Element, ...children: Element[]): Element;
80
+ replaceChildren(el: Element, ...children: NodeList | Array<Element> | string[]): Element;
83
81
  offset(el: Element | Document | Window): {
84
82
  top: number;
85
83
  left: number;
@@ -176,4 +174,6 @@ import dom from './dom.js';
176
174
  import * as math from './math.js';
177
175
  import * as utils from './utils.js';
178
176
  import eventDispatcher from './eventDispatcher.js';
179
- export { stringFunctions, arrayFunctions, traversal, is, random, getStyle, dom, math, utils, eventDispatcher };
177
+ import Mouse from './Mouse.js';
178
+ import * as i18n from './Translator.js';
179
+ export { stringFunctions, arrayFunctions, traversal, is, random, getStyle, dom, math, utils, eventDispatcher, Mouse };