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.
@@ -1,4 +1,8 @@
1
1
  export default TinyHtml;
2
+ /**
3
+ * Represents a TinyHtml instance with any constructor element values.
4
+ */
5
+ export type TinyHtmlAny = TinyHtml<ConstructorElValues>;
2
6
  /**
3
7
  * Callback invoked on each animation frame with the current scroll position,
4
8
  * normalized animation time (`0` to `1`), and a completion flag.
@@ -18,37 +22,37 @@ export type Easings = "linear" | "easeInQuad" | "easeOutQuad" | "easeInOutQuad"
18
22
  * This type is used to abstract interactions with both plain elements
19
23
  * and wrapped elements via the TinyHtml class.
20
24
  */
21
- export type TinyNode = Node | TinyHtml | null;
25
+ export type TinyNode = Node | TinyHtmlAny | null;
22
26
  /**
23
27
  * Represents a raw DOM element or an instance of TinyHtml.
24
28
  * This type is used to abstract interactions with both plain elements
25
29
  * and wrapped elements via the TinyHtml class.
26
30
  */
27
- export type TinyElement = Element | TinyHtml;
31
+ export type TinyElement = Element | TinyHtmlAny;
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
- export type TinyHtmlElement = HTMLElement | TinyHtml;
37
+ export type TinyHtmlElement = HTMLElement | TinyHtmlAny;
34
38
  /**
35
39
  * Represents a raw DOM event target element or an instance of TinyHtml.
36
40
  * This type is used to abstract interactions with both plain elements
37
41
  * and wrapped elements via the TinyHtml class.
38
42
  */
39
- export type TinyEventTarget = EventTarget | TinyHtml;
43
+ export type TinyEventTarget = EventTarget | TinyHtmlAny;
40
44
  /**
41
45
  * Represents a raw DOM input element or an instance of TinyHtml.
42
46
  * This type is used to abstract interactions with both plain elements
43
47
  * and wrapped elements via the TinyHtml class.
44
48
  */
45
- export type TinyInputElement = InputElement | TinyHtml;
49
+ export type TinyInputElement = InputElement | TinyHtmlAny;
46
50
  /**
47
51
  * Represents a raw DOM element/window or an instance of TinyHtml.
48
52
  * This type is used to abstract interactions with both plain elements
49
53
  * and wrapped elements via the TinyHtml class.
50
54
  */
51
- export type TinyElementAndWindow = ElementAndWindow | TinyHtml;
55
+ export type TinyElementAndWindow = ElementAndWindow | TinyHtmlAny;
52
56
  /**
53
57
  * Represents a value that can be either a DOM Element or the global Window object.
54
58
  * Useful for functions that operate generically on scrollable or measurable targets.
@@ -59,7 +63,7 @@ export type ElementAndWindow = Element | Window;
59
63
  * This type is used to abstract interactions with both plain elements
60
64
  * and wrapped elements via the TinyHtml class.
61
65
  */
62
- export type TinyElementAndWinAndDoc = ElementAndWinAndDoc | TinyHtml;
66
+ export type TinyElementAndWinAndDoc = ElementAndWinAndDoc | TinyHtmlAny;
63
67
  /**
64
68
  * Represents a value that can be either a DOM Element, or the global Window object, or the document object.
65
69
  * Useful for functions that operate generically on scrollable or measurable targets.
@@ -70,7 +74,7 @@ export type ElementAndWinAndDoc = Element | Window | Document;
70
74
  * This type is used to abstract interactions with both plain elements
71
75
  * and wrapped elements via the TinyHtml class.
72
76
  */
73
- export type TinyElementWithDoc = ElementWithDoc | TinyHtml;
77
+ export type TinyElementWithDoc = ElementWithDoc | TinyHtmlAny;
74
78
  /**
75
79
  * Represents a value that can be either a DOM Element, or the document object.
76
80
  * Useful for functions that operate generically on measurable targets.
@@ -206,9 +210,10 @@ attributes: Record<string, string>, // All element attributes as key-value pairs
206
210
  * Inspired by the jQuery project's open source implementations of element dimension
207
211
  * and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
208
212
  *
213
+ * @template {ConstructorElValues|ConstructorElValues[]|NodeListOf<Element>|HTMLCollectionOf<Element>|NodeListOf<HTMLElement>} TinyHtmlT
209
214
  * @class
210
215
  */
211
- declare class TinyHtml {
216
+ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValues[] | NodeListOf<Element> | HTMLCollectionOf<Element> | NodeListOf<HTMLElement>> {
212
217
  /** @typedef {import('../basics/collision.mjs').ObjRect} ObjRect */
213
218
  static Utils: {
214
219
  getElsRelativeCenterOffset(rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect): {
@@ -237,60 +242,8 @@ declare class TinyHtml {
237
242
  areElsCollPerfRight: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
238
243
  areElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
239
244
  areElsPerfColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
240
- getElsColliding: (
241
- /**
242
- * @typedef {'string' | 'date' | 'number'} GetValueTypes
243
- * Types of value extractors supported by TinyHtml._valTypes.
244
- */
245
- /**
246
- * @typedef {SetValueBase|SetValueBase[]} SetValueList - A single value or an array of values to be assigned to the input element.
247
- */
248
- /**
249
- * A list of HTML form elements that can have a `.value` property used by TinyHtml.
250
- * Includes common input types used in forms.
251
- *
252
- * @typedef {HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|HTMLOptionElement} InputElement
253
- */
254
- /**
255
- * Represents a parsed HTML element in JSON-like array form.
256
- *
257
- * @typedef {[
258
- * tagName: string, // The tag name of the element (e.g., 'div', 'img')
259
- * attributes: Record<string, string>, // All element attributes as key-value pairs
260
- * ...children: (string | HtmlParsed)[] // Text or nested elements
261
- * ]} HtmlParsed
262
- */
263
- /**
264
- * TinyHtml is a utility class that provides static and instance-level methods
265
- * for precise dimension and position computations on HTML elements.
266
- * It mimics some jQuery functionalities while using native browser APIs.
267
- *
268
- * Inspired by the jQuery project's open source implementations of element dimension
269
- * and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
270
- *
271
- * @class
272
- */
273
- rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => string | null;
274
- getElsPerfColliding: (rect1: TinyCollision.ObjRect /**
275
- * Represents a parsed HTML element in JSON-like array form.
276
- *
277
- * @typedef {[
278
- * tagName: string, // The tag name of the element (e.g., 'div', 'img')
279
- * attributes: Record<string, string>, // All element attributes as key-value pairs
280
- * ...children: (string | HtmlParsed)[] // Text or nested elements
281
- * ]} HtmlParsed
282
- */
283
- /**
284
- * TinyHtml is a utility class that provides static and instance-level methods
285
- * for precise dimension and position computations on HTML elements.
286
- * It mimics some jQuery functionalities while using native browser APIs.
287
- *
288
- * Inspired by the jQuery project's open source implementations of element dimension
289
- * and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
290
- *
291
- * @class
292
- */
293
- , rect2: TinyCollision.ObjRect) => "top" | "bottom" | "left" | "right" | null;
245
+ getElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => string | null;
246
+ getElsPerfColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => "top" | "bottom" | "left" | "right" | null;
294
247
  getElsCollOverlap: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => {
295
248
  overlapLeft: number;
296
249
  overlapRight: number;
@@ -332,9 +285,9 @@ declare class TinyHtml {
332
285
  *
333
286
  * @param {string} url - The URL of the HTML file.
334
287
  * @param {RequestInit} [ops] - Optional fetch configuration (e.g., method, headers, cache, etc).
335
- * @returns {Promise<TinyHtml[]>} A promise that resolves with the TinyHtml instances.
288
+ * @returns {Promise<TinyHtml<TinyElement|Text>[]>} A promise that resolves with the TinyHtml instances.
336
289
  */
337
- static fetchHtmlTinyElems(url: string, ops?: RequestInit): Promise<TinyHtml[]>;
290
+ static fetchHtmlTinyElems(url: string, ops?: RequestInit): Promise<TinyHtml<TinyElement | Text>[]>;
338
291
  /**
339
292
  * Converts the content of a <template> to an array of HtmlParsed.
340
293
  *
@@ -353,9 +306,9 @@ declare class TinyHtml {
353
306
  * Converts the content of a <template> to an array of TinyHtml elements.
354
307
  *
355
308
  * @param {HTMLTemplateElement} nodes
356
- * @returns {TinyHtml[]}
309
+ * @returns {TinyHtml<Element|Text>[]}
357
310
  */
358
- static templateToTinyElems(nodes: HTMLTemplateElement): TinyHtml[];
311
+ static templateToTinyElems(nodes: HTMLTemplateElement): TinyHtml<Element | Text>[];
359
312
  /**
360
313
  * Parses a full HTML string into a JSON-like structure.
361
314
  *
@@ -374,9 +327,9 @@ declare class TinyHtml {
374
327
  * Converts a JSON-like HTML structure back to TinyHtml instances.
375
328
  *
376
329
  * @param {HtmlParsed[]} jsonArray - Parsed JSON format of HTML.
377
- * @returns {TinyHtml[]} List of TinyHtml instances.
330
+ * @returns {TinyHtml<HTMLElement | Text>[]} List of TinyHtml instances.
378
331
  */
379
- static jsonToTinyElems(jsonArray: HtmlParsed[]): TinyHtml[];
332
+ static jsonToTinyElems(jsonArray: HtmlParsed[]): TinyHtml<HTMLElement | Text>[];
380
333
  /**
381
334
  * Creates a new TinyHtml element from a tag name and optional attributes.
382
335
  *
@@ -389,19 +342,19 @@ declare class TinyHtml {
389
342
  * @param {string} tagName - The HTML tag name (e.g., 'div', 'span', 'button').
390
343
  * @param {Record<string, string|null>} [attrs] - Optional key-value pairs representing HTML attributes.
391
344
  * If the value is `null`, the attribute will still be set with an empty value.
392
- * @returns {TinyHtml} - A new instance of TinyHtml representing the created element.
345
+ * @returns {TinyHtml<HTMLElement>} - A new instance of TinyHtml representing the created element.
393
346
  * @throws {TypeError} - If `tagName` is not a string, or `attrs` is not a plain object when defined.
394
347
  */
395
- static createFrom(tagName: string, attrs?: Record<string, string | null>): TinyHtml;
348
+ static createFrom(tagName: string, attrs?: Record<string, string | null>): TinyHtml<HTMLElement>;
396
349
  /**
397
350
  * Creates a new DOM element with the specified tag name and options, then wraps it in a TinyHtml instance.
398
351
  *
399
352
  * @param {string} tagName - The tag name of the element to create (e.g., 'div', 'span').
400
353
  * @param {ElementCreationOptions} [ops] - Optional settings for creating the element.
401
- * @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM element.
354
+ * @returns {TinyHtml<HTMLElement>} A TinyHtml instance wrapping the newly created DOM element.
402
355
  * @throws {TypeError} If tagName is not a string or ops is not an object.
403
356
  */
404
- static createElement(tagName: string, ops?: ElementCreationOptions): TinyHtml;
357
+ static createElement(tagName: string, ops?: ElementCreationOptions): TinyHtml<HTMLElement>;
405
358
  /**
406
359
  * Creates a new TinyHtml instance that wraps a DOM TextNode.
407
360
  *
@@ -410,56 +363,56 @@ declare class TinyHtml {
410
363
  * other TinyHtml element and can be appended or manipulated as needed.
411
364
  *
412
365
  * @param {string} value - The plain text content to be wrapped in a TextNode.
413
- * @returns {TinyHtml} A TinyHtml instance wrapping the newly created DOM TextNode.
366
+ * @returns {TinyHtml<Text>} A TinyHtml instance wrapping the newly created DOM TextNode.
414
367
  * @throws {TypeError} If the provided value is not a string.
415
368
  */
416
- static createTextNode(value: string): TinyHtml;
369
+ static createTextNode(value: string): TinyHtml<Text>;
417
370
  /**
418
371
  * Creates an HTMLElement or TextNode from an HTML string.
419
372
  * Supports both elements and plain text.
420
373
  *
421
374
  * @param {string} htmlString - The HTML string to convert.
422
- * @returns {TinyHtml} - A single HTMLElement or TextNode.
375
+ * @returns {TinyHtml<Element>} - A single HTMLElement or TextNode.
423
376
  */
424
- static createElementFromHTML(htmlString: string): TinyHtml;
377
+ static createElementFromHTML(htmlString: string): TinyHtml<Element>;
425
378
  /**
426
379
  * Queries the document for the first element matching the CSS selector and wraps it in a TinyHtml instance.
427
380
  *
428
381
  * @param {string} selector - A valid CSS selector string.
429
382
  * @param {Document|Element} elem - Target element.
430
- * @returns {TinyHtml|null} A TinyHtml instance wrapping the matched element.
383
+ * @returns {TinyHtml<Element>|null} A TinyHtml instance wrapping the matched element.
431
384
  */
432
- static query(selector: string, elem?: Document | Element): TinyHtml | null;
385
+ static query(selector: string, elem?: Document | Element): TinyHtml<Element> | null;
433
386
  /**
434
387
  * Queries the document for all elements matching the CSS selector and wraps them in TinyHtml instances.
435
388
  *
436
389
  * @param {string} selector - A valid CSS selector string.
437
390
  * @param {Document|Element} elem - Target element.
438
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
391
+ * @returns {TinyHtml<NodeListOf<Element>>} An array of TinyHtml instances wrapping the matched elements.
439
392
  */
440
- static queryAll(selector: string, elem?: Document | Element): TinyHtml;
393
+ static queryAll(selector: string, elem?: Document | Element): TinyHtml<NodeListOf<Element>>;
441
394
  /**
442
395
  * Retrieves an element by its ID and wraps it in a TinyHtml instance.
443
396
  *
444
397
  * @param {string} selector - The ID of the element to retrieve.
445
- * @returns {TinyHtml|null} A TinyHtml instance wrapping the found element.
398
+ * @returns {TinyHtml<HTMLElement>|null} A TinyHtml instance wrapping the found element.
446
399
  */
447
- static getById(selector: string): TinyHtml | null;
400
+ static getById(selector: string): TinyHtml<HTMLElement> | null;
448
401
  /**
449
402
  * Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
450
403
  *
451
404
  * @param {string} selector - The class name to search for.
452
405
  * @param {Document|Element} elem - Target element.
453
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
406
+ * @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
454
407
  */
455
- static getByClassName(selector: string, elem?: Document | Element): TinyHtml;
408
+ static getByClassName(selector: string, elem?: Document | Element): TinyHtml<HTMLCollectionOf<Element>>;
456
409
  /**
457
410
  * Retrieves all elements with the specified name attribute and wraps them in TinyHtml instances.
458
411
  *
459
412
  * @param {string} selector - The name attribute to search for.
460
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
413
+ * @returns {TinyHtml<NodeListOf<HTMLElement>>} An array of TinyHtml instances wrapping the found elements.
461
414
  */
462
- static getByName(selector: string): TinyHtml;
415
+ static getByName(selector: string): TinyHtml<NodeListOf<HTMLElement>>;
463
416
  /**
464
417
  * Retrieves all elements with the specified local tag name within the given namespace URI,
465
418
  * and wraps them in TinyHtml instances.
@@ -467,9 +420,9 @@ declare class TinyHtml {
467
420
  * @param {string} localName - The local name (tag) of the elements to search for.
468
421
  * @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
469
422
  * @param {Document|Element} elem - Target element.
470
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
423
+ * @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
471
424
  */
472
- static getByTagNameNS(localName: string, namespaceURI?: string | null, elem?: Document | Element): TinyHtml;
425
+ static getByTagNameNS(localName: string, namespaceURI?: string | null, elem?: Document | Element): TinyHtml<HTMLCollectionOf<Element>>;
473
426
  /**
474
427
  * Prepares and validates multiple elements against allowed types.
475
428
  *
@@ -677,9 +630,9 @@ declare class TinyHtml {
677
630
  * of the input form.
678
631
  *
679
632
  * @param {TinyElement|Text|(TinyElement|Text)[]} elems - A single element or an array of elements (DOM or TinyHtml).
680
- * @returns {TinyHtml[]} An array of TinyHtml instances corresponding to the input elements.
633
+ * @returns {TinyHtml<TinyElement|Text>[]} An array of TinyHtml instances corresponding to the input elements.
681
634
  */
682
- static toTinyElm(elems: TinyElement | Text | (TinyElement | Text)[]): TinyHtml[];
635
+ static toTinyElm(elems: TinyElement | Text | (TinyElement | Text)[]): TinyHtml<TinyElement | Text>[];
683
636
  /**
684
637
  * Extracts native `Element` instances from one or more elements,
685
638
  * which can be either raw DOM elements or wrapped in `TinyHtml`.
@@ -795,13 +748,14 @@ declare class TinyHtml {
795
748
  /**
796
749
  * Stores a value associated with a specific key for a DOM element.
797
750
  *
798
- * @param {TinyElement} el - The DOM element.
751
+ * @template {TinyElement} T
752
+ * @param {T} el - The DOM element.
799
753
  * @param {string} key - The key under which the data will be stored.
800
754
  * @param {any} value - The value to store.
801
755
  * @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
802
- * @returns {TinyElement}
756
+ * @returns {T}
803
757
  */
804
- static setData(el: TinyElement, key: string, value: any, isPrivate?: boolean): TinyElement;
758
+ static setData<T extends TinyElement>(el: T, key: string, value: any, isPrivate?: boolean): T;
805
759
  /**
806
760
  * Get the sibling element in a given direction.
807
761
  *
@@ -922,86 +876,96 @@ declare class TinyHtml {
922
876
  /**
923
877
  * Appends child elements or strings to the end of the target element(s).
924
878
  *
925
- * @param {TinyElement} el - The target element(s) to receive children.
879
+ * @template {TinyElement} T
880
+ * @param {T} el - The target element(s) to receive children.
926
881
  * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
927
- * @returns {TinyElement}
882
+ * @returns {T}
928
883
  */
929
- static append(el: TinyElement, ...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
884
+ static append<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
930
885
  /**
931
886
  * Prepends child elements or strings to the beginning of the target element(s).
932
887
  *
933
- * @param {TinyElement} el - The target element(s) to receive children.
888
+ * @template {TinyElement} T
889
+ * @param {T} el - The target element(s) to receive children.
934
890
  * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
935
- * @returns {TinyElement}
891
+ * @returns {T}
936
892
  */
937
- static prepend(el: TinyElement, ...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
893
+ static prepend<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
938
894
  /**
939
895
  * Inserts elements or strings immediately before the target element(s) in the DOM.
940
896
  *
941
- * @param {TinyElement} el - The target element(s) before which new content is inserted.
897
+ * @template {TinyElement} T
898
+ * @param {T} el - The target element(s) before which new content is inserted.
942
899
  * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
943
- * @returns {TinyElement}
900
+ * @returns {T}
944
901
  */
945
- static before(el: TinyElement, ...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
902
+ static before<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
946
903
  /**
947
904
  * Inserts elements or strings immediately after the target element(s) in the DOM.
948
905
  *
949
- * @param {TinyElement} el - The target element(s) after which new content is inserted.
906
+ * @template {TinyElement} T
907
+ * @param {T} el - The target element(s) after which new content is inserted.
950
908
  * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
951
- * @returns {TinyElement}
909
+ * @returns {T}
952
910
  */
953
- static after(el: TinyElement, ...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
911
+ static after<T extends TinyElement>(el: T, ...children: (TinyNode | TinyNode[] | string)[]): T;
954
912
  /**
955
913
  * Replaces the target element(s) in the DOM with new elements or text.
956
914
  *
957
- * @param {TinyElement} el - The element(s) to be replaced.
915
+ * @template {TinyElement} T
916
+ * @param {T} el - The element(s) to be replaced.
958
917
  * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
959
- * @returns {TinyElement}
918
+ * @returns {T}
960
919
  */
961
- static replaceWith(el: TinyElement, ...newNodes: (TinyNode | TinyNode[] | string)[]): TinyElement;
920
+ static replaceWith<T extends TinyElement>(el: T, ...newNodes: (TinyNode | TinyNode[] | string)[]): T;
962
921
  /**
963
922
  * Appends the given element(s) to each target element in sequence.
964
923
  *
965
- * @param {TinyNode | TinyNode[]} el - The element(s) to append.
924
+ * @template {TinyNode | TinyNode[]} T
925
+ * @param {T} el - The element(s) to append.
966
926
  * @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
967
- * @returns {TinyNode|TinyNode[]}
927
+ * @returns {T}
968
928
  */
969
- static appendTo(el: TinyNode | TinyNode[], targets: TinyNode | TinyNode[]): TinyNode | TinyNode[];
929
+ static appendTo<T extends TinyNode | TinyNode[]>(el: T, targets: TinyNode | TinyNode[]): T;
970
930
  /**
971
931
  * Prepends the given element(s) to each target element in sequence.
972
932
  *
973
- * @param {TinyElement | TinyElement[]} el - The element(s) to prepend.
933
+ * @template {TinyElement | TinyElement[]} T
934
+ * @param {T} el - The element(s) to prepend.
974
935
  * @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
975
- * @returns {TinyElement|TinyElement[]}
936
+ * @returns {T}
976
937
  */
977
- static prependTo(el: TinyElement | TinyElement[], targets: TinyElement | TinyElement[]): TinyElement | TinyElement[];
938
+ static prependTo<T extends TinyElement | TinyElement[]>(el: T, targets: TinyElement | TinyElement[]): T;
978
939
  /**
979
940
  * Inserts the element before a child of a given target, or before the target itself.
980
941
  *
981
- * @param {TinyNode | TinyNode[]} el - The element(s) to insert.
942
+ * @template {TinyNode | TinyNode[]} T
943
+ * @param {T} el - The element(s) to insert.
982
944
  * @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
983
945
  * @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
984
- * @returns {TinyNode|TinyNode[]}
946
+ * @returns {T}
985
947
  */
986
- static insertBefore(el: TinyNode | TinyNode[], target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): TinyNode | TinyNode[];
948
+ static insertBefore<T extends TinyNode | TinyNode[]>(el: T, target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): T;
987
949
  /**
988
950
  * Inserts the element after a child of a given target, or after the target itself.
989
951
  *
990
- * @param {TinyNode | TinyNode[]} el - The element(s) to insert.
952
+ * @template {TinyNode | TinyNode[]} T
953
+ * @param {T} el - The element(s) to insert.
991
954
  * @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
992
955
  * @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
993
- * @returns {TinyNode|TinyNode[]}
956
+ * @returns {T}
994
957
  */
995
- static insertAfter(el: TinyNode | TinyNode[], target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): TinyNode | TinyNode[];
958
+ static insertAfter<T extends TinyNode | TinyNode[]>(el: T, target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): T;
996
959
  /**
997
960
  * Replaces all target elements with the provided element(s).
998
961
  * If multiple targets exist, the inserted elements are cloned accordingly.
999
962
  *
1000
- * @param {TinyNode | TinyNode[]} el - The new element(s) to insert.
963
+ * @template {TinyNode | TinyNode[]} T
964
+ * @param {T} el - The new element(s) to insert.
1001
965
  * @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
1002
- * @returns {TinyNode|TinyNode[]}
966
+ * @returns {T}
1003
967
  */
1004
- static replaceAll(el: TinyNode | TinyNode[], targets: TinyNode | TinyNode[]): TinyNode | TinyNode[];
968
+ static replaceAll<T extends TinyNode | TinyNode[]>(el: T, targets: TinyNode | TinyNode[]): T;
1005
969
  /**
1006
970
  * Checks whether the given object is a window.
1007
971
  * @param {*} obj - The object to test.
@@ -1097,12 +1061,13 @@ declare class TinyHtml {
1097
1061
  * - If `prop` is a string, the `value` will be applied to that property.
1098
1062
  * - If `prop` is an object, each key-value pair will be applied as a CSS property and value.
1099
1063
  *
1100
- * @param {TinyHtmlElement|TinyHtmlElement[]} el - The element to inspect.
1064
+ * @template {TinyHtmlElement|TinyHtmlElement[]} T
1065
+ * @param {T} el - The element to inspect.
1101
1066
  * @param {string|Object} prop - The property name or an object with key-value pairs
1102
1067
  * @param {string|null} [value=null] - The value to set (if `prop` is a string)
1103
- * @returns {TinyHtmlElement|TinyHtmlElement[]}
1068
+ * @returns {T}
1104
1069
  */
1105
- static setStyle(el: TinyHtmlElement | TinyHtmlElement[], prop: string | Object, value?: string | null): TinyHtmlElement | TinyHtmlElement[];
1070
+ static setStyle<T extends TinyHtmlElement | TinyHtmlElement[]>(el: T, prop: string | Object, value?: string | null): T;
1106
1071
  /**
1107
1072
  * Gets the value of a specific inline style property.
1108
1073
  *
@@ -1133,51 +1098,57 @@ declare class TinyHtml {
1133
1098
  /**
1134
1099
  * Removes one or more inline CSS properties from the given element(s).
1135
1100
  *
1136
- * @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element or an array of elements.
1101
+ * @template {TinyHtmlElement|TinyHtmlElement[]} T
1102
+ * @param {T} el - A single element or an array of elements.
1137
1103
  * @param {string|string[]} prop - A property name or an array of property names to remove.
1138
- * @returns {TinyHtmlElement|TinyHtmlElement[]}
1104
+ * @returns {T}
1139
1105
  */
1140
- static removeStyle(el: TinyHtmlElement | TinyHtmlElement[], prop: string | string[]): TinyHtmlElement | TinyHtmlElement[];
1106
+ static removeStyle<T extends TinyHtmlElement | TinyHtmlElement[]>(el: T, prop: string | string[]): T;
1141
1107
  /**
1142
1108
  * Toggles a CSS property value between two given values.
1143
1109
  *
1144
1110
  * The current computed value is compared to `val1`. If it matches, the property is set to `val2`. Otherwise, it is set to `val1`.
1145
1111
  *
1146
- * @param {TinyHtmlElement|TinyHtmlElement[]} el - A single element or an array of elements.
1112
+ * @template {TinyHtmlElement|TinyHtmlElement[]} T
1113
+ * @param {T} el - A single element or an array of elements.
1147
1114
  * @param {string} prop - The CSS property to toggle.
1148
1115
  * @param {string} val1 - The first value (used as "current" check).
1149
1116
  * @param {string} val2 - The second value (used as the "alternative").
1150
- * @returns {TinyHtmlElement|TinyHtmlElement[]}
1117
+ * @returns {T}
1151
1118
  */
1152
- static toggleStyle(el: TinyHtmlElement | TinyHtmlElement[], prop: string, val1: string, val2: string): TinyHtmlElement | TinyHtmlElement[];
1119
+ static toggleStyle<T extends TinyHtmlElement | TinyHtmlElement[]>(el: T, prop: string, val1: string, val2: string): T;
1153
1120
  /**
1154
1121
  * Removes all inline styles (`style` attribute) from the given element(s).
1155
1122
  *
1156
- * @param {TinyElement|TinyElement[]} el - A single element or an array of elements.
1157
- * @returns {TinyElement|TinyElement[]}
1123
+ * @template {TinyElement|TinyElement[]} T
1124
+ * @param {T} el - A single element or an array of elements.
1125
+ * @returns {T}
1158
1126
  */
1159
- static clearStyle(el: TinyElement | TinyElement[]): TinyElement | TinyElement[];
1127
+ static clearStyle<T extends TinyElement | TinyElement[]>(el: T): T;
1160
1128
  /**
1161
1129
  * Focus the element.
1162
1130
  *
1163
- * @param {TinyHtmlElement} el - The element or a selector string.
1164
- * @returns {TinyHtmlElement}
1131
+ * @template {TinyHtmlElement} T
1132
+ * @param {T} el - The element or a selector string.
1133
+ * @returns {T}
1165
1134
  */
1166
- static focus(el: TinyHtmlElement): TinyHtmlElement;
1135
+ static focus<T extends TinyHtmlElement>(el: T): T;
1167
1136
  /**
1168
1137
  * Blur the element.
1169
1138
  *
1170
- * @param {TinyHtmlElement} el - The element or a selector string.
1171
- * @returns {TinyHtmlElement}
1139
+ * @template {TinyHtmlElement} T
1140
+ * @param {T} el - The element or a selector string.
1141
+ * @returns {T}
1172
1142
  */
1173
- static blur(el: TinyHtmlElement): TinyHtmlElement;
1143
+ static blur<T extends TinyHtmlElement>(el: T): T;
1174
1144
  /**
1175
1145
  * Select the text content of an input or textarea element.
1176
1146
  *
1177
- * @param {TinyHtml|HTMLInputElement|HTMLTextAreaElement} el - The element or a selector string.
1178
- * @returns {TinyHtml|HTMLInputElement|HTMLTextAreaElement}
1147
+ * @template {TinyHtmlAny|HTMLInputElement|HTMLTextAreaElement} T
1148
+ * @param {T} el - The element or a selector string.
1149
+ * @returns {T}
1179
1150
  */
1180
- static select(el: TinyHtml | HTMLInputElement | HTMLTextAreaElement): TinyHtml | HTMLInputElement | HTMLTextAreaElement;
1151
+ static select<T extends TinyHtmlAny | HTMLInputElement | HTMLTextAreaElement>(el: T): T;
1181
1152
  /**
1182
1153
  * Interprets a value as a boolean `true` if it matches a common truthy representation.
1183
1154
  *
@@ -1247,20 +1218,22 @@ declare class TinyHtml {
1247
1218
  static getDimension(el: TinyElementAndWinAndDoc, type: "width" | "height", extra?: "content" | "padding" | "border" | "margin"): number;
1248
1219
  /**
1249
1220
  * Sets the height of the element.
1250
- * @param {TinyHtmlElement} el - Target element.
1221
+ * @template {TinyHtmlElement} T
1222
+ * @param {T} el - Target element.
1251
1223
  * @param {string|number} value - Height value.
1252
1224
  * @throws {TypeError} If `value` is neither a string nor number.
1253
- * @returns {TinyHtmlElement}
1225
+ * @returns {T}
1254
1226
  */
1255
- static setHeight(el: TinyHtmlElement, value: string | number): TinyHtmlElement;
1227
+ static setHeight<T extends TinyHtmlElement>(el: T, value: string | number): T;
1256
1228
  /**
1257
1229
  * Sets the width of the element.
1258
- * @param {TinyHtmlElement} el - Target element.
1230
+ * @template {TinyHtmlElement} T
1231
+ * @param {T} el - Target element.
1259
1232
  * @param {string|number} value - Width value.
1260
1233
  * @throws {TypeError} If `value` is neither a string nor number.
1261
- * @returns {TinyHtmlElement}
1234
+ * @returns {T}
1262
1235
  */
1263
- static setWidth(el: TinyHtmlElement, value: string | number): TinyHtmlElement;
1236
+ static setWidth<T extends TinyHtmlElement>(el: T, value: string | number): T;
1264
1237
  /**
1265
1238
  * Returns content box height.
1266
1239
  * @param {TinyElementAndWinAndDoc} el - Target element.
@@ -1302,12 +1275,13 @@ declare class TinyHtml {
1302
1275
  /**
1303
1276
  * Applies an animation to one or multiple TinyElement instances.
1304
1277
  *
1305
- * @param {TinyElement|TinyElement[]} el - A single TinyElement or an array of TinyElements to animate.
1278
+ * @template {TinyElement|TinyElement[]} T
1279
+ * @param {T} el - A single TinyElement or an array of TinyElements to animate.
1306
1280
  * @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
1307
1281
  * @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
1308
- * @returns {TinyElement|TinyElement[]}
1282
+ * @returns {T}
1309
1283
  */
1310
- static animate(el: TinyElement | TinyElement[], keyframes: Keyframe[] | PropertyIndexedKeyframes | null, ops?: number | KeyframeAnimationOptions): TinyElement | TinyElement[];
1284
+ static animate<T extends TinyElement | TinyElement[]>(el: T, keyframes: Keyframe[] | PropertyIndexedKeyframes | null, ops?: number | KeyframeAnimationOptions): T;
1311
1285
  /**
1312
1286
  * Gets the offset of the element relative to the document.
1313
1287
  * @param {TinyElement} el - Target element.
@@ -1357,7 +1331,8 @@ declare class TinyHtml {
1357
1331
  *
1358
1332
  * If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
1359
1333
  *
1360
- * @param {TinyElementAndWindow | TinyElementAndWindow[]} el - A single element, array of elements, or the window to scroll.
1334
+ * @template {TinyElementAndWindow|TinyElementAndWindow[]} T
1335
+ * @param {T} el - A single element, array of elements, or the window to scroll.
1361
1336
  * @param {Object} [settings={}] - Configuration object for the scroll animation.
1362
1337
  * @param {number} [settings.targetX] - The horizontal scroll target in pixels.
1363
1338
  * @param {number} [settings.targetY] - The vertical scroll target in pixels.
@@ -1365,34 +1340,36 @@ declare class TinyHtml {
1365
1340
  * @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
1366
1341
  * @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
1367
1342
  * frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
1368
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
1343
+ * @returns {T}
1369
1344
  * @throws {TypeError} If `el` is not a valid element, array, or window.
1370
1345
  * @throws {TypeError} If `targetX` or `targetY` is defined but not a number.
1371
1346
  * @throws {TypeError} If `duration` is defined but not a number.
1372
1347
  * @throws {TypeError} If `easing` is defined but not a valid easing function name.
1373
1348
  * @throws {TypeError} If `onAnimation` is defined but not a function.
1374
1349
  */
1375
- static scrollToXY(el: TinyElementAndWindow | TinyElementAndWindow[], { targetX, targetY, duration, easing, onAnimation }?: {
1350
+ static scrollToXY<T extends TinyElementAndWindow | TinyElementAndWindow[]>(el: T, { targetX, targetY, duration, easing, onAnimation }?: {
1376
1351
  targetX?: number | undefined;
1377
1352
  targetY?: number | undefined;
1378
1353
  duration?: number | undefined;
1379
1354
  easing?: Easings | undefined;
1380
1355
  onAnimation?: OnScrollAnimation | undefined;
1381
- }): TinyElementAndWindow | TinyElementAndWindow[];
1356
+ }): T;
1382
1357
  /**
1383
1358
  * Sets the vertical scroll position.
1384
- * @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
1359
+ * @template {TinyElementAndWindow|TinyElementAndWindow[]} T
1360
+ * @param {T} el - Element or window.
1385
1361
  * @param {number} value - Scroll top value.
1386
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
1362
+ * @returns {T}
1387
1363
  */
1388
- static setScrollTop(el: TinyElementAndWindow | TinyElementAndWindow[], value: number): TinyElementAndWindow | TinyElementAndWindow[];
1364
+ static setScrollTop<T extends TinyElementAndWindow | TinyElementAndWindow[]>(el: T, value: number): T;
1389
1365
  /**
1390
1366
  * Sets the horizontal scroll position.
1391
- * @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
1367
+ * @template {TinyElementAndWindow|TinyElementAndWindow[]} T
1368
+ * @param {T} el - Element or window.
1392
1369
  * @param {number} value - Scroll left value.
1393
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
1370
+ * @returns {T}
1394
1371
  */
1395
- static setScrollLeft(el: TinyElementAndWindow | TinyElementAndWindow[], value: number): TinyElementAndWindow | TinyElementAndWindow[];
1372
+ static setScrollLeft<T extends TinyElementAndWindow | TinyElementAndWindow[]>(el: T, value: number): T;
1396
1373
  /**
1397
1374
  * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
1398
1375
  *
@@ -1421,8 +1398,22 @@ declare class TinyHtml {
1421
1398
  * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
1422
1399
  */
1423
1400
  static padding(el: TinyElement): HtmlElBoxSides;
1424
- static addClass(el: TinyElement | TinyElement[], ...tokens: string[]): (TinyElement | TinyElement[]);
1425
- static removeClass(el: TinyElement | TinyElement[], ...tokens: string[]): (TinyElement | TinyElement[]);
1401
+ /**
1402
+ * Adds one or more CSS class names to the element.
1403
+ * @template {TinyElement|TinyElement[]} T
1404
+ * @param {T} el
1405
+ * @param {...string} args - One or more class names to add.
1406
+ * @returns {T}
1407
+ */
1408
+ static addClass<T extends TinyElement | TinyElement[]>(el: T, ...args: string[]): T;
1409
+ /**
1410
+ * Removes one or more CSS class names from the element.
1411
+ * @template {TinyElement|TinyElement[]} T
1412
+ * @param {T} el
1413
+ * @param {...string} args - One or more class names to remove.
1414
+ * @returns {T}
1415
+ */
1416
+ static removeClass<T extends TinyElement | TinyElement[]>(el: T, ...args: string[]): T;
1426
1417
  /**
1427
1418
  * Replaces an existing class name with a new one.
1428
1419
  * @param {TinyElement|TinyElement[]} el - Target element.
@@ -1489,11 +1480,12 @@ declare class TinyHtml {
1489
1480
  static toBigInt(el: TinyElement): bigint | null;
1490
1481
  /**
1491
1482
  * Set BigInt content of elements.
1492
- * @param {TinyElement|TinyElement[]} el
1483
+ * @template {TinyElement|TinyElement[]} T
1484
+ * @param {T} el
1493
1485
  * @param {bigint} value
1494
- * @returns {TinyElement|TinyElement[]}
1486
+ * @returns {T}
1495
1487
  */
1496
- static setBigInt(el: TinyElement | TinyElement[], value: bigint): TinyElement | TinyElement[];
1488
+ static setBigInt<T extends TinyElement | TinyElement[]>(el: T, value: bigint): T;
1497
1489
  /**
1498
1490
  * Returns the Date content of the element.
1499
1491
  * @param {TinyElement} el - Target element.
@@ -1502,11 +1494,12 @@ declare class TinyHtml {
1502
1494
  static toDate(el: TinyElement): Date | null;
1503
1495
  /**
1504
1496
  * Set Date content of elements.
1505
- * @param {TinyElement|TinyElement[]} el
1497
+ * @template {TinyElement|TinyElement[]} T
1498
+ * @param {T} el
1506
1499
  * @param {Date} value
1507
- * @returns {TinyElement|TinyElement[]}
1500
+ * @returns {T}
1508
1501
  */
1509
- static setDate(el: TinyElement | TinyElement[], value: Date): TinyElement | TinyElement[];
1502
+ static setDate<T extends TinyElement | TinyElement[]>(el: T, value: Date): T;
1510
1503
  /**
1511
1504
  * Returns the JSON content of the element.
1512
1505
  * @param {TinyElement} el - Target element.
@@ -1515,13 +1508,14 @@ declare class TinyHtml {
1515
1508
  static toJson(el: TinyElement): any | null;
1516
1509
  /**
1517
1510
  * Set JSON content of elements.
1518
- * @param {TinyElement|TinyElement[]} el
1511
+ * @template {TinyElement|TinyElement[]} T
1512
+ * @param {T} el
1519
1513
  * @param {any} value - A JavaScript value, usually an object or array, to be converted.
1520
1514
  * @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
1521
1515
  * @param {number|string} [space] - Indentation level or string for formatting.
1522
- * @returns {TinyElement|TinyElement[]}
1516
+ * @returns {T}
1523
1517
  */
1524
- static setJson(el: TinyElement | TinyElement[], value: any, replacer?: (this: any, key: string, value: any) => any, space?: number | string): TinyElement | TinyElement[];
1518
+ static setJson<T extends TinyElement | TinyElement[]>(el: T, value: any, replacer?: (this: any, key: string, value: any) => any, space?: number | string): T;
1525
1519
  /**
1526
1520
  * Returns the number content of the element.
1527
1521
  * @param {TinyElement} el - Target element.
@@ -1530,11 +1524,12 @@ declare class TinyHtml {
1530
1524
  static toNumber(el: TinyElement): number | null;
1531
1525
  /**
1532
1526
  * Set number content of elements.
1533
- * @param {TinyElement|TinyElement[]} el
1527
+ * @template {TinyElement|TinyElement[]} T
1528
+ * @param {T} el
1534
1529
  * @param {number} value
1535
- * @returns {TinyElement|TinyElement[]}
1530
+ * @returns {T}
1536
1531
  */
1537
- static setNumber(el: TinyElement | TinyElement[], value: number): TinyElement | TinyElement[];
1532
+ static setNumber<T extends TinyElement | TinyElement[]>(el: T, value: number): T;
1538
1533
  /**
1539
1534
  * Returns the boolean content of the element.
1540
1535
  * @param {TinyElement} el - Target element.
@@ -1543,11 +1538,12 @@ declare class TinyHtml {
1543
1538
  static toBoolean(el: TinyElement): boolean | null;
1544
1539
  /**
1545
1540
  * Set boolean content of elements.
1546
- * @param {TinyElement|TinyElement[]} el
1541
+ * @template {TinyElement|TinyElement[]} T
1542
+ * @param {T} el
1547
1543
  * @param {boolean} value
1548
- * @returns {TinyElement|TinyElement[]}
1544
+ * @returns {T}
1549
1545
  */
1550
- static setBoolean(el: TinyElement | TinyElement[], value: boolean): TinyElement | TinyElement[];
1546
+ static setBoolean<T extends TinyElement | TinyElement[]>(el: T, value: boolean): T;
1551
1547
  /**
1552
1548
  * Returns the string content of the element.
1553
1549
  * @param {TinyElement} el - Target element.
@@ -1556,11 +1552,12 @@ declare class TinyHtml {
1556
1552
  static toString(el: TinyElement): string | null;
1557
1553
  /**
1558
1554
  * Set string content of elements.
1559
- * @param {TinyElement|TinyElement[]} el
1555
+ * @template {TinyElement|TinyElement[]} T
1556
+ * @param {T} el
1560
1557
  * @param {string} value
1561
- * @returns {TinyElement|TinyElement[]}
1558
+ * @returns {T}
1562
1559
  */
1563
- static setString(el: TinyElement | TinyElement[], value: string): TinyElement | TinyElement[];
1560
+ static setString<T extends TinyElement | TinyElement[]>(el: T, value: string): T;
1564
1561
  /**
1565
1562
  * Returns the text content of the element.
1566
1563
  * @param {TinyElement} el - Target element.
@@ -1569,17 +1566,19 @@ declare class TinyHtml {
1569
1566
  static text(el: TinyElement): string | null;
1570
1567
  /**
1571
1568
  * Set text content of elements.
1572
- * @param {TinyElement|TinyElement[]} el
1569
+ * @template {TinyElement|TinyElement[]} T
1570
+ * @param {T} el
1573
1571
  * @param {*} value
1574
- * @returns {TinyElement|TinyElement[]}
1572
+ * @returns {T}
1575
1573
  */
1576
- static setText(el: TinyElement | TinyElement[], value: any): TinyElement | TinyElement[];
1574
+ static setText<T extends TinyElement | TinyElement[]>(el: T, value: any): T;
1577
1575
  /**
1578
1576
  * Remove all child nodes from each element.
1579
- * @param {TinyElement|TinyElement[]} el
1580
- * @returns {TinyElement|TinyElement[]}
1577
+ * @template {TinyElement|TinyElement[]} T
1578
+ * @param {T} el
1579
+ * @returns {T}
1581
1580
  */
1582
- static empty(el: TinyElement | TinyElement[]): TinyElement | TinyElement[];
1581
+ static empty<T extends TinyElement | TinyElement[]>(el: T): T;
1583
1582
  /**
1584
1583
  * Get the innerHTML of the element.
1585
1584
  * @param {TinyElement} el
@@ -1589,11 +1588,12 @@ declare class TinyHtml {
1589
1588
  static html(el: TinyElement, ops?: GetHTMLOptions): string;
1590
1589
  /**
1591
1590
  * Set the innerHTML of each element.
1592
- * @param {TinyElement|TinyElement[]} el
1591
+ * @template {TinyElement|TinyElement[]} T
1592
+ * @param {T} el
1593
1593
  * @param {string} value
1594
- * @returns {TinyElement|TinyElement[]}
1594
+ * @returns {T}
1595
1595
  */
1596
- static setHtml(el: TinyElement | TinyElement[], value: string): TinyElement | TinyElement[];
1596
+ static setHtml<T extends TinyElement | TinyElement[]>(el: T, value: string): T;
1597
1597
  /** @readonly */
1598
1598
  static readonly _valHooks: {
1599
1599
  option: {
@@ -1644,12 +1644,13 @@ declare class TinyHtml {
1644
1644
  * Sets the value of the current HTML value element (input, select, textarea, etc.).
1645
1645
  * Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
1646
1646
  *
1647
- * @param {TinyInputElement|TinyInputElement[]} el - Target element.
1647
+ * @template {TinyInputElement|TinyInputElement[]} T
1648
+ * @param {T} el - Target element.
1648
1649
  * @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
1649
1650
  * @throws {Error} If the computed value is not a valid string or boolean.
1650
- * @returns {TinyInputElement|TinyInputElement[]}
1651
+ * @returns {T}
1651
1652
  */
1652
- static setVal(el: TinyInputElement | TinyInputElement[], value: SetValueList | ((el: InputElement, val: SetValueList) => SetValueList)): TinyInputElement | TinyInputElement[];
1653
+ static setVal<T extends TinyInputElement | TinyInputElement[]>(el: T, value: SetValueList | ((el: InputElement, val: SetValueList) => SetValueList)): T;
1653
1654
  /**
1654
1655
  * Maps value types to their corresponding getter functions.
1655
1656
  * Each function extracts a value of a specific type from a compatible HTMLInputElement.
@@ -1796,59 +1797,65 @@ declare class TinyHtml {
1796
1797
  /**
1797
1798
  * Registers an event listener on the specified element.
1798
1799
  *
1799
- * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
1800
+ * @template {TinyEventTarget|TinyEventTarget[]} T
1801
+ * @param {T} el - The target to listen on.
1800
1802
  * @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
1801
1803
  * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
1802
1804
  * @param {EventRegistryOptions} [options] - Optional event listener options.
1803
- * @returns {TinyEventTarget|TinyEventTarget[]}
1805
+ * @returns {T}
1804
1806
  */
1805
- static on(el: TinyEventTarget | TinyEventTarget[], events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: EventRegistryOptions): TinyEventTarget | TinyEventTarget[];
1807
+ static on<T extends TinyEventTarget | TinyEventTarget[]>(el: T, events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: EventRegistryOptions): T;
1806
1808
  /**
1807
1809
  * Registers an event listener that runs only once, then is removed.
1808
1810
  *
1809
- * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
1811
+ * @template {TinyEventTarget|TinyEventTarget[]} T
1812
+ * @param {T} el - The target to listen on.
1810
1813
  * @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
1811
1814
  * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
1812
1815
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
1813
- * @returns {TinyEventTarget|TinyEventTarget[]}
1816
+ * @returns {T}
1814
1817
  */
1815
- static once(el: TinyEventTarget | TinyEventTarget[], events: string | string[], handler: EventListenerOrEventListenerObject, options?: EventRegistryOptions): TinyEventTarget | TinyEventTarget[];
1818
+ static once<T extends TinyEventTarget | TinyEventTarget[]>(el: T, events: string | string[], handler: EventListenerOrEventListenerObject, options?: EventRegistryOptions): T;
1816
1819
  /**
1817
1820
  * Removes a specific event listener from an element.
1818
1821
  *
1819
- * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
1822
+ * @template {TinyEventTarget|TinyEventTarget[]} T
1823
+ * @param {T} el - The target element.
1820
1824
  * @param {string|string[]} events - The event type.
1821
1825
  * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
1822
1826
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
1823
- * @returns {TinyEventTarget|TinyEventTarget[]}
1827
+ * @returns {T}
1824
1828
  */
1825
- static off(el: TinyEventTarget | TinyEventTarget[], events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): TinyEventTarget | TinyEventTarget[];
1829
+ static off<T extends TinyEventTarget | TinyEventTarget[]>(el: T, events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): T;
1826
1830
  /**
1827
1831
  * Removes all event listeners of a specific type from the element.
1828
1832
  *
1829
- * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
1833
+ * @template {TinyEventTarget|TinyEventTarget[]} T
1834
+ * @param {T} el - The target element.
1830
1835
  * @param {string|string[]} events - The event type to remove (e.g. 'click').
1831
- * @returns {TinyEventTarget|TinyEventTarget[]}
1836
+ * @returns {T}
1832
1837
  */
1833
- static offAll(el: TinyEventTarget | TinyEventTarget[], events: string | string[]): TinyEventTarget | TinyEventTarget[];
1838
+ static offAll<T extends TinyEventTarget | TinyEventTarget[]>(el: T, events: string | string[]): T;
1834
1839
  /**
1835
1840
  * Removes all event listeners of all types from the element.
1836
1841
  *
1837
- * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
1842
+ * @template {TinyEventTarget|TinyEventTarget[]} T
1843
+ * @param {T} el - The target element.
1838
1844
  * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
1839
1845
  * Optional filter function to selectively remove specific handlers.
1840
- * @returns {TinyEventTarget|TinyEventTarget[]}
1846
+ * @returns {T}
1841
1847
  */
1842
- static offAllTypes(el: TinyEventTarget | TinyEventTarget[], filterFn?: ((handler: EventListenerOrEventListenerObject | null, event: string) => boolean) | null): TinyEventTarget | TinyEventTarget[];
1848
+ static offAllTypes<T extends TinyEventTarget | TinyEventTarget[]>(el: T, filterFn?: ((handler: EventListenerOrEventListenerObject | null, event: string) => boolean) | null): T;
1843
1849
  /**
1844
1850
  * Triggers all handlers associated with a specific event on the given element.
1845
1851
  *
1846
- * @param {TinyEventTarget|TinyEventTarget[]} el - Target element where the event should be triggered.
1852
+ * @template {TinyEventTarget|TinyEventTarget[]} T
1853
+ * @param {T} el - Target element where the event should be triggered.
1847
1854
  * @param {string|string[]} events - Name of the event to trigger.
1848
1855
  * @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
1849
- * @returns {TinyEventTarget|TinyEventTarget[]}
1856
+ * @returns {T}
1850
1857
  */
1851
- static trigger(el: TinyEventTarget | TinyEventTarget[], events: string | string[], payload?: Event | CustomEvent | CustomEventInit): TinyEventTarget | TinyEventTarget[];
1858
+ static trigger<T extends TinyEventTarget | TinyEventTarget[]>(el: T, events: string | string[], payload?: Event | CustomEvent | CustomEventInit): T;
1852
1859
  /**
1853
1860
  * Internal property name normalization map (similar to jQuery's `propFix`).
1854
1861
  * Maps attribute-like names to their JavaScript DOM property equivalents.
@@ -1905,19 +1912,21 @@ declare class TinyHtml {
1905
1912
  static attr(el: TinyElement, name: string): string | null;
1906
1913
  /**
1907
1914
  * Set an attribute on an element.
1908
- * @param {TinyElement|TinyElement[]} el
1915
+ * @template {TinyElement|TinyElement[]} T
1916
+ * @param {T} el
1909
1917
  * @param {string} name
1910
1918
  * @param {string|null} [value=null]
1911
- * @returns {TinyElement|TinyElement[]}
1919
+ * @returns {T}
1912
1920
  */
1913
- static setAttr(el: TinyElement | TinyElement[], name: string, value?: string | null): TinyElement | TinyElement[];
1921
+ static setAttr<T extends TinyElement | TinyElement[]>(el: T, name: string, value?: string | null): T;
1914
1922
  /**
1915
1923
  * Remove attribute(s) from an element.
1916
- * @param {TinyElement|TinyElement[]} el
1924
+ * @template {TinyElement|TinyElement[]} T
1925
+ * @param {T} el
1917
1926
  * @param {string} name Space-separated list of attributes.
1918
- * @returns {TinyElement|TinyElement[]}
1927
+ * @returns {T}
1919
1928
  */
1920
- static removeAttr(el: TinyElement | TinyElement[], name: string): TinyElement | TinyElement[];
1929
+ static removeAttr<T extends TinyElement | TinyElement[]>(el: T, name: string): T;
1921
1930
  /**
1922
1931
  * Check if an attribute exists on an element.
1923
1932
  * @param {TinyElement} el
@@ -1934,31 +1943,36 @@ declare class TinyHtml {
1934
1943
  static hasProp(el: TinyElement, name: string): boolean;
1935
1944
  /**
1936
1945
  * Set a property on an element.
1937
- * @param {TinyElement|TinyElement[]} el
1946
+ * @template {TinyElement|TinyElement[]} T
1947
+ * @param {T} el
1938
1948
  * @param {string} name
1939
- * @returns {TinyElement|TinyElement[]}
1949
+ * @returns {T}
1940
1950
  */
1941
- static addProp(el: TinyElement | TinyElement[], name: string): TinyElement | TinyElement[];
1951
+ static addProp<T extends TinyElement | TinyElement[]>(el: T, name: string): T;
1942
1952
  /**
1943
1953
  * Remove a property from an element.
1944
- * @param {TinyElement|TinyElement[]} el
1954
+ * @template {TinyElement|TinyElement[]} T
1955
+ * @param {T} el
1945
1956
  * @param {string} name
1946
- * @returns {TinyElement|TinyElement[]}
1957
+ * @returns {T}
1947
1958
  */
1948
- static removeProp(el: TinyElement | TinyElement[], name: string): TinyElement | TinyElement[];
1959
+ static removeProp<T extends TinyElement | TinyElement[]>(el: T, name: string): T;
1949
1960
  /**
1950
1961
  * Toggle a boolean property.
1951
- * @param {TinyElement|TinyElement[]} el
1962
+ * @template {TinyElement|TinyElement[]} T
1963
+ * @param {T} el
1952
1964
  * @param {string} name
1953
1965
  * @param {boolean} [force]
1966
+ * @returns {T}
1954
1967
  */
1955
- static toggleProp(el: TinyElement | TinyElement[], name: string, force?: boolean): void;
1968
+ static toggleProp<T extends TinyElement | TinyElement[]>(el: T, name: string, force?: boolean): T;
1956
1969
  /**
1957
1970
  * Removes an element from the DOM.
1958
- * @param {TinyElement|TinyElement[]} el - The DOM element or selector to remove.
1959
- * @returns {TinyElement|TinyElement[]}
1971
+ * @template {TinyElement|TinyElement[]} T
1972
+ * @param {T} el - The DOM element or selector to remove.
1973
+ * @returns {T}
1960
1974
  */
1961
- static remove(el: TinyElement | TinyElement[]): TinyElement | TinyElement[];
1975
+ static remove<T extends TinyElement | TinyElement[]>(el: T): T;
1962
1976
  /**
1963
1977
  * Returns the index of the first element within its parent or relative to a selector/element.
1964
1978
  *
@@ -2093,45 +2107,45 @@ declare class TinyHtml {
2093
2107
  /**
2094
2108
  * Creates an instance of TinyHtml for a specific Element.
2095
2109
  * Useful when you want to operate repeatedly on the same element using instance methods.
2096
- * @param {ConstructorElValues|ConstructorElValues[]|NodeListOf<Element>|HTMLCollectionOf<Element>|NodeListOf<HTMLElement>} el - The element to wrap and manipulate.
2110
+ * @param {TinyHtmlT} el - The element to wrap and manipulate.
2097
2111
  */
2098
- constructor(el: ConstructorElValues | ConstructorElValues[] | NodeListOf<Element> | HTMLCollectionOf<Element> | NodeListOf<HTMLElement>);
2112
+ constructor(el: TinyHtmlT);
2099
2113
  /**
2100
2114
  * Queries the element for the first element matching the CSS selector and wraps it in a TinyHtml instance.
2101
2115
  *
2102
2116
  * @param {string} selector - A valid CSS selector string.
2103
- * @returns {TinyHtml|null} A TinyHtml instance wrapping the matched element.
2117
+ * @returns {TinyHtml<Element>|null} A TinyHtml instance wrapping the matched element.
2104
2118
  */
2105
- querySelector(selector: string): TinyHtml | null;
2119
+ querySelector(selector: string): TinyHtml<Element> | null;
2106
2120
  /**
2107
2121
  * Queries the element for all elements matching the CSS selector and wraps them in TinyHtml instances.
2108
2122
  *
2109
2123
  * @param {string} selector - A valid CSS selector string.
2110
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the matched elements.
2124
+ * @returns {TinyHtml<NodeListOf<Element>>} An array of TinyHtml instances wrapping the matched elements.
2111
2125
  */
2112
- querySelectorAll(selector: string): TinyHtml;
2126
+ querySelectorAll(selector: string): TinyHtml<NodeListOf<Element>>;
2113
2127
  /**
2114
2128
  * Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
2115
2129
  *
2116
2130
  * @param {string} selector - The class name to search for.
2117
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
2131
+ * @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
2118
2132
  */
2119
- getElementsByClassName(selector: string): TinyHtml;
2133
+ getElementsByClassName(selector: string): TinyHtml<HTMLCollectionOf<Element>>;
2120
2134
  /**
2121
2135
  * Retrieves all elements with the specified local tag name within the given namespace URI,
2122
2136
  * and wraps them in TinyHtml instances.
2123
2137
  *
2124
2138
  * @param {string} localName - The local name (tag) of the elements to search for.
2125
2139
  * @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
2126
- * @returns {TinyHtml} An array of TinyHtml instances wrapping the found elements.
2140
+ * @returns {TinyHtml<HTMLCollectionOf<Element>>} An array of TinyHtml instances wrapping the found elements.
2127
2141
  */
2128
- getElementsByTagNameNS(localName: string, namespaceURI?: string | null): TinyHtml;
2142
+ getElementsByTagNameNS(localName: string, namespaceURI?: string | null): TinyHtml<HTMLCollectionOf<Element>>;
2129
2143
  /**
2130
2144
  * Iterates over all elements, executing the provided callback on each.
2131
- * @param {(element: TinyHtml, index: number, items: TinyHtml[]) => void} callback - Function invoked for each element.
2132
- * @returns {TinyHtml} The current instance for chaining.
2145
+ * @param {(element: TinyHtmlAny, index: number, items: TinyHtmlAny[]) => void} callback - Function invoked for each element.
2146
+ * @returns {this} The current instance for chaining.
2133
2147
  */
2134
- forEach(callback: (element: TinyHtml, index: number, items: TinyHtml[]) => void): TinyHtml;
2148
+ forEach(callback: (element: TinyHtmlAny, index: number, items: TinyHtmlAny[]) => void): this;
2135
2149
  /**
2136
2150
  * Returns the current target held by this instance.
2137
2151
  *
@@ -2143,9 +2157,9 @@ declare class TinyHtml {
2143
2157
  * Extracts a single DOM element from the internal list at the specified index.
2144
2158
  *
2145
2159
  * @param {number} index - The index of the element to extract.
2146
- * @returns {TinyHtml} A new TinyHtml instance wrapping the extracted element.
2160
+ * @returns {TinyHtmlAny} A new TinyHtml instance wrapping the extracted element.
2147
2161
  */
2148
- extract(index: number): TinyHtml;
2162
+ extract(index: number): TinyHtmlAny;
2149
2163
  /**
2150
2164
  * Checks whether the element exists at the given index.
2151
2165
  *
@@ -2248,9 +2262,9 @@ declare class TinyHtml {
2248
2262
  * @param {string} key - The key under which the data will be stored.
2249
2263
  * @param {any} value - The value to store.
2250
2264
  * @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
2251
- * @returns {TinyElement}
2265
+ * @returns {this}
2252
2266
  */
2253
- setData(key: string, value: any, isPrivate?: boolean): TinyElement;
2267
+ setData(key: string, value: any, isPrivate?: boolean): this;
2254
2268
  /**
2255
2269
  * Returns the direct parent node of the given element, excluding document fragments.
2256
2270
  *
@@ -2330,75 +2344,75 @@ declare class TinyHtml {
2330
2344
  * Appends child elements or strings to the end of the target element(s).
2331
2345
  *
2332
2346
  * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
2333
- * @returns {TinyElement}
2347
+ * @returns {this}
2334
2348
  */
2335
- append(...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
2349
+ append(...children: (TinyNode | TinyNode[] | string)[]): this;
2336
2350
  /**
2337
2351
  * Prepends child elements or strings to the beginning of the target element(s).
2338
2352
  *
2339
2353
  * @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
2340
- * @returns {TinyElement}
2354
+ * @returns {this}
2341
2355
  */
2342
- prepend(...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
2356
+ prepend(...children: (TinyNode | TinyNode[] | string)[]): this;
2343
2357
  /**
2344
2358
  * Inserts elements or strings immediately before the target element(s) in the DOM.
2345
2359
  *
2346
2360
  * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
2347
- * @returns {TinyElement}
2361
+ * @returns {this}
2348
2362
  */
2349
- before(...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
2363
+ before(...children: (TinyNode | TinyNode[] | string)[]): this;
2350
2364
  /**
2351
2365
  * Inserts elements or strings immediately after the target element(s) in the DOM.
2352
2366
  *
2353
2367
  * @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
2354
- * @returns {TinyElement}
2368
+ * @returns {this}
2355
2369
  */
2356
- after(...children: (TinyNode | TinyNode[] | string)[]): TinyElement;
2370
+ after(...children: (TinyNode | TinyNode[] | string)[]): this;
2357
2371
  /**
2358
2372
  * Replaces the target element(s) in the DOM with new elements or text.
2359
2373
  *
2360
2374
  * @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
2361
- * @returns {TinyElement}
2375
+ * @returns {this}
2362
2376
  */
2363
- replaceWith(...newNodes: (TinyNode | TinyNode[] | string)[]): TinyElement;
2377
+ replaceWith(...newNodes: (TinyNode | TinyNode[] | string)[]): this;
2364
2378
  /**
2365
2379
  * Appends the given element(s) to each target element in sequence.
2366
2380
  *
2367
2381
  * @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
2368
- * @returns {TinyNode|TinyNode[]}
2382
+ * @returns {this}
2369
2383
  */
2370
- appendTo(targets: TinyNode | TinyNode[]): TinyNode | TinyNode[];
2384
+ appendTo(targets: TinyNode | TinyNode[]): this;
2371
2385
  /**
2372
2386
  * Prepends the given element(s) to each target element in sequence.
2373
2387
  *
2374
2388
  * @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
2375
- * @returns {TinyElement|TinyElement[]}
2389
+ * @returns {this}
2376
2390
  */
2377
- prependTo(targets: TinyElement | TinyElement[]): TinyElement | TinyElement[];
2391
+ prependTo(targets: TinyElement | TinyElement[]): this;
2378
2392
  /**
2379
2393
  * Inserts the element before a child of a given target, or before the target itself.
2380
2394
  *
2381
2395
  * @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
2382
2396
  * @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
2383
- * @returns {TinyNode|TinyNode[]}
2397
+ * @returns {this}
2384
2398
  */
2385
- insertBefore(target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): TinyNode | TinyNode[];
2399
+ insertBefore(target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): this;
2386
2400
  /**
2387
2401
  * Inserts the element after a child of a given target, or after the target itself.
2388
2402
  *
2389
2403
  * @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
2390
2404
  * @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
2391
- * @returns {TinyNode|TinyNode[]}
2405
+ * @returns {this}
2392
2406
  */
2393
- insertAfter(target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): TinyNode | TinyNode[];
2407
+ insertAfter(target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): this;
2394
2408
  /**
2395
2409
  * Replaces all target elements with the provided element(s).
2396
2410
  * If multiple targets exist, the inserted elements are cloned accordingly.
2397
2411
  *
2398
2412
  * @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
2399
- * @returns {TinyNode|TinyNode[]}
2413
+ * @returns {this}
2400
2414
  */
2401
- replaceAll(targets: TinyNode | TinyNode[]): TinyNode | TinyNode[];
2415
+ replaceAll(targets: TinyNode | TinyNode[]): this;
2402
2416
  /**
2403
2417
  * Returns the number of elements currently stored in the internal element list.
2404
2418
  *
@@ -2445,9 +2459,9 @@ declare class TinyHtml {
2445
2459
  *
2446
2460
  * @param {string|Object} prop - The property name or an object with key-value pairs
2447
2461
  * @param {string|null} [value=null] - The value to set (if `prop` is a string)
2448
- * @returns {TinyHtmlElement|TinyHtmlElement[]}
2462
+ * @returns {this}
2449
2463
  */
2450
- setStyle(prop: string | Object, value?: string | null): TinyHtmlElement | TinyHtmlElement[];
2464
+ setStyle(prop: string | Object, value?: string | null): this;
2451
2465
  /**
2452
2466
  * Gets the value of a specific inline style property.
2453
2467
  *
@@ -2475,9 +2489,9 @@ declare class TinyHtml {
2475
2489
  * Removes one or more inline CSS properties from the given element(s).
2476
2490
  *
2477
2491
  * @param {string|string[]} prop - A property name or an array of property names to remove.
2478
- * @returns {TinyHtmlElement|TinyHtmlElement[]}
2492
+ * @returns {this}
2479
2493
  */
2480
- removeStyle(prop: string | string[]): TinyHtmlElement | TinyHtmlElement[];
2494
+ removeStyle(prop: string | string[]): this;
2481
2495
  /**
2482
2496
  * Toggles a CSS property value between two given values.
2483
2497
  *
@@ -2486,29 +2500,29 @@ declare class TinyHtml {
2486
2500
  * @param {string} prop - The CSS property to toggle.
2487
2501
  * @param {string} val1 - The first value (used as "current" check).
2488
2502
  * @param {string} val2 - The second value (used as the "alternative").
2489
- * @returns {TinyHtmlElement|TinyHtmlElement[]}
2503
+ * @returns {this}
2490
2504
  */
2491
- toggleStyle(prop: string, val1: string, val2: string): TinyHtmlElement | TinyHtmlElement[];
2505
+ toggleStyle(prop: string, val1: string, val2: string): this;
2492
2506
  /**
2493
2507
  * Removes all inline styles (`style` attribute) from the given element(s).
2494
- * @returns {TinyElement|TinyElement[]}
2508
+ * @returns {this}
2495
2509
  */
2496
- clearStyle(): TinyElement | TinyElement[];
2510
+ clearStyle(): this;
2497
2511
  /**
2498
2512
  * Focus the element.
2499
- * @returns {TinyHtmlElement}
2513
+ * @returns {this}
2500
2514
  */
2501
- focus(): TinyHtmlElement;
2515
+ focus(): this;
2502
2516
  /**
2503
2517
  * Blur the element.
2504
- * @returns {TinyHtmlElement}
2518
+ * @returns {this}
2505
2519
  */
2506
- blur(): TinyHtmlElement;
2520
+ blur(): this;
2507
2521
  /**
2508
2522
  * Select the text content of an input or textarea element.
2509
- * @returns {TinyHtml|HTMLInputElement|HTMLTextAreaElement}
2523
+ * @returns {this}
2510
2524
  */
2511
- select(): TinyHtml | HTMLInputElement | HTMLTextAreaElement;
2525
+ select(): this;
2512
2526
  /**
2513
2527
  * Gets the width or height of an element based on the box model.
2514
2528
  * @param {"width"|"height"} type - Dimension type.
@@ -2519,15 +2533,15 @@ declare class TinyHtml {
2519
2533
  /**
2520
2534
  * Sets the height of the element.
2521
2535
  * @param {string|number} value - Height value.
2522
- * @returns {TinyHtmlElement}
2536
+ * @returns {this}
2523
2537
  */
2524
- setHeight(value: string | number): TinyHtmlElement;
2538
+ setHeight(value: string | number): this;
2525
2539
  /**
2526
2540
  * Sets the width of the element.
2527
2541
  * @param {string|number} value - Width value.
2528
- * @returns {TinyHtmlElement}
2542
+ * @returns {this}
2529
2543
  */
2530
- setWidth(value: string | number): TinyHtmlElement;
2544
+ setWidth(value: string | number): this;
2531
2545
  /**
2532
2546
  * Returns content box height.
2533
2547
  * @returns {number}
@@ -2565,9 +2579,9 @@ declare class TinyHtml {
2565
2579
  *
2566
2580
  * @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
2567
2581
  * @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
2568
- * @returns {TinyElement|TinyElement[]}
2582
+ * @returns {this}
2569
2583
  */
2570
- animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, ops?: number | KeyframeAnimationOptions): TinyElement | TinyElement[];
2584
+ animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, ops?: number | KeyframeAnimationOptions): this;
2571
2585
  /**
2572
2586
  * Gets the offset of the element relative to the document.
2573
2587
  * @returns {{top: number, left: number}}
@@ -2612,7 +2626,7 @@ declare class TinyHtml {
2612
2626
  * @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
2613
2627
  * @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
2614
2628
  * frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
2615
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
2629
+ * @returns {this}
2616
2630
  */
2617
2631
  scrollToXY({ targetX, targetY, duration, easing, onAnimation }?: {
2618
2632
  targetX?: number | undefined;
@@ -2620,19 +2634,19 @@ declare class TinyHtml {
2620
2634
  duration?: number | undefined;
2621
2635
  easing?: Easings | undefined;
2622
2636
  onAnimation?: OnScrollAnimation | undefined;
2623
- }): TinyElementAndWindow | TinyElementAndWindow[];
2637
+ }): this;
2624
2638
  /**
2625
2639
  * Sets the vertical scroll position.
2626
2640
  * @param {number} value - Scroll top value.
2627
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
2641
+ * @returns {this}
2628
2642
  */
2629
- setScrollTop(value: number): TinyElementAndWindow | TinyElementAndWindow[];
2643
+ setScrollTop(value: number): this;
2630
2644
  /**
2631
2645
  * Sets the horizontal scroll position.
2632
2646
  * @param {number} value - Scroll left value.
2633
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
2647
+ * @returns {this}
2634
2648
  */
2635
- setScrollLeft(value: number): TinyElementAndWindow | TinyElementAndWindow[];
2649
+ setScrollLeft(value: number): this;
2636
2650
  /**
2637
2651
  * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
2638
2652
  *
@@ -2657,8 +2671,18 @@ declare class TinyHtml {
2657
2671
  * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
2658
2672
  */
2659
2673
  padding(): HtmlElBoxSides;
2660
- addClass(...tokens: string[]): (TinyElement | TinyElement[]);
2661
- removeClass(...tokens: string[]): (TinyElement | TinyElement[]);
2674
+ /**
2675
+ * Adds one or more CSS class names to the element.
2676
+ * @param {...string} args - One or more class names to add.
2677
+ * @returns {this}
2678
+ */
2679
+ addClass(...args: string[]): this;
2680
+ /**
2681
+ * Removes one or more CSS class names from the element.
2682
+ * @param {...string} args - One or more class names to remove.
2683
+ * @returns {this}
2684
+ */
2685
+ removeClass(...args: string[]): this;
2662
2686
  /**
2663
2687
  * Replaces an existing class name with a new one.
2664
2688
  * @param {string} token - The class name to be replaced.
@@ -2717,9 +2741,9 @@ declare class TinyHtml {
2717
2741
  /**
2718
2742
  * Set BigInt content of the element.
2719
2743
  * @param {bigint} value
2720
- * @returns {TinyElement|TinyElement[]}
2744
+ * @returns {this}
2721
2745
  */
2722
- setBigInt(value: bigint): TinyElement | TinyElement[];
2746
+ setBigInt(value: bigint): this;
2723
2747
  /**
2724
2748
  * Returns the Date content of the element.
2725
2749
  * @returns {Date|null}
@@ -2728,9 +2752,9 @@ declare class TinyHtml {
2728
2752
  /**
2729
2753
  * Set Date content of the element.
2730
2754
  * @param {Date} value
2731
- * @returns {TinyElement|TinyElement[]}
2755
+ * @returns {this}
2732
2756
  */
2733
- setDate(value: Date): TinyElement | TinyElement[];
2757
+ setDate(value: Date): this;
2734
2758
  /**
2735
2759
  * Returns the JSON content of the element.
2736
2760
  * @returns {any|null}
@@ -2741,9 +2765,9 @@ declare class TinyHtml {
2741
2765
  * @param {any} value - A JavaScript value, usually an object or array, to be converted.
2742
2766
  * @param {(this: any, key: string, value: any) => any} [replacer] - A function that transforms the results.
2743
2767
  * @param {number|string} [space] - Indentation level or string for formatting.
2744
- * @returns {TinyElement|TinyElement[]}
2768
+ * @returns {this}
2745
2769
  */
2746
- setJson(value: any, replacer?: (this: any, key: string, value: any) => any, space?: number | string): TinyElement | TinyElement[];
2770
+ setJson(value: any, replacer?: (this: any, key: string, value: any) => any, space?: number | string): this;
2747
2771
  /**
2748
2772
  * Returns the number content of the element.
2749
2773
  * @returns {number|null} The text content or null if none.
@@ -2752,9 +2776,9 @@ declare class TinyHtml {
2752
2776
  /**
2753
2777
  * Set number content of the element.
2754
2778
  * @param {number} value
2755
- * @returns {TinyElement|TinyElement[]}
2779
+ * @returns {this}
2756
2780
  */
2757
- setNumber(value: number): TinyElement | TinyElement[];
2781
+ setNumber(value: number): this;
2758
2782
  /**
2759
2783
  * Returns the boolean content of the element.
2760
2784
  * @returns {boolean|null}
@@ -2763,9 +2787,9 @@ declare class TinyHtml {
2763
2787
  /**
2764
2788
  * Set boolean content of the element.
2765
2789
  * @param {boolean} value
2766
- * @returns {TinyElement|TinyElement[]}
2790
+ * @returns {this}
2767
2791
  */
2768
- setBoolean(value: boolean): TinyElement | TinyElement[];
2792
+ setBoolean(value: boolean): this;
2769
2793
  /**
2770
2794
  * Returns the string content of the element.
2771
2795
  * @returns {string|null} The string content or null if none.
@@ -2774,9 +2798,9 @@ declare class TinyHtml {
2774
2798
  /**
2775
2799
  * Set string content of the element.
2776
2800
  * @param {string} value
2777
- * @returns {TinyElement|TinyElement[]}
2801
+ * @returns {this}
2778
2802
  */
2779
- setString(value: string): TinyElement | TinyElement[];
2803
+ setString(value: string): this;
2780
2804
  /**
2781
2805
  * Returns the text content of the element.
2782
2806
  * @returns {string|null} The text content or null if none.
@@ -2785,14 +2809,14 @@ declare class TinyHtml {
2785
2809
  /**
2786
2810
  * Set text content of the element.
2787
2811
  * @param {*} value
2788
- * @returns {TinyElement|TinyElement[]}
2812
+ * @returns {this}
2789
2813
  */
2790
- setText(value: any): TinyElement | TinyElement[];
2814
+ setText(value: any): this;
2791
2815
  /**
2792
2816
  * Remove all child nodes of the element.
2793
- * @returns {TinyElement|TinyElement[]}
2817
+ * @returns {this}
2794
2818
  */
2795
- empty(): TinyElement | TinyElement[];
2819
+ empty(): this;
2796
2820
  /**
2797
2821
  * Get the innerHTML of the element.
2798
2822
  * @param {GetHTMLOptions} [ops]
@@ -2802,18 +2826,18 @@ declare class TinyHtml {
2802
2826
  /**
2803
2827
  * Set the innerHTML of the element.
2804
2828
  * @param {string} value
2805
- * @returns {TinyElement|TinyElement[]}
2829
+ * @returns {this}
2806
2830
  */
2807
- setHtml(value: string): TinyElement | TinyElement[];
2831
+ setHtml(value: string): this;
2808
2832
  /**
2809
2833
  * Sets the value of the current HTML value element (input, select, textarea, etc.).
2810
2834
  * Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
2811
2835
  *
2812
2836
  * @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
2813
- * @returns {TinyInputElement|TinyInputElement[]}
2837
+ * @returns {this}
2814
2838
  * @throws {Error} If the computed value is not a valid string or boolean.
2815
2839
  */
2816
- setVal(value: SetValueList | ((el: InputElement, val: SetValueList) => SetValueList)): TinyInputElement | TinyInputElement[];
2840
+ setVal(value: SetValueList | ((el: InputElement, val: SetValueList) => SetValueList)): this;
2817
2841
  /**
2818
2842
  * Retrieves the raw value from the HTML input element.
2819
2843
  * If a custom value hook exists, it will be used first.
@@ -2911,50 +2935,50 @@ declare class TinyHtml {
2911
2935
  * @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
2912
2936
  * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
2913
2937
  * @param {EventRegistryOptions} [options] - Optional event listener options.
2914
- * @returns {TinyEventTarget|TinyEventTarget[]}
2938
+ * @returns {this}
2915
2939
  */
2916
- on(events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: EventRegistryOptions): TinyEventTarget | TinyEventTarget[];
2940
+ on(events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: EventRegistryOptions): this;
2917
2941
  /**
2918
2942
  * Registers an event listener that runs only once, then is removed.
2919
2943
  *
2920
2944
  * @param {string|string[]} events - The event type (e.g. 'click', 'keydown').
2921
2945
  * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
2922
2946
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
2923
- * @returns {TinyEventTarget|TinyEventTarget[]}
2947
+ * @returns {this}
2924
2948
  */
2925
- once(events: string | string[], handler: EventListenerOrEventListenerObject, options?: EventRegistryOptions): TinyEventTarget | TinyEventTarget[];
2949
+ once(events: string | string[], handler: EventListenerOrEventListenerObject, options?: EventRegistryOptions): this;
2926
2950
  /**
2927
2951
  * Removes a specific event listener from an element.
2928
2952
  *
2929
2953
  * @param {string|string[]} events - The event type.
2930
2954
  * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
2931
2955
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
2932
- * @returns {TinyEventTarget|TinyEventTarget[]}
2956
+ * @returns {this}
2933
2957
  */
2934
- off(events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): TinyEventTarget | TinyEventTarget[];
2958
+ off(events: string | string[], handler: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): this;
2935
2959
  /**
2936
2960
  * Removes all event listeners of a specific type from the element.
2937
2961
  *
2938
2962
  * @param {string|string[]} events - The event type to remove (e.g. 'click').
2939
- * @returns {TinyEventTarget|TinyEventTarget[]}
2963
+ * @returns {this}
2940
2964
  */
2941
- offAll(events: string | string[]): TinyEventTarget | TinyEventTarget[];
2965
+ offAll(events: string | string[]): this;
2942
2966
  /**
2943
2967
  * Removes all event listeners of all types from the element.
2944
2968
  *
2945
2969
  * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
2946
2970
  * Optional filter function to selectively remove specific handlers.
2947
- * @returns {TinyEventTarget|TinyEventTarget[]}
2971
+ * @returns {this}
2948
2972
  */
2949
- offAllTypes(filterFn?: ((handler: EventListenerOrEventListenerObject | null, event: string) => boolean) | null): TinyEventTarget | TinyEventTarget[];
2973
+ offAllTypes(filterFn?: ((handler: EventListenerOrEventListenerObject | null, event: string) => boolean) | null): this;
2950
2974
  /**
2951
2975
  * Triggers all handlers associated with a specific event on the given element.
2952
2976
  *
2953
2977
  * @param {string|string[]} events - Name of the event to trigger.
2954
2978
  * @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
2955
- * @returns {TinyEventTarget|TinyEventTarget[]}
2979
+ * @returns {this}
2956
2980
  */
2957
- trigger(events: string | string[], payload?: Event | CustomEvent | CustomEventInit): TinyEventTarget | TinyEventTarget[];
2981
+ trigger(events: string | string[], payload?: Event | CustomEvent | CustomEventInit): this;
2958
2982
  /**
2959
2983
  * Get an attribute on an element.
2960
2984
  * @param {string} name
@@ -2965,15 +2989,15 @@ declare class TinyHtml {
2965
2989
  * Set an attribute on an element.
2966
2990
  * @param {string} name
2967
2991
  * @param {string|null} [value=null]
2968
- * @returns {TinyElement|TinyElement[]}
2992
+ * @returns {this}
2969
2993
  */
2970
- setAttr(name: string, value?: string | null): TinyElement | TinyElement[];
2994
+ setAttr(name: string, value?: string | null): this;
2971
2995
  /**
2972
2996
  * Remove attribute(s) from an element.
2973
2997
  * @param {string} name Space-separated list of attributes.
2974
- * @returns {TinyElement|TinyElement[]}
2998
+ * @returns {this}
2975
2999
  */
2976
- removeAttr(name: string): TinyElement | TinyElement[];
3000
+ removeAttr(name: string): this;
2977
3001
  /**
2978
3002
  * Check if an attribute exists on an element.
2979
3003
  * @param {string} name
@@ -2989,26 +3013,27 @@ declare class TinyHtml {
2989
3013
  /**
2990
3014
  * Set a property on an element.
2991
3015
  * @param {string} name
2992
- * @returns {TinyElement|TinyElement[]}
3016
+ * @returns {this}
2993
3017
  */
2994
- addProp(name: string): TinyElement | TinyElement[];
3018
+ addProp(name: string): this;
2995
3019
  /**
2996
3020
  * Remove a property from an element.
2997
3021
  * @param {string} name
2998
- * @returns {TinyElement|TinyElement[]}
3022
+ * @returns {this}
2999
3023
  */
3000
- removeProp(name: string): TinyElement | TinyElement[];
3024
+ removeProp(name: string): this;
3001
3025
  /**
3002
3026
  * Toggle a boolean property.
3003
3027
  * @param {string} name
3004
3028
  * @param {boolean} [force]
3029
+ * @returns {this}
3005
3030
  */
3006
- toggleProp(name: string, force?: boolean): void;
3031
+ toggleProp(name: string, force?: boolean): this;
3007
3032
  /**
3008
3033
  * Removes the element from the DOM.
3009
- * @returns {TinyElement|TinyElement[]}
3034
+ * @returns {this}
3010
3035
  */
3011
- remove(): TinyElement | TinyElement[];
3036
+ remove(): this;
3012
3037
  /**
3013
3038
  * Returns the index of the first element within its parent or relative to a selector/element.
3014
3039
  *