tiny-essentials 1.21.8 → 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 +235 -170
- package/dist/v1/libs/TinyHtml.d.mts +364 -339
- package/dist/v1/libs/TinyHtml.mjs +234 -170
- 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
|
@@ -11,6 +11,11 @@ const {
|
|
|
11
11
|
areElsCollRight,
|
|
12
12
|
} = collision;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Represents a TinyHtml instance with any constructor element values.
|
|
16
|
+
* @typedef {TinyHtml<ConstructorElValues>} TinyHtmlAny
|
|
17
|
+
*/
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Callback invoked on each animation frame with the current scroll position,
|
|
16
21
|
* normalized animation time (`0` to `1`), and a completion flag.
|
|
@@ -29,7 +34,7 @@ const {
|
|
|
29
34
|
* This type is used to abstract interactions with both plain elements
|
|
30
35
|
* and wrapped elements via the TinyHtml class.
|
|
31
36
|
*
|
|
32
|
-
* @typedef {Node|
|
|
37
|
+
* @typedef {Node|TinyHtmlAny|null} TinyNode
|
|
33
38
|
*/
|
|
34
39
|
|
|
35
40
|
/**
|
|
@@ -37,7 +42,7 @@ const {
|
|
|
37
42
|
* This type is used to abstract interactions with both plain elements
|
|
38
43
|
* and wrapped elements via the TinyHtml class.
|
|
39
44
|
*
|
|
40
|
-
* @typedef {Element|
|
|
45
|
+
* @typedef {Element|TinyHtmlAny} TinyElement
|
|
41
46
|
*/
|
|
42
47
|
|
|
43
48
|
/**
|
|
@@ -45,7 +50,7 @@ const {
|
|
|
45
50
|
* This type is used to abstract interactions with both plain elements
|
|
46
51
|
* and wrapped elements via the TinyHtml class.
|
|
47
52
|
*
|
|
48
|
-
* @typedef {HTMLElement|
|
|
53
|
+
* @typedef {HTMLElement|TinyHtmlAny} TinyHtmlElement
|
|
49
54
|
*/
|
|
50
55
|
|
|
51
56
|
/**
|
|
@@ -53,7 +58,7 @@ const {
|
|
|
53
58
|
* This type is used to abstract interactions with both plain elements
|
|
54
59
|
* and wrapped elements via the TinyHtml class.
|
|
55
60
|
*
|
|
56
|
-
* @typedef {EventTarget|
|
|
61
|
+
* @typedef {EventTarget|TinyHtmlAny} TinyEventTarget
|
|
57
62
|
*/
|
|
58
63
|
|
|
59
64
|
/**
|
|
@@ -61,7 +66,7 @@ const {
|
|
|
61
66
|
* This type is used to abstract interactions with both plain elements
|
|
62
67
|
* and wrapped elements via the TinyHtml class.
|
|
63
68
|
*
|
|
64
|
-
* @typedef {InputElement|
|
|
69
|
+
* @typedef {InputElement|TinyHtmlAny} TinyInputElement
|
|
65
70
|
*/
|
|
66
71
|
|
|
67
72
|
/**
|
|
@@ -69,7 +74,7 @@ const {
|
|
|
69
74
|
* This type is used to abstract interactions with both plain elements
|
|
70
75
|
* and wrapped elements via the TinyHtml class.
|
|
71
76
|
*
|
|
72
|
-
* @typedef {ElementAndWindow|
|
|
77
|
+
* @typedef {ElementAndWindow|TinyHtmlAny} TinyElementAndWindow
|
|
73
78
|
*/
|
|
74
79
|
|
|
75
80
|
/**
|
|
@@ -84,7 +89,7 @@ const {
|
|
|
84
89
|
* This type is used to abstract interactions with both plain elements
|
|
85
90
|
* and wrapped elements via the TinyHtml class.
|
|
86
91
|
*
|
|
87
|
-
* @typedef {ElementAndWinAndDoc|
|
|
92
|
+
* @typedef {ElementAndWinAndDoc|TinyHtmlAny} TinyElementAndWinAndDoc
|
|
88
93
|
*/
|
|
89
94
|
|
|
90
95
|
/**
|
|
@@ -99,7 +104,7 @@ const {
|
|
|
99
104
|
* This type is used to abstract interactions with both plain elements
|
|
100
105
|
* and wrapped elements via the TinyHtml class.
|
|
101
106
|
*
|
|
102
|
-
* @typedef {ElementWithDoc|
|
|
107
|
+
* @typedef {ElementWithDoc|TinyHtmlAny} TinyElementWithDoc
|
|
103
108
|
*/
|
|
104
109
|
|
|
105
110
|
/**
|
|
@@ -243,6 +248,7 @@ const __elemCollision = {
|
|
|
243
248
|
* Inspired by the jQuery project's open source implementations of element dimension
|
|
244
249
|
* and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
|
|
245
250
|
*
|
|
251
|
+
* @template {ConstructorElValues|ConstructorElValues[]|NodeListOf<Element>|HTMLCollectionOf<Element>|NodeListOf<HTMLElement>} TinyHtmlT
|
|
246
252
|
* @class
|
|
247
253
|
*/
|
|
248
254
|
class TinyHtml {
|
|
@@ -289,7 +295,7 @@ class TinyHtml {
|
|
|
289
295
|
*
|
|
290
296
|
* @param {string} url - The URL of the HTML file.
|
|
291
297
|
* @param {RequestInit} [ops] - Optional fetch configuration (e.g., method, headers, cache, etc).
|
|
292
|
-
* @returns {Promise<TinyHtml[]>} A promise that resolves with the TinyHtml instances.
|
|
298
|
+
* @returns {Promise<TinyHtml<TinyElement|Text>[]>} A promise that resolves with the TinyHtml instances.
|
|
293
299
|
*/
|
|
294
300
|
static async fetchHtmlTinyElems(url, ops) {
|
|
295
301
|
const nodes = await TinyHtml.fetchHtmlNodes(url, ops);
|
|
@@ -335,7 +341,7 @@ class TinyHtml {
|
|
|
335
341
|
* Converts the content of a <template> to an array of TinyHtml elements.
|
|
336
342
|
*
|
|
337
343
|
* @param {HTMLTemplateElement} nodes
|
|
338
|
-
* @returns {TinyHtml[]}
|
|
344
|
+
* @returns {TinyHtml<Element|Text>[]}
|
|
339
345
|
*/
|
|
340
346
|
static templateToTinyElems(nodes) {
|
|
341
347
|
return TinyHtml.toTinyElm(TinyHtml.templateToNodes(nodes));
|
|
@@ -426,7 +432,7 @@ class TinyHtml {
|
|
|
426
432
|
* Converts a JSON-like HTML structure back to TinyHtml instances.
|
|
427
433
|
*
|
|
428
434
|
* @param {HtmlParsed[]} jsonArray - Parsed JSON format of HTML.
|
|
429
|
-
* @returns {TinyHtml[]} List of TinyHtml instances.
|
|
435
|
+
* @returns {TinyHtml<HTMLElement | Text>[]} List of TinyHtml instances.
|
|
430
436
|
*/
|
|
431
437
|
static jsonToTinyElems(jsonArray) {
|
|
432
438
|
return TinyHtml.toTinyElm(TinyHtml.jsonToNodes(jsonArray));
|
|
@@ -444,7 +450,7 @@ class TinyHtml {
|
|
|
444
450
|
* @param {string} tagName - The HTML tag name (e.g., 'div', 'span', 'button').
|
|
445
451
|
* @param {Record<string, string|null>} [attrs] - Optional key-value pairs representing HTML attributes.
|
|
446
452
|
* If the value is `null`, the attribute will still be set with an empty value.
|
|
447
|
-
* @returns {TinyHtml} - A new instance of TinyHtml representing the created element.
|
|
453
|
+
* @returns {TinyHtml<HTMLElement>} - A new instance of TinyHtml representing the created element.
|
|
448
454
|
* @throws {TypeError} - If `tagName` is not a string, or `attrs` is not a plain object when defined.
|
|
449
455
|
*/
|
|
450
456
|
static createFrom(tagName, attrs) {
|
|
@@ -465,7 +471,7 @@ class TinyHtml {
|
|
|
465
471
|
*
|
|
466
472
|
* @param {string} tagName - The tag name of the element to create (e.g., 'div', 'span').
|
|
467
473
|
* @param {ElementCreationOptions} [ops] - Optional settings for creating the element.
|
|
468
|
-
* @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM element.
|
|
474
|
+
* @returns {TinyHtml<HTMLElement>} A TinyHtml instance wrapping the newly created DOM element.
|
|
469
475
|
* @throws {TypeError} If tagName is not a string or ops is not an object.
|
|
470
476
|
*/
|
|
471
477
|
static createElement(tagName, ops) {
|
|
@@ -484,7 +490,7 @@ class TinyHtml {
|
|
|
484
490
|
* other TinyHtml element and can be appended or manipulated as needed.
|
|
485
491
|
*
|
|
486
492
|
* @param {string} value - The plain text content to be wrapped in a TextNode.
|
|
487
|
-
* @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM TextNode.
|
|
493
|
+
* @returns {TinyHtml<Text>} A TinyHtml instance wrapping the newly created DOM TextNode.
|
|
488
494
|
* @throws {TypeError} If the provided value is not a string.
|
|
489
495
|
*/
|
|
490
496
|
static createTextNode(value) {
|
|
@@ -498,7 +504,7 @@ class TinyHtml {
|
|
|
498
504
|
* Supports both elements and plain text.
|
|
499
505
|
*
|
|
500
506
|
* @param {string} htmlString - The HTML string to convert.
|
|
501
|
-
* @returns {TinyHtml} - A single HTMLElement or TextNode.
|
|
507
|
+
* @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
|
|
502
508
|
*/
|
|
503
509
|
static createElementFromHTML(htmlString) {
|
|
504
510
|
const template = document.createElement('template');
|
|
@@ -520,7 +526,7 @@ class TinyHtml {
|
|
|
520
526
|
*
|
|
521
527
|
* @param {string} selector - A valid CSS selector string.
|
|
522
528
|
* @param {Document|Element} elem - Target element.
|
|
523
|
-
* @returns {TinyHtml
|
|
529
|
+
* @returns {TinyHtml<Element>|null} A TinyHtml instance wrapping the matched element.
|
|
524
530
|
*/
|
|
525
531
|
static query(selector, elem = document) {
|
|
526
532
|
const newEl = elem.querySelector(selector);
|
|
@@ -532,7 +538,7 @@ class TinyHtml {
|
|
|
532
538
|
* Queries the element for the first element matching the CSS selector and wraps it in a TinyHtml instance.
|
|
533
539
|
*
|
|
534
540
|
* @param {string} selector - A valid CSS selector string.
|
|
535
|
-
* @returns {TinyHtml
|
|
541
|
+
* @returns {TinyHtml<Element>|null} A TinyHtml instance wrapping the matched element.
|
|
536
542
|
*/
|
|
537
543
|
querySelector(selector) {
|
|
538
544
|
return TinyHtml.query(selector, TinyHtml._preElem(this, 'query'));
|
|
@@ -543,7 +549,7 @@ class TinyHtml {
|
|
|
543
549
|
*
|
|
544
550
|
* @param {string} selector - A valid CSS selector string.
|
|
545
551
|
* @param {Document|Element} elem - Target element.
|
|
546
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
|
|
552
|
+
* @returns {TinyHtml<NodeListOf<Element>>} An array of TinyHtml instances wrapping the matched elements.
|
|
547
553
|
*/
|
|
548
554
|
static queryAll(selector, elem = document) {
|
|
549
555
|
return new TinyHtml(elem.querySelectorAll(selector));
|
|
@@ -553,7 +559,7 @@ class TinyHtml {
|
|
|
553
559
|
* Queries the element for all elements matching the CSS selector and wraps them in TinyHtml instances.
|
|
554
560
|
*
|
|
555
561
|
* @param {string} selector - A valid CSS selector string.
|
|
556
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
|
|
562
|
+
* @returns {TinyHtml<NodeListOf<Element>>} An array of TinyHtml instances wrapping the matched elements.
|
|
557
563
|
*/
|
|
558
564
|
querySelectorAll(selector) {
|
|
559
565
|
return TinyHtml.queryAll(selector, TinyHtml._preElem(this, 'queryAll'));
|
|
@@ -563,7 +569,7 @@ class TinyHtml {
|
|
|
563
569
|
* Retrieves an element by its ID and wraps it in a TinyHtml instance.
|
|
564
570
|
*
|
|
565
571
|
* @param {string} selector - The ID of the element to retrieve.
|
|
566
|
-
* @returns {TinyHtml
|
|
572
|
+
* @returns {TinyHtml<HTMLElement>|null} A TinyHtml instance wrapping the found element.
|
|
567
573
|
*/
|
|
568
574
|
static getById(selector) {
|
|
569
575
|
const newEl = document.getElementById(selector);
|
|
@@ -576,7 +582,7 @@ class TinyHtml {
|
|
|
576
582
|
*
|
|
577
583
|
* @param {string} selector - The class name to search for.
|
|
578
584
|
* @param {Document|Element} elem - Target element.
|
|
579
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
585
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
580
586
|
*/
|
|
581
587
|
static getByClassName(selector, elem = document) {
|
|
582
588
|
return new TinyHtml(elem.getElementsByClassName(selector));
|
|
@@ -586,7 +592,7 @@ class TinyHtml {
|
|
|
586
592
|
* Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
|
|
587
593
|
*
|
|
588
594
|
* @param {string} selector - The class name to search for.
|
|
589
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
595
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
590
596
|
*/
|
|
591
597
|
getElementsByClassName(selector) {
|
|
592
598
|
return TinyHtml.getByClassName(selector, TinyHtml._preElem(this, 'getByClassName'));
|
|
@@ -596,7 +602,7 @@ class TinyHtml {
|
|
|
596
602
|
* Retrieves all elements with the specified name attribute and wraps them in TinyHtml instances.
|
|
597
603
|
*
|
|
598
604
|
* @param {string} selector - The name attribute to search for.
|
|
599
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
605
|
+
* @returns {TinyHtml<NodeListOf<HTMLElement>>} An array of TinyHtml instances wrapping the found elements.
|
|
600
606
|
*/
|
|
601
607
|
static getByName(selector) {
|
|
602
608
|
return new TinyHtml(document.getElementsByName(selector));
|
|
@@ -609,7 +615,7 @@ class TinyHtml {
|
|
|
609
615
|
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
610
616
|
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
611
617
|
* @param {Document|Element} elem - Target element.
|
|
612
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
618
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
613
619
|
*/
|
|
614
620
|
static getByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml', elem = document) {
|
|
615
621
|
return new TinyHtml(elem.getElementsByTagNameNS(namespaceURI, localName));
|
|
@@ -621,7 +627,7 @@ class TinyHtml {
|
|
|
621
627
|
*
|
|
622
628
|
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
623
629
|
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
624
|
-
* @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
|
|
630
|
+
* @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
|
|
625
631
|
*/
|
|
626
632
|
getElementsByTagNameNS(localName, namespaceURI = 'http://www.w3.org/1999/xhtml') {
|
|
627
633
|
return TinyHtml.getByTagNameNS(
|
|
@@ -635,8 +641,8 @@ class TinyHtml {
|
|
|
635
641
|
|
|
636
642
|
/**
|
|
637
643
|
* Iterates over all elements, executing the provided callback on each.
|
|
638
|
-
* @param {(element:
|
|
639
|
-
* @returns {
|
|
644
|
+
* @param {(element: TinyHtmlAny, index: number, items: TinyHtmlAny[]) => void} callback - Function invoked for each element.
|
|
645
|
+
* @returns {this} The current instance for chaining.
|
|
640
646
|
*/
|
|
641
647
|
forEach(callback) {
|
|
642
648
|
const elems = this.getAll().map((el, index) => this.extract(index));
|
|
@@ -660,7 +666,7 @@ class TinyHtml {
|
|
|
660
666
|
* Extracts a single DOM element from the internal list at the specified index.
|
|
661
667
|
*
|
|
662
668
|
* @param {number} index - The index of the element to extract.
|
|
663
|
-
* @returns {
|
|
669
|
+
* @returns {TinyHtmlAny} A new TinyHtml instance wrapping the extracted element.
|
|
664
670
|
*/
|
|
665
671
|
extract(index) {
|
|
666
672
|
if (typeof index !== 'number') throw new TypeError('The index must be a number.');
|
|
@@ -1075,7 +1081,7 @@ class TinyHtml {
|
|
|
1075
1081
|
* of the input form.
|
|
1076
1082
|
*
|
|
1077
1083
|
* @param {TinyElement|Text|(TinyElement|Text)[]} elems - A single element or an array of elements (DOM or TinyHtml).
|
|
1078
|
-
* @returns {TinyHtml[]} An array of TinyHtml instances corresponding to the input elements.
|
|
1084
|
+
* @returns {TinyHtml<TinyElement|Text>[]} An array of TinyHtml instances corresponding to the input elements.
|
|
1079
1085
|
*/
|
|
1080
1086
|
static toTinyElm(elems) {
|
|
1081
1087
|
/** @param {(TinyElement|Text)[]} item */
|
|
@@ -1430,11 +1436,12 @@ class TinyHtml {
|
|
|
1430
1436
|
/**
|
|
1431
1437
|
* Stores a value associated with a specific key for a DOM element.
|
|
1432
1438
|
*
|
|
1433
|
-
* @
|
|
1439
|
+
* @template {TinyElement} T
|
|
1440
|
+
* @param {T} el - The DOM element.
|
|
1434
1441
|
* @param {string} key - The key under which the data will be stored.
|
|
1435
1442
|
* @param {any} value - The value to store.
|
|
1436
1443
|
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
1437
|
-
* @returns {
|
|
1444
|
+
* @returns {T}
|
|
1438
1445
|
*/
|
|
1439
1446
|
static setData(el, key, value, isPrivate = false) {
|
|
1440
1447
|
const data = TinyHtml._dataSelector[!isPrivate ? 'public' : 'private']('setData', el);
|
|
@@ -1449,7 +1456,7 @@ class TinyHtml {
|
|
|
1449
1456
|
* @param {string} key - The key under which the data will be stored.
|
|
1450
1457
|
* @param {any} value - The value to store.
|
|
1451
1458
|
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
1452
|
-
* @returns {
|
|
1459
|
+
* @returns {this}
|
|
1453
1460
|
*/
|
|
1454
1461
|
setData(key, value, isPrivate = false) {
|
|
1455
1462
|
return TinyHtml.setData(this, key, value, isPrivate);
|
|
@@ -1796,9 +1803,10 @@ class TinyHtml {
|
|
|
1796
1803
|
/**
|
|
1797
1804
|
* Appends child elements or strings to the end of the target element(s).
|
|
1798
1805
|
*
|
|
1799
|
-
* @
|
|
1806
|
+
* @template {TinyElement} T
|
|
1807
|
+
* @param {T} el - The target element(s) to receive children.
|
|
1800
1808
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
1801
|
-
* @returns {
|
|
1809
|
+
* @returns {T}
|
|
1802
1810
|
*/
|
|
1803
1811
|
static append(el, ...children) {
|
|
1804
1812
|
const elem = TinyHtml._preElem(el, 'append');
|
|
@@ -1810,7 +1818,7 @@ class TinyHtml {
|
|
|
1810
1818
|
* Appends child elements or strings to the end of the target element(s).
|
|
1811
1819
|
*
|
|
1812
1820
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
1813
|
-
* @returns {
|
|
1821
|
+
* @returns {this}
|
|
1814
1822
|
*/
|
|
1815
1823
|
append(...children) {
|
|
1816
1824
|
return TinyHtml.append(this, ...children);
|
|
@@ -1819,9 +1827,10 @@ class TinyHtml {
|
|
|
1819
1827
|
/**
|
|
1820
1828
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1821
1829
|
*
|
|
1822
|
-
* @
|
|
1830
|
+
* @template {TinyElement} T
|
|
1831
|
+
* @param {T} el - The target element(s) to receive children.
|
|
1823
1832
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
1824
|
-
* @returns {
|
|
1833
|
+
* @returns {T}
|
|
1825
1834
|
*/
|
|
1826
1835
|
static prepend(el, ...children) {
|
|
1827
1836
|
const elem = TinyHtml._preElem(el, 'prepend');
|
|
@@ -1833,7 +1842,7 @@ class TinyHtml {
|
|
|
1833
1842
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1834
1843
|
*
|
|
1835
1844
|
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
1836
|
-
* @returns {
|
|
1845
|
+
* @returns {this}
|
|
1837
1846
|
*/
|
|
1838
1847
|
prepend(...children) {
|
|
1839
1848
|
return TinyHtml.prepend(this, ...children);
|
|
@@ -1842,9 +1851,10 @@ class TinyHtml {
|
|
|
1842
1851
|
/**
|
|
1843
1852
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1844
1853
|
*
|
|
1845
|
-
* @
|
|
1854
|
+
* @template {TinyElement} T
|
|
1855
|
+
* @param {T} el - The target element(s) before which new content is inserted.
|
|
1846
1856
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
1847
|
-
* @returns {
|
|
1857
|
+
* @returns {T}
|
|
1848
1858
|
*/
|
|
1849
1859
|
static before(el, ...children) {
|
|
1850
1860
|
const elem = TinyHtml._preElem(el, 'before');
|
|
@@ -1856,7 +1866,7 @@ class TinyHtml {
|
|
|
1856
1866
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1857
1867
|
*
|
|
1858
1868
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
1859
|
-
* @returns {
|
|
1869
|
+
* @returns {this}
|
|
1860
1870
|
*/
|
|
1861
1871
|
before(...children) {
|
|
1862
1872
|
return TinyHtml.before(this, ...children);
|
|
@@ -1865,9 +1875,10 @@ class TinyHtml {
|
|
|
1865
1875
|
/**
|
|
1866
1876
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1867
1877
|
*
|
|
1868
|
-
* @
|
|
1878
|
+
* @template {TinyElement} T
|
|
1879
|
+
* @param {T} el - The target element(s) after which new content is inserted.
|
|
1869
1880
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
1870
|
-
* @returns {
|
|
1881
|
+
* @returns {T}
|
|
1871
1882
|
*/
|
|
1872
1883
|
static after(el, ...children) {
|
|
1873
1884
|
const elem = TinyHtml._preElem(el, 'after');
|
|
@@ -1879,7 +1890,7 @@ class TinyHtml {
|
|
|
1879
1890
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1880
1891
|
*
|
|
1881
1892
|
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
1882
|
-
* @returns {
|
|
1893
|
+
* @returns {this}
|
|
1883
1894
|
*/
|
|
1884
1895
|
after(...children) {
|
|
1885
1896
|
return TinyHtml.after(this, ...children);
|
|
@@ -1888,9 +1899,10 @@ class TinyHtml {
|
|
|
1888
1899
|
/**
|
|
1889
1900
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1890
1901
|
*
|
|
1891
|
-
* @
|
|
1902
|
+
* @template {TinyElement} T
|
|
1903
|
+
* @param {T} el - The element(s) to be replaced.
|
|
1892
1904
|
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
1893
|
-
* @returns {
|
|
1905
|
+
* @returns {T}
|
|
1894
1906
|
*/
|
|
1895
1907
|
static replaceWith(el, ...newNodes) {
|
|
1896
1908
|
const elem = TinyHtml._preElem(el, 'replaceWith');
|
|
@@ -1902,7 +1914,7 @@ class TinyHtml {
|
|
|
1902
1914
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1903
1915
|
*
|
|
1904
1916
|
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
1905
|
-
* @returns {
|
|
1917
|
+
* @returns {this}
|
|
1906
1918
|
*/
|
|
1907
1919
|
replaceWith(...newNodes) {
|
|
1908
1920
|
return TinyHtml.replaceWith(this, ...newNodes);
|
|
@@ -1911,9 +1923,10 @@ class TinyHtml {
|
|
|
1911
1923
|
/**
|
|
1912
1924
|
* Appends the given element(s) to each target element in sequence.
|
|
1913
1925
|
*
|
|
1914
|
-
* @
|
|
1926
|
+
* @template {TinyNode | TinyNode[]} T
|
|
1927
|
+
* @param {T} el - The element(s) to append.
|
|
1915
1928
|
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
1916
|
-
* @returns {
|
|
1929
|
+
* @returns {T}
|
|
1917
1930
|
*/
|
|
1918
1931
|
static appendTo(el, targets) {
|
|
1919
1932
|
const elems = TinyHtml._preNodeElems(el, 'appendTo');
|
|
@@ -1930,7 +1943,7 @@ class TinyHtml {
|
|
|
1930
1943
|
* Appends the given element(s) to each target element in sequence.
|
|
1931
1944
|
*
|
|
1932
1945
|
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
1933
|
-
* @returns {
|
|
1946
|
+
* @returns {this}
|
|
1934
1947
|
*/
|
|
1935
1948
|
appendTo(targets) {
|
|
1936
1949
|
return TinyHtml.appendTo(this, targets);
|
|
@@ -1939,9 +1952,10 @@ class TinyHtml {
|
|
|
1939
1952
|
/**
|
|
1940
1953
|
* Prepends the given element(s) to each target element in sequence.
|
|
1941
1954
|
*
|
|
1942
|
-
* @
|
|
1955
|
+
* @template {TinyElement | TinyElement[]} T
|
|
1956
|
+
* @param {T} el - The element(s) to prepend.
|
|
1943
1957
|
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
1944
|
-
* @returns {
|
|
1958
|
+
* @returns {T}
|
|
1945
1959
|
*/
|
|
1946
1960
|
static prependTo(el, targets) {
|
|
1947
1961
|
const elems = TinyHtml._preElems(el, 'prependTo');
|
|
@@ -1959,7 +1973,7 @@ class TinyHtml {
|
|
|
1959
1973
|
* Prepends the given element(s) to each target element in sequence.
|
|
1960
1974
|
*
|
|
1961
1975
|
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
1962
|
-
* @returns {
|
|
1976
|
+
* @returns {this}
|
|
1963
1977
|
*/
|
|
1964
1978
|
prependTo(targets) {
|
|
1965
1979
|
return TinyHtml.prependTo(this, targets);
|
|
@@ -1968,10 +1982,11 @@ class TinyHtml {
|
|
|
1968
1982
|
/**
|
|
1969
1983
|
* Inserts the element before a child of a given target, or before the target itself.
|
|
1970
1984
|
*
|
|
1971
|
-
* @
|
|
1985
|
+
* @template {TinyNode | TinyNode[]} T
|
|
1986
|
+
* @param {T} el - The element(s) to insert.
|
|
1972
1987
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1973
1988
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
1974
|
-
* @returns {
|
|
1989
|
+
* @returns {T}
|
|
1975
1990
|
*/
|
|
1976
1991
|
static insertBefore(el, target, child = null) {
|
|
1977
1992
|
const elem = TinyHtml._preNodeElem(el, 'insertBefore');
|
|
@@ -1988,7 +2003,7 @@ class TinyHtml {
|
|
|
1988
2003
|
*
|
|
1989
2004
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1990
2005
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
1991
|
-
* @returns {
|
|
2006
|
+
* @returns {this}
|
|
1992
2007
|
*/
|
|
1993
2008
|
insertBefore(target, child) {
|
|
1994
2009
|
return TinyHtml.insertBefore(this, target, child);
|
|
@@ -1997,10 +2012,11 @@ class TinyHtml {
|
|
|
1997
2012
|
/**
|
|
1998
2013
|
* Inserts the element after a child of a given target, or after the target itself.
|
|
1999
2014
|
*
|
|
2000
|
-
* @
|
|
2015
|
+
* @template {TinyNode | TinyNode[]} T
|
|
2016
|
+
* @param {T} el - The element(s) to insert.
|
|
2001
2017
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
2002
2018
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
2003
|
-
* @returns {
|
|
2019
|
+
* @returns {T}
|
|
2004
2020
|
*/
|
|
2005
2021
|
static insertAfter(el, target, child = null) {
|
|
2006
2022
|
const elem = TinyHtml._preNodeElem(el, 'insertAfter');
|
|
@@ -2016,7 +2032,7 @@ class TinyHtml {
|
|
|
2016
2032
|
*
|
|
2017
2033
|
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
2018
2034
|
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
2019
|
-
* @returns {
|
|
2035
|
+
* @returns {this}
|
|
2020
2036
|
*/
|
|
2021
2037
|
insertAfter(target, child) {
|
|
2022
2038
|
return TinyHtml.insertAfter(this, target, child);
|
|
@@ -2026,9 +2042,10 @@ class TinyHtml {
|
|
|
2026
2042
|
* Replaces all target elements with the provided element(s).
|
|
2027
2043
|
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
2028
2044
|
*
|
|
2029
|
-
* @
|
|
2045
|
+
* @template {TinyNode | TinyNode[]} T
|
|
2046
|
+
* @param {T} el - The new element(s) to insert.
|
|
2030
2047
|
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
2031
|
-
* @returns {
|
|
2048
|
+
* @returns {T}
|
|
2032
2049
|
*/
|
|
2033
2050
|
static replaceAll(el, targets) {
|
|
2034
2051
|
const elems = TinyHtml._preNodeElems(el, 'replaceAll');
|
|
@@ -2048,7 +2065,7 @@ class TinyHtml {
|
|
|
2048
2065
|
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
2049
2066
|
*
|
|
2050
2067
|
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
2051
|
-
* @returns {
|
|
2068
|
+
* @returns {this}
|
|
2052
2069
|
*/
|
|
2053
2070
|
replaceAll(targets) {
|
|
2054
2071
|
return TinyHtml.replaceAll(this, targets);
|
|
@@ -2074,7 +2091,7 @@ class TinyHtml {
|
|
|
2074
2091
|
/**
|
|
2075
2092
|
* Creates an instance of TinyHtml for a specific Element.
|
|
2076
2093
|
* Useful when you want to operate repeatedly on the same element using instance methods.
|
|
2077
|
-
* @param {
|
|
2094
|
+
* @param {TinyHtmlT} el - The element to wrap and manipulate.
|
|
2078
2095
|
*/
|
|
2079
2096
|
constructor(el) {
|
|
2080
2097
|
if (el instanceof TinyHtml)
|
|
@@ -2100,6 +2117,8 @@ class TinyHtml {
|
|
|
2100
2117
|
elCheck(el);
|
|
2101
2118
|
this.#el = el;
|
|
2102
2119
|
} else if (el instanceof NodeList || el instanceof HTMLCollection) {
|
|
2120
|
+
/** @type {ConstructorElValues[]} */
|
|
2121
|
+
// @ts-ignore
|
|
2103
2122
|
const els = [...el];
|
|
2104
2123
|
elCheck(els);
|
|
2105
2124
|
this.#el = els;
|
|
@@ -2565,10 +2584,11 @@ class TinyHtml {
|
|
|
2565
2584
|
* - If `prop` is a string, the `value` will be applied to that property.
|
|
2566
2585
|
* - If `prop` is an object, each key-value pair will be applied as a CSS property and value.
|
|
2567
2586
|
*
|
|
2568
|
-
* @
|
|
2587
|
+
* @template {TinyHtmlElement|TinyHtmlElement[]} T
|
|
2588
|
+
* @param {T} el - The element to inspect.
|
|
2569
2589
|
* @param {string|Object} prop - The property name or an object with key-value pairs
|
|
2570
2590
|
* @param {string|null} [value=null] - The value to set (if `prop` is a string)
|
|
2571
|
-
* @returns {
|
|
2591
|
+
* @returns {T}
|
|
2572
2592
|
*/
|
|
2573
2593
|
static setStyle(el, prop, value = null) {
|
|
2574
2594
|
TinyHtml._preHtmlElems(el, 'setStyle').forEach((elem) => {
|
|
@@ -2592,7 +2612,7 @@ class TinyHtml {
|
|
|
2592
2612
|
*
|
|
2593
2613
|
* @param {string|Object} prop - The property name or an object with key-value pairs
|
|
2594
2614
|
* @param {string|null} [value=null] - The value to set (if `prop` is a string)
|
|
2595
|
-
* @returns {
|
|
2615
|
+
* @returns {this}
|
|
2596
2616
|
*/
|
|
2597
2617
|
setStyle(prop, value) {
|
|
2598
2618
|
return TinyHtml.setStyle(this, prop, value);
|
|
@@ -2686,9 +2706,10 @@ class TinyHtml {
|
|
|
2686
2706
|
/**
|
|
2687
2707
|
* Removes one or more inline CSS properties from the given element(s).
|
|
2688
2708
|
*
|
|
2689
|
-
* @
|
|
2709
|
+
* @template {TinyHtmlElement|TinyHtmlElement[]} T
|
|
2710
|
+
* @param {T} el - A single element or an array of elements.
|
|
2690
2711
|
* @param {string|string[]} prop - A property name or an array of property names to remove.
|
|
2691
|
-
* @returns {
|
|
2712
|
+
* @returns {T}
|
|
2692
2713
|
*/
|
|
2693
2714
|
static removeStyle(el, prop) {
|
|
2694
2715
|
TinyHtml._preHtmlElems(el, 'removeStyle').forEach((elem) => {
|
|
@@ -2705,7 +2726,7 @@ class TinyHtml {
|
|
|
2705
2726
|
* Removes one or more inline CSS properties from the given element(s).
|
|
2706
2727
|
*
|
|
2707
2728
|
* @param {string|string[]} prop - A property name or an array of property names to remove.
|
|
2708
|
-
* @returns {
|
|
2729
|
+
* @returns {this}
|
|
2709
2730
|
*/
|
|
2710
2731
|
removeStyle(prop) {
|
|
2711
2732
|
return TinyHtml.removeStyle(this, prop);
|
|
@@ -2716,11 +2737,12 @@ class TinyHtml {
|
|
|
2716
2737
|
*
|
|
2717
2738
|
* The current computed value is compared to `val1`. If it matches, the property is set to `val2`. Otherwise, it is set to `val1`.
|
|
2718
2739
|
*
|
|
2719
|
-
* @
|
|
2740
|
+
* @template {TinyHtmlElement|TinyHtmlElement[]} T
|
|
2741
|
+
* @param {T} el - A single element or an array of elements.
|
|
2720
2742
|
* @param {string} prop - The CSS property to toggle.
|
|
2721
2743
|
* @param {string} val1 - The first value (used as "current" check).
|
|
2722
2744
|
* @param {string} val2 - The second value (used as the "alternative").
|
|
2723
|
-
* @returns {
|
|
2745
|
+
* @returns {T}
|
|
2724
2746
|
*/
|
|
2725
2747
|
static toggleStyle(el, prop, val1, val2) {
|
|
2726
2748
|
TinyHtml._preHtmlElems(el, 'toggleStyle').forEach((elem) => {
|
|
@@ -2739,7 +2761,7 @@ class TinyHtml {
|
|
|
2739
2761
|
* @param {string} prop - The CSS property to toggle.
|
|
2740
2762
|
* @param {string} val1 - The first value (used as "current" check).
|
|
2741
2763
|
* @param {string} val2 - The second value (used as the "alternative").
|
|
2742
|
-
* @returns {
|
|
2764
|
+
* @returns {this}
|
|
2743
2765
|
*/
|
|
2744
2766
|
toggleStyle(prop, val1, val2) {
|
|
2745
2767
|
return TinyHtml.toggleStyle(this, prop, val1, val2);
|
|
@@ -2748,8 +2770,9 @@ class TinyHtml {
|
|
|
2748
2770
|
/**
|
|
2749
2771
|
* Removes all inline styles (`style` attribute) from the given element(s).
|
|
2750
2772
|
*
|
|
2751
|
-
* @
|
|
2752
|
-
* @
|
|
2773
|
+
* @template {TinyElement|TinyElement[]} T
|
|
2774
|
+
* @param {T} el - A single element or an array of elements.
|
|
2775
|
+
* @returns {T}
|
|
2753
2776
|
*/
|
|
2754
2777
|
static clearStyle(el) {
|
|
2755
2778
|
TinyHtml._preElems(el, 'clearStyle').forEach((elem) => elem.removeAttribute('style'));
|
|
@@ -2758,7 +2781,7 @@ class TinyHtml {
|
|
|
2758
2781
|
|
|
2759
2782
|
/**
|
|
2760
2783
|
* Removes all inline styles (`style` attribute) from the given element(s).
|
|
2761
|
-
* @returns {
|
|
2784
|
+
* @returns {this}
|
|
2762
2785
|
*/
|
|
2763
2786
|
clearStyle() {
|
|
2764
2787
|
return TinyHtml.clearStyle(this);
|
|
@@ -2769,8 +2792,9 @@ class TinyHtml {
|
|
|
2769
2792
|
/**
|
|
2770
2793
|
* Focus the element.
|
|
2771
2794
|
*
|
|
2772
|
-
* @
|
|
2773
|
-
* @
|
|
2795
|
+
* @template {TinyHtmlElement} T
|
|
2796
|
+
* @param {T} el - The element or a selector string.
|
|
2797
|
+
* @returns {T}
|
|
2774
2798
|
*/
|
|
2775
2799
|
static focus(el) {
|
|
2776
2800
|
const elem = TinyHtml._preHtmlElem(el, 'focus');
|
|
@@ -2780,7 +2804,7 @@ class TinyHtml {
|
|
|
2780
2804
|
|
|
2781
2805
|
/**
|
|
2782
2806
|
* Focus the element.
|
|
2783
|
-
* @returns {
|
|
2807
|
+
* @returns {this}
|
|
2784
2808
|
*/
|
|
2785
2809
|
focus() {
|
|
2786
2810
|
return TinyHtml.focus(this);
|
|
@@ -2789,8 +2813,9 @@ class TinyHtml {
|
|
|
2789
2813
|
/**
|
|
2790
2814
|
* Blur the element.
|
|
2791
2815
|
*
|
|
2792
|
-
* @
|
|
2793
|
-
* @
|
|
2816
|
+
* @template {TinyHtmlElement} T
|
|
2817
|
+
* @param {T} el - The element or a selector string.
|
|
2818
|
+
* @returns {T}
|
|
2794
2819
|
*/
|
|
2795
2820
|
static blur(el) {
|
|
2796
2821
|
const elem = TinyHtml._preHtmlElem(el, 'blur');
|
|
@@ -2800,7 +2825,7 @@ class TinyHtml {
|
|
|
2800
2825
|
|
|
2801
2826
|
/**
|
|
2802
2827
|
* Blur the element.
|
|
2803
|
-
* @returns {
|
|
2828
|
+
* @returns {this}
|
|
2804
2829
|
*/
|
|
2805
2830
|
blur() {
|
|
2806
2831
|
return TinyHtml.blur(this);
|
|
@@ -2809,8 +2834,9 @@ class TinyHtml {
|
|
|
2809
2834
|
/**
|
|
2810
2835
|
* Select the text content of an input or textarea element.
|
|
2811
2836
|
*
|
|
2812
|
-
* @
|
|
2813
|
-
* @
|
|
2837
|
+
* @template {TinyHtmlAny|HTMLInputElement|HTMLTextAreaElement} T
|
|
2838
|
+
* @param {T} el - The element or a selector string.
|
|
2839
|
+
* @returns {T}
|
|
2814
2840
|
*/
|
|
2815
2841
|
static select(el) {
|
|
2816
2842
|
const elem = TinyHtml._preHtmlElem(el, 'select');
|
|
@@ -2821,7 +2847,7 @@ class TinyHtml {
|
|
|
2821
2847
|
|
|
2822
2848
|
/**
|
|
2823
2849
|
* Select the text content of an input or textarea element.
|
|
2824
|
-
* @returns {
|
|
2850
|
+
* @returns {this}
|
|
2825
2851
|
*/
|
|
2826
2852
|
select() {
|
|
2827
2853
|
return TinyHtml.select(this);
|
|
@@ -3021,10 +3047,11 @@ class TinyHtml {
|
|
|
3021
3047
|
|
|
3022
3048
|
/**
|
|
3023
3049
|
* Sets the height of the element.
|
|
3024
|
-
* @
|
|
3050
|
+
* @template {TinyHtmlElement} T
|
|
3051
|
+
* @param {T} el - Target element.
|
|
3025
3052
|
* @param {string|number} value - Height value.
|
|
3026
3053
|
* @throws {TypeError} If `value` is neither a string nor number.
|
|
3027
|
-
* @returns {
|
|
3054
|
+
* @returns {T}
|
|
3028
3055
|
*/
|
|
3029
3056
|
static setHeight(el, value) {
|
|
3030
3057
|
const elem = TinyHtml._preHtmlElem(el, 'setHeight');
|
|
@@ -3037,7 +3064,7 @@ class TinyHtml {
|
|
|
3037
3064
|
/**
|
|
3038
3065
|
* Sets the height of the element.
|
|
3039
3066
|
* @param {string|number} value - Height value.
|
|
3040
|
-
* @returns {
|
|
3067
|
+
* @returns {this}
|
|
3041
3068
|
*/
|
|
3042
3069
|
setHeight(value) {
|
|
3043
3070
|
return TinyHtml.setHeight(this, value);
|
|
@@ -3045,10 +3072,11 @@ class TinyHtml {
|
|
|
3045
3072
|
|
|
3046
3073
|
/**
|
|
3047
3074
|
* Sets the width of the element.
|
|
3048
|
-
* @
|
|
3075
|
+
* @template {TinyHtmlElement} T
|
|
3076
|
+
* @param {T} el - Target element.
|
|
3049
3077
|
* @param {string|number} value - Width value.
|
|
3050
3078
|
* @throws {TypeError} If `value` is neither a string nor number.
|
|
3051
|
-
* @returns {
|
|
3079
|
+
* @returns {T}
|
|
3052
3080
|
*/
|
|
3053
3081
|
static setWidth(el, value) {
|
|
3054
3082
|
const elem = TinyHtml._preHtmlElem(el, 'setWidth');
|
|
@@ -3061,7 +3089,7 @@ class TinyHtml {
|
|
|
3061
3089
|
/**
|
|
3062
3090
|
* Sets the width of the element.
|
|
3063
3091
|
* @param {string|number} value - Width value.
|
|
3064
|
-
* @returns {
|
|
3092
|
+
* @returns {this}
|
|
3065
3093
|
*/
|
|
3066
3094
|
setWidth(value) {
|
|
3067
3095
|
return TinyHtml.setWidth(this, value);
|
|
@@ -3188,10 +3216,11 @@ class TinyHtml {
|
|
|
3188
3216
|
/**
|
|
3189
3217
|
* Applies an animation to one or multiple TinyElement instances.
|
|
3190
3218
|
*
|
|
3191
|
-
* @
|
|
3219
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3220
|
+
* @param {T} el - A single TinyElement or an array of TinyElements to animate.
|
|
3192
3221
|
* @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
|
|
3193
3222
|
* @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
|
|
3194
|
-
* @returns {
|
|
3223
|
+
* @returns {T}
|
|
3195
3224
|
*/
|
|
3196
3225
|
static animate(el, keyframes, ops) {
|
|
3197
3226
|
TinyHtml._preElems(el, 'animate').forEach((elem) => elem.animate(keyframes, ops));
|
|
@@ -3203,7 +3232,7 @@ class TinyHtml {
|
|
|
3203
3232
|
*
|
|
3204
3233
|
* @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
|
|
3205
3234
|
* @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
|
|
3206
|
-
* @returns {
|
|
3235
|
+
* @returns {this}
|
|
3207
3236
|
*/
|
|
3208
3237
|
animate(keyframes, ops) {
|
|
3209
3238
|
return TinyHtml.animate(this, keyframes, ops);
|
|
@@ -3385,7 +3414,8 @@ class TinyHtml {
|
|
|
3385
3414
|
*
|
|
3386
3415
|
* If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
|
|
3387
3416
|
*
|
|
3388
|
-
* @
|
|
3417
|
+
* @template {TinyElementAndWindow|TinyElementAndWindow[]} T
|
|
3418
|
+
* @param {T} el - A single element, array of elements, or the window to scroll.
|
|
3389
3419
|
* @param {Object} [settings={}] - Configuration object for the scroll animation.
|
|
3390
3420
|
* @param {number} [settings.targetX] - The horizontal scroll target in pixels.
|
|
3391
3421
|
* @param {number} [settings.targetY] - The vertical scroll target in pixels.
|
|
@@ -3393,7 +3423,7 @@ class TinyHtml {
|
|
|
3393
3423
|
* @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
|
|
3394
3424
|
* @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
|
|
3395
3425
|
* frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
|
|
3396
|
-
* @returns {
|
|
3426
|
+
* @returns {T}
|
|
3397
3427
|
* @throws {TypeError} If `el` is not a valid element, array, or window.
|
|
3398
3428
|
* @throws {TypeError} If `targetX` or `targetY` is defined but not a number.
|
|
3399
3429
|
* @throws {TypeError} If `duration` is defined but not a number.
|
|
@@ -3488,7 +3518,7 @@ class TinyHtml {
|
|
|
3488
3518
|
* @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
|
|
3489
3519
|
* @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
|
|
3490
3520
|
* frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
|
|
3491
|
-
* @returns {
|
|
3521
|
+
* @returns {this}
|
|
3492
3522
|
*/
|
|
3493
3523
|
scrollToXY({ targetX, targetY, duration, easing, onAnimation } = {}) {
|
|
3494
3524
|
return TinyHtml.scrollToXY(this, { targetX, targetY, duration, easing, onAnimation });
|
|
@@ -3496,9 +3526,10 @@ class TinyHtml {
|
|
|
3496
3526
|
|
|
3497
3527
|
/**
|
|
3498
3528
|
* Sets the vertical scroll position.
|
|
3499
|
-
* @
|
|
3529
|
+
* @template {TinyElementAndWindow|TinyElementAndWindow[]} T
|
|
3530
|
+
* @param {T} el - Element or window.
|
|
3500
3531
|
* @param {number} value - Scroll top value.
|
|
3501
|
-
* @returns {
|
|
3532
|
+
* @returns {T}
|
|
3502
3533
|
*/
|
|
3503
3534
|
static setScrollTop(el, value) {
|
|
3504
3535
|
if (typeof value !== 'number') throw new TypeError('ScrollTop value must be a number.');
|
|
@@ -3508,7 +3539,7 @@ class TinyHtml {
|
|
|
3508
3539
|
/**
|
|
3509
3540
|
* Sets the vertical scroll position.
|
|
3510
3541
|
* @param {number} value - Scroll top value.
|
|
3511
|
-
* @returns {
|
|
3542
|
+
* @returns {this}
|
|
3512
3543
|
*/
|
|
3513
3544
|
setScrollTop(value) {
|
|
3514
3545
|
return TinyHtml.setScrollTop(this, value);
|
|
@@ -3516,9 +3547,10 @@ class TinyHtml {
|
|
|
3516
3547
|
|
|
3517
3548
|
/**
|
|
3518
3549
|
* Sets the horizontal scroll position.
|
|
3519
|
-
* @
|
|
3550
|
+
* @template {TinyElementAndWindow|TinyElementAndWindow[]} T
|
|
3551
|
+
* @param {T} el - Element or window.
|
|
3520
3552
|
* @param {number} value - Scroll left value.
|
|
3521
|
-
* @returns {
|
|
3553
|
+
* @returns {T}
|
|
3522
3554
|
*/
|
|
3523
3555
|
static setScrollLeft(el, value) {
|
|
3524
3556
|
if (typeof value !== 'number') throw new TypeError('ScrollLeft value must be a number.');
|
|
@@ -3528,7 +3560,7 @@ class TinyHtml {
|
|
|
3528
3560
|
/**
|
|
3529
3561
|
* Sets the horizontal scroll position.
|
|
3530
3562
|
* @param {number} value - Scroll left value.
|
|
3531
|
-
* @returns {
|
|
3563
|
+
* @returns {this}
|
|
3532
3564
|
*/
|
|
3533
3565
|
setScrollLeft(value) {
|
|
3534
3566
|
return TinyHtml.setScrollLeft(this, value);
|
|
@@ -3659,7 +3691,10 @@ class TinyHtml {
|
|
|
3659
3691
|
|
|
3660
3692
|
/**
|
|
3661
3693
|
* Adds one or more CSS class names to the element.
|
|
3662
|
-
* @
|
|
3694
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3695
|
+
* @param {T} el
|
|
3696
|
+
* @param {...string} args - One or more class names to add.
|
|
3697
|
+
* @returns {T}
|
|
3663
3698
|
*/
|
|
3664
3699
|
static addClass(el, ...args) {
|
|
3665
3700
|
TinyHtml._preElems(el, 'addClass').forEach((elem) => elem.classList.add(...args));
|
|
@@ -3668,7 +3703,8 @@ class TinyHtml {
|
|
|
3668
3703
|
|
|
3669
3704
|
/**
|
|
3670
3705
|
* Adds one or more CSS class names to the element.
|
|
3671
|
-
* @
|
|
3706
|
+
* @param {...string} args - One or more class names to add.
|
|
3707
|
+
* @returns {this}
|
|
3672
3708
|
*/
|
|
3673
3709
|
addClass(...args) {
|
|
3674
3710
|
return TinyHtml.addClass(this, ...args);
|
|
@@ -3676,7 +3712,10 @@ class TinyHtml {
|
|
|
3676
3712
|
|
|
3677
3713
|
/**
|
|
3678
3714
|
* Removes one or more CSS class names from the element.
|
|
3679
|
-
* @
|
|
3715
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3716
|
+
* @param {T} el
|
|
3717
|
+
* @param {...string} args - One or more class names to remove.
|
|
3718
|
+
* @returns {T}
|
|
3680
3719
|
*/
|
|
3681
3720
|
static removeClass(el, ...args) {
|
|
3682
3721
|
TinyHtml._preElems(el, 'removeClass').forEach((elem) => elem.classList.remove(...args));
|
|
@@ -3685,7 +3724,8 @@ class TinyHtml {
|
|
|
3685
3724
|
|
|
3686
3725
|
/**
|
|
3687
3726
|
* Removes one or more CSS class names from the element.
|
|
3688
|
-
* @
|
|
3727
|
+
* @param {...string} args - One or more class names to remove.
|
|
3728
|
+
* @returns {this}
|
|
3689
3729
|
*/
|
|
3690
3730
|
removeClass(...args) {
|
|
3691
3731
|
return TinyHtml.removeClass(this, ...args);
|
|
@@ -3900,9 +3940,10 @@ class TinyHtml {
|
|
|
3900
3940
|
|
|
3901
3941
|
/**
|
|
3902
3942
|
* Set BigInt content of elements.
|
|
3903
|
-
* @
|
|
3943
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3944
|
+
* @param {T} el
|
|
3904
3945
|
* @param {bigint} value
|
|
3905
|
-
* @returns {
|
|
3946
|
+
* @returns {T}
|
|
3906
3947
|
*/
|
|
3907
3948
|
static setBigInt(el, value) {
|
|
3908
3949
|
if (typeof value !== 'bigint') throw new Error('Value is not a valid BigInt.');
|
|
@@ -3914,7 +3955,7 @@ class TinyHtml {
|
|
|
3914
3955
|
/**
|
|
3915
3956
|
* Set BigInt content of the element.
|
|
3916
3957
|
* @param {bigint} value
|
|
3917
|
-
* @returns {
|
|
3958
|
+
* @returns {this}
|
|
3918
3959
|
*/
|
|
3919
3960
|
setBigInt(value) {
|
|
3920
3961
|
return TinyHtml.setBigInt(this, value);
|
|
@@ -3943,9 +3984,10 @@ class TinyHtml {
|
|
|
3943
3984
|
|
|
3944
3985
|
/**
|
|
3945
3986
|
* Set Date content of elements.
|
|
3946
|
-
* @
|
|
3987
|
+
* @template {TinyElement|TinyElement[]} T
|
|
3988
|
+
* @param {T} el
|
|
3947
3989
|
* @param {Date} value
|
|
3948
|
-
* @returns {
|
|
3990
|
+
* @returns {T}
|
|
3949
3991
|
*/
|
|
3950
3992
|
static setDate(el, value) {
|
|
3951
3993
|
if (!(value instanceof Date) || Number.isNaN(value.getTime()))
|
|
@@ -3958,7 +4000,7 @@ class TinyHtml {
|
|
|
3958
4000
|
/**
|
|
3959
4001
|
* Set Date content of the element.
|
|
3960
4002
|
* @param {Date} value
|
|
3961
|
-
* @returns {
|
|
4003
|
+
* @returns {this}
|
|
3962
4004
|
*/
|
|
3963
4005
|
setDate(value) {
|
|
3964
4006
|
return TinyHtml.setDate(this, value);
|
|
@@ -3990,11 +4032,12 @@ class TinyHtml {
|
|
|
3990
4032
|
|
|
3991
4033
|
/**
|
|
3992
4034
|
* Set JSON content of elements.
|
|
3993
|
-
* @
|
|
4035
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4036
|
+
* @param {T} el
|
|
3994
4037
|
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
3995
4038
|
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
3996
4039
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
3997
|
-
* @returns {
|
|
4040
|
+
* @returns {T}
|
|
3998
4041
|
*/
|
|
3999
4042
|
static setJson(el, value, replacer, space) {
|
|
4000
4043
|
const data = JSON.stringify(value, replacer, space);
|
|
@@ -4007,7 +4050,7 @@ class TinyHtml {
|
|
|
4007
4050
|
* @param {any} value - A JavaScript value, usually an object or array, to be converted.
|
|
4008
4051
|
* @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
|
|
4009
4052
|
* @param {number|string} [space] - Indentation level or string for formatting.
|
|
4010
|
-
* @returns {
|
|
4053
|
+
* @returns {this}
|
|
4011
4054
|
*/
|
|
4012
4055
|
setJson(value, replacer, space) {
|
|
4013
4056
|
return TinyHtml.setJson(this, value, replacer, space);
|
|
@@ -4033,9 +4076,10 @@ class TinyHtml {
|
|
|
4033
4076
|
|
|
4034
4077
|
/**
|
|
4035
4078
|
* Set number content of elements.
|
|
4036
|
-
* @
|
|
4079
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4080
|
+
* @param {T} el
|
|
4037
4081
|
* @param {number} value
|
|
4038
|
-
* @returns {
|
|
4082
|
+
* @returns {T}
|
|
4039
4083
|
*/
|
|
4040
4084
|
static setNumber(el, value) {
|
|
4041
4085
|
if (typeof value !== 'number') throw new Error('Value is not a valid number.');
|
|
@@ -4047,7 +4091,7 @@ class TinyHtml {
|
|
|
4047
4091
|
/**
|
|
4048
4092
|
* Set number content of the element.
|
|
4049
4093
|
* @param {number} value
|
|
4050
|
-
* @returns {
|
|
4094
|
+
* @returns {this}
|
|
4051
4095
|
*/
|
|
4052
4096
|
setNumber(value) {
|
|
4053
4097
|
return TinyHtml.setNumber(this, value);
|
|
@@ -4075,9 +4119,10 @@ class TinyHtml {
|
|
|
4075
4119
|
|
|
4076
4120
|
/**
|
|
4077
4121
|
* Set boolean content of elements.
|
|
4078
|
-
* @
|
|
4122
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4123
|
+
* @param {T} el
|
|
4079
4124
|
* @param {boolean} value
|
|
4080
|
-
* @returns {
|
|
4125
|
+
* @returns {T}
|
|
4081
4126
|
*/
|
|
4082
4127
|
static setBoolean(el, value) {
|
|
4083
4128
|
if (typeof value !== 'boolean') throw new Error('Value is not a valid boolean.');
|
|
@@ -4089,7 +4134,7 @@ class TinyHtml {
|
|
|
4089
4134
|
/**
|
|
4090
4135
|
* Set boolean content of the element.
|
|
4091
4136
|
* @param {boolean} value
|
|
4092
|
-
* @returns {
|
|
4137
|
+
* @returns {this}
|
|
4093
4138
|
*/
|
|
4094
4139
|
setBoolean(value) {
|
|
4095
4140
|
return TinyHtml.setBoolean(this, value);
|
|
@@ -4115,9 +4160,10 @@ class TinyHtml {
|
|
|
4115
4160
|
|
|
4116
4161
|
/**
|
|
4117
4162
|
* Set string content of elements.
|
|
4118
|
-
* @
|
|
4163
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4164
|
+
* @param {T} el
|
|
4119
4165
|
* @param {string} value
|
|
4120
|
-
* @returns {
|
|
4166
|
+
* @returns {T}
|
|
4121
4167
|
*/
|
|
4122
4168
|
static setString(el, value) {
|
|
4123
4169
|
if (typeof value !== 'string') throw new Error('Value is not a valid string.');
|
|
@@ -4128,7 +4174,7 @@ class TinyHtml {
|
|
|
4128
4174
|
/**
|
|
4129
4175
|
* Set string content of the element.
|
|
4130
4176
|
* @param {string} value
|
|
4131
|
-
* @returns {
|
|
4177
|
+
* @returns {this}
|
|
4132
4178
|
*/
|
|
4133
4179
|
setString(value) {
|
|
4134
4180
|
return TinyHtml.setString(this, value);
|
|
@@ -4154,9 +4200,10 @@ class TinyHtml {
|
|
|
4154
4200
|
|
|
4155
4201
|
/**
|
|
4156
4202
|
* Set text content of elements.
|
|
4157
|
-
* @
|
|
4203
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4204
|
+
* @param {T} el
|
|
4158
4205
|
* @param {*} value
|
|
4159
|
-
* @returns {
|
|
4206
|
+
* @returns {T}
|
|
4160
4207
|
*/
|
|
4161
4208
|
static setText(el, value) {
|
|
4162
4209
|
const data = typeof value !== 'undefined' && value !== null ? String(value) : '';
|
|
@@ -4167,7 +4214,7 @@ class TinyHtml {
|
|
|
4167
4214
|
/**
|
|
4168
4215
|
* Set text content of the element.
|
|
4169
4216
|
* @param {*} value
|
|
4170
|
-
* @returns {
|
|
4217
|
+
* @returns {this}
|
|
4171
4218
|
*/
|
|
4172
4219
|
setText(value) {
|
|
4173
4220
|
return TinyHtml.setText(this, value);
|
|
@@ -4175,8 +4222,9 @@ class TinyHtml {
|
|
|
4175
4222
|
|
|
4176
4223
|
/**
|
|
4177
4224
|
* Remove all child nodes from each element.
|
|
4178
|
-
* @
|
|
4179
|
-
* @
|
|
4225
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4226
|
+
* @param {T} el
|
|
4227
|
+
* @returns {T}
|
|
4180
4228
|
*/
|
|
4181
4229
|
static empty(el) {
|
|
4182
4230
|
TinyHtml._preElems(el, 'empty').forEach((el) => (el.textContent = ''));
|
|
@@ -4185,7 +4233,7 @@ class TinyHtml {
|
|
|
4185
4233
|
|
|
4186
4234
|
/**
|
|
4187
4235
|
* Remove all child nodes of the element.
|
|
4188
|
-
* @returns {
|
|
4236
|
+
* @returns {this}
|
|
4189
4237
|
*/
|
|
4190
4238
|
empty() {
|
|
4191
4239
|
return TinyHtml.empty(this);
|
|
@@ -4213,9 +4261,10 @@ class TinyHtml {
|
|
|
4213
4261
|
|
|
4214
4262
|
/**
|
|
4215
4263
|
* Set the innerHTML of each element.
|
|
4216
|
-
* @
|
|
4264
|
+
* @template {TinyElement|TinyElement[]} T
|
|
4265
|
+
* @param {T} el
|
|
4217
4266
|
* @param {string} value
|
|
4218
|
-
* @returns {
|
|
4267
|
+
* @returns {T}
|
|
4219
4268
|
*/
|
|
4220
4269
|
static setHtml(el, value) {
|
|
4221
4270
|
if (typeof value !== 'string') throw new Error('Value is not a valid string.');
|
|
@@ -4226,7 +4275,7 @@ class TinyHtml {
|
|
|
4226
4275
|
/**
|
|
4227
4276
|
* Set the innerHTML of the element.
|
|
4228
4277
|
* @param {string} value
|
|
4229
|
-
* @returns {
|
|
4278
|
+
* @returns {this}
|
|
4230
4279
|
*/
|
|
4231
4280
|
setHtml(value) {
|
|
4232
4281
|
return TinyHtml.setHtml(this, value);
|
|
@@ -4357,10 +4406,11 @@ class TinyHtml {
|
|
|
4357
4406
|
* Sets the value of the current HTML value element (input, select, textarea, etc.).
|
|
4358
4407
|
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
4359
4408
|
*
|
|
4360
|
-
* @
|
|
4409
|
+
* @template {TinyInputElement|TinyInputElement[]} T
|
|
4410
|
+
* @param {T} el - Target element.
|
|
4361
4411
|
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
4362
4412
|
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
4363
|
-
* @returns {
|
|
4413
|
+
* @returns {T}
|
|
4364
4414
|
*/
|
|
4365
4415
|
static setVal(el, value) {
|
|
4366
4416
|
TinyHtml._preInputElems(el, 'setVal').forEach((elem) => {
|
|
@@ -4408,7 +4458,7 @@ class TinyHtml {
|
|
|
4408
4458
|
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
4409
4459
|
*
|
|
4410
4460
|
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
4411
|
-
* @returns {
|
|
4461
|
+
* @returns {this}
|
|
4412
4462
|
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
4413
4463
|
*/
|
|
4414
4464
|
setVal(value) {
|
|
@@ -4782,11 +4832,12 @@ class TinyHtml {
|
|
|
4782
4832
|
/**
|
|
4783
4833
|
* Registers an event listener on the specified element.
|
|
4784
4834
|
*
|
|
4785
|
-
* @
|
|
4835
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4836
|
+
* @param {T} el - The target to listen on.
|
|
4786
4837
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4787
4838
|
* @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
|
|
4788
4839
|
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
4789
|
-
* @returns {
|
|
4840
|
+
* @returns {T}
|
|
4790
4841
|
*/
|
|
4791
4842
|
static on(el, events, handler, options) {
|
|
4792
4843
|
if (
|
|
@@ -4815,7 +4866,7 @@ class TinyHtml {
|
|
|
4815
4866
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4816
4867
|
* @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
|
|
4817
4868
|
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
4818
|
-
* @returns {
|
|
4869
|
+
* @returns {this}
|
|
4819
4870
|
*/
|
|
4820
4871
|
on(events, handler, options) {
|
|
4821
4872
|
return TinyHtml.on(this, events, handler, options);
|
|
@@ -4824,11 +4875,12 @@ class TinyHtml {
|
|
|
4824
4875
|
/**
|
|
4825
4876
|
* Registers an event listener that runs only once, then is removed.
|
|
4826
4877
|
*
|
|
4827
|
-
* @
|
|
4878
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4879
|
+
* @param {T} el - The target to listen on.
|
|
4828
4880
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4829
4881
|
* @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
|
|
4830
4882
|
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
4831
|
-
* @returns {
|
|
4883
|
+
* @returns {T}
|
|
4832
4884
|
*/
|
|
4833
4885
|
static once(el, events, handler, options = {}) {
|
|
4834
4886
|
if (
|
|
@@ -4862,7 +4914,7 @@ class TinyHtml {
|
|
|
4862
4914
|
* @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
|
|
4863
4915
|
* @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
|
|
4864
4916
|
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
4865
|
-
* @returns {
|
|
4917
|
+
* @returns {this}
|
|
4866
4918
|
*/
|
|
4867
4919
|
once(events, handler, options = {}) {
|
|
4868
4920
|
return TinyHtml.once(this, events, handler, options);
|
|
@@ -4871,11 +4923,12 @@ class TinyHtml {
|
|
|
4871
4923
|
/**
|
|
4872
4924
|
* Removes a specific event listener from an element.
|
|
4873
4925
|
*
|
|
4874
|
-
* @
|
|
4926
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4927
|
+
* @param {T} el - The target element.
|
|
4875
4928
|
* @param {string|string[]} events - The event type.
|
|
4876
4929
|
* @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
|
|
4877
4930
|
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
4878
|
-
* @returns {
|
|
4931
|
+
* @returns {T}
|
|
4879
4932
|
*/
|
|
4880
4933
|
static off(el, events, handler, options) {
|
|
4881
4934
|
if (
|
|
@@ -4904,7 +4957,7 @@ class TinyHtml {
|
|
|
4904
4957
|
* @param {string|string[]} events - The event type.
|
|
4905
4958
|
* @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
|
|
4906
4959
|
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
4907
|
-
* @returns {
|
|
4960
|
+
* @returns {this}
|
|
4908
4961
|
*/
|
|
4909
4962
|
off(events, handler, options) {
|
|
4910
4963
|
return TinyHtml.off(this, events, handler, options);
|
|
@@ -4913,9 +4966,10 @@ class TinyHtml {
|
|
|
4913
4966
|
/**
|
|
4914
4967
|
* Removes all event listeners of a specific type from the element.
|
|
4915
4968
|
*
|
|
4916
|
-
* @
|
|
4969
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
4970
|
+
* @param {T} el - The target element.
|
|
4917
4971
|
* @param {string|string[]} events - The event type to remove (e.g. 'click').
|
|
4918
|
-
* @returns {
|
|
4972
|
+
* @returns {T}
|
|
4919
4973
|
*/
|
|
4920
4974
|
static offAll(el, events) {
|
|
4921
4975
|
if (
|
|
@@ -4942,7 +4996,7 @@ class TinyHtml {
|
|
|
4942
4996
|
* Removes all event listeners of a specific type from the element.
|
|
4943
4997
|
*
|
|
4944
4998
|
* @param {string|string[]} events - The event type to remove (e.g. 'click').
|
|
4945
|
-
* @returns {
|
|
4999
|
+
* @returns {this}
|
|
4946
5000
|
*/
|
|
4947
5001
|
offAll(events) {
|
|
4948
5002
|
return TinyHtml.offAll(this, events);
|
|
@@ -4951,10 +5005,11 @@ class TinyHtml {
|
|
|
4951
5005
|
/**
|
|
4952
5006
|
* Removes all event listeners of all types from the element.
|
|
4953
5007
|
*
|
|
4954
|
-
* @
|
|
5008
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
5009
|
+
* @param {T} el - The target element.
|
|
4955
5010
|
* @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
|
|
4956
5011
|
* Optional filter function to selectively remove specific handlers.
|
|
4957
|
-
* @returns {
|
|
5012
|
+
* @returns {T}
|
|
4958
5013
|
*/
|
|
4959
5014
|
static offAllTypes(el, filterFn = null) {
|
|
4960
5015
|
if (filterFn !== null && typeof filterFn !== 'function')
|
|
@@ -4981,7 +5036,7 @@ class TinyHtml {
|
|
|
4981
5036
|
*
|
|
4982
5037
|
* @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
|
|
4983
5038
|
* Optional filter function to selectively remove specific handlers.
|
|
4984
|
-
* @returns {
|
|
5039
|
+
* @returns {this}
|
|
4985
5040
|
*/
|
|
4986
5041
|
offAllTypes(filterFn = null) {
|
|
4987
5042
|
return TinyHtml.offAllTypes(this, filterFn);
|
|
@@ -4990,10 +5045,11 @@ class TinyHtml {
|
|
|
4990
5045
|
/**
|
|
4991
5046
|
* Triggers all handlers associated with a specific event on the given element.
|
|
4992
5047
|
*
|
|
4993
|
-
* @
|
|
5048
|
+
* @template {TinyEventTarget|TinyEventTarget[]} T
|
|
5049
|
+
* @param {T} el - Target element where the event should be triggered.
|
|
4994
5050
|
* @param {string|string[]} events - Name of the event to trigger.
|
|
4995
5051
|
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
4996
|
-
* @returns {
|
|
5052
|
+
* @returns {T}
|
|
4997
5053
|
*/
|
|
4998
5054
|
static trigger(el, events, payload = {}) {
|
|
4999
5055
|
if (
|
|
@@ -5024,7 +5080,7 @@ class TinyHtml {
|
|
|
5024
5080
|
*
|
|
5025
5081
|
* @param {string|string[]} events - Name of the event to trigger.
|
|
5026
5082
|
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
5027
|
-
* @returns {
|
|
5083
|
+
* @returns {this}
|
|
5028
5084
|
*/
|
|
5029
5085
|
trigger(events, payload = {}) {
|
|
5030
5086
|
return TinyHtml.trigger(this, events, payload);
|
|
@@ -5127,10 +5183,11 @@ class TinyHtml {
|
|
|
5127
5183
|
|
|
5128
5184
|
/**
|
|
5129
5185
|
* Set an attribute on an element.
|
|
5130
|
-
* @
|
|
5186
|
+
* @template {TinyElement|TinyElement[]} T
|
|
5187
|
+
* @param {T} el
|
|
5131
5188
|
* @param {string} name
|
|
5132
5189
|
* @param {string|null} [value=null]
|
|
5133
|
-
* @returns {
|
|
5190
|
+
* @returns {T}
|
|
5134
5191
|
*/
|
|
5135
5192
|
static setAttr(el, name, value = null) {
|
|
5136
5193
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -5147,7 +5204,7 @@ class TinyHtml {
|
|
|
5147
5204
|
* Set an attribute on an element.
|
|
5148
5205
|
* @param {string} name
|
|
5149
5206
|
* @param {string|null} [value=null]
|
|
5150
|
-
* @returns {
|
|
5207
|
+
* @returns {this}
|
|
5151
5208
|
*/
|
|
5152
5209
|
setAttr(name, value) {
|
|
5153
5210
|
return TinyHtml.setAttr(this, name, value);
|
|
@@ -5155,9 +5212,10 @@ class TinyHtml {
|
|
|
5155
5212
|
|
|
5156
5213
|
/**
|
|
5157
5214
|
* Remove attribute(s) from an element.
|
|
5158
|
-
* @
|
|
5215
|
+
* @template {TinyElement|TinyElement[]} T
|
|
5216
|
+
* @param {T} el
|
|
5159
5217
|
* @param {string} name Space-separated list of attributes.
|
|
5160
|
-
* @returns {
|
|
5218
|
+
* @returns {T}
|
|
5161
5219
|
*/
|
|
5162
5220
|
static removeAttr(el, name) {
|
|
5163
5221
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -5170,7 +5228,7 @@ class TinyHtml {
|
|
|
5170
5228
|
/**
|
|
5171
5229
|
* Remove attribute(s) from an element.
|
|
5172
5230
|
* @param {string} name Space-separated list of attributes.
|
|
5173
|
-
* @returns {
|
|
5231
|
+
* @returns {this}
|
|
5174
5232
|
*/
|
|
5175
5233
|
removeAttr(name) {
|
|
5176
5234
|
return TinyHtml.removeAttr(this, name);
|
|
@@ -5221,9 +5279,10 @@ class TinyHtml {
|
|
|
5221
5279
|
|
|
5222
5280
|
/**
|
|
5223
5281
|
* Set a property on an element.
|
|
5224
|
-
* @
|
|
5282
|
+
* @template {TinyElement|TinyElement[]} T
|
|
5283
|
+
* @param {T} el
|
|
5225
5284
|
* @param {string} name
|
|
5226
|
-
* @returns {
|
|
5285
|
+
* @returns {T}
|
|
5227
5286
|
*/
|
|
5228
5287
|
static addProp(el, name) {
|
|
5229
5288
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -5237,7 +5296,7 @@ class TinyHtml {
|
|
|
5237
5296
|
/**
|
|
5238
5297
|
* Set a property on an element.
|
|
5239
5298
|
* @param {string} name
|
|
5240
|
-
* @returns {
|
|
5299
|
+
* @returns {this}
|
|
5241
5300
|
*/
|
|
5242
5301
|
addProp(name) {
|
|
5243
5302
|
return TinyHtml.addProp(this, name);
|
|
@@ -5245,9 +5304,10 @@ class TinyHtml {
|
|
|
5245
5304
|
|
|
5246
5305
|
/**
|
|
5247
5306
|
* Remove a property from an element.
|
|
5248
|
-
* @
|
|
5307
|
+
* @template {TinyElement|TinyElement[]} T
|
|
5308
|
+
* @param {T} el
|
|
5249
5309
|
* @param {string} name
|
|
5250
|
-
* @returns {
|
|
5310
|
+
* @returns {T}
|
|
5251
5311
|
*/
|
|
5252
5312
|
static removeProp(el, name) {
|
|
5253
5313
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -5261,7 +5321,7 @@ class TinyHtml {
|
|
|
5261
5321
|
/**
|
|
5262
5322
|
* Remove a property from an element.
|
|
5263
5323
|
* @param {string} name
|
|
5264
|
-
* @returns {
|
|
5324
|
+
* @returns {this}
|
|
5265
5325
|
*/
|
|
5266
5326
|
removeProp(name) {
|
|
5267
5327
|
return TinyHtml.removeProp(this, name);
|
|
@@ -5269,9 +5329,11 @@ class TinyHtml {
|
|
|
5269
5329
|
|
|
5270
5330
|
/**
|
|
5271
5331
|
* Toggle a boolean property.
|
|
5272
|
-
* @
|
|
5332
|
+
* @template {TinyElement|TinyElement[]} T
|
|
5333
|
+
* @param {T} el
|
|
5273
5334
|
* @param {string} name
|
|
5274
5335
|
* @param {boolean} [force]
|
|
5336
|
+
* @returns {T}
|
|
5275
5337
|
*/
|
|
5276
5338
|
static toggleProp(el, name, force) {
|
|
5277
5339
|
if (typeof name !== 'string') throw new TypeError('The "name" must be a string.');
|
|
@@ -5284,12 +5346,14 @@ class TinyHtml {
|
|
|
5284
5346
|
if (shouldEnable) TinyHtml.addProp(elem, name);
|
|
5285
5347
|
else TinyHtml.removeProp(elem, name);
|
|
5286
5348
|
});
|
|
5349
|
+
return el;
|
|
5287
5350
|
}
|
|
5288
5351
|
|
|
5289
5352
|
/**
|
|
5290
5353
|
* Toggle a boolean property.
|
|
5291
5354
|
* @param {string} name
|
|
5292
5355
|
* @param {boolean} [force]
|
|
5356
|
+
* @returns {this}
|
|
5293
5357
|
*/
|
|
5294
5358
|
toggleProp(name, force) {
|
|
5295
5359
|
return TinyHtml.toggleProp(this, name, force);
|
|
@@ -5299,8 +5363,9 @@ class TinyHtml {
|
|
|
5299
5363
|
|
|
5300
5364
|
/**
|
|
5301
5365
|
* Removes an element from the DOM.
|
|
5302
|
-
* @
|
|
5303
|
-
* @
|
|
5366
|
+
* @template {TinyElement|TinyElement[]} T
|
|
5367
|
+
* @param {T} el - The DOM element or selector to remove.
|
|
5368
|
+
* @returns {T}
|
|
5304
5369
|
*/
|
|
5305
5370
|
static remove(el) {
|
|
5306
5371
|
TinyHtml._preElems(el, 'remove').forEach((elem) => elem.remove());
|
|
@@ -5309,7 +5374,7 @@ class TinyHtml {
|
|
|
5309
5374
|
|
|
5310
5375
|
/**
|
|
5311
5376
|
* Removes the element from the DOM.
|
|
5312
|
-
* @returns {
|
|
5377
|
+
* @returns {this}
|
|
5313
5378
|
*/
|
|
5314
5379
|
remove() {
|
|
5315
5380
|
return TinyHtml.remove(this);
|