@webalternatif/js-core 1.3.1 → 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/dist/cjs/Mouse.js +62 -0
- package/dist/cjs/Translator.js +110 -0
- package/dist/cjs/dom.js +174 -23
- package/dist/cjs/index.js +5 -3
- package/dist/cjs/string.js +31 -33
- package/dist/cjs/traversal.js +7 -6
- package/dist/esm/Mouse.js +62 -0
- package/dist/esm/Translator.js +110 -0
- package/dist/esm/dom.js +174 -23
- package/dist/esm/index.js +5 -3
- package/dist/esm/string.js +31 -33
- package/dist/esm/traversal.js +7 -6
- package/package.json +1 -1
- package/types/Mouse.d.ts +13 -0
- package/types/Translator.d.ts +34 -0
- package/types/dom.d.ts +13 -13
- package/types/index.d.ts +11 -11
package/types/Mouse.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default Mouse;
|
|
2
|
+
declare class Mouse {
|
|
3
|
+
static getPosition(ev: any, element: any): {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
static getViewportPosition(ev: any): {
|
|
8
|
+
x: any;
|
|
9
|
+
y: any;
|
|
10
|
+
};
|
|
11
|
+
static getElement(ev: any): Element | null;
|
|
12
|
+
static "__#1@#getEvent"(ev: any): any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {string | (() => string)} TranslatorValue
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Record<string, Record<string, Record<string, TranslatorValue>>>} TranslatorNsMapping
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Record<string, Record<string, TranslatorValue>>} TranslatorCoreMapping
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {TranslatorNsMapping | TranslatorCoreMapping} TranslatorMapping
|
|
12
|
+
*/
|
|
13
|
+
export default class Translator {
|
|
14
|
+
/**
|
|
15
|
+
* @param {TranslatorMapping} mapping
|
|
16
|
+
* @param {string} [defaultLang]
|
|
17
|
+
*/
|
|
18
|
+
constructor(mapping: TranslatorMapping, defaultLang?: string);
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} label
|
|
21
|
+
* @param {string} [namespace]
|
|
22
|
+
* @param {string} [lang]
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
translate(label: string, namespace?: string, lang?: string): string;
|
|
26
|
+
_(...args: any[]): string;
|
|
27
|
+
getLang(): string;
|
|
28
|
+
setLang(lang: any): void;
|
|
29
|
+
#private;
|
|
30
|
+
}
|
|
31
|
+
export type TranslatorValue = string | (() => string);
|
|
32
|
+
export type TranslatorNsMapping = Record<string, Record<string, Record<string, TranslatorValue>>>;
|
|
33
|
+
export type TranslatorCoreMapping = Record<string, Record<string, TranslatorValue>>;
|
|
34
|
+
export type TranslatorMapping = TranslatorNsMapping | TranslatorCoreMapping;
|
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
|
-
|
|
5
|
+
export default dom;
|
|
6
|
+
declare namespace dom {
|
|
6
7
|
/**
|
|
7
8
|
* @param {Element} el
|
|
8
9
|
* @param {string} [selector]
|
|
@@ -199,12 +200,12 @@ declare namespace _default {
|
|
|
199
200
|
/**
|
|
200
201
|
* @param {Element|Document|Window} el
|
|
201
202
|
* @param {string} [events]
|
|
202
|
-
* @param {string|Element|function} selector
|
|
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
|
|
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 {
|
|
222
|
+
* @returns {Array<Element>}
|
|
222
223
|
*/
|
|
223
|
-
function closestFind(el: Element, selectorClosest: string, selectorFind: string):
|
|
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
|
|
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
|
-
"__#
|
|
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
|
-
|
|
14
|
-
|
|
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;
|
|
@@ -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
|
|
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):
|
|
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
|
|
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
|
-
|
|
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 };
|