tiny-essentials 1.22.8 → 1.22.10
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/changelog/1/22/10.md +15 -0
- package/changelog/1/22/9.md +9 -0
- 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/libs/TinyHtml.cjs +35 -26
- package/dist/v1/libs/TinyHtml.d.mts +30 -74
- package/dist/v1/libs/TinyHtml.mjs +35 -23
- package/package.json +1 -1
|
@@ -23,7 +23,13 @@ const {
|
|
|
23
23
|
/**
|
|
24
24
|
* Represents the valid values that can be appended to a TinyNode.
|
|
25
25
|
*
|
|
26
|
-
* @typedef {TinyNode | TinyNode[] | string | false | null | undefined}
|
|
26
|
+
* @typedef {TinyNode | TinyNode[] | string | false | null | undefined} AppendCheckerTemplate
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Represents the the collection of values that can be appended to a TinyNode.
|
|
31
|
+
*
|
|
32
|
+
* @typedef {AppendCheckerTemplate|AppendCheckerTemplate[]} AppendCheckerValues
|
|
27
33
|
*/
|
|
28
34
|
|
|
29
35
|
/**
|
|
@@ -1621,12 +1627,12 @@ class TinyHtml {
|
|
|
1621
1627
|
}
|
|
1622
1628
|
|
|
1623
1629
|
/**
|
|
1624
|
-
*
|
|
1630
|
+
* Returns elements from the current list that contain the given target(s).
|
|
1625
1631
|
* @param {string|TinyElement|TinyElement[]} target - Selector or DOM element(s).
|
|
1626
|
-
* @returns {
|
|
1632
|
+
* @returns {Element[]} Elements that contain the target.
|
|
1627
1633
|
*/
|
|
1628
1634
|
has(target) {
|
|
1629
|
-
return TinyHtml.has(this, target)
|
|
1635
|
+
return TinyHtml.has(this, target);
|
|
1630
1636
|
}
|
|
1631
1637
|
|
|
1632
1638
|
/**
|
|
@@ -2148,22 +2154,25 @@ class TinyHtml {
|
|
|
2148
2154
|
/**
|
|
2149
2155
|
* Normalize and validate nodes before DOM insertion.
|
|
2150
2156
|
* Converts TinyNode-like structures or strings into DOM-compatible nodes.
|
|
2151
|
-
* @type {(where: string, ...nodes: AppendCheckerValues[]) => (Node | string)[]}
|
|
2157
|
+
* @type {(where: string, ...nodes: (AppendCheckerValues|Record<string, AppendCheckerValues>)[]) => (Node | string)[]}
|
|
2152
2158
|
* @readonly
|
|
2153
2159
|
*/
|
|
2154
2160
|
static _appendChecker(where, ...nodes) {
|
|
2161
|
+
/** @type {(string | Node)[]} */
|
|
2155
2162
|
const results = [];
|
|
2156
|
-
const
|
|
2157
|
-
|
|
2158
|
-
if (
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2163
|
+
for (const item of nodes) {
|
|
2164
|
+
if (typeof item === 'undefined' || item === null || item === false) continue;
|
|
2165
|
+
if (typeof item !== 'string' && typeof item !== 'number') {
|
|
2166
|
+
if (item instanceof Node || item instanceof TinyHtml)
|
|
2167
|
+
results.push(TinyHtml._preNodeElems(item, where)[0]);
|
|
2168
|
+
else if (Array.isArray(item)) results.push(...TinyHtml._appendChecker(where, ...item));
|
|
2169
|
+
else {
|
|
2170
|
+
for (const name in item) {
|
|
2171
|
+
const elems = item[name];
|
|
2172
|
+
results.push(...TinyHtml._appendChecker(where, elems));
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
} else results.push(item);
|
|
2167
2176
|
}
|
|
2168
2177
|
return results;
|
|
2169
2178
|
}
|
|
@@ -2173,7 +2182,7 @@ class TinyHtml {
|
|
|
2173
2182
|
*
|
|
2174
2183
|
* @template {TinyElement} T
|
|
2175
2184
|
* @param {T} el - The target element(s) to receive children.
|
|
2176
|
-
* @param {...AppendCheckerValues} children - The child elements or text to append.
|
|
2185
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to append.
|
|
2177
2186
|
* @returns {T}
|
|
2178
2187
|
*/
|
|
2179
2188
|
static append(el, ...children) {
|
|
@@ -2185,7 +2194,7 @@ class TinyHtml {
|
|
|
2185
2194
|
/**
|
|
2186
2195
|
* Appends child elements or strings to the end of the target element(s).
|
|
2187
2196
|
*
|
|
2188
|
-
* @param {...AppendCheckerValues} children - The child elements or text to append.
|
|
2197
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to append.
|
|
2189
2198
|
* @returns {this}
|
|
2190
2199
|
*/
|
|
2191
2200
|
append(...children) {
|
|
@@ -2197,7 +2206,7 @@ class TinyHtml {
|
|
|
2197
2206
|
*
|
|
2198
2207
|
* @template {TinyElement} T
|
|
2199
2208
|
* @param {T} el - The target element(s) to receive children.
|
|
2200
|
-
* @param {...AppendCheckerValues} children - The child elements or text to prepend.
|
|
2209
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to prepend.
|
|
2201
2210
|
* @returns {T}
|
|
2202
2211
|
*/
|
|
2203
2212
|
static prepend(el, ...children) {
|
|
@@ -2209,7 +2218,7 @@ class TinyHtml {
|
|
|
2209
2218
|
/**
|
|
2210
2219
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
2211
2220
|
*
|
|
2212
|
-
* @param {...AppendCheckerValues} children - The child elements or text to prepend.
|
|
2221
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to prepend.
|
|
2213
2222
|
* @returns {this}
|
|
2214
2223
|
*/
|
|
2215
2224
|
prepend(...children) {
|
|
@@ -2221,7 +2230,7 @@ class TinyHtml {
|
|
|
2221
2230
|
*
|
|
2222
2231
|
* @template {TinyElement} T
|
|
2223
2232
|
* @param {T} el - The target element(s) before which new content is inserted.
|
|
2224
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert before the target.
|
|
2233
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert before the target.
|
|
2225
2234
|
* @returns {T}
|
|
2226
2235
|
*/
|
|
2227
2236
|
static before(el, ...children) {
|
|
@@ -2233,7 +2242,7 @@ class TinyHtml {
|
|
|
2233
2242
|
/**
|
|
2234
2243
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
2235
2244
|
*
|
|
2236
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert before the target.
|
|
2245
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert before the target.
|
|
2237
2246
|
* @returns {this}
|
|
2238
2247
|
*/
|
|
2239
2248
|
before(...children) {
|
|
@@ -2245,7 +2254,7 @@ class TinyHtml {
|
|
|
2245
2254
|
*
|
|
2246
2255
|
* @template {TinyElement} T
|
|
2247
2256
|
* @param {T} el - The target element(s) after which new content is inserted.
|
|
2248
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert after the target.
|
|
2257
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert after the target.
|
|
2249
2258
|
* @returns {T}
|
|
2250
2259
|
*/
|
|
2251
2260
|
static after(el, ...children) {
|
|
@@ -2257,7 +2266,7 @@ class TinyHtml {
|
|
|
2257
2266
|
/**
|
|
2258
2267
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
2259
2268
|
*
|
|
2260
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert after the target.
|
|
2269
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert after the target.
|
|
2261
2270
|
* @returns {this}
|
|
2262
2271
|
*/
|
|
2263
2272
|
after(...children) {
|
|
@@ -2269,7 +2278,7 @@ class TinyHtml {
|
|
|
2269
2278
|
*
|
|
2270
2279
|
* @template {TinyElement} T
|
|
2271
2280
|
* @param {T} el - The element(s) to be replaced.
|
|
2272
|
-
* @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
|
|
2281
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} newNodes - New elements or text to replace the target.
|
|
2273
2282
|
* @returns {T}
|
|
2274
2283
|
*/
|
|
2275
2284
|
static replaceWith(el, ...newNodes) {
|
|
@@ -2281,7 +2290,7 @@ class TinyHtml {
|
|
|
2281
2290
|
/**
|
|
2282
2291
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
2283
2292
|
*
|
|
2284
|
-
* @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
|
|
2293
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} newNodes - New elements or text to replace the target.
|
|
2285
2294
|
* @returns {this}
|
|
2286
2295
|
*/
|
|
2287
2296
|
replaceWith(...newNodes) {
|
|
@@ -6,7 +6,11 @@ export type TinyHtmlAny = TinyHtml<ConstructorElValues>;
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents the valid values that can be appended to a TinyNode.
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
9
|
+
export type AppendCheckerTemplate = TinyNode | TinyNode[] | string | false | null | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Represents the the collection of values that can be appended to a TinyNode.
|
|
12
|
+
*/
|
|
13
|
+
export type AppendCheckerValues = AppendCheckerTemplate | AppendCheckerTemplate[];
|
|
10
14
|
/**
|
|
11
15
|
* Callback function used for hover events.
|
|
12
16
|
*/
|
|
@@ -279,55 +283,7 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
|
|
|
279
283
|
areElsCollPerfTop: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
280
284
|
areElsCollPerfBottom: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
281
285
|
areElsCollPerfLeft: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
282
|
-
areElsCollPerfRight: (rect1: TinyCollision.ObjRect,
|
|
283
|
-
/**
|
|
284
|
-
* Represents a value that can be either a DOM Element, or the document object.
|
|
285
|
-
* Useful for functions that operate generically on measurable targets.
|
|
286
|
-
*
|
|
287
|
-
* @typedef {Element|Document} ElementWithDoc
|
|
288
|
-
*/
|
|
289
|
-
/**
|
|
290
|
-
* A parameter type used for filtering or matching elements.
|
|
291
|
-
* It can be:
|
|
292
|
-
* - A string (CSS selector),
|
|
293
|
-
* - A raw DOM element,
|
|
294
|
-
* - An array of raw DOM elements,
|
|
295
|
-
* - A filtering function that receives an index and element,
|
|
296
|
-
* and returns true if it matches.
|
|
297
|
-
*
|
|
298
|
-
* @typedef {string|Element|Element[]|((index: number, el: Element) => boolean)} WinnowRequest
|
|
299
|
-
*/
|
|
300
|
-
/**
|
|
301
|
-
* Elements accepted as constructor values for TinyHtml.
|
|
302
|
-
* These include common DOM elements and root containers.
|
|
303
|
-
*
|
|
304
|
-
* @typedef {Window|Element|Document|Text} ConstructorElValues
|
|
305
|
-
*/
|
|
306
|
-
/**
|
|
307
|
-
* Options passed to `addEventListener` or `removeEventListener`.
|
|
308
|
-
* Can be a boolean or an object of type `AddEventListenerOptions`.
|
|
309
|
-
*
|
|
310
|
-
* @typedef {boolean|AddEventListenerOptions} EventRegistryOptions
|
|
311
|
-
*/
|
|
312
|
-
/**
|
|
313
|
-
* Structure describing a registered event callback and its options.
|
|
314
|
-
*
|
|
315
|
-
* @typedef {Object} EventRegistryItem
|
|
316
|
-
* @property {EventListenerOrEventListenerObject|null} handler - The function to be executed when the event is triggered.
|
|
317
|
-
* @property {EventRegistryOptions} [options] - Optional configuration passed to the listener.
|
|
318
|
-
*/
|
|
319
|
-
/**
|
|
320
|
-
* Maps event names (e.g., `"click"`, `"keydown"`) to a list of registered handlers and options.
|
|
321
|
-
*
|
|
322
|
-
* @typedef {Record<string, EventRegistryItem[]>} EventRegistryList
|
|
323
|
-
*/
|
|
324
|
-
/**
|
|
325
|
-
* WeakMap storing all event listeners per element.
|
|
326
|
-
* Each element has a registry mapping event names to their handler lists.
|
|
327
|
-
*
|
|
328
|
-
* @type {WeakMap<ConstructorElValues|EventTarget, EventRegistryList>}
|
|
329
|
-
*/
|
|
330
|
-
rect2: TinyCollision.ObjRect) => boolean;
|
|
286
|
+
areElsCollPerfRight: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
331
287
|
areElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
332
288
|
areElsPerfColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
333
289
|
getElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => string | null;
|
|
@@ -1021,52 +977,52 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
|
|
|
1021
977
|
* @returns {Node[]}
|
|
1022
978
|
*/
|
|
1023
979
|
static clone(el: TinyNode | TinyNode[], deep?: boolean): Node[];
|
|
1024
|
-
static readonly _appendChecker(where: string, ...nodes: AppendCheckerValues[]): (Node | string)[];
|
|
980
|
+
static readonly _appendChecker(where: string, ...nodes: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): (Node | string)[];
|
|
1025
981
|
/**
|
|
1026
982
|
* Appends child elements or strings to the end of the target element(s).
|
|
1027
983
|
*
|
|
1028
984
|
* @template {TinyElement} T
|
|
1029
985
|
* @param {T} el - The target element(s) to receive children.
|
|
1030
|
-
* @param {...AppendCheckerValues} children - The child elements or text to append.
|
|
986
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to append.
|
|
1031
987
|
* @returns {T}
|
|
1032
988
|
*/
|
|
1033
|
-
static append<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
|
|
989
|
+
static append<T extends TinyElement>(el: T, ...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): T;
|
|
1034
990
|
/**
|
|
1035
991
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1036
992
|
*
|
|
1037
993
|
* @template {TinyElement} T
|
|
1038
994
|
* @param {T} el - The target element(s) to receive children.
|
|
1039
|
-
* @param {...AppendCheckerValues} children - The child elements or text to prepend.
|
|
995
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to prepend.
|
|
1040
996
|
* @returns {T}
|
|
1041
997
|
*/
|
|
1042
|
-
static prepend<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
|
|
998
|
+
static prepend<T extends TinyElement>(el: T, ...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): T;
|
|
1043
999
|
/**
|
|
1044
1000
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1045
1001
|
*
|
|
1046
1002
|
* @template {TinyElement} T
|
|
1047
1003
|
* @param {T} el - The target element(s) before which new content is inserted.
|
|
1048
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert before the target.
|
|
1004
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert before the target.
|
|
1049
1005
|
* @returns {T}
|
|
1050
1006
|
*/
|
|
1051
|
-
static before<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
|
|
1007
|
+
static before<T extends TinyElement>(el: T, ...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): T;
|
|
1052
1008
|
/**
|
|
1053
1009
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1054
1010
|
*
|
|
1055
1011
|
* @template {TinyElement} T
|
|
1056
1012
|
* @param {T} el - The target element(s) after which new content is inserted.
|
|
1057
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert after the target.
|
|
1013
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert after the target.
|
|
1058
1014
|
* @returns {T}
|
|
1059
1015
|
*/
|
|
1060
|
-
static after<T extends TinyElement>(el: T, ...children: AppendCheckerValues[]): T;
|
|
1016
|
+
static after<T extends TinyElement>(el: T, ...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): T;
|
|
1061
1017
|
/**
|
|
1062
1018
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1063
1019
|
*
|
|
1064
1020
|
* @template {TinyElement} T
|
|
1065
1021
|
* @param {T} el - The element(s) to be replaced.
|
|
1066
|
-
* @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
|
|
1022
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} newNodes - New elements or text to replace the target.
|
|
1067
1023
|
* @returns {T}
|
|
1068
1024
|
*/
|
|
1069
|
-
static replaceWith<T extends TinyElement>(el: T, ...newNodes: AppendCheckerValues[]): T;
|
|
1025
|
+
static replaceWith<T extends TinyElement>(el: T, ...newNodes: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): T;
|
|
1070
1026
|
/**
|
|
1071
1027
|
* Appends the given element(s) to each target element in sequence.
|
|
1072
1028
|
*
|
|
@@ -2865,11 +2821,11 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
|
|
|
2865
2821
|
*/
|
|
2866
2822
|
is(selector: WinnowRequest): boolean;
|
|
2867
2823
|
/**
|
|
2868
|
-
*
|
|
2824
|
+
* Returns elements from the current list that contain the given target(s).
|
|
2869
2825
|
* @param {string|TinyElement|TinyElement[]} target - Selector or DOM element(s).
|
|
2870
|
-
* @returns {
|
|
2826
|
+
* @returns {Element[]} Elements that contain the target.
|
|
2871
2827
|
*/
|
|
2872
|
-
has(target: string | TinyElement | TinyElement[]):
|
|
2828
|
+
has(target: string | TinyElement | TinyElement[]): Element[];
|
|
2873
2829
|
/**
|
|
2874
2830
|
* Finds the closest ancestor (including self) that matches the selector.
|
|
2875
2831
|
*
|
|
@@ -2996,38 +2952,38 @@ declare class TinyHtml<TinyHtmlT extends ConstructorElValues | ConstructorElValu
|
|
|
2996
2952
|
/**
|
|
2997
2953
|
* Appends child elements or strings to the end of the target element(s).
|
|
2998
2954
|
*
|
|
2999
|
-
* @param {...AppendCheckerValues} children - The child elements or text to append.
|
|
2955
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to append.
|
|
3000
2956
|
* @returns {this}
|
|
3001
2957
|
*/
|
|
3002
|
-
append(...children: AppendCheckerValues[]): this;
|
|
2958
|
+
append(...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): this;
|
|
3003
2959
|
/**
|
|
3004
2960
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
3005
2961
|
*
|
|
3006
|
-
* @param {...AppendCheckerValues} children - The child elements or text to prepend.
|
|
2962
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to prepend.
|
|
3007
2963
|
* @returns {this}
|
|
3008
2964
|
*/
|
|
3009
|
-
prepend(...children: AppendCheckerValues[]): this;
|
|
2965
|
+
prepend(...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): this;
|
|
3010
2966
|
/**
|
|
3011
2967
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
3012
2968
|
*
|
|
3013
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert before the target.
|
|
2969
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert before the target.
|
|
3014
2970
|
* @returns {this}
|
|
3015
2971
|
*/
|
|
3016
|
-
before(...children: AppendCheckerValues[]): this;
|
|
2972
|
+
before(...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): this;
|
|
3017
2973
|
/**
|
|
3018
2974
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
3019
2975
|
*
|
|
3020
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert after the target.
|
|
2976
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert after the target.
|
|
3021
2977
|
* @returns {this}
|
|
3022
2978
|
*/
|
|
3023
|
-
after(...children: AppendCheckerValues[]): this;
|
|
2979
|
+
after(...children: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): this;
|
|
3024
2980
|
/**
|
|
3025
2981
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
3026
2982
|
*
|
|
3027
|
-
* @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
|
|
2983
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} newNodes - New elements or text to replace the target.
|
|
3028
2984
|
* @returns {this}
|
|
3029
2985
|
*/
|
|
3030
|
-
replaceWith(...newNodes: AppendCheckerValues[]): this;
|
|
2986
|
+
replaceWith(...newNodes: (AppendCheckerValues | Record<string, AppendCheckerValues>)[]): this;
|
|
3031
2987
|
/**
|
|
3032
2988
|
* Appends the given element(s) to each target element in sequence.
|
|
3033
2989
|
*
|
|
@@ -11,7 +11,12 @@ const { areElsColliding, areElsPerfColliding, areElsCollTop, areElsCollBottom, a
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents the valid values that can be appended to a TinyNode.
|
|
13
13
|
*
|
|
14
|
-
* @typedef {TinyNode | TinyNode[] | string | false | null | undefined}
|
|
14
|
+
* @typedef {TinyNode | TinyNode[] | string | false | null | undefined} AppendCheckerTemplate
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Represents the the collection of values that can be appended to a TinyNode.
|
|
18
|
+
*
|
|
19
|
+
* @typedef {AppendCheckerTemplate|AppendCheckerTemplate[]} AppendCheckerValues
|
|
15
20
|
*/
|
|
16
21
|
/**
|
|
17
22
|
* Callback function used for hover events.
|
|
@@ -1400,12 +1405,12 @@ class TinyHtml {
|
|
|
1400
1405
|
return TinyHtml._preElems(roots, 'has').filter((root) => targets.some((t) => root && root.contains(t)));
|
|
1401
1406
|
}
|
|
1402
1407
|
/**
|
|
1403
|
-
*
|
|
1408
|
+
* Returns elements from the current list that contain the given target(s).
|
|
1404
1409
|
* @param {string|TinyElement|TinyElement[]} target - Selector or DOM element(s).
|
|
1405
|
-
* @returns {
|
|
1410
|
+
* @returns {Element[]} Elements that contain the target.
|
|
1406
1411
|
*/
|
|
1407
1412
|
has(target) {
|
|
1408
|
-
return TinyHtml.has(this, target)
|
|
1413
|
+
return TinyHtml.has(this, target);
|
|
1409
1414
|
}
|
|
1410
1415
|
/**
|
|
1411
1416
|
* Finds the closest ancestor (including self) that matches the selector.
|
|
@@ -1873,22 +1878,29 @@ class TinyHtml {
|
|
|
1873
1878
|
/**
|
|
1874
1879
|
* Normalize and validate nodes before DOM insertion.
|
|
1875
1880
|
* Converts TinyNode-like structures or strings into DOM-compatible nodes.
|
|
1876
|
-
* @type {(where: string, ...nodes: AppendCheckerValues[]) => (Node | string)[]}
|
|
1881
|
+
* @type {(where: string, ...nodes: (AppendCheckerValues|Record<string, AppendCheckerValues>)[]) => (Node | string)[]}
|
|
1877
1882
|
* @readonly
|
|
1878
1883
|
*/
|
|
1879
1884
|
static _appendChecker(where, ...nodes) {
|
|
1885
|
+
/** @type {(string | Node)[]} */
|
|
1880
1886
|
const results = [];
|
|
1881
|
-
const
|
|
1882
|
-
|
|
1883
|
-
if (typeof nds[index] === 'undefined' ||
|
|
1884
|
-
nds[index] === null ||
|
|
1885
|
-
nds[index] === false)
|
|
1887
|
+
for (const item of nodes) {
|
|
1888
|
+
if (typeof item === 'undefined' || item === null || item === false)
|
|
1886
1889
|
continue;
|
|
1887
|
-
if (typeof
|
|
1888
|
-
|
|
1890
|
+
if (typeof item !== 'string' && typeof item !== 'number') {
|
|
1891
|
+
if (item instanceof Node || item instanceof TinyHtml)
|
|
1892
|
+
results.push(TinyHtml._preNodeElems(item, where)[0]);
|
|
1893
|
+
else if (Array.isArray(item))
|
|
1894
|
+
results.push(...TinyHtml._appendChecker(where, ...item));
|
|
1895
|
+
else {
|
|
1896
|
+
for (const name in item) {
|
|
1897
|
+
const elems = item[name];
|
|
1898
|
+
results.push(...TinyHtml._appendChecker(where, elems));
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1889
1901
|
}
|
|
1890
1902
|
else
|
|
1891
|
-
results.push(
|
|
1903
|
+
results.push(item);
|
|
1892
1904
|
}
|
|
1893
1905
|
return results;
|
|
1894
1906
|
}
|
|
@@ -1897,7 +1909,7 @@ class TinyHtml {
|
|
|
1897
1909
|
*
|
|
1898
1910
|
* @template {TinyElement} T
|
|
1899
1911
|
* @param {T} el - The target element(s) to receive children.
|
|
1900
|
-
* @param {...AppendCheckerValues} children - The child elements or text to append.
|
|
1912
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to append.
|
|
1901
1913
|
* @returns {T}
|
|
1902
1914
|
*/
|
|
1903
1915
|
static append(el, ...children) {
|
|
@@ -1908,7 +1920,7 @@ class TinyHtml {
|
|
|
1908
1920
|
/**
|
|
1909
1921
|
* Appends child elements or strings to the end of the target element(s).
|
|
1910
1922
|
*
|
|
1911
|
-
* @param {...AppendCheckerValues} children - The child elements or text to append.
|
|
1923
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to append.
|
|
1912
1924
|
* @returns {this}
|
|
1913
1925
|
*/
|
|
1914
1926
|
append(...children) {
|
|
@@ -1919,7 +1931,7 @@ class TinyHtml {
|
|
|
1919
1931
|
*
|
|
1920
1932
|
* @template {TinyElement} T
|
|
1921
1933
|
* @param {T} el - The target element(s) to receive children.
|
|
1922
|
-
* @param {...AppendCheckerValues} children - The child elements or text to prepend.
|
|
1934
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to prepend.
|
|
1923
1935
|
* @returns {T}
|
|
1924
1936
|
*/
|
|
1925
1937
|
static prepend(el, ...children) {
|
|
@@ -1930,7 +1942,7 @@ class TinyHtml {
|
|
|
1930
1942
|
/**
|
|
1931
1943
|
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1932
1944
|
*
|
|
1933
|
-
* @param {...AppendCheckerValues} children - The child elements or text to prepend.
|
|
1945
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - The child elements or text to prepend.
|
|
1934
1946
|
* @returns {this}
|
|
1935
1947
|
*/
|
|
1936
1948
|
prepend(...children) {
|
|
@@ -1941,7 +1953,7 @@ class TinyHtml {
|
|
|
1941
1953
|
*
|
|
1942
1954
|
* @template {TinyElement} T
|
|
1943
1955
|
* @param {T} el - The target element(s) before which new content is inserted.
|
|
1944
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert before the target.
|
|
1956
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert before the target.
|
|
1945
1957
|
* @returns {T}
|
|
1946
1958
|
*/
|
|
1947
1959
|
static before(el, ...children) {
|
|
@@ -1952,7 +1964,7 @@ class TinyHtml {
|
|
|
1952
1964
|
/**
|
|
1953
1965
|
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1954
1966
|
*
|
|
1955
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert before the target.
|
|
1967
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert before the target.
|
|
1956
1968
|
* @returns {this}
|
|
1957
1969
|
*/
|
|
1958
1970
|
before(...children) {
|
|
@@ -1963,7 +1975,7 @@ class TinyHtml {
|
|
|
1963
1975
|
*
|
|
1964
1976
|
* @template {TinyElement} T
|
|
1965
1977
|
* @param {T} el - The target element(s) after which new content is inserted.
|
|
1966
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert after the target.
|
|
1978
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert after the target.
|
|
1967
1979
|
* @returns {T}
|
|
1968
1980
|
*/
|
|
1969
1981
|
static after(el, ...children) {
|
|
@@ -1974,7 +1986,7 @@ class TinyHtml {
|
|
|
1974
1986
|
/**
|
|
1975
1987
|
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1976
1988
|
*
|
|
1977
|
-
* @param {...AppendCheckerValues} children - Elements or text to insert after the target.
|
|
1989
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} children - Elements or text to insert after the target.
|
|
1978
1990
|
* @returns {this}
|
|
1979
1991
|
*/
|
|
1980
1992
|
after(...children) {
|
|
@@ -1985,7 +1997,7 @@ class TinyHtml {
|
|
|
1985
1997
|
*
|
|
1986
1998
|
* @template {TinyElement} T
|
|
1987
1999
|
* @param {T} el - The element(s) to be replaced.
|
|
1988
|
-
* @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
|
|
2000
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} newNodes - New elements or text to replace the target.
|
|
1989
2001
|
* @returns {T}
|
|
1990
2002
|
*/
|
|
1991
2003
|
static replaceWith(el, ...newNodes) {
|
|
@@ -1996,7 +2008,7 @@ class TinyHtml {
|
|
|
1996
2008
|
/**
|
|
1997
2009
|
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1998
2010
|
*
|
|
1999
|
-
* @param {...AppendCheckerValues} newNodes - New elements or text to replace the target.
|
|
2011
|
+
* @param {...(AppendCheckerValues|Record<string, AppendCheckerValues>)} newNodes - New elements or text to replace the target.
|
|
2000
2012
|
* @returns {this}
|
|
2001
2013
|
*/
|
|
2002
2014
|
replaceWith(...newNodes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.10",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|