tiny-essentials 1.21.7 → 1.21.9
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/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/libs/TinyDragger.cjs +1 -1
- package/dist/v1/libs/TinyDragger.d.mts +2 -2
- package/dist/v1/libs/TinyDragger.mjs +1 -1
- package/dist/v1/libs/TinyGamepad.d.mts +1 -1
- package/dist/v1/libs/TinyHtml.cjs +236 -171
- package/dist/v1/libs/TinyHtml.d.mts +364 -339
- package/dist/v1/libs/TinyHtml.mjs +235 -171
- package/dist/v1/libs/TinyInventory.d.mts +1 -1
- package/dist/v1/libs/TinyTextRangeEditor.cjs +18 -18
- package/dist/v1/libs/TinyTextRangeEditor.d.mts +36 -36
- package/dist/v1/libs/TinyTextRangeEditor.mjs +18 -18
- package/dist/v1/libs/UltraRandomMsgGen.cjs +103 -31
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +74 -44
- package/dist/v1/libs/UltraRandomMsgGen.mjs +98 -31
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as TinyCollision from '../basics/collision.mjs';
|
|
2
2
|
const { areElsColliding, areElsPerfColliding, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, } = TinyCollision;
|
|
3
|
+
/**
|
|
4
|
+
* Represents a TinyHtml instance with any constructor element values.
|
|
5
|
+
* @typedef {TinyHtml<ConstructorElValues>} TinyHtmlAny
|
|
6
|
+
*/
|
|
3
7
|
/**
|
|
4
8
|
* Callback invoked on each animation frame with the current scroll position,
|
|
5
9
|
* normalized animation time (`0` to `1`), and a completion flag.
|
|
@@ -16,42 +20,42 @@ const { areElsColliding, areElsPerfColliding, areElsCollTop, areElsCollBottom, a
|
|
|
16
20
|
* This type is used to abstract interactions with both plain elements
|
|
17
21
|
* and wrapped elements via the TinyHtml class.
|
|
18
22
|
*
|
|
19
|
-
* @typedef {Node|
|
|
23
|
+
* @typedef {Node|TinyHtmlAny|null} TinyNode
|
|
20
24
|
*/
|
|
21
25
|
/**
|
|
22
26
|
* Represents a raw DOM element or an instance of TinyHtml.
|
|
23
27
|
* This type is used to abstract interactions with both plain elements
|
|
24
28
|
* and wrapped elements via the TinyHtml class.
|
|
25
29
|
*
|
|
26
|
-
* @typedef {Element|
|
|
30
|
+
* @typedef {Element|TinyHtmlAny} TinyElement
|
|
27
31
|
*/
|
|
28
32
|
/**
|
|
29
33
|
* Represents a raw DOM html element or an instance of TinyHtml.
|
|
30
34
|
* This type is used to abstract interactions with both plain elements
|
|
31
35
|
* and wrapped elements via the TinyHtml class.
|
|
32
36
|
*
|
|
33
|
-
* @typedef {HTMLElement|
|
|
37
|
+
* @typedef {HTMLElement|TinyHtmlAny} TinyHtmlElement
|
|
34
38
|
*/
|
|
35
39
|
/**
|
|
36
40
|
* Represents a raw DOM event target element or an instance of TinyHtml.
|
|
37
41
|
* This type is used to abstract interactions with both plain elements
|
|
38
42
|
* and wrapped elements via the TinyHtml class.
|
|
39
43
|
*
|
|
40
|
-
* @typedef {EventTarget|
|
|
44
|
+
* @typedef {EventTarget|TinyHtmlAny} TinyEventTarget
|
|
41
45
|
*/
|
|
42
46
|
/**
|
|
43
47
|
* Represents a raw DOM input element or an instance of TinyHtml.
|
|
44
48
|
* This type is used to abstract interactions with both plain elements
|
|
45
49
|
* and wrapped elements via the TinyHtml class.
|
|
46
50
|
*
|
|
47
|
-
* @typedef {InputElement|
|
|
51
|
+
* @typedef {InputElement|TinyHtmlAny} TinyInputElement
|
|
48
52
|
*/
|
|
49
53
|
/**
|
|
50
54
|
* Represents a raw DOM element/window or an instance of TinyHtml.
|
|
51
55
|
* This type is used to abstract interactions with both plain elements
|
|
52
56
|
* and wrapped elements via the TinyHtml class.
|
|
53
57
|
*
|
|
54
|
-
* @typedef {ElementAndWindow|
|
|
58
|
+
* @typedef {ElementAndWindow|TinyHtmlAny} TinyElementAndWindow
|
|
55
59
|
*/
|
|
56
60
|
/**
|
|
57
61
|
* Represents a value that can be either a DOM Element or the global Window object.
|
|
@@ -64,7 +68,7 @@ const { areElsColliding, areElsPerfColliding, areElsCollTop, areElsCollBottom, a
|
|
|
64
68
|
* This type is used to abstract interactions with both plain elements
|
|
65
69
|
* and wrapped elements via the TinyHtml class.
|
|
66
70
|
*
|
|
67
|
-
* @typedef {ElementAndWinAndDoc|
|
|
71
|
+
* @typedef {ElementAndWinAndDoc|TinyHtmlAny} TinyElementAndWinAndDoc
|
|
68
72
|
*/
|
|
69
73
|
/**
|
|
70
74
|
* Represents a value that can be either a DOM Element, or the global Window object, or the document object.
|
|
@@ -77,7 +81,7 @@ const { areElsColliding, areElsPerfColliding, areElsCollTop, areElsCollBottom, a
|
|
|
77
81
|
* This type is used to abstract interactions with both plain elements
|
|
78
82
|
* and wrapped elements via the TinyHtml class.
|
|
79
83
|
*
|
|
80
|
-
* @typedef {ElementWithDoc|
|
|
84
|
+
* @typedef {ElementWithDoc|TinyHtmlAny} TinyElementWithDoc
|
|
81
85
|
*/
|
|
82
86
|
/**
|
|
83
87
|
* Represents a value that can be either a DOM Element, or the document object.
|
|
@@ -203,6 +207,7 @@ const __elemCollision = {
|
|
|
203
207
|
* Inspired by the jQuery project's open source implementations of element dimension
|
|
204
208
|
* and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
|
|
205
209
|
*
|
|
210
|
+
* @template {ConstructorElValues|ConstructorElValues[]|NodeListOf<Element>|HTMLCollectionOf<Element>|NodeListOf<HTMLElement>} TinyHtmlT
|
|
206
211
|
* @class
|
|
207
212
|
*/
|
|
208
213
|
class TinyHtml {
|
|
@@ -243,7 +248,7 @@ class TinyHtml {
|
|
|
243
248
|
*
|
|
244
249
|
* @param {string} url - The URL of the HTML file.
|
|
245
250
|
* @param {RequestInit} [ops] - Optional fetch configuration (e.g., method, headers, cache, etc).
|
|
246
|
-
* @returns {Promise<TinyHtml[]>} A promise that resolves with the TinyHtml instances.
|
|
251
|
+
* @returns {Promise<TinyHtml<TinyElement|Text>[]>} A promise that resolves with the TinyHtml instances.
|
|
247
252
|
*/
|
|
248
253
|
static async fetchHtmlTinyElems(url, ops) {
|
|
249
254
|
const nodes = await TinyHtml.fetchHtmlNodes(url, ops);
|
|
@@ -281,7 +286,7 @@ class TinyHtml {
|
|
|
281
286
|
* Converts the content of a <template> to an array of TinyHtml elements.
|
|
282
287
|
*
|
|
283
288
|
* @param {HTMLTemplateElement} nodes
|
|
284
|
-
* @returns {TinyHtml[]}
|
|
289
|
+
* @returns {TinyHtml<Element|Text>[]}
|
|
285
290
|
*/
|
|
286
291
|
static templateToTinyElems(nodes) {
|
|
287
292
|
return TinyHtml.toTinyElm(TinyHtml.templateToNodes(nodes));
|
|
@@ -362,7 +367,7 @@ class TinyHtml {
|
|
|
362
367
|
* Converts a JSON-like HTML structure back to TinyHtml instances.
|
|
363
368
|
*
|
|
364
369
|
* @param {HtmlParsed[]} jsonArray - Parsed JSON format of HTML.
|
|
365
|
-
* @returns {TinyHtml[]} List of TinyHtml instances.
|
|
370
|
+
* @returns {TinyHtml<HTMLElement | Text>[]} List of TinyHtml instances.
|
|
366
371
|
*/
|
|
367
372
|
static jsonToTinyElems(jsonArray) {
|
|
368
373
|
return TinyHtml.toTinyElm(TinyHtml.jsonToNodes(jsonArray));
|
|
@@ -379,7 +384,7 @@ class TinyHtml {
|
|
|
379
384
|
* @param {string} tagName - The HTML tag name (e.g., 'div', 'span', 'button').
|
|
380
385
|
* @param {Record<string, string|null>} [attrs] - Optional key-value pairs representing HTML attributes.
|
|
381
386
|
* If the value is `null`, the attribute will still be set with an empty value.
|
|
382
|
-
* @returns {TinyHtml} - A new instance of TinyHtml representing the created element.
|
|
387
|
+
* @returns {TinyHtml<HTMLElement>} - A new instance of TinyHtml representing the created element.
|
|
383
388
|
* @throws {TypeError} - If `tagName` is not a string, or `attrs` is not a plain object when defined.
|
|
384
389
|
*/
|
|
385
390
|
static createFrom(tagName, attrs) {
|
|
@@ -400,7 +405,7 @@ class TinyHtml {
|
|
|
400
405
|
*
|
|
401
406
|
* @param {string} tagName - The tag name of the element to create (e.g., 'div', 'span').
|
|
402
407
|
* @param {ElementCreationOptions} [ops] - Optional settings for creating the element.
|
|
403
|
-
* @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM element.
|
|
408
|
+
* @returns {TinyHtml<HTMLElement>} A TinyHtml instance wrapping the newly created DOM element.
|
|
404
409
|
* @throws {TypeError} If tagName is not a string or ops is not an object.
|
|
405
410
|
*/
|
|
406
411
|
static createElement(tagName, ops) {
|
|
@@ -418,7 +423,7 @@ class TinyHtml {
|
|
|
418
423
|
* other TinyHtml element and can be appended or manipulated as needed.
|
|
419
424
|
*
|
|
420
425
|
* @param {string} value - The plain text content to be wrapped in a TextNode.
|
|
421
|
-
* @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM TextNode.
|
|
426
|
+
* @returns {TinyHtml<Text>} A TinyHtml instance wrapping the newly created DOM TextNode.
|
|
422
427
|
* @throws {TypeError} If the provided value is not a string.
|
|
423
428
|
*/
|
|
424
429
|
static createTextNode(value) {
|
|
@@ -431,7 +436,7 @@ class TinyHtml {
|
|
|
431
436
|
* Supports both elements and plain text.
|
|
432
437
|
*
|
|
433
438
|
* @param {string} htmlString - The HTML string to convert.
|
|
434
|
-
* @returns {TinyHtml} - A single HTMLElement or TextNode.
|
|
439
|
+
* @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
|
|
435
440
|
*/
|
|
436
441
|
static createElementFromHTML(htmlString) {
|
|
437
442
|
const template = document.createElement('template');
|
|
@@ -450,7 +455,7 @@ class TinyHtml {
|
|
|
450
455
|
*
|
|
451
456
|
* @param {string} selector - A valid CSS selector string.
|
|
452
457
|
* @param {Document|Element} elem - Target element.
|
|
453
|
-
* @returns {TinyHtml
|
|
458
|
+
* @returns {TinyHtml<Element>|null} A TinyHtml instance wrapping the matched element.
|
|
454
459
|
*/
|
|
455
460
|
static query(selector, elem = document) {
|
|
456
461
|
const newEl = elem.querySelector(selector);
|
|
@@ -462,7 +467,7 @@ class TinyHtml {
|
|
|
462
467
|
* Queries the element for the first element matching the CSS selector and wraps it in a TinyHtml instance.
|
|
463
468
|
*
|
|
464
469
|
* @param {string} selector - A valid CSS selector string.
|
|
465
|
-
* @returns {TinyHtml
|
|
470
|
+
* @returns {TinyHtml<Element>|null} A TinyHtml instance wrapping the matched element.
|
|
466
471
|
*/
|
|
467
472
|
querySelector(selector) {
|
|
468
473
|
return TinyHtml.query(selector, TinyHtml._preElem(this, 'query'));
|
|
@@ -472,7 +477,7 @@ class TinyHtml {
|
|
|
472
477
|
*
|
|
473
478
|
* @param {string} selector - A valid CSS selector string.
|
|
474
479
|
* @param {Document|Element} elem - Target element.
|
|
475
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
|
|
480
|
+
* @returns {TinyHtml<NodeListOf<Element>>} An array of TinyHtml instances wrapping the matched elements.
|
|
476
481
|
*/
|
|
477
482
|
static queryAll(selector, elem = document) {
|
|
478
483
|
return new TinyHtml(elem.querySelectorAll(selector));
|
|
@@ -481,7 +486,7 @@ class TinyHtml {
|
|
|
481
486
|
* Queries the element for all elements matching the CSS selector and wraps them in TinyHtml instances.
|
|
482
487
|
*
|
|
483
488
|
* @param {string} selector - A valid CSS selector string.
|
|
484
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
|
|
489
|
+
* @returns {TinyHtml<NodeListOf<Element>>} An array of TinyHtml instances wrapping the matched elements.
|
|
485
490
|
*/
|
|
486
491
|
querySelectorAll(selector) {
|
|
487
492
|
return TinyHtml.queryAll(selector, TinyHtml._preElem(this, 'queryAll'));
|
|
@@ -490,7 +495,7 @@ class TinyHtml {
|
|
|
490
495
|
* Retrieves an element by its ID and wraps it in a TinyHtml instance.
|
|
491
496
|
*
|
|
492
497
|
* @param {string} selector - The ID of the element to retrieve.
|
|
493
|
-
* @returns {TinyHtml
|
|
498
|
+
* @returns {TinyHtml<HTMLElement>|null} A TinyHtml instance wrapping the found element.
|
|
494
499
|
*/
|
|
495
500
|
static getById(selector) {
|
|
496
501
|
const newEl = document.getElementById(selector);
|
|
@@ -503,7 +508,7 @@ class TinyHtml {
|
|
|
503
508
|
*
|
|
504
509
|
* @param {string} selector - The class name to search for.
|
|
505
510
|
* @param {Document|Element} elem - Target element.
|
|
506
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
511
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
507
512
|
*/
|
|
508
513
|
static getByClassName(selector, elem = document) {
|
|
509
514
|
return new TinyHtml(elem.getElementsByClassName(selector));
|
|
@@ -512,7 +517,7 @@ class TinyHtml {
|
|
|
512
517
|
* Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
|
|
513
518
|
*
|
|
514
519
|
* @param {string} selector - The class name to search for.
|
|
515
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
520
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
516
521
|
*/
|
|
517
522
|
getElementsByClassName(selector) {
|
|
518
523
|
return TinyHtml.getByClassName(selector, TinyHtml._preElem(this, 'getByClassName'));
|
|
@@ -521,7 +526,7 @@ class TinyHtml {
|
|
|
521
526
|
* Retrieves all elements with the specified name attribute and wraps them in TinyHtml instances.
|
|
522
527
|
*
|
|
523
528
|
* @param {string} selector - The name attribute to search for.
|
|
524
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
529
|
+
* @returns {TinyHtml<NodeListOf<HTMLElement>>} An array of TinyHtml instances wrapping the found elements.
|
|
525
530
|
*/
|
|
526
531
|
static getByName(selector) {
|
|
527
532
|
return new TinyHtml(document.getElementsByName(selector));
|
|
@@ -533,7 +538,7 @@ class TinyHtml {
|
|
|
533
538
|
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
534
539
|
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
535
540
|
* @param {Document|Element} elem - Target element.
|
|
536
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
541
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
537
542
|
*/
|
|
538
543
|
static getByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml', elem = document) {
|
|
539
544
|
return new TinyHtml(elem.getElementsByTagNameNS(namespaceURI, localName));
|
|
@@ -544,7 +549,7 @@ class TinyHtml {
|
|
|
544
549
|
*
|
|
545
550
|
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
546
551
|
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
547
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
552
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
548
553
|
*/
|
|
549
554
|
getElementsByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
550
555
|
return TinyHtml.getByTagNameNS(localName, namespaceURI, TinyHtml._preElem(this, 'getByTagNameNS'));
|
|
@@ -552,8 +557,8 @@ class TinyHtml {
|
|
|
552
557
|
//////////////////////////////////////////////////////////////////
|
|
553
558
|
/**
|
|
554
559
|
* Iterates over all elements, executing the provided callback on each.
|
|
555
|
-
* @param {(element:
|
|
556
|
-
* @returns {
|
|
560
|
+
* @param {(element: TinyHtmlAny, index: number, items: TinyHtmlAny[]) => void} callback - Function invoked for each element.
|
|
561
|
+
* @returns {this} The current instance for chaining.
|
|
557
562
|
*/
|
|
558
563
|
forEach(callback) {
|
|
559
564
|
const elems = this.getAll().map((el, index) => this.extract(index));
|
|
@@ -578,7 +583,7 @@ class TinyHtml {
|
|
|
578
583
|
* Extracts a single DOM element from the internal list at the specified index.
|
|
579
584
|
*
|
|
580
585
|
* @param {number} index - The index of the element to extract.
|
|
581
|
-
* @returns {
|
|
586
|
+
* @returns {TinyHtmlAny} A new TinyHtml instance wrapping the extracted element.
|
|
582
587
|
*/
|
|
583
588
|
extract(index) {
|
|
584
589
|
if (typeof index !== 'number')
|
|
@@ -935,7 +940,7 @@ class TinyHtml {
|
|
|
935
940
|
* of the input form.
|
|
936
941
|
*
|
|
937
942
|
* @param {TinyElement|Text|(TinyElement|Text)[]} elems - A single element or an array of elements (DOM or TinyHtml).
|
|
938
|
-
* @returns {TinyHtml[]} An array of TinyHtml instances corresponding to the input elements.
|
|
943
|
+
* @returns {TinyHtml<TinyElement|Text>[]} An array of TinyHtml instances corresponding to the input elements.
|
|
939
944
|
*/
|
|
940
945
|
static toTinyElm(elems) {
|
|
941
946
|
/** @param {(TinyElement|Text)[]} item */
|
|
@@ -1246,11 +1251,12 @@ class TinyHtml {
|
|
|
1246
1251
|
/**
|
|
1247
1252
|
* Stores a value associated with a specific key for a DOM element.
|
|
1248
1253
|
*
|
|
1249
|
-
* @
|
|
1254
|
+
* @template {TinyElement} T
|
|
1255
|
+
* @param {T} el - The DOM element.
|
|
1250
1256
|
* @param {string} key - The key under which the data will be stored.
|
|
1251
1257
|
* @param {any} value - The value to store.
|
|
1252
1258
|
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
1253
|
-
* @returns {
|
|
1259
|
+
* @returns {T}
|
|
1254
1260
|
*/
|
|
1255
1261
|
static setData(el, key, value, isPrivate = false) {
|
|
1256
1262
|
const data = TinyHtml._dataSelector[!isPrivate ? 'public' : 'private']('setData', el);
|
|
@@ -1265,7 +1271,7 @@ class TinyHtml {
|
|
|
1265
1271
|
* @param {string} key - The key under which the data will be stored.
|
|
1266
1272
|
* @param {any} value - The value to store.
|
|
1267
1273
|
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
1268
|
-
* @returns {
|
|
1274
|
+
* @returns {this}
|
|
1269
1275
|
*/
|
|
1270
1276
|
setData(key, value, isPrivate = false) {
|
|
1271
1277
|
return TinyHtml.setData(this, key, value, isPrivate);
|
|
@@ -1583,9 +1589,10 @@ class TinyHtml {
|
|
|
1583
1589
|
/**
|
|
1584
1590
|
* Appends child elements or strings to the end of the target element(s).
|
|
1585
1591
|
*
|
|
1586
|
-
* @
|
|
1592
|
+
* @template {TinyElement} T
|
|
1593
|
+
* @param {T} el - The target element(s) to receive children.
|
|
1587
1594
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
1588
|
-
* @returns {
|
|
1595
|
+
* @returns {T}
|
|
1589
1596
|
*/
|
|
1590
1597
|
static append(el, ...children) {
|
|
1591
1598
|
const elem = TinyHtml._preElem(el, 'append');
|
|
@@ -1596,7 +1603,7 @@ class TinyHtml {
|
|
|
1596
1603
|
* Appends child elements or strings to the end of the target element(s).
|
|
1597
1604
|
*
|
|
1598
1605
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
1599
|
-
* @returns {
|
|
1606
|
+
* @returns {this}
|
|
1600
1607
|
*/
|
|
1601
1608
|
append(...children) {
|
|
1602
1609
|
return TinyHtml.append(this, ...children);
|
|
@@ -1604,9 +1611,10 @@ class TinyHtml {
|
|
|
1604
1611
|
/**
|
|
1605
1612
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1606
1613
|
*
|
|
1607
|
-
* @
|
|
1614
|
+
* @template {TinyElement} T
|
|
1615
|
+
* @param {T} el - The target element(s) to receive children.
|
|
1608
1616
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
1609
|
-
* @returns {
|
|
1617
|
+
* @returns {T}
|
|
1610
1618
|
*/
|
|
1611
1619
|
static prepend(el, ...children) {
|
|
1612
1620
|
const elem = TinyHtml._preElem(el, 'prepend');
|
|
@@ -1617,7 +1625,7 @@ class TinyHtml {
|
|
|
1617
1625
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1618
1626
|
*
|
|
1619
1627
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
1620
|
-
* @returns {
|
|
1628
|
+
* @returns {this}
|
|
1621
1629
|
*/
|
|
1622
1630
|
prepend(...children) {
|
|
1623
1631
|
return TinyHtml.prepend(this, ...children);
|
|
@@ -1625,9 +1633,10 @@ class TinyHtml {
|
|
|
1625
1633
|
/**
|
|
1626
1634
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1627
1635
|
*
|
|
1628
|
-
* @
|
|
1636
|
+
* @template {TinyElement} T
|
|
1637
|
+
* @param {T} el - The target element(s) before which new content is inserted.
|
|
1629
1638
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
1630
|
-
* @returns {
|
|
1639
|
+
* @returns {T}
|
|
1631
1640
|
*/
|
|
1632
1641
|
static before(el, ...children) {
|
|
1633
1642
|
const elem = TinyHtml._preElem(el, 'before');
|
|
@@ -1638,7 +1647,7 @@ class TinyHtml {
|
|
|
1638
1647
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1639
1648
|
*
|
|
1640
1649
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
1641
|
-
* @returns {
|
|
1650
|
+
* @returns {this}
|
|
1642
1651
|
*/
|
|
1643
1652
|
before(...children) {
|
|
1644
1653
|
return TinyHtml.before(this, ...children);
|
|
@@ -1646,9 +1655,10 @@ class TinyHtml {
|
|
|
1646
1655
|
/**
|
|
1647
1656
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1648
1657
|
*
|
|
1649
|
-
* @
|
|
1658
|
+
* @template {TinyElement} T
|
|
1659
|
+
* @param {T} el - The target element(s) after which new content is inserted.
|
|
1650
1660
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
1651
|
-
* @returns {
|
|
1661
|
+
* @returns {T}
|
|
1652
1662
|
*/
|
|
1653
1663
|
static after(el, ...children) {
|
|
1654
1664
|
const elem = TinyHtml._preElem(el, 'after');
|
|
@@ -1659,7 +1669,7 @@ class TinyHtml {
|
|
|
1659
1669
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1660
1670
|
*
|
|
1661
1671
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
1662
|
-
* @returns {
|
|
1672
|
+
* @returns {this}
|
|
1663
1673
|
*/
|
|
1664
1674
|
after(...children) {
|
|
1665
1675
|
return TinyHtml.after(this, ...children);
|
|
@@ -1667,9 +1677,10 @@ class TinyHtml {
|
|
|
1667
1677
|
/**
|
|
1668
1678
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1669
1679
|
*
|
|
1670
|
-
* @
|
|
1680
|
+
* @template {TinyElement} T
|
|
1681
|
+
* @param {T} el - The element(s) to be replaced.
|
|
1671
1682
|
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
1672
|
-
* @returns {
|
|
1683
|
+
* @returns {T}
|
|
1673
1684
|
*/
|
|
1674
1685
|
static replaceWith(el, ...newNodes) {
|
|
1675
1686
|
const elem = TinyHtml._preElem(el, 'replaceWith');
|
|
@@ -1680,7 +1691,7 @@ class TinyHtml {
|
|
|
1680
1691
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1681
1692
|
*
|
|
1682
1693
|
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
1683
|
-
* @returns {
|
|
1694
|
+
* @returns {this}
|
|
1684
1695
|
*/
|
|
1685
1696
|
replaceWith(...newNodes) {
|
|
1686
1697
|
return TinyHtml.replaceWith(this, ...newNodes);
|
|
@@ -1688,9 +1699,10 @@ class TinyHtml {
|
|
|
1688
1699
|
/**
|
|
1689
1700
|
* Appends the given element(s) to each target element in sequence.
|
|
1690
1701
|
*
|
|
1691
|
-
* @
|
|
1702
|
+
* @template {TinyNode | TinyNode[]} T
|
|
1703
|
+
* @param {T} el - The element(s) to append.
|
|
1692
1704
|
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
1693
|
-
* @returns {
|
|
1705
|
+
* @returns {T}
|
|
1694
1706
|
*/
|
|
1695
1707
|
static appendTo(el, targets) {
|
|
1696
1708
|
const elems = TinyHtml._preNodeElems(el, 'appendTo');
|
|
@@ -1704,7 +1716,7 @@ class TinyHtml {
|
|
|
1704
1716
|
* Appends the given element(s) to each target element in sequence.
|
|
1705
1717
|
*
|
|
1706
1718
|
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
1707
|
-
* @returns {
|
|
1719
|
+
* @returns {this}
|
|
1708
1720
|
*/
|
|
1709
1721
|
appendTo(targets) {
|
|
1710
1722
|
return TinyHtml.appendTo(this, targets);
|
|
@@ -1712,9 +1724,10 @@ class TinyHtml {
|
|
|
1712
1724
|
/**
|
|
1713
1725
|
* Prepends the given element(s) to each target element in sequence.
|
|
1714
1726
|
*
|
|
1715
|
-
* @
|
|
1727
|
+
* @template {TinyElement | TinyElement[]} T
|
|
1728
|
+
* @param {T} el - The element(s) to prepend.
|
|
1716
1729
|
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
1717
|
-
* @returns {
|
|
1730
|
+
* @returns {T}
|
|
1718
1731
|
*/
|
|
1719
1732
|
static prependTo(el, targets) {
|
|
1720
1733
|
const elems = TinyHtml._preElems(el, 'prependTo');
|
|
@@ -1731,7 +1744,7 @@ class TinyHtml {
|
|
|
1731
1744
|
* Prepends the given element(s) to each target element in sequence.
|
|
1732
1745
|
*
|
|
1733
1746
|
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
1734
|
-
* @returns {
|
|
1747
|
+
* @returns {this}
|
|
1735
1748
|
*/
|
|
1736
1749
|
prependTo(targets) {
|
|
1737
1750
|
return TinyHtml.prependTo(this, targets);
|
|
@@ -1739,10 +1752,11 @@ class TinyHtml {
|
|
|
1739
1752
|
/**
|
|
1740
1753
|
* Inserts the element before a child of a given target, or before the target itself.
|
|
1741
1754
|
*
|
|
1742
|
-
* @
|
|
1755
|
+
* @template {TinyNode | TinyNode[]} T
|
|
1756
|
+
* @param {T} el - The element(s) to insert.
|
|
1743
1757
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1744
1758
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
1745
|
-
* @returns {
|
|
1759
|
+
* @returns {T}
|
|
1746
1760
|
*/
|
|
1747
1761
|
static insertBefore(el, target, child = null) {
|
|
1748
1762
|
const elem = TinyHtml._preNodeElem(el, 'insertBefore');
|
|
@@ -1758,7 +1772,7 @@ class TinyHtml {
|
|
|
1758
1772
|
*
|
|
1759
1773
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1760
1774
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
1761
|
-
* @returns {
|
|
1775
|
+
* @returns {this}
|
|
1762
1776
|
*/
|
|
1763
1777
|
insertBefore(target, child) {
|
|
1764
1778
|
return TinyHtml.insertBefore(this, target, child);
|
|
@@ -1766,10 +1780,11 @@ class TinyHtml {
|
|
|
1766
1780
|
/**
|
|
1767
1781
|
* Inserts the element after a child of a given target, or after the target itself.
|
|
1768
1782
|
*
|
|
1769
|
-
* @
|
|
1783
|
+
* @template {TinyNode | TinyNode[]} T
|
|
1784
|
+
* @param {T} el - The element(s) to insert.
|
|
1770
1785
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1771
1786
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
1772
|
-
* @returns {
|
|
1787
|
+
* @returns {T}
|
|
1773
1788
|
*/
|
|
1774
1789
|
static insertAfter(el, target, child = null) {
|
|
1775
1790
|
const elem = TinyHtml._preNodeElem(el, 'insertAfter');
|
|
@@ -1785,7 +1800,7 @@ class TinyHtml {
|
|
|
1785
1800
|
*
|
|
1786
1801
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1787
1802
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
1788
|
-
* @returns {
|
|
1803
|
+
* @returns {this}
|
|
1789
1804
|
*/
|
|
1790
1805
|
insertAfter(target, child) {
|
|
1791
1806
|
return TinyHtml.insertAfter(this, target, child);
|
|
@@ -1794,9 +1809,10 @@ class TinyHtml {
|
|
|
1794
1809
|
* Replaces all target elements with the provided element(s).
|
|
1795
1810
|
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
1796
1811
|
*
|
|
1797
|
-
* @
|
|
1812
|
+
* @template {TinyNode | TinyNode[]} T
|
|
1813
|
+
* @param {T} el - The new element(s) to insert.
|
|
1798
1814
|
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
1799
|
-
* @returns {
|
|
1815
|
+
* @returns {T}
|
|
1800
1816
|
*/
|
|
1801
1817
|
static replaceAll(el, targets) {
|
|
1802
1818
|
const elems = TinyHtml._preNodeElems(el, 'replaceAll');
|
|
@@ -1815,7 +1831,7 @@ class TinyHtml {
|
|
|
1815
1831
|
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
1816
1832
|
*
|
|
1817
1833
|
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
1818
|
-
* @returns {
|
|
1834
|
+
* @returns {this}
|
|
1819
1835
|
*/
|
|
1820
1836
|
replaceAll(targets) {
|
|
1821
1837
|
return TinyHtml.replaceAll(this, targets);
|
|
@@ -1837,7 +1853,7 @@ class TinyHtml {
|
|
|
1837
1853
|
/**
|
|
1838
1854
|
* Creates an instance of TinyHtml for a specific Element.
|
|
1839
1855
|
* Useful when you want to operate repeatedly on the same element using instance methods.
|
|
1840
|
-
* @param {
|
|
1856
|
+
* @param {TinyHtmlT} el - The element to wrap and manipulate.
|
|
1841
1857
|
*/
|
|
1842
1858
|
constructor(el) {
|
|
1843
1859
|
if (el instanceof TinyHtml)
|
|
@@ -1855,6 +1871,8 @@ class TinyHtml {
|
|
|
1855
1871
|
this.#el = el;
|
|
1856
1872
|
}
|
|
1857
1873
|
else if (el instanceof NodeList || el instanceof HTMLCollection) {
|
|
1874
|
+
/** @type {ConstructorElValues[]} */
|
|
1875
|
+
// @ts-ignore
|
|
1858
1876
|
const els = [...el];
|
|
1859
1877
|
elCheck(els);
|
|
1860
1878
|
this.#el = els;
|
|
@@ -2303,10 +2321,11 @@ class TinyHtml {
|
|
|
2303
2321
|
* - If `prop` is a string, the `value` will be applied to that property.
|
|
2304
2322
|
* - If `prop` is an object, each key-value pair will be applied as a CSS property and value.
|
|
2305
2323
|
*
|
|
2306
|
-
* @
|
|
2324
|
+
* @template {TinyHtmlElement|TinyHtmlElement[]} T
|
|
2325
|
+
* @param {T} el - The element to inspect.
|
|
2307
2326
|
* @param {string|Object} prop - The property name or an object with key-value pairs
|
|
2308
2327
|
* @param {string|null} [value=null] - The value to set (if `prop` is a string)
|
|
2309
|
-
* @returns {
|
|
2328
|
+
* @returns {T}
|
|
2310
2329
|
*/
|
|
2311
2330
|
static setStyle(el, prop, value = null) {
|
|
2312
2331
|
TinyHtml._preHtmlElems(el, 'setStyle').forEach((elem) => {
|
|
@@ -2328,7 +2347,7 @@ class TinyHtml {
|
|
|
2328
2347
|
*
|
|
2329
2348
|
* @param {string|Object} prop - The property name or an object with key-value pairs
|
|
2330
2349
|
* @param {string|null} [value=null] - The value to set (if `prop` is a string)
|
|
2331
|
-
* @returns {
|
|
2350
|
+
* @returns {this}
|
|
2332
2351
|
*/
|
|
2333
2352
|
setStyle(prop, value) {
|
|
2334
2353
|
return TinyHtml.setStyle(this, prop, value);
|
|
@@ -2415,9 +2434,10 @@ class TinyHtml {
|
|
|
2415
2434
|
/**
|
|
2416
2435
|
* Removes one or more inline CSS properties from the given element(s).
|
|
2417
2436
|
*
|
|
2418
|
-
* @
|
|
2437
|
+
* @template {TinyHtmlElement|TinyHtmlElement[]} T
|
|
2438
|
+
* @param {T} el - A single element or an array of elements.
|
|
2419
2439
|
* @param {string|string[]} prop - A property name or an array of property names to remove.
|
|
2420
|
-
* @returns {
|
|
2440
|
+
* @returns {T}
|
|
2421
2441
|
*/
|
|
2422
2442
|
static removeStyle(el, prop) {
|
|
2423
2443
|
TinyHtml._preHtmlElems(el, 'removeStyle').forEach((elem) => {
|
|
@@ -2435,7 +2455,7 @@ class TinyHtml {
|
|
|
2435
2455
|
* Removes one or more inline CSS properties from the given element(s).
|
|
2436
2456
|
*
|
|
2437
2457
|
* @param {string|string[]} prop - A property name or an array of property names to remove.
|
|
2438
|
-
* @returns {
|
|
2458
|
+
* @returns {this}
|
|
2439
2459
|
*/
|
|
2440
2460
|
removeStyle(prop) {
|
|
2441
2461
|
return TinyHtml.removeStyle(this, prop);
|
|
@@ -2445,11 +2465,12 @@ class TinyHtml {
|
|
|
2445
2465
|
*
|
|
2446
2466
|
* The current computed value is compared to `val1`. If it matches, the property is set to `val2`. Otherwise, it is set to `val1`.
|
|
2447
2467
|
*
|
|
2448
|
-
* @
|
|
2468
|
+
* @template {TinyHtmlElement|TinyHtmlElement[]} T
|
|
2469
|
+
* @param {T} el - A single element or an array of elements.
|
|
2449
2470
|
* @param {string} prop - The CSS property to toggle.
|
|
2450
2471
|
* @param {string} val1 - The first value (used as "current" check).
|
|
2451
2472
|
* @param {string} val2 - The second value (used as the "alternative").
|
|
2452
|
-
* @returns {
|
|
2473
|
+
* @returns {T}
|
|
2453
2474
|
*/
|
|
2454
2475
|
static toggleStyle(el, prop, val1, val2) {
|
|
2455
2476
|
TinyHtml._preHtmlElems(el, 'toggleStyle').forEach((elem) => {
|
|
@@ -2467,7 +2488,7 @@ class TinyHtml {
|
|
|
2467
2488
|
* @param {string} prop - The CSS property to toggle.
|
|
2468
2489
|
* @param {string} val1 - The first value (used as "current" check).
|
|
2469
2490
|
* @param {string} val2 - The second value (used as the "alternative").
|
|
2470
|
-
* @returns {
|
|
2491
|
+
* @returns {this}
|
|
2471
2492
|
*/
|
|
2472
2493
|
toggleStyle(prop, val1, val2) {
|
|
2473
2494
|
return TinyHtml.toggleStyle(this, prop, val1, val2);
|
|
@@ -2475,8 +2496,9 @@ class TinyHtml {
|
|
|
2475
2496
|
/**
|
|
2476
2497
|
* Removes all inline styles (`style` attribute) from the given element(s).
|
|
2477
2498
|
*
|
|
2478
|
-
* @
|
|
2479
|
-
* @
|
|
2499
|
+
* @template {TinyElement|TinyElement[]} T
|
|
2500
|
+
* @param {T} el - A single element or an array of elements.
|
|
2501
|
+
* @returns {T}
|
|
2480
2502
|
*/
|
|
2481
2503
|
static clearStyle(el) {
|
|
2482
2504
|
TinyHtml._preElems(el, 'clearStyle').forEach((elem) => elem.removeAttribute('style'));
|
|
@@ -2484,7 +2506,7 @@ class TinyHtml {
|
|
|
2484
2506
|
}
|
|
2485
2507
|
/**
|
|
2486
2508
|
* Removes all inline styles (`style` attribute) from the given element(s).
|
|
2487
|
-
* @returns {
|
|
2509
|
+
* @returns {this}
|
|
2488
2510
|
*/
|
|
2489
2511
|
clearStyle() {
|
|
2490
2512
|
return TinyHtml.clearStyle(this);
|
|
@@ -2493,8 +2515,9 @@ class TinyHtml {
|
|
|
2493
2515
|
/**
|
|
2494
2516
|
* Focus the element.
|
|
2495
2517
|
*
|
|
2496
|
-
* @
|
|
2497
|
-
* @
|
|
2518
|
+
* @template {TinyHtmlElement} T
|
|
2519
|
+
* @param {T} el - The element or a selector string.
|
|
2520
|
+
* @returns {T}
|
|
2498
2521
|
*/
|
|
2499
2522
|
static focus(el) {
|
|
2500
2523
|
const elem = TinyHtml._preHtmlElem(el, 'focus');
|
|
@@ -2503,7 +2526,7 @@ class TinyHtml {
|
|
|
2503
2526
|
}
|
|
2504
2527
|
/**
|
|
2505
2528
|
* Focus the element.
|
|
2506
|
-
* @returns {
|
|
2529
|
+
* @returns {this}
|
|
2507
2530
|
*/
|
|
2508
2531
|
focus() {
|
|
2509
2532
|
return TinyHtml.focus(this);
|
|
@@ -2511,8 +2534,9 @@ class TinyHtml {
|
|
|
2511
2534
|
/**
|
|
2512
2535
|
* Blur the element.
|
|
2513
2536
|
*
|
|
2514
|
-
* @
|
|
2515
|
-
* @
|
|
2537
|
+
* @template {TinyHtmlElement} T
|
|
2538
|
+
* @param {T} el - The element or a selector string.
|
|
2539
|
+
* @returns {T}
|
|
2516
2540
|
*/
|
|
2517
2541
|
static blur(el) {
|
|
2518
2542
|
const elem = TinyHtml._preHtmlElem(el, 'blur');
|
|
@@ -2521,7 +2545,7 @@ class TinyHtml {
|
|
|
2521
2545
|
}
|
|
2522
2546
|
/**
|
|
2523
2547
|
* Blur the element.
|
|
2524
|
-
* @returns {
|
|
2548
|
+
* @returns {this}
|
|
2525
2549
|
*/
|
|
2526
2550
|
blur() {
|
|
2527
2551
|
return TinyHtml.blur(this);
|
|
@@ -2529,8 +2553,9 @@ class TinyHtml {
|
|
|
2529
2553
|
/**
|
|
2530
2554
|
* Select the text content of an input or textarea element.
|
|
2531
2555
|
*
|
|
2532
|
-
* @
|
|
2533
|
-
* @
|
|
2556
|
+
* @template {TinyHtmlAny|HTMLInputElement|HTMLTextAreaElement} T
|
|
2557
|
+
* @param {T} el - The element or a selector string.
|
|
2558
|
+
* @returns {T}
|
|
2534
2559
|
*/
|
|
2535
2560
|
static select(el) {
|
|
2536
2561
|
const elem = TinyHtml._preHtmlElem(el, 'select');
|
|
@@ -2542,7 +2567,7 @@ class TinyHtml {
|
|
|
2542
2567
|
}
|
|
2543
2568
|
/**
|
|
2544
2569
|
* Select the text content of an input or textarea element.
|
|
2545
|
-
* @returns {
|
|
2570
|
+
* @returns {this}
|
|
2546
2571
|
*/
|
|
2547
2572
|
select() {
|
|
2548
2573
|
return TinyHtml.select(this);
|
|
@@ -2715,10 +2740,11 @@ class TinyHtml {
|
|
|
2715
2740
|
}
|
|
2716
2741
|
/**
|
|
2717
2742
|
* Sets the height of the element.
|
|
2718
|
-
* @
|
|
2743
|
+
* @template {TinyHtmlElement} T
|
|
2744
|
+
* @param {T} el - Target element.
|
|
2719
2745
|
* @param {string|number} value - Height value.
|
|
2720
2746
|
* @throws {TypeError} If `value` is neither a string nor number.
|
|
2721
|
-
* @returns {
|
|
2747
|
+
* @returns {T}
|
|
2722
2748
|
*/
|
|
2723
2749
|
static setHeight(el, value) {
|
|
2724
2750
|
const elem = TinyHtml._preHtmlElem(el, 'setHeight');
|
|
@@ -2730,17 +2756,18 @@ class TinyHtml {
|
|
|
2730
2756
|
/**
|
|
2731
2757
|
* Sets the height of the element.
|
|
2732
2758
|
* @param {string|number} value - Height value.
|
|
2733
|
-
* @returns {
|
|
2759
|
+
* @returns {this}
|
|
2734
2760
|
*/
|
|
2735
2761
|
setHeight(value) {
|
|
2736
2762
|
return TinyHtml.setHeight(this, value);
|
|
2737
2763
|
}
|
|
2738
2764
|
/**
|
|
2739
2765
|
* Sets the width of the element.
|
|
2740
|
-
* @
|
|
2766
|
+
* @template {TinyHtmlElement} T
|
|
2767
|
+
* @param {T} el - Target element.
|
|
2741
2768
|
* @param {string|number} value - Width value.
|
|
2742
2769
|
* @throws {TypeError} If `value` is neither a string nor number.
|
|
2743
|
-
* @returns {
|
|
2770
|
+
* @returns {T}
|
|
2744
2771
|
*/
|
|
2745
2772
|
static setWidth(el, value) {
|
|
2746
2773
|
const elem = TinyHtml._preHtmlElem(el, 'setWidth');
|
|
@@ -2752,7 +2779,7 @@ class TinyHtml {
|
|
|
2752
2779
|
/**
|
|
2753
2780
|
* Sets the width of the element.
|
|
2754
2781
|
* @param {string|number} value - Width value.
|
|
2755
|
-
* @returns {
|
|
2782
|
+
* @returns {this}
|
|
2756
2783
|
*/
|
|
2757
2784
|
setWidth(value) {
|
|
2758
2785
|
return TinyHtml.setWidth(this, value);
|
|
@@ -2865,10 +2892,11 @@ class TinyHtml {
|
|
|
2865
2892
|
/**
|
|
2866
2893
|
* Applies an animation to one or multiple TinyElement instances.
|
|
2867
2894
|
*
|
|
2868
|
-
* @
|
|
2895
|
+
* @template {TinyElement|TinyElement[]} T
|
|
2896
|
+
* @param {T} el - A single TinyElement or an array of TinyElements to animate.
|
|
2869
2897
|
* @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
|
|
2870
2898
|
* @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
|
|
2871
|
-
* @returns {
|
|
2899
|
+
* @returns {T}
|
|
2872
2900
|
*/
|
|
2873
2901
|
static animate(el, keyframes, ops) {
|
|
2874
2902
|
TinyHtml._preElems(el, 'animate').forEach((elem) => elem.animate(keyframes, ops));
|
|
@@ -2879,7 +2907,7 @@ class TinyHtml {
|
|
|
2879
2907
|
*
|
|
2880
2908
|
* @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
|
|
2881
2909
|
* @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
|
|
2882
|
-
* @returns {
|
|
2910
|
+
* @returns {this}
|
|
2883
2911
|
*/
|
|
2884
2912
|
animate(keyframes, ops) {
|
|
2885
2913
|
return TinyHtml.animate(this, keyframes, ops);
|
|
@@ -3038,7 +3066,8 @@ class TinyHtml {
|
|
|
3038
3066
|
*
|
|
3039
3067
|
* If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
|
|
3040
3068
|
*
|
|
3041
|
-
* @
|
|
3069
|
+
* @template {TinyElementAndWindow|TinyElementAndWindow[]} T
|
|
3070
|
+
* @param {T} el - A single element, array of elements, or the window to scroll.
|
|
3042
3071
|
* @param {Object} [settings={}] - Configuration object for the scroll animation.
|
|
3043
3072
|
* @param {number} [settings.targetX] - The horizontal scroll target in pixels.
|
|
3044
3073
|
* @param {number} [settings.targetY] - The vertical scroll target in pixels.
|
|
@@ -3046,7 +3075,7 @@ class TinyHtml {
|
|
|
3046
3075
|
* @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
|
|
3047
3076
|
* @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
|
|
3048
3077
|
* frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
|
|
3049
|
-
* @returns {
|
|
3078
|
+
* @returns {T}
|
|
3050
3079
|
* @throws {TypeError} If `el` is not a valid element, array, or window.
|
|
3051
3080
|
* @throws {TypeError} If `targetX` or `targetY` is defined but not a number.
|
|
3052
3081
|
* @throws {TypeError} If `duration` is defined but not a number.
|
|
@@ -3138,16 +3167,17 @@ class TinyHtml {
|
|
|
3138
3167
|
* @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
|
|
3139
3168
|
* @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
|
|
3140
3169
|
* frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
|
|
3141
|
-
* @returns {
|
|
3170
|
+
* @returns {this}
|
|
3142
3171
|
*/
|
|
3143
3172
|
scrollToXY({ targetX, targetY, duration, easing, onAnimation } = {}) {
|
|
3144
3173
|
return TinyHtml.scrollToXY(this, { targetX, targetY, duration, easing, onAnimation });
|
|
3145
3174
|
}
|
|
3146
3175
|
/**
|
|
3147
3176
|
* Sets the vertical scroll position.
|
|
3148
|
-
* @
|
|
3177
|
+
* @template {TinyElementAndWindow|TinyElementAndWindow[]} T
|
|
3178
|
+
* @param {T} el - Element or window.
|
|
3149
3179
|
* @param {number} value - Scroll top value.
|
|
3150
|
-
* @returns {
|
|
3180
|
+
* @returns {T}
|
|
3151
3181
|
*/
|
|
3152
3182
|
static setScrollTop(el, value) {
|
|
3153
3183
|
if (typeof value !== 'number')
|
|
@@ -3157,16 +3187,17 @@ class TinyHtml {
|
|
|
3157
3187
|
/**
|
|
3158
3188
|
* Sets the vertical scroll position.
|
|
3159
3189
|
* @param {number} value - Scroll top value.
|
|
3160
|
-
* @returns {
|
|
3190
|
+
* @returns {this}
|
|
3161
3191
|
*/
|
|
3162
3192
|
setScrollTop(value) {
|
|
3163
3193
|
return TinyHtml.setScrollTop(this, value);
|
|
3164
3194
|
}
|
|
3165
3195
|
/**
|
|
3166
3196
|
* Sets the horizontal scroll position.
|
|
3167
|
-
* @
|
|
3197
|
+
* @template {TinyElementAndWindow|TinyElementAndWindow[]} T
|
|
3198
|
+
* @param {T} el - Element or window.
|
|
3168
3199
|
* @param {number} value - Scroll left value.
|
|
3169
|
-
* @returns {
|
|
3200
|
+
* @returns {T}
|
|
3170
3201
|
*/
|
|
3171
3202
|
static setScrollLeft(el, value) {
|
|
3172
3203
|
if (typeof value !== 'number')
|
|
@@ -3176,7 +3207,7 @@ class TinyHtml {
|
|
|
3176
3207
|
/**
|
|
3177
3208
|
* Sets the horizontal scroll position.
|
|
3178
3209
|
* @param {number} value - Scroll left value.
|
|
3179
|
-
* @returns {
|
|
3210
|
+
* @returns {this}
|
|
3180
3211
|
*/
|
|
3181
3212
|
setScrollLeft(value) {
|
|
3182
3213
|
return TinyHtml.setScrollLeft(this, value);
|
|
@@ -3273,7 +3304,10 @@ class TinyHtml {
|
|
|
3273
3304
|
/////////////////////////////////////////////
|
|
3274
3305
|
/**
|
|
3275
3306
|
* Adds one or more CSS class names to the element.
|
|
3276
|
-
* @
|
|
3307
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3308
|
+
* @param {T} el
|
|
3309
|
+
* @param {...string} args - One or more class names to add.
|
|
3310
|
+
* @returns {T}
|
|
3277
3311
|
*/
|
|
3278
3312
|
static addClass(el, ...args) {
|
|
3279
3313
|
TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...args));
|
|
@@ -3281,14 +3315,18 @@ class TinyHtml {
|
|
|
3281
3315
|
}
|
|
3282
3316
|
/**
|
|
3283
3317
|
* Adds one or more CSS class names to the element.
|
|
3284
|
-
* @
|
|
3318
|
+
* @param {...string} args - One or more class names to add.
|
|
3319
|
+
* @returns {this}
|
|
3285
3320
|
*/
|
|
3286
3321
|
addClass(...args) {
|
|
3287
3322
|
return TinyHtml.addClass(this, ...args);
|
|
3288
3323
|
}
|
|
3289
3324
|
/**
|
|
3290
3325
|
* Removes one or more CSS class names from the element.
|
|
3291
|
-
* @
|
|
3326
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3327
|
+
* @param {T} el
|
|
3328
|
+
* @param {...string} args - One or more class names to remove.
|
|
3329
|
+
* @returns {T}
|
|
3292
3330
|
*/
|
|
3293
3331
|
static removeClass(el, ...args) {
|
|
3294
3332
|
TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...args));
|
|
@@ -3296,7 +3334,8 @@ class TinyHtml {
|
|
|
3296
3334
|
}
|
|
3297
3335
|
/**
|
|
3298
3336
|
* Removes one or more CSS class names from the element.
|
|
3299
|
-
* @
|
|
3337
|
+
* @param {...string} args - One or more class names to remove.
|
|
3338
|
+
* @returns {this}
|
|
3300
3339
|
*/
|
|
3301
3340
|
removeClass(...args) {
|
|
3302
3341
|
return TinyHtml.removeClass(this, ...args);
|
|
@@ -3492,9 +3531,10 @@ class TinyHtml {
|
|
|
3492
3531
|
}
|
|
3493
3532
|
/**
|
|
3494
3533
|
* Set BigInt content of elements.
|
|
3495
|
-
* @
|
|
3534
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3535
|
+
* @param {T} el
|
|
3496
3536
|
* @param {bigint} value
|
|
3497
|
-
* @returns {
|
|
3537
|
+
* @returns {T}
|
|
3498
3538
|
*/
|
|
3499
3539
|
static setBigInt(el, value) {
|
|
3500
3540
|
if (typeof value !== 'bigint')
|
|
@@ -3506,7 +3546,7 @@ class TinyHtml {
|
|
|
3506
3546
|
/**
|
|
3507
3547
|
* Set BigInt content of the element.
|
|
3508
3548
|
* @param {bigint} value
|
|
3509
|
-
* @returns {
|
|
3549
|
+
* @returns {this}
|
|
3510
3550
|
*/
|
|
3511
3551
|
setBigInt(value) {
|
|
3512
3552
|
return TinyHtml.setBigInt(this, value);
|
|
@@ -3533,9 +3573,10 @@ class TinyHtml {
|
|
|
3533
3573
|
}
|
|
3534
3574
|
/**
|
|
3535
3575
|
* Set Date content of elements.
|
|
3536
|
-
* @
|
|
3576
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3577
|
+
* @param {T} el
|
|
3537
3578
|
* @param {Date} value
|
|
3538
|
-
* @returns {
|
|
3579
|
+
* @returns {T}
|
|
3539
3580
|
*/
|
|
3540
3581
|
static setDate(el, value) {
|
|
3541
3582
|
if (!(value instanceof Date) || Number.isNaN(value.getTime()))
|
|
@@ -3547,7 +3588,7 @@ class TinyHtml {
|
|
|
3547
3588
|
/**
|
|
3548
3589
|
* Set Date content of the element.
|
|
3549
3590
|
* @param {Date} value
|
|
3550
|
-
* @returns {
|
|
3591
|
+
* @returns {this}
|
|
3551
3592
|
*/
|
|
3552
3593
|
setDate(value) {
|
|
3553
3594
|
return TinyHtml.setDate(this, value);
|
|
@@ -3578,11 +3619,12 @@ class TinyHtml {
|
|
|
3578
3619
|
}
|
|
3579
3620
|
/**
|
|
3580
3621
|
* Set JSON content of elements.
|
|
3581
|
-
* @
|
|
3622
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3623
|
+
* @param {T} el
|
|
3582
3624
|
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
3583
3625
|
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
3584
3626
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3585
|
-
* @returns {
|
|
3627
|
+
* @returns {T}
|
|
3586
3628
|
*/
|
|
3587
3629
|
static setJson(el, value, replacer, space) {
|
|
3588
3630
|
const data = JSON.stringify(value, replacer, space);
|
|
@@ -3594,7 +3636,7 @@ class TinyHtml {
|
|
|
3594
3636
|
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
3595
3637
|
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
3596
3638
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3597
|
-
* @returns {
|
|
3639
|
+
* @returns {this}
|
|
3598
3640
|
*/
|
|
3599
3641
|
setJson(value, replacer, space) {
|
|
3600
3642
|
return TinyHtml.setJson(this, value, replacer, space);
|
|
@@ -3617,9 +3659,10 @@ class TinyHtml {
|
|
|
3617
3659
|
}
|
|
3618
3660
|
/**
|
|
3619
3661
|
* Set number content of elements.
|
|
3620
|
-
* @
|
|
3662
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3663
|
+
* @param {T} el
|
|
3621
3664
|
* @param {number} value
|
|
3622
|
-
* @returns {
|
|
3665
|
+
* @returns {T}
|
|
3623
3666
|
*/
|
|
3624
3667
|
static setNumber(el, value) {
|
|
3625
3668
|
if (typeof value !== 'number')
|
|
@@ -3631,7 +3674,7 @@ class TinyHtml {
|
|
|
3631
3674
|
/**
|
|
3632
3675
|
* Set number content of the element.
|
|
3633
3676
|
* @param {number} value
|
|
3634
|
-
* @returns {
|
|
3677
|
+
* @returns {this}
|
|
3635
3678
|
*/
|
|
3636
3679
|
setNumber(value) {
|
|
3637
3680
|
return TinyHtml.setNumber(this, value);
|
|
@@ -3657,9 +3700,10 @@ class TinyHtml {
|
|
|
3657
3700
|
}
|
|
3658
3701
|
/**
|
|
3659
3702
|
* Set boolean content of elements.
|
|
3660
|
-
* @
|
|
3703
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3704
|
+
* @param {T} el
|
|
3661
3705
|
* @param {boolean} value
|
|
3662
|
-
* @returns {
|
|
3706
|
+
* @returns {T}
|
|
3663
3707
|
*/
|
|
3664
3708
|
static setBoolean(el, value) {
|
|
3665
3709
|
if (typeof value !== 'boolean')
|
|
@@ -3671,7 +3715,7 @@ class TinyHtml {
|
|
|
3671
3715
|
/**
|
|
3672
3716
|
* Set boolean content of the element.
|
|
3673
3717
|
* @param {boolean} value
|
|
3674
|
-
* @returns {
|
|
3718
|
+
* @returns {this}
|
|
3675
3719
|
*/
|
|
3676
3720
|
setBoolean(value) {
|
|
3677
3721
|
return TinyHtml.setBoolean(this, value);
|
|
@@ -3694,9 +3738,10 @@ class TinyHtml {
|
|
|
3694
3738
|
}
|
|
3695
3739
|
/**
|
|
3696
3740
|
* Set string content of elements.
|
|
3697
|
-
* @
|
|
3741
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3742
|
+
* @param {T} el
|
|
3698
3743
|
* @param {string} value
|
|
3699
|
-
* @returns {
|
|
3744
|
+
* @returns {T}
|
|
3700
3745
|
*/
|
|
3701
3746
|
static setString(el, value) {
|
|
3702
3747
|
if (typeof value !== 'string')
|
|
@@ -3707,7 +3752,7 @@ class TinyHtml {
|
|
|
3707
3752
|
/**
|
|
3708
3753
|
* Set string content of the element.
|
|
3709
3754
|
* @param {string} value
|
|
3710
|
-
* @returns {
|
|
3755
|
+
* @returns {this}
|
|
3711
3756
|
*/
|
|
3712
3757
|
setString(value) {
|
|
3713
3758
|
return TinyHtml.setString(this, value);
|
|
@@ -3730,27 +3775,29 @@ class TinyHtml {
|
|
|
3730
3775
|
}
|
|
3731
3776
|
/**
|
|
3732
3777
|
* Set text content of elements.
|
|
3733
|
-
* @
|
|
3778
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3779
|
+
* @param {T} el
|
|
3734
3780
|
* @param {*} value
|
|
3735
|
-
* @returns {
|
|
3781
|
+
* @returns {T}
|
|
3736
3782
|
*/
|
|
3737
3783
|
static setText(el, value) {
|
|
3738
|
-
const data = String(value);
|
|
3784
|
+
const data = typeof value !== 'undefined' && value !== null ? String(value) : '';
|
|
3739
3785
|
TinyHtml._preElems(el, 'setText').forEach((el) => (el.textContent = data));
|
|
3740
3786
|
return el;
|
|
3741
3787
|
}
|
|
3742
3788
|
/**
|
|
3743
3789
|
* Set text content of the element.
|
|
3744
3790
|
* @param {*} value
|
|
3745
|
-
* @returns {
|
|
3791
|
+
* @returns {this}
|
|
3746
3792
|
*/
|
|
3747
3793
|
setText(value) {
|
|
3748
3794
|
return TinyHtml.setText(this, value);
|
|
3749
3795
|
}
|
|
3750
3796
|
/**
|
|
3751
3797
|
* Remove all child nodes from each element.
|
|
3752
|
-
* @
|
|
3753
|
-
* @
|
|
3798
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3799
|
+
* @param {T} el
|
|
3800
|
+
* @returns {T}
|
|
3754
3801
|
*/
|
|
3755
3802
|
static empty(el) {
|
|
3756
3803
|
TinyHtml._preElems(el, 'empty').forEach((el) => (el.textContent = ''));
|
|
@@ -3758,7 +3805,7 @@ class TinyHtml {
|
|
|
3758
3805
|
}
|
|
3759
3806
|
/**
|
|
3760
3807
|
* Remove all child nodes of the element.
|
|
3761
|
-
* @returns {
|
|
3808
|
+
* @returns {this}
|
|
3762
3809
|
*/
|
|
3763
3810
|
empty() {
|
|
3764
3811
|
return TinyHtml.empty(this);
|
|
@@ -3783,9 +3830,10 @@ class TinyHtml {
|
|
|
3783
3830
|
}
|
|
3784
3831
|
/**
|
|
3785
3832
|
* Set the innerHTML of each element.
|
|
3786
|
-
* @
|
|
3833
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3834
|
+
* @param {T} el
|
|
3787
3835
|
* @param {string} value
|
|
3788
|
-
* @returns {
|
|
3836
|
+
* @returns {T}
|
|
3789
3837
|
*/
|
|
3790
3838
|
static setHtml(el, value) {
|
|
3791
3839
|
if (typeof value !== 'string')
|
|
@@ -3796,7 +3844,7 @@ class TinyHtml {
|
|
|
3796
3844
|
/**
|
|
3797
3845
|
* Set the innerHTML of the element.
|
|
3798
3846
|
* @param {string} value
|
|
3799
|
-
* @returns {
|
|
3847
|
+
* @returns {this}
|
|
3800
3848
|
*/
|
|
3801
3849
|
setHtml(value) {
|
|
3802
3850
|
return TinyHtml.setHtml(this, value);
|
|
@@ -3914,10 +3962,11 @@ class TinyHtml {
|
|
|
3914
3962
|
* Sets the value of the current HTML value element (input, select, textarea, etc.).
|
|
3915
3963
|
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
3916
3964
|
*
|
|
3917
|
-
* @
|
|
3965
|
+
* @template {TinyInputElement|TinyInputElement[]} T
|
|
3966
|
+
* @param {T} el - Target element.
|
|
3918
3967
|
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
3919
3968
|
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
3920
|
-
* @returns {
|
|
3969
|
+
* @returns {T}
|
|
3921
3970
|
*/
|
|
3922
3971
|
static setVal(el, value) {
|
|
3923
3972
|
TinyHtml._preInputElems(el, 'setVal').forEach((elem) => {
|
|
@@ -3963,7 +4012,7 @@ class TinyHtml {
|
|
|
3963
4012
|
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
3964
4013
|
*
|
|
3965
4014
|
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
3966
|
-
* @returns {
|
|
4015
|
+
* @returns {this}
|
|
3967
4016
|
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
3968
4017
|
*/
|
|
3969
4018
|
setVal(value) {
|
|
@@ -4321,11 +4370,12 @@ class TinyHtml {
|
|
|
4321
4370
|
/**
|
|
4322
4371
|
* Registers an event listener on the specified element.
|
|
4323
4372
|
*
|
|
4324
|
-
* @
|
|
4373
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4374
|
+
* @param {T} el - The target to listen on.
|
|
4325
4375
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4326
4376
|
* @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
|
|
4327
4377
|
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
4328
|
-
* @returns {
|
|
4378
|
+
* @returns {T}
|
|
4329
4379
|
*/
|
|
4330
4380
|
static on(el, events, handler, options) {
|
|
4331
4381
|
if (typeof events !== 'string' &&
|
|
@@ -4354,7 +4404,7 @@ class TinyHtml {
|
|
|
4354
4404
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4355
4405
|
* @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
|
|
4356
4406
|
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
4357
|
-
* @returns {
|
|
4407
|
+
* @returns {this}
|
|
4358
4408
|
*/
|
|
4359
4409
|
on(events, handler, options) {
|
|
4360
4410
|
return TinyHtml.on(this, events, handler, options);
|
|
@@ -4362,11 +4412,12 @@ class TinyHtml {
|
|
|
4362
4412
|
/**
|
|
4363
4413
|
* Registers an event listener that runs only once, then is removed.
|
|
4364
4414
|
*
|
|
4365
|
-
* @
|
|
4415
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4416
|
+
* @param {T} el - The target to listen on.
|
|
4366
4417
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4367
4418
|
* @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
|
|
4368
4419
|
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
4369
|
-
* @returns {
|
|
4420
|
+
* @returns {T}
|
|
4370
4421
|
*/
|
|
4371
4422
|
static once(el, events, handler, options = {}) {
|
|
4372
4423
|
if (typeof events !== 'string' &&
|
|
@@ -4393,7 +4444,7 @@ class TinyHtml {
|
|
|
4393
4444
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4394
4445
|
* @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
|
|
4395
4446
|
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
4396
|
-
* @returns {
|
|
4447
|
+
* @returns {this}
|
|
4397
4448
|
*/
|
|
4398
4449
|
once(events, handler, options = {}) {
|
|
4399
4450
|
return TinyHtml.once(this, events, handler, options);
|
|
@@ -4401,11 +4452,12 @@ class TinyHtml {
|
|
|
4401
4452
|
/**
|
|
4402
4453
|
* Removes a specific event listener from an element.
|
|
4403
4454
|
*
|
|
4404
|
-
* @
|
|
4455
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4456
|
+
* @param {T} el - The target element.
|
|
4405
4457
|
* @param {string|string[]} events - The event type.
|
|
4406
4458
|
* @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
|
|
4407
4459
|
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
4408
|
-
* @returns {
|
|
4460
|
+
* @returns {T}
|
|
4409
4461
|
*/
|
|
4410
4462
|
static off(el, events, handler, options) {
|
|
4411
4463
|
if (typeof events !== 'string' &&
|
|
@@ -4432,7 +4484,7 @@ class TinyHtml {
|
|
|
4432
4484
|
* @param {string|string[]} events - The event type.
|
|
4433
4485
|
* @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
|
|
4434
4486
|
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
4435
|
-
* @returns {
|
|
4487
|
+
* @returns {this}
|
|
4436
4488
|
*/
|
|
4437
4489
|
off(events, handler, options) {
|
|
4438
4490
|
return TinyHtml.off(this, events, handler, options);
|
|
@@ -4440,9 +4492,10 @@ class TinyHtml {
|
|
|
4440
4492
|
/**
|
|
4441
4493
|
* Removes all event listeners of a specific type from the element.
|
|
4442
4494
|
*
|
|
4443
|
-
* @
|
|
4495
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4496
|
+
* @param {T} el - The target element.
|
|
4444
4497
|
* @param {string|string[]} events - The event type to remove (e.g. 'click').
|
|
4445
|
-
* @returns {
|
|
4498
|
+
* @returns {T}
|
|
4446
4499
|
*/
|
|
4447
4500
|
static offAll(el, events) {
|
|
4448
4501
|
if (typeof events !== 'string' &&
|
|
@@ -4467,7 +4520,7 @@ class TinyHtml {
|
|
|
4467
4520
|
* Removes all event listeners of a specific type from the element.
|
|
4468
4521
|
*
|
|
4469
4522
|
* @param {string|string[]} events - The event type to remove (e.g. 'click').
|
|
4470
|
-
* @returns {
|
|
4523
|
+
* @returns {this}
|
|
4471
4524
|
*/
|
|
4472
4525
|
offAll(events) {
|
|
4473
4526
|
return TinyHtml.offAll(this, events);
|
|
@@ -4475,10 +4528,11 @@ class TinyHtml {
|
|
|
4475
4528
|
/**
|
|
4476
4529
|
* Removes all event listeners of all types from the element.
|
|
4477
4530
|
*
|
|
4478
|
-
* @
|
|
4531
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4532
|
+
* @param {T} el - The target element.
|
|
4479
4533
|
* @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
|
|
4480
4534
|
* Optional filter function to selectively remove specific handlers.
|
|
4481
|
-
* @returns {
|
|
4535
|
+
* @returns {T}
|
|
4482
4536
|
*/
|
|
4483
4537
|
static offAllTypes(el, filterFn = null) {
|
|
4484
4538
|
if (filterFn !== null && typeof filterFn !== 'function')
|
|
@@ -4503,7 +4557,7 @@ class TinyHtml {
|
|
|
4503
4557
|
*
|
|
4504
4558
|
* @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
|
|
4505
4559
|
* Optional filter function to selectively remove specific handlers.
|
|
4506
|
-
* @returns {
|
|
4560
|
+
* @returns {this}
|
|
4507
4561
|
*/
|
|
4508
4562
|
offAllTypes(filterFn = null) {
|
|
4509
4563
|
return TinyHtml.offAllTypes(this, filterFn);
|
|
@@ -4511,10 +4565,11 @@ class TinyHtml {
|
|
|
4511
4565
|
/**
|
|
4512
4566
|
* Triggers all handlers associated with a specific event on the given element.
|
|
4513
4567
|
*
|
|
4514
|
-
* @
|
|
4568
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4569
|
+
* @param {T} el - Target element where the event should be triggered.
|
|
4515
4570
|
* @param {string|string[]} events - Name of the event to trigger.
|
|
4516
4571
|
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
4517
|
-
* @returns {
|
|
4572
|
+
* @returns {T}
|
|
4518
4573
|
*/
|
|
4519
4574
|
static trigger(el, events, payload = {}) {
|
|
4520
4575
|
if (typeof events !== 'string' &&
|
|
@@ -4541,7 +4596,7 @@ class TinyHtml {
|
|
|
4541
4596
|
*
|
|
4542
4597
|
* @param {string|string[]} events - Name of the event to trigger.
|
|
4543
4598
|
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
4544
|
-
* @returns {
|
|
4599
|
+
* @returns {this}
|
|
4545
4600
|
*/
|
|
4546
4601
|
trigger(events, payload = {}) {
|
|
4547
4602
|
return TinyHtml.trigger(this, events, payload);
|
|
@@ -4634,10 +4689,11 @@ class TinyHtml {
|
|
|
4634
4689
|
}
|
|
4635
4690
|
/**
|
|
4636
4691
|
* Set an attribute on an element.
|
|
4637
|
-
* @
|
|
4692
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4693
|
+
* @param {T} el
|
|
4638
4694
|
* @param {string} name
|
|
4639
4695
|
* @param {string|null} [value=null]
|
|
4640
|
-
* @returns {
|
|
4696
|
+
* @returns {T}
|
|
4641
4697
|
*/
|
|
4642
4698
|
static setAttr(el, name, value = null) {
|
|
4643
4699
|
if (typeof name !== 'string')
|
|
@@ -4656,16 +4712,17 @@ class TinyHtml {
|
|
|
4656
4712
|
* Set an attribute on an element.
|
|
4657
4713
|
* @param {string} name
|
|
4658
4714
|
* @param {string|null} [value=null]
|
|
4659
|
-
* @returns {
|
|
4715
|
+
* @returns {this}
|
|
4660
4716
|
*/
|
|
4661
4717
|
setAttr(name, value) {
|
|
4662
4718
|
return TinyHtml.setAttr(this, name, value);
|
|
4663
4719
|
}
|
|
4664
4720
|
/**
|
|
4665
4721
|
* Remove attribute(s) from an element.
|
|
4666
|
-
* @
|
|
4722
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4723
|
+
* @param {T} el
|
|
4667
4724
|
* @param {string} name Space-separated list of attributes.
|
|
4668
|
-
* @returns {
|
|
4725
|
+
* @returns {T}
|
|
4669
4726
|
*/
|
|
4670
4727
|
static removeAttr(el, name) {
|
|
4671
4728
|
if (typeof name !== 'string')
|
|
@@ -4676,7 +4733,7 @@ class TinyHtml {
|
|
|
4676
4733
|
/**
|
|
4677
4734
|
* Remove attribute(s) from an element.
|
|
4678
4735
|
* @param {string} name Space-separated list of attributes.
|
|
4679
|
-
* @returns {
|
|
4736
|
+
* @returns {this}
|
|
4680
4737
|
*/
|
|
4681
4738
|
removeAttr(name) {
|
|
4682
4739
|
return TinyHtml.removeAttr(this, name);
|
|
@@ -4724,9 +4781,10 @@ class TinyHtml {
|
|
|
4724
4781
|
}
|
|
4725
4782
|
/**
|
|
4726
4783
|
* Set a property on an element.
|
|
4727
|
-
* @
|
|
4784
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4785
|
+
* @param {T} el
|
|
4728
4786
|
* @param {string} name
|
|
4729
|
-
* @returns {
|
|
4787
|
+
* @returns {T}
|
|
4730
4788
|
*/
|
|
4731
4789
|
static addProp(el, name) {
|
|
4732
4790
|
if (typeof name !== 'string')
|
|
@@ -4740,16 +4798,17 @@ class TinyHtml {
|
|
|
4740
4798
|
/**
|
|
4741
4799
|
* Set a property on an element.
|
|
4742
4800
|
* @param {string} name
|
|
4743
|
-
* @returns {
|
|
4801
|
+
* @returns {this}
|
|
4744
4802
|
*/
|
|
4745
4803
|
addProp(name) {
|
|
4746
4804
|
return TinyHtml.addProp(this, name);
|
|
4747
4805
|
}
|
|
4748
4806
|
/**
|
|
4749
4807
|
* Remove a property from an element.
|
|
4750
|
-
* @
|
|
4808
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4809
|
+
* @param {T} el
|
|
4751
4810
|
* @param {string} name
|
|
4752
|
-
* @returns {
|
|
4811
|
+
* @returns {T}
|
|
4753
4812
|
*/
|
|
4754
4813
|
static removeProp(el, name) {
|
|
4755
4814
|
if (typeof name !== 'string')
|
|
@@ -4763,16 +4822,18 @@ class TinyHtml {
|
|
|
4763
4822
|
/**
|
|
4764
4823
|
* Remove a property from an element.
|
|
4765
4824
|
* @param {string} name
|
|
4766
|
-
* @returns {
|
|
4825
|
+
* @returns {this}
|
|
4767
4826
|
*/
|
|
4768
4827
|
removeProp(name) {
|
|
4769
4828
|
return TinyHtml.removeProp(this, name);
|
|
4770
4829
|
}
|
|
4771
4830
|
/**
|
|
4772
4831
|
* Toggle a boolean property.
|
|
4773
|
-
* @
|
|
4832
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4833
|
+
* @param {T} el
|
|
4774
4834
|
* @param {string} name
|
|
4775
4835
|
* @param {boolean} [force]
|
|
4836
|
+
* @returns {T}
|
|
4776
4837
|
*/
|
|
4777
4838
|
static toggleProp(el, name, force) {
|
|
4778
4839
|
if (typeof name !== 'string')
|
|
@@ -4788,11 +4849,13 @@ class TinyHtml {
|
|
|
4788
4849
|
else
|
|
4789
4850
|
TinyHtml.removeProp(elem, name);
|
|
4790
4851
|
});
|
|
4852
|
+
return el;
|
|
4791
4853
|
}
|
|
4792
4854
|
/**
|
|
4793
4855
|
* Toggle a boolean property.
|
|
4794
4856
|
* @param {string} name
|
|
4795
4857
|
* @param {boolean} [force]
|
|
4858
|
+
* @returns {this}
|
|
4796
4859
|
*/
|
|
4797
4860
|
toggleProp(name, force) {
|
|
4798
4861
|
return TinyHtml.toggleProp(this, name, force);
|
|
@@ -4800,8 +4863,9 @@ class TinyHtml {
|
|
|
4800
4863
|
/////////////////////////////////////////////////////
|
|
4801
4864
|
/**
|
|
4802
4865
|
* Removes an element from the DOM.
|
|
4803
|
-
* @
|
|
4804
|
-
* @
|
|
4866
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4867
|
+
* @param {T} el - The DOM element or selector to remove.
|
|
4868
|
+
* @returns {T}
|
|
4805
4869
|
*/
|
|
4806
4870
|
static remove(el) {
|
|
4807
4871
|
TinyHtml._preElems(el, 'remove').forEach((elem) => elem.remove());
|
|
@@ -4809,7 +4873,7 @@ class TinyHtml {
|
|
|
4809
4873
|
}
|
|
4810
4874
|
/**
|
|
4811
4875
|
* Removes the element from the DOM.
|
|
4812
|
-
* @returns {
|
|
4876
|
+
* @returns {this}
|
|
4813
4877
|
*/
|
|
4814
4878
|
remove() {
|
|
4815
4879
|
return TinyHtml.remove(this);
|