@webalternatif/js-core 1.2.0 → 1.3.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/dom.js +237 -38
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/random.js +14 -9
- package/dist/cjs/string.js +35 -7
- package/dist/cjs/traversal.js +2 -2
- package/dist/esm/dom.js +237 -38
- package/dist/esm/index.js +6 -3
- package/dist/esm/random.js +14 -9
- package/dist/esm/string.js +35 -7
- package/dist/esm/traversal.js +2 -2
- package/package.json +4 -3
- package/types/dom.d.ts +71 -23
- package/types/index.d.ts +49 -12
- package/types/random.d.ts +1 -1
- package/types/string.d.ts +1 -1
- package/types/traversal.d.ts +1 -1
package/types/dom.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export function isWindow(o: any): boolean;
|
|
2
|
+
export function isDocument(o: any): boolean;
|
|
2
3
|
export function isDomElement(o: any): boolean;
|
|
3
|
-
export function getStyle(
|
|
4
|
+
export function getStyle(el: Element, cssRule: string): string;
|
|
4
5
|
declare namespace _default {
|
|
5
6
|
/**
|
|
6
7
|
* @param {Element} el
|
|
@@ -26,6 +27,20 @@ declare namespace _default {
|
|
|
26
27
|
* @returns {Array<Element>}
|
|
27
28
|
*/
|
|
28
29
|
function find(refEl: Element | Document, selector: string | Element | NodeList | Array<Element>): Array<Element>;
|
|
30
|
+
/**
|
|
31
|
+
* @param {Element} el
|
|
32
|
+
* @param {string} data
|
|
33
|
+
* @param {string} value
|
|
34
|
+
* @returns {Element|null}
|
|
35
|
+
*/
|
|
36
|
+
function findOneByData(el: Element, data: string, value: string): Element | null;
|
|
37
|
+
/**
|
|
38
|
+
* @param {Element} el
|
|
39
|
+
* @param {string} data
|
|
40
|
+
* @param {string} value
|
|
41
|
+
* @returns {Element[]}
|
|
42
|
+
*/
|
|
43
|
+
function findByData(el: Element, data: string, value: string): Element[];
|
|
29
44
|
/**
|
|
30
45
|
* @param {Element|NodeList|Array<Element>} el
|
|
31
46
|
* @param {string} className
|
|
@@ -53,16 +68,16 @@ declare namespace _default {
|
|
|
53
68
|
function hasClass(el: Element, classNames: string): boolean;
|
|
54
69
|
/**
|
|
55
70
|
* @param {Node} node
|
|
56
|
-
* @param {...Node} children
|
|
71
|
+
* @param {...(Node|string)} children
|
|
57
72
|
* @returns {Node}
|
|
58
73
|
*/
|
|
59
|
-
function append(node: Node, ...children: Node[]): Node;
|
|
74
|
+
function append(node: Node, ...children: (Node | string)[]): Node;
|
|
60
75
|
/**
|
|
61
76
|
* @param {Node} node
|
|
62
|
-
* @param {...Node} children
|
|
77
|
+
* @param {...(Node|string)} children
|
|
63
78
|
* @returns {Node}
|
|
64
79
|
*/
|
|
65
|
-
function prepend(node: Node, ...children: Node[]): Node;
|
|
80
|
+
function prepend(node: Node, ...children: (Node | string)[]): Node;
|
|
66
81
|
/**
|
|
67
82
|
* @param {Element|NodeList|Array<Element>|string} els
|
|
68
83
|
* @returns {void}
|
|
@@ -174,20 +189,22 @@ declare namespace _default {
|
|
|
174
189
|
function removeData(el: Element, name: string): Element | any;
|
|
175
190
|
/**
|
|
176
191
|
* @param {Element|Document|Window} el
|
|
177
|
-
* @param {string}
|
|
178
|
-
* @param {function}
|
|
179
|
-
* @param {AddEventListenerOptions|
|
|
192
|
+
* @param {string} events
|
|
193
|
+
* @param {string|Element|function} selector
|
|
194
|
+
* @param {function|AddEventListenerOptions|boolean} [handler]
|
|
195
|
+
* @param {AddEventListenerOptions|boolean} [options]
|
|
180
196
|
* @returns {Element}
|
|
181
197
|
*/
|
|
182
|
-
function on(el: Element | Document | Window,
|
|
198
|
+
function on(el: Element | Document | Window, events: string, selector: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
|
|
183
199
|
/**
|
|
184
200
|
* @param {Element|Document|Window} el
|
|
185
|
-
* @param {string}
|
|
186
|
-
* @param {function}
|
|
187
|
-
* @param {
|
|
201
|
+
* @param {string} events
|
|
202
|
+
* @param {string|Element|function} selector
|
|
203
|
+
* @param {function|AddEventListenerOptions|boolean} [handler]
|
|
204
|
+
* @param {AddEventListenerOptions|boolean} [options]
|
|
188
205
|
* @returns {Element}
|
|
189
206
|
*/
|
|
190
|
-
function off(el: Element | Document | Window,
|
|
207
|
+
function off(el: Element | Document | Window, events: string, selector: string | Element | Function, handler?: Function | AddEventListenerOptions | boolean, options?: AddEventListenerOptions | boolean): Element;
|
|
191
208
|
/**
|
|
192
209
|
* @param {HTMLElement} el
|
|
193
210
|
* @param {Object<string, string>|string} style
|
|
@@ -212,10 +229,10 @@ declare namespace _default {
|
|
|
212
229
|
*/
|
|
213
230
|
function closestFindOne(el: Element, selectorClosest: string, selectorFindOne: string): Element | null;
|
|
214
231
|
/**
|
|
215
|
-
* @param {NodeList} nodeList
|
|
232
|
+
* @param {NodeList|Element|Array<Element>} nodeList
|
|
216
233
|
* @returns {Element|null}
|
|
217
234
|
*/
|
|
218
|
-
function first(nodeList: NodeList): Element | null;
|
|
235
|
+
function first(nodeList: NodeList | Element | Array<Element>): Element | null;
|
|
219
236
|
/**
|
|
220
237
|
* @param {NodeList|Array<Element>} nodeList
|
|
221
238
|
* @returns {Element|null}
|
|
@@ -227,23 +244,23 @@ declare namespace _default {
|
|
|
227
244
|
*/
|
|
228
245
|
function create(html: string): Element | null;
|
|
229
246
|
/**
|
|
230
|
-
* @param {NodeList} nodeList
|
|
247
|
+
* @param {NodeList|Array<Element>} nodeList
|
|
231
248
|
* @param {number} [index=0]
|
|
232
249
|
* @returns {Element|null}
|
|
233
250
|
*/
|
|
234
|
-
function eq(nodeList: NodeList
|
|
251
|
+
function eq(nodeList: NodeList | Array<Element>, index?: number): Element | null;
|
|
235
252
|
/**
|
|
236
253
|
* @param {Element} el
|
|
237
|
-
* @param {Element} newEl
|
|
238
|
-
* @returns {Element}
|
|
254
|
+
* @param {Element|string} newEl
|
|
255
|
+
* @returns {Element|null}
|
|
239
256
|
*/
|
|
240
|
-
function after(el: Element, newEl: Element): Element;
|
|
257
|
+
function after(el: Element, newEl: Element | string): Element | null;
|
|
241
258
|
/**
|
|
242
259
|
* @param {Element} el
|
|
243
|
-
* @param {Element} newEl
|
|
244
|
-
* @returns {Element}
|
|
260
|
+
* @param {Element|string} newEl
|
|
261
|
+
* @returns {Element|null}
|
|
245
262
|
*/
|
|
246
|
-
function before(el: Element, newEl: Element): Element;
|
|
263
|
+
function before(el: Element, newEl: Element | string): Element | null;
|
|
247
264
|
/**
|
|
248
265
|
* @param {Element} el
|
|
249
266
|
* @returns {Element}
|
|
@@ -255,5 +272,36 @@ declare namespace _default {
|
|
|
255
272
|
* @return {Element[]}
|
|
256
273
|
*/
|
|
257
274
|
function not(el: Element | NodeList, selector: string | Element): Element[];
|
|
275
|
+
/**
|
|
276
|
+
* @param {Element} elem1
|
|
277
|
+
* @param {Element} elem2
|
|
278
|
+
* @returns {boolean}
|
|
279
|
+
*/
|
|
280
|
+
function collide(elem1: Element, elem2: Element): boolean;
|
|
281
|
+
/**
|
|
282
|
+
* @param {Element} el
|
|
283
|
+
* @param {string|Element} selector
|
|
284
|
+
*/
|
|
285
|
+
function matches(el: Element, selector: string | Element): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* @param {Element} el
|
|
288
|
+
* @param {Element} child
|
|
289
|
+
* @param {Element} oldChild
|
|
290
|
+
*/
|
|
291
|
+
function replaceChild(el: Element, child: Element, oldChild: Element): Element;
|
|
292
|
+
/**
|
|
293
|
+
* @param {Element} el
|
|
294
|
+
* @param {Element[]} children
|
|
295
|
+
* @returns {Element}
|
|
296
|
+
*/
|
|
297
|
+
function replaceChildren(el: Element, ...children: Element[]): Element;
|
|
298
|
+
/**
|
|
299
|
+
* @param {Element|Document|Window} el
|
|
300
|
+
* @returns {{top: number, left: number}}
|
|
301
|
+
*/
|
|
302
|
+
function offset(el: Element | Document | Window): {
|
|
303
|
+
top: number;
|
|
304
|
+
left: number;
|
|
305
|
+
};
|
|
258
306
|
}
|
|
259
307
|
export default _default;
|
package/types/index.d.ts
CHANGED
|
@@ -33,12 +33,14 @@ declare const webf: {
|
|
|
33
33
|
child(el: Element, selector?: string): Element | null;
|
|
34
34
|
findOne(refEl: Element | Document, selector?: string | Element | NodeList | Array<Element>): Element | null;
|
|
35
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[];
|
|
36
38
|
addClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
|
|
37
39
|
removeClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
|
|
38
40
|
toggleClass(el: Element, classNames: string, force?: boolean): Element;
|
|
39
41
|
hasClass(el: Element, classNames: string): boolean;
|
|
40
|
-
append(node: Node, ...children: Node[]): Node;
|
|
41
|
-
prepend(node: Node, ...children: Node[]): Node;
|
|
42
|
+
append(node: Node, ...children: (Node | string)[]): Node;
|
|
43
|
+
prepend(node: Node, ...children: (Node | string)[]): Node;
|
|
42
44
|
remove(...els: Element | NodeList | Array<Element> | string): void;
|
|
43
45
|
closest(el: Element, selector: string | Element): Element | null;
|
|
44
46
|
next(el: Element, selector?: string): Element | null;
|
|
@@ -59,28 +61,61 @@ declare const webf: {
|
|
|
59
61
|
[x: string]: string;
|
|
60
62
|
} | string, value?: string): Element | DOMStringMap;
|
|
61
63
|
removeData(el: Element, name: string): Element | any;
|
|
62
|
-
on(el: Element | Document | Window,
|
|
63
|
-
off(el: Element | Document | Window,
|
|
64
|
+
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;
|
|
64
66
|
css(el: HTMLElement, style: {
|
|
65
67
|
[x: string]: string;
|
|
66
68
|
} | string, value?: string): Element;
|
|
67
69
|
closestFind(el: Element, selectorClosest: string, selectorFind: string): NodeList | null;
|
|
68
70
|
closestFindOne(el: Element, selectorClosest: string, selectorFindOne: string): Element | null;
|
|
69
|
-
first(nodeList: NodeList): Element | null;
|
|
71
|
+
first(nodeList: NodeList | Element | Array<Element>): Element | null;
|
|
70
72
|
last(nodeList: NodeList | Array<Element>): Element | null;
|
|
71
73
|
create(html: string): Element | null;
|
|
72
|
-
eq(nodeList: NodeList
|
|
73
|
-
after(el: Element, newEl: Element): Element;
|
|
74
|
-
before(el: Element, newEl: Element): Element;
|
|
74
|
+
eq(nodeList: NodeList | Array<Element>, index?: number): Element | null;
|
|
75
|
+
after(el: Element, newEl: Element | string): Element | null;
|
|
76
|
+
before(el: Element, newEl: Element | string): Element | null;
|
|
75
77
|
empty(el: Element): Element;
|
|
76
78
|
not(el: Element | NodeList, selector: string | Element): Element[];
|
|
79
|
+
collide(elem1: Element, elem2: Element): boolean;
|
|
80
|
+
matches(el: Element, selector: string | Element): boolean;
|
|
81
|
+
replaceChild(el: Element, child: Element, oldChild: Element): Element;
|
|
82
|
+
replaceChildren(el: Element, ...children: Element[]): Element;
|
|
83
|
+
offset(el: Element | Document | Window): {
|
|
84
|
+
top: number;
|
|
85
|
+
left: number;
|
|
86
|
+
};
|
|
77
87
|
};
|
|
78
88
|
isWindow: (o: any) => boolean;
|
|
89
|
+
isDocument: (o: any) => boolean;
|
|
79
90
|
isDomElement: (o: any) => boolean;
|
|
80
|
-
getStyle: (
|
|
91
|
+
getStyle: (el: Element, cssRule: string) => string;
|
|
92
|
+
randAlpha: (n: any) => string;
|
|
93
|
+
randAlphaCs: (n: any) => string;
|
|
94
|
+
randAlphaNum: (n: any) => string;
|
|
95
|
+
randAlphaNumCs: (n: any) => string;
|
|
96
|
+
randNum: (n: any) => string;
|
|
97
|
+
rand: (range: any, n: any) => string;
|
|
98
|
+
uniqid: (prefix?: string) => string;
|
|
99
|
+
isString: (str: any) => boolean;
|
|
100
|
+
isObject: (o: any) => boolean;
|
|
101
|
+
isFunction: (f: any) => boolean;
|
|
102
|
+
isPlainObject: (o: any) => boolean;
|
|
103
|
+
isBoolean: (b: any) => boolean;
|
|
104
|
+
isBool: (b: any) => boolean;
|
|
105
|
+
isUndefined: (v: any) => v is undefined;
|
|
106
|
+
isArrayLike: (o: any) => boolean;
|
|
107
|
+
isArray: (a: any) => a is any[];
|
|
108
|
+
isDate: (o: any) => boolean;
|
|
109
|
+
isEvent: (o: any) => boolean;
|
|
110
|
+
isInteger: (n: any) => boolean;
|
|
111
|
+
isInt: (n: any) => boolean;
|
|
112
|
+
isFloat: (n: any) => boolean;
|
|
113
|
+
isScalar: (value: any) => boolean;
|
|
114
|
+
isEventSupported: (eventName: any) => boolean;
|
|
115
|
+
isTouchDevice: () => boolean;
|
|
81
116
|
each: <T>(o: Collection<T>, callback: (key: number | string, value: T, o: Collection<T>, index: number) => (void | boolean), context?: any) => typeof o;
|
|
82
117
|
foreach: <T>(o: Collection<T>, callback: (value: T, key: number | string, o: Collection<T>, index: number) => (void | boolean), context?: any) => typeof o;
|
|
83
|
-
map: <T, R>(o: Collection<T>, callback: (key: number | string, value: T, o: Collection<T>, index: number) => (R | null | false), context?: any) =>
|
|
118
|
+
map: <T, R>(o: Collection<T>, callback: (key: number | string, value: T, o: Collection<T>, index: number) => (R | null | false), context?: any) => Array<R>;
|
|
84
119
|
reduce: <T, R>(o: Collection<T>, callback: (accumulator: R | T, value: T, key: any, index: number, o: Collection<T>) => R, initialValue?: R) => R;
|
|
85
120
|
extend: <T>(...args: (boolean | T)[]) => T;
|
|
86
121
|
clone: <T>(o: T) => T;
|
|
@@ -123,7 +158,7 @@ declare const webf: {
|
|
|
123
158
|
stripTags: (str: any, tag: any) => any;
|
|
124
159
|
toUrl: (str: any) => any;
|
|
125
160
|
escapeRegex: (str: any) => any;
|
|
126
|
-
camelCase: (str: any) =>
|
|
161
|
+
camelCase: (str: any) => string;
|
|
127
162
|
format: (str: any, ...args: any[]) => any;
|
|
128
163
|
f: (str: any, ...args: any[]) => any;
|
|
129
164
|
toCssClassName: (str: any) => any;
|
|
@@ -134,9 +169,11 @@ declare const webf: {
|
|
|
134
169
|
import * as stringFunctions from './string.js';
|
|
135
170
|
import * as arrayFunctions from './array.js';
|
|
136
171
|
import * as traversal from './traversal.js';
|
|
172
|
+
import * as is from './is.js';
|
|
173
|
+
import * as random from './random.js';
|
|
137
174
|
import { getStyle } from './dom.js';
|
|
138
175
|
import dom from './dom.js';
|
|
139
176
|
import * as math from './math.js';
|
|
140
177
|
import * as utils from './utils.js';
|
|
141
178
|
import eventDispatcher from './eventDispatcher.js';
|
|
142
|
-
export { stringFunctions, arrayFunctions, traversal, getStyle, dom, math, utils, eventDispatcher };
|
|
179
|
+
export { stringFunctions, arrayFunctions, traversal, is, random, getStyle, dom, math, utils, eventDispatcher };
|
package/types/random.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function uniqid(): string;
|
|
2
1
|
export function randAlpha(n: any): string;
|
|
3
2
|
export function randAlphaCs(n: any): string;
|
|
4
3
|
export function randAlphaNum(n: any): string;
|
|
5
4
|
export function randAlphaNumCs(n: any): string;
|
|
6
5
|
export function randNum(n: any): string;
|
|
7
6
|
export function rand(range: any, n: any): string;
|
|
7
|
+
export function uniqid(prefix?: string): string;
|
package/types/string.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function repeat(str: any, n: any): string;
|
|
|
28
28
|
export function stripTags(str: any, tag: any): any;
|
|
29
29
|
export function toUrl(str: any): any;
|
|
30
30
|
export function escapeRegex(str: any): any;
|
|
31
|
-
export function camelCase(str: any):
|
|
31
|
+
export function camelCase(str: any): string;
|
|
32
32
|
export function format(str: any, ...args: any[]): any;
|
|
33
33
|
export function f(str: any, ...args: any[]): any;
|
|
34
34
|
export function toCssClassName(str: any): any;
|
package/types/traversal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function each<T>(o: Collection<T>, callback: (key: number | string, value: T, o: Collection<T>, index: number) => (void | boolean), context?: any): typeof o;
|
|
2
2
|
export function foreach<T>(o: Collection<T>, callback: (value: T, key: number | string, o: Collection<T>, index: number) => (void | boolean), context?: any): typeof o;
|
|
3
|
-
export function map<T, R>(o: Collection<T>, callback: (key: number | string, value: T, o: Collection<T>, index: number) => (R | null | false), context?: any):
|
|
3
|
+
export function map<T, R>(o: Collection<T>, callback: (key: number | string, value: T, o: Collection<T>, index: number) => (R | null | false), context?: any): Array<R>;
|
|
4
4
|
export function reduce<T, R>(o: Collection<T>, callback: (accumulator: R | T, value: T, key: any, index: number, o: Collection<T>) => R, initialValue?: R): R;
|
|
5
5
|
export function extend<T>(...args: (boolean | T)[]): T;
|
|
6
6
|
export function clone<T>(o: T): T;
|