tiny-essentials 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v1/TinyBasicsEs.js +4585 -270
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +4386 -471
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.js +4634 -242
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.js +4327 -0
- package/dist/v1/TinyHtml.min.js +1 -0
- package/dist/v1/TinyUploadClicker.js +4628 -246
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/collision.cjs +413 -0
- package/dist/v1/basics/collision.d.mts +187 -0
- package/dist/v1/basics/collision.mjs +350 -0
- package/dist/v1/basics/html.cjs +5 -109
- package/dist/v1/basics/html.d.mts +2 -28
- package/dist/v1/basics/html.mjs +5 -91
- package/dist/v1/basics/html_deprecated.cjs +124 -0
- package/dist/v1/basics/html_deprecated.d.mts +40 -0
- package/dist/v1/basics/html_deprecated.mjs +97 -0
- package/dist/v1/basics/index.cjs +27 -5
- package/dist/v1/basics/index.d.mts +26 -6
- package/dist/v1/basics/index.mjs +4 -2
- package/dist/v1/build/TinyHtml.cjs +7 -0
- package/dist/v1/build/TinyHtml.d.mts +3 -0
- package/dist/v1/build/TinyHtml.mjs +2 -0
- package/dist/v1/index.cjs +29 -5
- package/dist/v1/index.d.mts +27 -6
- package/dist/v1/index.mjs +5 -2
- package/dist/v1/libs/TinyDragger.cjs +91 -16
- package/dist/v1/libs/TinyDragger.d.mts +78 -2
- package/dist/v1/libs/TinyDragger.mjs +93 -17
- package/dist/v1/libs/TinyHtml.cjs +3859 -0
- package/dist/v1/libs/TinyHtml.d.mts +2151 -0
- package/dist/v1/libs/TinyHtml.mjs +3457 -0
- package/docs/v1/README.md +2 -0
- package/docs/v1/basics/collision.md +237 -0
- package/docs/v1/basics/html.md +1 -105
- package/docs/v1/basics/html_deprecated.md +127 -0
- package/docs/v1/libs/TinyDragger.md +45 -15
- package/docs/v1/libs/TinyHtml.md +1333 -0
- package/package.json +8 -2
|
@@ -0,0 +1,2151 @@
|
|
|
1
|
+
export default TinyHtml;
|
|
2
|
+
/**
|
|
3
|
+
* Represents a raw Node element or an instance of TinyHtml.
|
|
4
|
+
* This type is used to abstract interactions with both plain elements
|
|
5
|
+
* and wrapped elements via the TinyHtml class.
|
|
6
|
+
*/
|
|
7
|
+
export type TinyNode = Node | TinyHtml | null;
|
|
8
|
+
/**
|
|
9
|
+
* Represents a raw DOM element or an instance of TinyHtml.
|
|
10
|
+
* This type is used to abstract interactions with both plain elements
|
|
11
|
+
* and wrapped elements via the TinyHtml class.
|
|
12
|
+
*/
|
|
13
|
+
export type TinyElement = Element | TinyHtml;
|
|
14
|
+
/**
|
|
15
|
+
* Represents a raw DOM html element or an instance of TinyHtml.
|
|
16
|
+
* This type is used to abstract interactions with both plain elements
|
|
17
|
+
* and wrapped elements via the TinyHtml class.
|
|
18
|
+
*/
|
|
19
|
+
export type TinyHtmlElement = HTMLElement | TinyHtml;
|
|
20
|
+
/**
|
|
21
|
+
* Represents a raw DOM event target element or an instance of TinyHtml.
|
|
22
|
+
* This type is used to abstract interactions with both plain elements
|
|
23
|
+
* and wrapped elements via the TinyHtml class.
|
|
24
|
+
*/
|
|
25
|
+
export type TinyEventTarget = EventTarget | TinyHtml;
|
|
26
|
+
/**
|
|
27
|
+
* Represents a raw DOM input element or an instance of TinyHtml.
|
|
28
|
+
* This type is used to abstract interactions with both plain elements
|
|
29
|
+
* and wrapped elements via the TinyHtml class.
|
|
30
|
+
*/
|
|
31
|
+
export type TinyInputElement = InputElement | TinyHtml;
|
|
32
|
+
/**
|
|
33
|
+
* Represents a raw DOM element/window or an instance of TinyHtml.
|
|
34
|
+
* This type is used to abstract interactions with both plain elements
|
|
35
|
+
* and wrapped elements via the TinyHtml class.
|
|
36
|
+
*/
|
|
37
|
+
export type TinyElementAndWindow = ElementAndWindow | TinyHtml;
|
|
38
|
+
/**
|
|
39
|
+
* Represents a value that can be either a DOM Element or the global Window object.
|
|
40
|
+
* Useful for functions that operate generically on scrollable or measurable targets.
|
|
41
|
+
*/
|
|
42
|
+
export type ElementAndWindow = Element | Window;
|
|
43
|
+
/**
|
|
44
|
+
* A parameter type used for filtering or matching elements.
|
|
45
|
+
* It can be:
|
|
46
|
+
* - A string (CSS selector),
|
|
47
|
+
* - A raw DOM element,
|
|
48
|
+
* - An array of raw DOM elements,
|
|
49
|
+
* - A filtering function that receives an index and element,
|
|
50
|
+
* and returns true if it matches.
|
|
51
|
+
*/
|
|
52
|
+
export type WinnowRequest = string | Element | Element[] | ((index: number, el: Element) => boolean);
|
|
53
|
+
/**
|
|
54
|
+
* Elements accepted as constructor values for TinyHtml.
|
|
55
|
+
* These include common DOM elements and root containers.
|
|
56
|
+
*/
|
|
57
|
+
export type ConstructorElValues = Window | Element | Document;
|
|
58
|
+
/**
|
|
59
|
+
* The handler function used in event listeners.
|
|
60
|
+
*/
|
|
61
|
+
export type EventRegistryHandle = (e: Event) => any;
|
|
62
|
+
/**
|
|
63
|
+
* Options passed to `addEventListener` or `removeEventListener`.
|
|
64
|
+
* Can be a boolean or an object of type `AddEventListenerOptions`.
|
|
65
|
+
*/
|
|
66
|
+
export type EventRegistryOptions = boolean | AddEventListenerOptions;
|
|
67
|
+
/**
|
|
68
|
+
* Structure describing a registered event callback and its options.
|
|
69
|
+
*/
|
|
70
|
+
export type EventRegistryItem = {
|
|
71
|
+
/**
|
|
72
|
+
* - The function to be executed when the event is triggered.
|
|
73
|
+
*/
|
|
74
|
+
handler: EventRegistryHandle;
|
|
75
|
+
/**
|
|
76
|
+
* - Optional configuration passed to the listener.
|
|
77
|
+
*/
|
|
78
|
+
options?: EventRegistryOptions | undefined;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Maps event names (e.g., `"click"`, `"keydown"`) to a list of registered handlers and options.
|
|
82
|
+
*/
|
|
83
|
+
export type EventRegistryList = Record<string, EventRegistryItem[]>;
|
|
84
|
+
/**
|
|
85
|
+
* A key-value store associated with a specific DOM element.
|
|
86
|
+
* Keys are strings, and values can be of any type.
|
|
87
|
+
*/
|
|
88
|
+
export type ElementDataStore = Record<string, any>;
|
|
89
|
+
/**
|
|
90
|
+
* Possible directions from which a collision was detected and locked.
|
|
91
|
+
*/
|
|
92
|
+
export type CollisionDirLock = "top" | "bottom" | "left" | "right";
|
|
93
|
+
export type HtmlElBoxSides = {
|
|
94
|
+
/**
|
|
95
|
+
* - Total horizontal size (left + right)
|
|
96
|
+
*/
|
|
97
|
+
x: number;
|
|
98
|
+
/**
|
|
99
|
+
* - Total vertical size (top + bottom)
|
|
100
|
+
*/
|
|
101
|
+
y: number;
|
|
102
|
+
left: number;
|
|
103
|
+
right: number;
|
|
104
|
+
top: number;
|
|
105
|
+
bottom: number;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* - Primitive types accepted as input values.
|
|
109
|
+
*/
|
|
110
|
+
export type SetValueBase = string | number | Date | boolean | null;
|
|
111
|
+
/**
|
|
112
|
+
* Types of value extractors supported by TinyHtml._valTypes.
|
|
113
|
+
*/
|
|
114
|
+
export type GetValueTypes = "string" | "date" | "number";
|
|
115
|
+
/**
|
|
116
|
+
* - A single value or an array of values to be assigned to the input element.
|
|
117
|
+
*/
|
|
118
|
+
export type SetValueList = SetValueBase | SetValueBase[];
|
|
119
|
+
/**
|
|
120
|
+
* A list of HTML form elements that can have a `.value` property used by TinyHtml.
|
|
121
|
+
* Includes common input types used in forms.
|
|
122
|
+
*/
|
|
123
|
+
export type InputElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLOptionElement;
|
|
124
|
+
/**
|
|
125
|
+
* Possible directions from which a collision was detected and locked.
|
|
126
|
+
*
|
|
127
|
+
* @typedef {'top'|'bottom'|'left'|'right'} CollisionDirLock
|
|
128
|
+
*/
|
|
129
|
+
/**
|
|
130
|
+
* @typedef {Object} HtmlElBoxSides
|
|
131
|
+
* @property {number} x - Total horizontal size (left + right)
|
|
132
|
+
* @property {number} y - Total vertical size (top + bottom)
|
|
133
|
+
* @property {number} left
|
|
134
|
+
* @property {number} right
|
|
135
|
+
* @property {number} top
|
|
136
|
+
* @property {number} bottom
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* @typedef {string | number | Date | boolean | null} SetValueBase - Primitive types accepted as input values.
|
|
140
|
+
*/
|
|
141
|
+
/**
|
|
142
|
+
* @typedef {'string' | 'date' | 'number'} GetValueTypes
|
|
143
|
+
* Types of value extractors supported by TinyHtml._valTypes.
|
|
144
|
+
*/
|
|
145
|
+
/**
|
|
146
|
+
* @typedef {SetValueBase|SetValueBase[]} SetValueList - A single value or an array of values to be assigned to the input element.
|
|
147
|
+
*/
|
|
148
|
+
/**
|
|
149
|
+
* A list of HTML form elements that can have a `.value` property used by TinyHtml.
|
|
150
|
+
* Includes common input types used in forms.
|
|
151
|
+
*
|
|
152
|
+
* @typedef {HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|HTMLOptionElement} InputElement
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* TinyHtml is a utility class that provides static and instance-level methods
|
|
156
|
+
* for precise dimension and position computations on HTML elements.
|
|
157
|
+
* It mimics some jQuery functionalities while using native browser APIs.
|
|
158
|
+
*
|
|
159
|
+
* Inspired by the jQuery project's open source implementations of element dimension
|
|
160
|
+
* and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
|
|
161
|
+
*
|
|
162
|
+
* @class
|
|
163
|
+
*/
|
|
164
|
+
declare class TinyHtml {
|
|
165
|
+
/** @typedef {import('../basics/collision.mjs').ObjRect} ObjRect */
|
|
166
|
+
static Utils: {
|
|
167
|
+
getElsRelativeCenterOffset(rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect): {
|
|
168
|
+
x: number;
|
|
169
|
+
y: number;
|
|
170
|
+
};
|
|
171
|
+
getElsCollDirDepth(rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect): {
|
|
172
|
+
inDir: Dirs | null;
|
|
173
|
+
dirX: Dirs | null;
|
|
174
|
+
dirY: Dirs | null;
|
|
175
|
+
depthX: number;
|
|
176
|
+
depthY: number;
|
|
177
|
+
};
|
|
178
|
+
getElsCollDetails(rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect): {
|
|
179
|
+
depth: CollData;
|
|
180
|
+
dirs: CollDirs;
|
|
181
|
+
isNeg: NegCollDirs;
|
|
182
|
+
};
|
|
183
|
+
areElsCollTop: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
184
|
+
areElsCollBottom: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
185
|
+
areElsCollLeft: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
186
|
+
areElsCollRight: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
187
|
+
areElsCollPerfTop: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
188
|
+
areElsCollPerfBottom: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
189
|
+
areElsCollPerfLeft: (rect1: TinyCollision.ObjRect,
|
|
190
|
+
/**
|
|
191
|
+
* @typedef {string | number | Date | boolean | null} SetValueBase - Primitive types accepted as input values.
|
|
192
|
+
*/
|
|
193
|
+
/**
|
|
194
|
+
* @typedef {'string' | 'date' | 'number'} GetValueTypes
|
|
195
|
+
* Types of value extractors supported by TinyHtml._valTypes.
|
|
196
|
+
*/
|
|
197
|
+
/**
|
|
198
|
+
* @typedef {SetValueBase|SetValueBase[]} SetValueList - A single value or an array of values to be assigned to the input element.
|
|
199
|
+
*/
|
|
200
|
+
/**
|
|
201
|
+
* A list of HTML form elements that can have a `.value` property used by TinyHtml.
|
|
202
|
+
* Includes common input types used in forms.
|
|
203
|
+
*
|
|
204
|
+
* @typedef {HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|HTMLOptionElement} InputElement
|
|
205
|
+
*/
|
|
206
|
+
/**
|
|
207
|
+
* TinyHtml is a utility class that provides static and instance-level methods
|
|
208
|
+
* for precise dimension and position computations on HTML elements.
|
|
209
|
+
* It mimics some jQuery functionalities while using native browser APIs.
|
|
210
|
+
*
|
|
211
|
+
* Inspired by the jQuery project's open source implementations of element dimension
|
|
212
|
+
* and offset utilities. This class serves as a lightweight alternative using modern DOM APIs.
|
|
213
|
+
*
|
|
214
|
+
* @class
|
|
215
|
+
*/
|
|
216
|
+
rect2: TinyCollision.ObjRect) => boolean;
|
|
217
|
+
areElsCollPerfRight: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
218
|
+
areElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
219
|
+
areElsPerfColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => boolean;
|
|
220
|
+
getElsColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => string | null;
|
|
221
|
+
getElsPerfColliding: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => "top" | "bottom" | "left" | "right" | null;
|
|
222
|
+
getElsCollOverlap: (rect1: TinyCollision.ObjRect, rect2: TinyCollision.ObjRect) => {
|
|
223
|
+
overlapLeft: number;
|
|
224
|
+
overlapRight: number;
|
|
225
|
+
overlapTop: number;
|
|
226
|
+
overlapBottom: number;
|
|
227
|
+
};
|
|
228
|
+
getElsCollOverlapPos: ({ overlapLeft, overlapRight, overlapTop, overlapBottom, }?: {
|
|
229
|
+
overlapLeft?: number | undefined;
|
|
230
|
+
overlapRight?: number | undefined;
|
|
231
|
+
overlapTop?: number | undefined;
|
|
232
|
+
overlapBottom?: number | undefined;
|
|
233
|
+
}) => {
|
|
234
|
+
dirX: Dirs;
|
|
235
|
+
dirY: Dirs;
|
|
236
|
+
};
|
|
237
|
+
getRectCenter: (rect: TinyCollision.ObjRect) => {
|
|
238
|
+
x: number;
|
|
239
|
+
y: number;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Queries the document for the first element matching the CSS selector and wraps it in a TinyHtml instance.
|
|
244
|
+
*
|
|
245
|
+
* @param {string} selector - A valid CSS selector string.
|
|
246
|
+
* @returns {TinyHtml} A TinyHtml instance wrapping the matched element.
|
|
247
|
+
* @throws {Error} If no element matches the selector.
|
|
248
|
+
*/
|
|
249
|
+
static query(selector: string): TinyHtml;
|
|
250
|
+
/**
|
|
251
|
+
* Queries the document for all elements matching the CSS selector and wraps them in TinyHtml instances.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} selector - A valid CSS selector string.
|
|
254
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the matched elements.
|
|
255
|
+
*/
|
|
256
|
+
static queryAll(selector: string): TinyHtml[];
|
|
257
|
+
/**
|
|
258
|
+
* Retrieves an element by its ID and wraps it in a TinyHtml instance.
|
|
259
|
+
*
|
|
260
|
+
* @param {string} selector - The ID of the element to retrieve.
|
|
261
|
+
* @returns {TinyHtml} A TinyHtml instance wrapping the found element.
|
|
262
|
+
* @throws {Error} If no element is found with the specified ID.
|
|
263
|
+
*/
|
|
264
|
+
static getById(selector: string): TinyHtml;
|
|
265
|
+
/**
|
|
266
|
+
* Retrieves all elements with the specified class name and wraps them in TinyHtml instances.
|
|
267
|
+
*
|
|
268
|
+
* @param {string} selector - The class name to search for.
|
|
269
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
270
|
+
*/
|
|
271
|
+
static getByClassName(selector: string): TinyHtml[];
|
|
272
|
+
/**
|
|
273
|
+
* Retrieves all elements with the specified name attribute and wraps them in TinyHtml instances.
|
|
274
|
+
*
|
|
275
|
+
* @param {string} selector - The name attribute to search for.
|
|
276
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
277
|
+
*/
|
|
278
|
+
static getByName(selector: string): TinyHtml[];
|
|
279
|
+
/**
|
|
280
|
+
* Retrieves all elements with the specified local tag name within the given namespace URI,
|
|
281
|
+
* and wraps them in TinyHtml instances.
|
|
282
|
+
*
|
|
283
|
+
* @param {string} localName - The local name (tag) of the elements to search for.
|
|
284
|
+
* @param {string|null} [namespaceURI='http://www.w3.org/1999/xhtml'] - The namespace URI to search within.
|
|
285
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances wrapping the found elements.
|
|
286
|
+
*/
|
|
287
|
+
static getByTagNameNS(localName: string, namespaceURI?: string | null): TinyHtml[];
|
|
288
|
+
/**
|
|
289
|
+
* @param {TinyElement|EventTarget|null|(TinyElement|EventTarget|null)[]} elems
|
|
290
|
+
* @param {string} where
|
|
291
|
+
* @param {any[]} TheTinyElements
|
|
292
|
+
* @param {string[]} elemName
|
|
293
|
+
* @returns {any[]}
|
|
294
|
+
* @readonly
|
|
295
|
+
*/
|
|
296
|
+
static readonly _preElemsTemplate(elems: TinyElement | EventTarget | null | (TinyElement | EventTarget | null)[], where: string, TheTinyElements: any[], elemName: string[]): any[];
|
|
297
|
+
/**
|
|
298
|
+
* @param {TinyElement|EventTarget|null|(TinyElement|EventTarget|null)[]} elems
|
|
299
|
+
* @param {string} where
|
|
300
|
+
* @param {any[]} TheTinyElements
|
|
301
|
+
* @param {string[]} elemName
|
|
302
|
+
* @param {boolean} [canNull=false]
|
|
303
|
+
* @returns {any}
|
|
304
|
+
* @readonly
|
|
305
|
+
*/
|
|
306
|
+
static readonly _preElemTemplate(elems: TinyElement | EventTarget | null | (TinyElement | EventTarget | null)[], where: string, TheTinyElements: any[], elemName: string[], canNull?: boolean): any;
|
|
307
|
+
/**
|
|
308
|
+
* Ensures the input is returned as an array.
|
|
309
|
+
* Useful to normalize operations across multiple or single elements.
|
|
310
|
+
*
|
|
311
|
+
* @param {TinyElement|TinyElement[]} elems - A single element or array of elements.
|
|
312
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
313
|
+
* @returns {Element[]} - Always returns an array of elements.
|
|
314
|
+
* @readonly
|
|
315
|
+
*/
|
|
316
|
+
static readonly _preElems(elems: TinyElement | TinyElement[], where: string): Element[];
|
|
317
|
+
/**
|
|
318
|
+
* Ensures the input is returned as an single element.
|
|
319
|
+
* Useful to normalize operations across multiple or single elements.
|
|
320
|
+
*
|
|
321
|
+
* @param {TinyElement|TinyElement[]} elems - A single element or array of elements.
|
|
322
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
323
|
+
* @returns {Element} - Always returns an single element.
|
|
324
|
+
* @readonly
|
|
325
|
+
*/
|
|
326
|
+
static readonly _preElem(elems: TinyElement | TinyElement[], where: string): Element;
|
|
327
|
+
/**
|
|
328
|
+
* Ensures the input is returned as an array.
|
|
329
|
+
* Useful to normalize operations across multiple or single nodes.
|
|
330
|
+
*
|
|
331
|
+
* @param {TinyNode|TinyNode[]} elems - A single node or array of nodes.
|
|
332
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
333
|
+
* @returns {Node[]} - Always returns an array of nodes.
|
|
334
|
+
* @readonly
|
|
335
|
+
*/
|
|
336
|
+
static readonly _preNodeElems(elems: TinyNode | TinyNode[], where: string): Node[];
|
|
337
|
+
/**
|
|
338
|
+
* Ensures the input is returned as an single node.
|
|
339
|
+
* Useful to normalize operations across multiple or single nodes.
|
|
340
|
+
*
|
|
341
|
+
* @param {TinyNode|TinyNode[]} elems - A single node or array of nodes.
|
|
342
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
343
|
+
* @returns {Node} - Always returns an single node.
|
|
344
|
+
* @readonly
|
|
345
|
+
*/
|
|
346
|
+
static readonly _preNodeElem(elems: TinyNode | TinyNode[], where: string): Node;
|
|
347
|
+
/**
|
|
348
|
+
* Ensures the input is returned as an single node.
|
|
349
|
+
* Useful to normalize operations across multiple or single nodes.
|
|
350
|
+
*
|
|
351
|
+
* @param {TinyNode|TinyNode[]} elems - A single node or array of nodes.
|
|
352
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
353
|
+
* @returns {Node|null} - Always returns an single node or null.
|
|
354
|
+
* @readonly
|
|
355
|
+
*/
|
|
356
|
+
static readonly _preNodeElemWithNull(elems: TinyNode | TinyNode[], where: string): Node | null;
|
|
357
|
+
/**
|
|
358
|
+
* Ensures the input is returned as an array.
|
|
359
|
+
* Useful to normalize operations across multiple or single html elements.
|
|
360
|
+
*
|
|
361
|
+
* @param {TinyElement|TinyElement[]} elems - A single html element or array of html elements.
|
|
362
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
363
|
+
* @returns {HTMLElement[]} - Always returns an array of html elements.
|
|
364
|
+
* @readonly
|
|
365
|
+
*/
|
|
366
|
+
static readonly _preHtmlElems(elems: TinyElement | TinyElement[], where: string): HTMLElement[];
|
|
367
|
+
/**
|
|
368
|
+
* Ensures the input is returned as an single html element.
|
|
369
|
+
* Useful to normalize operations across multiple or single html elements.
|
|
370
|
+
*
|
|
371
|
+
* @param {TinyElement|TinyElement[]} elems - A single html element or array of html elements.
|
|
372
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
373
|
+
* @returns {HTMLElement} - Always returns an single html element.
|
|
374
|
+
* @readonly
|
|
375
|
+
*/
|
|
376
|
+
static readonly _preHtmlElem(elems: TinyElement | TinyElement[], where: string): HTMLElement;
|
|
377
|
+
/**
|
|
378
|
+
* Ensures the input is returned as an array.
|
|
379
|
+
* Useful to normalize operations across multiple or single event target elements.
|
|
380
|
+
*
|
|
381
|
+
* @param {TinyInputElement|TinyInputElement[]} elems - A single event target element or array of html elements.
|
|
382
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
383
|
+
* @returns {InputElement[]} - Always returns an array of event target elements.
|
|
384
|
+
* @readonly
|
|
385
|
+
*/
|
|
386
|
+
static readonly _preInputElems(elems: TinyInputElement | TinyInputElement[], where: string): InputElement[];
|
|
387
|
+
/**
|
|
388
|
+
* Ensures the input is returned as an single event target element.
|
|
389
|
+
* Useful to normalize operations across multiple or single event target elements.
|
|
390
|
+
*
|
|
391
|
+
* @param {TinyInputElement|TinyInputElement[]} elems - A single event target element or array of html elements.
|
|
392
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
393
|
+
* @returns {InputElement} - Always returns an single event target element.
|
|
394
|
+
* @readonly
|
|
395
|
+
*/
|
|
396
|
+
static readonly _preInputElem(elems: TinyInputElement | TinyInputElement[], where: string): InputElement;
|
|
397
|
+
/**
|
|
398
|
+
* Ensures the input is returned as an array.
|
|
399
|
+
* Useful to normalize operations across multiple or single event target elements.
|
|
400
|
+
*
|
|
401
|
+
* @param {TinyEventTarget|TinyEventTarget[]} elems - A single event target element or array of html elements.
|
|
402
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
403
|
+
* @returns {EventTarget[]} - Always returns an array of event target elements.
|
|
404
|
+
* @readonly
|
|
405
|
+
*/
|
|
406
|
+
static readonly _preEventTargetElems(elems: TinyEventTarget | TinyEventTarget[], where: string): EventTarget[];
|
|
407
|
+
/**
|
|
408
|
+
* Ensures the input is returned as an single event target element.
|
|
409
|
+
* Useful to normalize operations across multiple or single event target elements.
|
|
410
|
+
*
|
|
411
|
+
* @param {TinyEventTarget|TinyEventTarget[]} elems - A single event target element or array of html elements.
|
|
412
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
413
|
+
* @returns {EventTarget} - Always returns an single event target element.
|
|
414
|
+
* @readonly
|
|
415
|
+
*/
|
|
416
|
+
static readonly _preEventTargetElem(elems: TinyEventTarget | TinyEventTarget[], where: string): EventTarget;
|
|
417
|
+
/**
|
|
418
|
+
* Ensures the input is returned as an array.
|
|
419
|
+
* Useful to normalize operations across multiple or single element/window elements.
|
|
420
|
+
*
|
|
421
|
+
* @param {TinyElementAndWindow|TinyElementAndWindow[]} elems - A single element/window element or array of html elements.
|
|
422
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
423
|
+
* @returns {ElementAndWindow[]} - Always returns an array of element/window elements.
|
|
424
|
+
* @readonly
|
|
425
|
+
*/
|
|
426
|
+
static readonly _preElemsAndWindow(elems: TinyElementAndWindow | TinyElementAndWindow[], where: string): ElementAndWindow[];
|
|
427
|
+
/**
|
|
428
|
+
* Ensures the input is returned as an single element/window element.
|
|
429
|
+
* Useful to normalize operations across multiple or single element/window elements.
|
|
430
|
+
*
|
|
431
|
+
* @param {TinyElementAndWindow|TinyElementAndWindow[]} elems - A single element/window element or array of html elements.
|
|
432
|
+
* @param {string} where - The method or context name where validation is being called.
|
|
433
|
+
* @returns {ElementAndWindow} - Always returns an single element/window element.
|
|
434
|
+
* @readonly
|
|
435
|
+
*/
|
|
436
|
+
static readonly _preElemAndWindow(elems: TinyElementAndWindow | TinyElementAndWindow[], where: string): ElementAndWindow;
|
|
437
|
+
/**
|
|
438
|
+
* Normalizes and converts one or more DOM elements (or TinyHtml instances)
|
|
439
|
+
* into an array of `TinyHtml` instances.
|
|
440
|
+
*
|
|
441
|
+
* - If a plain DOM element is passed, it is wrapped into a `TinyHtml` instance.
|
|
442
|
+
* - If a `TinyHtml` instance is already passed, it is preserved.
|
|
443
|
+
* - If an array is passed, all elements inside are converted accordingly.
|
|
444
|
+
*
|
|
445
|
+
* This ensures consistent access to methods of the `TinyHtml` class regardless
|
|
446
|
+
* of the input form.
|
|
447
|
+
*
|
|
448
|
+
* @param {TinyElement|TinyElement[]} elems - A single element or an array of elements (DOM or TinyHtml).
|
|
449
|
+
* @returns {TinyHtml[]} An array of TinyHtml instances corresponding to the input elements.
|
|
450
|
+
*/
|
|
451
|
+
static toTinyElm(elems: TinyElement | TinyElement[]): TinyHtml[];
|
|
452
|
+
/**
|
|
453
|
+
* Extracts native `Element` instances from one or more elements,
|
|
454
|
+
* which can be either raw DOM elements or wrapped in `TinyHtml`.
|
|
455
|
+
*
|
|
456
|
+
* - If a `TinyHtml` instance is passed, its internal DOM element is extracted.
|
|
457
|
+
* - If a raw DOM element is passed, it is returned as-is.
|
|
458
|
+
* - If an array is passed, each element is processed accordingly.
|
|
459
|
+
*
|
|
460
|
+
* This function guarantees that the return value is always an array of
|
|
461
|
+
* raw `Element` objects, regardless of whether the input was
|
|
462
|
+
* a mix of `TinyHtml` or native DOM elements.
|
|
463
|
+
*
|
|
464
|
+
* @param {TinyElement|TinyElement[]} elems - A single element or an array of elements (DOM or TinyHtml`).
|
|
465
|
+
* @returns {Element[]} An array of Element instances extracted from the input.
|
|
466
|
+
*/
|
|
467
|
+
static fromTinyElm(elems: TinyElement | TinyElement[]): Element[];
|
|
468
|
+
/**
|
|
469
|
+
* Filters an array of elements based on a selector, function, element, or array of elements.
|
|
470
|
+
*
|
|
471
|
+
* @param {TinyElement|TinyElement[]} elems
|
|
472
|
+
* @param {WinnowRequest} qualifier
|
|
473
|
+
* @param {string} where - The context/method name using this validation.
|
|
474
|
+
* @param {boolean} not Whether to invert the result (used for .not())
|
|
475
|
+
* @returns {Element[]}
|
|
476
|
+
*/
|
|
477
|
+
static winnow(elems: TinyElement | TinyElement[], qualifier: WinnowRequest, where: string, not?: boolean): Element[];
|
|
478
|
+
/**
|
|
479
|
+
* Filters a set of elements by a CSS selector.
|
|
480
|
+
*
|
|
481
|
+
* @param {TinyElement|TinyElement[]} elems
|
|
482
|
+
* @param {string} selector
|
|
483
|
+
* @param {boolean} not
|
|
484
|
+
* @returns {Element[]}
|
|
485
|
+
*/
|
|
486
|
+
static filter(elems: TinyElement | TinyElement[], selector: string, not?: boolean): Element[];
|
|
487
|
+
/**
|
|
488
|
+
* Returns only the elements matching the given selector or function.
|
|
489
|
+
*
|
|
490
|
+
* @param {TinyElement|TinyElement[]} elems
|
|
491
|
+
* @param {WinnowRequest} selector
|
|
492
|
+
* @returns {Element[]}
|
|
493
|
+
*/
|
|
494
|
+
static filterOnly(elems: TinyElement | TinyElement[], selector: WinnowRequest): Element[];
|
|
495
|
+
/**
|
|
496
|
+
* Returns only the elements **not** matching the given selector or function.
|
|
497
|
+
*
|
|
498
|
+
* @param {TinyElement|TinyElement[]} elems
|
|
499
|
+
* @param {WinnowRequest} selector
|
|
500
|
+
* @returns {Element[]}
|
|
501
|
+
*/
|
|
502
|
+
static not(elems: TinyElement | TinyElement[], selector: WinnowRequest): Element[];
|
|
503
|
+
/**
|
|
504
|
+
* Finds elements matching a selector within a context.
|
|
505
|
+
*
|
|
506
|
+
* @param {TinyElement|TinyElement[]} context
|
|
507
|
+
* @param {string} selector
|
|
508
|
+
* @returns {Element[]}
|
|
509
|
+
*/
|
|
510
|
+
static find(context: TinyElement | TinyElement[], selector: string): Element[];
|
|
511
|
+
/**
|
|
512
|
+
* Checks if at least one element matches the selector.
|
|
513
|
+
*
|
|
514
|
+
* @param {TinyElement|TinyElement[]} elems
|
|
515
|
+
* @param {WinnowRequest} selector
|
|
516
|
+
* @returns {boolean}
|
|
517
|
+
*/
|
|
518
|
+
static is(elems: TinyElement | TinyElement[], selector: WinnowRequest): boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Returns elements from the current list that contain the given target(s).
|
|
521
|
+
* @param {TinyElement|TinyElement[]} roots - A single element or an array of elements (DOM or TinyHtml).
|
|
522
|
+
* @param {string|TinyElement|TinyElement[]} target - Selector or DOM element(s).
|
|
523
|
+
* @returns {Element[]} Elements that contain the target.
|
|
524
|
+
*/
|
|
525
|
+
static has(roots: TinyElement | TinyElement[], target: string | TinyElement | TinyElement[]): Element[];
|
|
526
|
+
/**
|
|
527
|
+
* Finds the closest ancestor (including self) that matches the selector.
|
|
528
|
+
*
|
|
529
|
+
* @param {TinyElement|TinyElement[]} els - A single element or an array of elements (DOM or TinyHtml).
|
|
530
|
+
* @param {string|Element} selector - A selector string or DOM element to match.
|
|
531
|
+
* @param {Element|null} [context] - An optional context to stop searching.
|
|
532
|
+
* @returns {Element[]}
|
|
533
|
+
*/
|
|
534
|
+
static closest(els: TinyElement | TinyElement[], selector: string | Element, context?: Element | null): Element[];
|
|
535
|
+
/**
|
|
536
|
+
* Compares two DOM elements to determine if they refer to the same node in the document.
|
|
537
|
+
*
|
|
538
|
+
* This performs a strict equality check (`===`) between the two elements.
|
|
539
|
+
*
|
|
540
|
+
* @param {TinyNode} elem - The first DOM element to compare.
|
|
541
|
+
* @param {TinyNode} otherElem - The second DOM element to compare.
|
|
542
|
+
* @returns {boolean} `true` if both elements are the same DOM node; otherwise, `false`.
|
|
543
|
+
*/
|
|
544
|
+
static isSameDom(elem: TinyNode, otherElem: TinyNode): boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Internal data selectors for accessing public or private data stores.
|
|
547
|
+
*
|
|
548
|
+
* @type {Record<string, (where: string, elem: TinyElement) => ElementDataStore>}
|
|
549
|
+
* @readonly
|
|
550
|
+
*/
|
|
551
|
+
static readonly _dataSelector: Record<string, (where: string, elem: TinyElement) => ElementDataStore>;
|
|
552
|
+
/**
|
|
553
|
+
* Retrieves data associated with a DOM element.
|
|
554
|
+
*
|
|
555
|
+
* If a `key` is provided, the corresponding value is returned.
|
|
556
|
+
* If no `key` is given, a shallow copy of all stored data is returned.
|
|
557
|
+
*
|
|
558
|
+
* @param {TinyElement} el - The DOM element.
|
|
559
|
+
* @param {string|null} [key] - The specific key to retrieve from the data store.
|
|
560
|
+
* @param {boolean} [isPrivate=false] - Whether to access the private data store.
|
|
561
|
+
* @returns {ElementDataStore|undefined|any} - The stored value, all data, or undefined if the key doesn't exist.
|
|
562
|
+
*/
|
|
563
|
+
static data(el: TinyElement, key?: string | null, isPrivate?: boolean): ElementDataStore | undefined | any;
|
|
564
|
+
/**
|
|
565
|
+
* Stores a value associated with a specific key for a DOM element.
|
|
566
|
+
*
|
|
567
|
+
* @param {TinyElement} el - The DOM element.
|
|
568
|
+
* @param {string} key - The key under which the data will be stored.
|
|
569
|
+
* @param {any} value - The value to store.
|
|
570
|
+
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
571
|
+
* @returns {void}
|
|
572
|
+
*/
|
|
573
|
+
static setData(el: TinyElement, key: string, value: any, isPrivate?: boolean): void;
|
|
574
|
+
/**
|
|
575
|
+
* Get the sibling element in a given direction.
|
|
576
|
+
*
|
|
577
|
+
* @param {TinyNode} el
|
|
578
|
+
* @param {"previousSibling"|"nextSibling"} direction
|
|
579
|
+
* @param {string} where
|
|
580
|
+
* @returns {ChildNode|null}
|
|
581
|
+
* @readonly
|
|
582
|
+
*/
|
|
583
|
+
static readonly _getSibling(el: TinyNode, direction: "previousSibling" | "nextSibling", where: string): ChildNode | null;
|
|
584
|
+
/**
|
|
585
|
+
* Get all sibling elements excluding the given one.
|
|
586
|
+
*
|
|
587
|
+
* @param {Node|null} start
|
|
588
|
+
* @param {Node|null} [exclude]
|
|
589
|
+
* @returns {ChildNode[]}
|
|
590
|
+
* @readonly
|
|
591
|
+
*/
|
|
592
|
+
static readonly _getSiblings(start: Node | null, exclude?: Node | null): ChildNode[];
|
|
593
|
+
/**
|
|
594
|
+
* Traverse DOM in a direction collecting elements.
|
|
595
|
+
*
|
|
596
|
+
* @param {TinyNode} el
|
|
597
|
+
* @param {"parentNode"|"nextSibling"|"previousSibling"} direction
|
|
598
|
+
* @param {TinyNode|string} [until]
|
|
599
|
+
* @param {string} [where='domDir']
|
|
600
|
+
* @returns {ChildNode[]}
|
|
601
|
+
*/
|
|
602
|
+
static domDir(el: TinyNode, direction: "parentNode" | "nextSibling" | "previousSibling", until?: TinyNode | string, where?: string): ChildNode[];
|
|
603
|
+
/**
|
|
604
|
+
* Returns the direct parent node of the given element, excluding document fragments.
|
|
605
|
+
*
|
|
606
|
+
* @param {TinyNode} el - The DOM node to find the parent of.
|
|
607
|
+
* @returns {ParentNode|null} The parent node or null if not found.
|
|
608
|
+
*/
|
|
609
|
+
static parent(el: TinyNode): ParentNode | null;
|
|
610
|
+
/**
|
|
611
|
+
* Returns all ancestor nodes of the given element, optionally stopping before a specific ancestor.
|
|
612
|
+
*
|
|
613
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
614
|
+
* @param {TinyNode|string} [until] - A node or selector to stop before.
|
|
615
|
+
* @returns {ChildNode[]} An array of ancestor nodes.
|
|
616
|
+
*/
|
|
617
|
+
static parents(el: TinyNode, until?: TinyNode | string): ChildNode[];
|
|
618
|
+
/**
|
|
619
|
+
* Returns the next sibling of the given element.
|
|
620
|
+
*
|
|
621
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
622
|
+
* @returns {ChildNode|null} The next sibling or null if none found.
|
|
623
|
+
*/
|
|
624
|
+
static next(el: TinyNode): ChildNode | null;
|
|
625
|
+
/**
|
|
626
|
+
* Returns the previous sibling of the given element.
|
|
627
|
+
*
|
|
628
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
629
|
+
* @returns {ChildNode|null} The previous sibling or null if none found.
|
|
630
|
+
*/
|
|
631
|
+
static prev(el: TinyNode): ChildNode | null;
|
|
632
|
+
/**
|
|
633
|
+
* Returns all next sibling nodes after the given element.
|
|
634
|
+
*
|
|
635
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
636
|
+
* @returns {ChildNode[]} An array of next sibling nodes.
|
|
637
|
+
*/
|
|
638
|
+
static nextAll(el: TinyNode): ChildNode[];
|
|
639
|
+
/**
|
|
640
|
+
* Returns all previous sibling nodes before the given element.
|
|
641
|
+
*
|
|
642
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
643
|
+
* @returns {ChildNode[]} An array of previous sibling nodes.
|
|
644
|
+
*/
|
|
645
|
+
static prevAll(el: TinyNode): ChildNode[];
|
|
646
|
+
/**
|
|
647
|
+
* Returns all next sibling nodes up to (but not including) the node matched by a selector or element.
|
|
648
|
+
*
|
|
649
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
650
|
+
* @param {TinyNode|string} [until] - A node or selector to stop before.
|
|
651
|
+
* @returns {ChildNode[]} An array of next sibling nodes.
|
|
652
|
+
*/
|
|
653
|
+
static nextUntil(el: TinyNode, until?: TinyNode | string): ChildNode[];
|
|
654
|
+
/**
|
|
655
|
+
* Returns all previous sibling nodes up to (but not including) the node matched by a selector or element.
|
|
656
|
+
*
|
|
657
|
+
* @param {TinyNode} el - The DOM node to start from.
|
|
658
|
+
* @param {TinyNode|string} [until] - A node or selector to stop before.
|
|
659
|
+
* @returns {ChildNode[]} An array of previous sibling nodes.
|
|
660
|
+
*/
|
|
661
|
+
static prevUntil(el: TinyNode, until?: TinyNode | string): ChildNode[];
|
|
662
|
+
/**
|
|
663
|
+
* Returns all sibling nodes of the given element, excluding itself.
|
|
664
|
+
*
|
|
665
|
+
* @param {TinyNode} el - The DOM node to find siblings of.
|
|
666
|
+
* @returns {ChildNode[]} An array of sibling nodes.
|
|
667
|
+
*/
|
|
668
|
+
static siblings(el: TinyNode): ChildNode[];
|
|
669
|
+
/**
|
|
670
|
+
* Returns all child nodes of the given element.
|
|
671
|
+
*
|
|
672
|
+
* @param {TinyNode} el - The DOM node to get children from.
|
|
673
|
+
* @returns {ChildNode[]} An array of child nodes.
|
|
674
|
+
*/
|
|
675
|
+
static children(el: TinyNode): ChildNode[];
|
|
676
|
+
/**
|
|
677
|
+
* Returns the contents of the given node. For `<template>` it returns its content; for `<iframe>`, the document.
|
|
678
|
+
*
|
|
679
|
+
* @param {TinyNode} el - The DOM node to get contents from.
|
|
680
|
+
* @returns {(ChildNode|DocumentFragment)[]|Document[]} An array of child nodes or the content document of an iframe.
|
|
681
|
+
*/
|
|
682
|
+
static contents(el: TinyNode): (ChildNode | DocumentFragment)[] | Document[];
|
|
683
|
+
/**
|
|
684
|
+
* Clone each element.
|
|
685
|
+
* @param {TinyNode|TinyNode[]} el
|
|
686
|
+
* @param {boolean} [deep=true]
|
|
687
|
+
* @returns {Node[]}
|
|
688
|
+
*/
|
|
689
|
+
static clone(el: TinyNode | TinyNode[], deep?: boolean): Node[];
|
|
690
|
+
static readonly _appendChecker(where: string, ...nodes: (TinyNode | TinyNode[] | string)[]): (Node | string)[];
|
|
691
|
+
/**
|
|
692
|
+
* Appends child elements or strings to the end of the target element(s).
|
|
693
|
+
*
|
|
694
|
+
* @param {TinyElement | TinyElement[]} el - The target element(s) to receive children.
|
|
695
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
696
|
+
*/
|
|
697
|
+
static append(el: TinyElement | TinyElement[], ...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
698
|
+
/**
|
|
699
|
+
* Prepends child elements or strings to the beginning of the target element(s).
|
|
700
|
+
*
|
|
701
|
+
* @param {TinyElement | TinyElement[]} el - The target element(s) to receive children.
|
|
702
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
703
|
+
*/
|
|
704
|
+
static prepend(el: TinyElement | TinyElement[], ...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
705
|
+
/**
|
|
706
|
+
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
707
|
+
*
|
|
708
|
+
* @param {TinyElement | TinyElement[]} el - The target element(s) before which new content is inserted.
|
|
709
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
710
|
+
*/
|
|
711
|
+
static before(el: TinyElement | TinyElement[], ...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
712
|
+
/**
|
|
713
|
+
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
714
|
+
*
|
|
715
|
+
* @param {TinyElement | TinyElement[]} el - The target element(s) after which new content is inserted.
|
|
716
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
717
|
+
*/
|
|
718
|
+
static after(el: TinyElement | TinyElement[], ...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
719
|
+
/**
|
|
720
|
+
* Replaces the target element(s) in the DOM with new elements or text.
|
|
721
|
+
*
|
|
722
|
+
* @param {TinyElement | TinyElement[]} el - The element(s) to be replaced.
|
|
723
|
+
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
724
|
+
*/
|
|
725
|
+
static replaceWith(el: TinyElement | TinyElement[], ...newNodes: (TinyNode | TinyNode[] | string)[]): void;
|
|
726
|
+
/**
|
|
727
|
+
* Appends the given element(s) to each target element in sequence.
|
|
728
|
+
*
|
|
729
|
+
* @param {TinyNode | TinyNode[]} el - The element(s) to append.
|
|
730
|
+
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
731
|
+
*/
|
|
732
|
+
static appendTo(el: TinyNode | TinyNode[], targets: TinyNode | TinyNode[]): void;
|
|
733
|
+
/**
|
|
734
|
+
* Prepends the given element(s) to each target element in sequence.
|
|
735
|
+
*
|
|
736
|
+
* @param {TinyElement | TinyElement[]} el - The element(s) to prepend.
|
|
737
|
+
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
738
|
+
*/
|
|
739
|
+
static prependTo(el: TinyElement | TinyElement[], targets: TinyElement | TinyElement[]): void;
|
|
740
|
+
/**
|
|
741
|
+
* Inserts the element before a child of a given target, or before the target itself.
|
|
742
|
+
*
|
|
743
|
+
* @param {TinyNode | TinyNode[]} el - The element(s) to insert.
|
|
744
|
+
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
745
|
+
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
746
|
+
*/
|
|
747
|
+
static insertBefore(el: TinyNode | TinyNode[], target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): void;
|
|
748
|
+
/**
|
|
749
|
+
* Inserts the element after a child of a given target, or after the target itself.
|
|
750
|
+
*
|
|
751
|
+
* @param {TinyNode | TinyNode[]} el - The element(s) to insert.
|
|
752
|
+
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
753
|
+
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
754
|
+
*/
|
|
755
|
+
static insertAfter(el: TinyNode | TinyNode[], target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): void;
|
|
756
|
+
/**
|
|
757
|
+
* Replaces all target elements with the provided element(s).
|
|
758
|
+
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
759
|
+
*
|
|
760
|
+
* @param {TinyNode | TinyNode[]} el - The new element(s) to insert.
|
|
761
|
+
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
762
|
+
*/
|
|
763
|
+
static replaceAll(el: TinyNode | TinyNode[], targets: TinyNode | TinyNode[]): void;
|
|
764
|
+
/**
|
|
765
|
+
* Checks whether the given object is a window.
|
|
766
|
+
* @param {*} obj - The object to test.
|
|
767
|
+
* @returns {obj is Window} - True if it's a Window.
|
|
768
|
+
*/
|
|
769
|
+
static isWindow(obj: any): obj is Window;
|
|
770
|
+
/**
|
|
771
|
+
* Returns the full computed CSS styles for the given element.
|
|
772
|
+
*
|
|
773
|
+
* @param {TinyElement} el - The element to retrieve styles from.
|
|
774
|
+
* @returns {CSSStyleDeclaration} The computed style object for the element.
|
|
775
|
+
*/
|
|
776
|
+
static css(el: TinyElement): CSSStyleDeclaration;
|
|
777
|
+
/**
|
|
778
|
+
* Returns the value of a specific computed CSS property from the given element as a string.
|
|
779
|
+
*
|
|
780
|
+
* @param {TinyElement} el - The element to retrieve the style property from.
|
|
781
|
+
* @param {string} prop - The name of the CSS property (camelCase or kebab-case).
|
|
782
|
+
* @returns {string|null} The value of the CSS property as a string, or null if not found or invalid.
|
|
783
|
+
*/
|
|
784
|
+
static cssString(el: TinyElement, prop: string): string | null;
|
|
785
|
+
/**
|
|
786
|
+
* Returns a subset of computed CSS styles based on the given list of properties.
|
|
787
|
+
*
|
|
788
|
+
* @param {TinyElement} el - The element to retrieve styles from.
|
|
789
|
+
* @param {string[]} prop - An array of CSS property names to retrieve.
|
|
790
|
+
* @returns {Partial<CSSStyleDeclaration>} An object containing the requested styles.
|
|
791
|
+
*/
|
|
792
|
+
static cssList(el: TinyElement, prop: string[]): Partial<CSSStyleDeclaration>;
|
|
793
|
+
/**
|
|
794
|
+
* Returns the computed CSS float value of a property.
|
|
795
|
+
* @param {TinyElement} el - The element to inspect.
|
|
796
|
+
* @param {string} prop - The CSS property.
|
|
797
|
+
* @returns {number} - The parsed float value.
|
|
798
|
+
*/
|
|
799
|
+
static cssFloat(el: TinyElement, prop: string): number;
|
|
800
|
+
/**
|
|
801
|
+
* Returns computed float values of multiple CSS properties.
|
|
802
|
+
* @param {TinyElement} el - The element to inspect.
|
|
803
|
+
* @param {string[]} prop - An array of CSS properties.
|
|
804
|
+
* @returns {Record<string, number>} - Map of property to float value.
|
|
805
|
+
*/
|
|
806
|
+
static cssFloats(el: TinyElement, prop: string[]): Record<string, number>;
|
|
807
|
+
/**
|
|
808
|
+
* Focus the element.
|
|
809
|
+
*
|
|
810
|
+
* @param {TinyHtmlElement} el - The element or a selector string.
|
|
811
|
+
*/
|
|
812
|
+
static focus(el: TinyHtmlElement): void;
|
|
813
|
+
/**
|
|
814
|
+
* Blur the element.
|
|
815
|
+
*
|
|
816
|
+
* @param {TinyHtmlElement} el - The element or a selector string.
|
|
817
|
+
*/
|
|
818
|
+
static blur(el: TinyHtmlElement): void;
|
|
819
|
+
/**
|
|
820
|
+
* Sets the vertical scroll position of the window.
|
|
821
|
+
* @param {number} value - Sets the scroll position.
|
|
822
|
+
*/
|
|
823
|
+
static setWinScrollTop(value: number): void;
|
|
824
|
+
/**
|
|
825
|
+
* Sets the horizontal scroll position of the window.
|
|
826
|
+
* @param {number} value - Sets the scroll position.
|
|
827
|
+
*/
|
|
828
|
+
static setWinScrollLeft(value: number): void;
|
|
829
|
+
/**
|
|
830
|
+
* Gets the vertical scroll position of the window.
|
|
831
|
+
* @returns {number} - The current scroll top value.
|
|
832
|
+
*/
|
|
833
|
+
static winScrollTop(): number;
|
|
834
|
+
/**
|
|
835
|
+
* Gets the horizontal scroll position of the window.
|
|
836
|
+
* @returns {number} - The current scroll left value.
|
|
837
|
+
*/
|
|
838
|
+
static winScrollLeft(): number;
|
|
839
|
+
/**
|
|
840
|
+
* Returns the current height of the viewport.
|
|
841
|
+
* @returns {number} - Viewport height in pixels.
|
|
842
|
+
*/
|
|
843
|
+
static winInnerHeight(): number;
|
|
844
|
+
/**
|
|
845
|
+
* Returns the current width of the viewport.
|
|
846
|
+
* @returns {number} - Viewport width in pixels.
|
|
847
|
+
*/
|
|
848
|
+
static winInnerWidth(): number;
|
|
849
|
+
/**
|
|
850
|
+
* Gets the width or height of an element based on the box model.
|
|
851
|
+
* @param {TinyElementAndWindow} el - The element or window.
|
|
852
|
+
* @param {"width"|"height"} type - Dimension type.
|
|
853
|
+
* @param {"content"|"padding"|"border"|"margin"} [extra='content'] - Box model context.
|
|
854
|
+
* @returns {number} - Computed dimension.
|
|
855
|
+
* @throws {TypeError} If `type` or `extra` is not a string.
|
|
856
|
+
*/
|
|
857
|
+
static getDimension(el: TinyElementAndWindow, type: "width" | "height", extra?: "content" | "padding" | "border" | "margin"): number;
|
|
858
|
+
/**
|
|
859
|
+
* Sets the height of the element.
|
|
860
|
+
* @param {TinyHtmlElement} el - Target element.
|
|
861
|
+
* @param {string|number} value - Height value.
|
|
862
|
+
* @throws {TypeError} If `value` is neither a string nor number.
|
|
863
|
+
*/
|
|
864
|
+
static setHeight(el: TinyHtmlElement, value: string | number): void;
|
|
865
|
+
/**
|
|
866
|
+
* Sets the width of the element.
|
|
867
|
+
* @param {TinyHtmlElement} el - Target element.
|
|
868
|
+
* @param {string|number} value - Width value.
|
|
869
|
+
* @throws {TypeError} If `value` is neither a string nor number.
|
|
870
|
+
*/
|
|
871
|
+
static setWidth(el: TinyHtmlElement, value: string | number): void;
|
|
872
|
+
/**
|
|
873
|
+
* Returns content box height.
|
|
874
|
+
* @param {TinyElementAndWindow} el - Target element.
|
|
875
|
+
* @returns {number}
|
|
876
|
+
*/
|
|
877
|
+
static height(el: TinyElementAndWindow): number;
|
|
878
|
+
/**
|
|
879
|
+
* Returns content box width.
|
|
880
|
+
* @param {TinyElementAndWindow} el - Target element.
|
|
881
|
+
* @returns {number}
|
|
882
|
+
*/
|
|
883
|
+
static width(el: TinyElementAndWindow): number;
|
|
884
|
+
/**
|
|
885
|
+
* Returns padding box height.
|
|
886
|
+
* @param {TinyElementAndWindow} el - Target element.
|
|
887
|
+
* @returns {number}
|
|
888
|
+
*/
|
|
889
|
+
static innerHeight(el: TinyElementAndWindow): number;
|
|
890
|
+
/**
|
|
891
|
+
* Returns padding box width.
|
|
892
|
+
* @param {TinyElementAndWindow} el - Target element.
|
|
893
|
+
* @returns {number}
|
|
894
|
+
*/
|
|
895
|
+
static innerWidth(el: TinyElementAndWindow): number;
|
|
896
|
+
/**
|
|
897
|
+
* Returns outer height of the element, optionally including margin.
|
|
898
|
+
* @param {TinyElementAndWindow} el - Target element.
|
|
899
|
+
* @param {boolean} [includeMargin=false] - Whether to include margin.
|
|
900
|
+
* @returns {number}
|
|
901
|
+
*/
|
|
902
|
+
static outerHeight(el: TinyElementAndWindow, includeMargin?: boolean): number;
|
|
903
|
+
/**
|
|
904
|
+
* Returns outer width of the element, optionally including margin.
|
|
905
|
+
* @param {TinyElementAndWindow} el - Target element.
|
|
906
|
+
* @param {boolean} [includeMargin=false] - Whether to include margin.
|
|
907
|
+
* @returns {number}
|
|
908
|
+
*/
|
|
909
|
+
static outerWidth(el: TinyElementAndWindow, includeMargin?: boolean): number;
|
|
910
|
+
/**
|
|
911
|
+
* Gets the offset of the element relative to the document.
|
|
912
|
+
* @param {TinyElement} el - Target element.
|
|
913
|
+
* @returns {{top: number, left: number}}
|
|
914
|
+
*/
|
|
915
|
+
static offset(el: TinyElement): {
|
|
916
|
+
top: number;
|
|
917
|
+
left: number;
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* Gets the position of the element relative to its offset parent.
|
|
921
|
+
* @param {TinyHtmlElement} el - Target element.
|
|
922
|
+
* @returns {{top: number, left: number}}
|
|
923
|
+
*/
|
|
924
|
+
static position(el: TinyHtmlElement): {
|
|
925
|
+
top: number;
|
|
926
|
+
left: number;
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* Gets the closest positioned ancestor element.
|
|
930
|
+
* @param {TinyHtmlElement} el - Target element.
|
|
931
|
+
* @returns {HTMLElement} - Offset parent element.
|
|
932
|
+
*/
|
|
933
|
+
static offsetParent(el: TinyHtmlElement): HTMLElement;
|
|
934
|
+
/**
|
|
935
|
+
* Gets the vertical scroll position.
|
|
936
|
+
* @param {TinyElementAndWindow} el - Element or window.
|
|
937
|
+
* @returns {number}
|
|
938
|
+
*/
|
|
939
|
+
static scrollTop(el: TinyElementAndWindow): number;
|
|
940
|
+
/**
|
|
941
|
+
* Gets the horizontal scroll position.
|
|
942
|
+
* @param {TinyElementAndWindow} el - Element or window.
|
|
943
|
+
* @returns {number}
|
|
944
|
+
*/
|
|
945
|
+
static scrollLeft(el: TinyElementAndWindow): number;
|
|
946
|
+
/**
|
|
947
|
+
* Sets the vertical scroll position.
|
|
948
|
+
* @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
|
|
949
|
+
* @param {number} value - Scroll top value.
|
|
950
|
+
*/
|
|
951
|
+
static setScrollTop(el: TinyElementAndWindow | TinyElementAndWindow[], value: number): void;
|
|
952
|
+
/**
|
|
953
|
+
* Sets the horizontal scroll position.
|
|
954
|
+
* @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
|
|
955
|
+
* @param {number} value - Scroll left value.
|
|
956
|
+
*/
|
|
957
|
+
static setScrollLeft(el: TinyElementAndWindow | TinyElementAndWindow[], value: number): void;
|
|
958
|
+
/**
|
|
959
|
+
* Returns the total border width and individual sides from `border{Side}Width` CSS properties.
|
|
960
|
+
*
|
|
961
|
+
* @param {TinyElement} el - The target DOM element.
|
|
962
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
|
|
963
|
+
*/
|
|
964
|
+
static borderWidth(el: TinyElement): HtmlElBoxSides;
|
|
965
|
+
/**
|
|
966
|
+
* Returns the total border size and individual sides from `border{Side}` CSS properties.
|
|
967
|
+
*
|
|
968
|
+
* @param {TinyElement} el - The target DOM element.
|
|
969
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
|
|
970
|
+
*/
|
|
971
|
+
static border(el: TinyElement): HtmlElBoxSides;
|
|
972
|
+
/**
|
|
973
|
+
* Returns the total margin and individual sides from `margin{Side}` CSS properties.
|
|
974
|
+
*
|
|
975
|
+
* @param {TinyElement} el - The target DOM element.
|
|
976
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
|
|
977
|
+
*/
|
|
978
|
+
static margin(el: TinyElement): HtmlElBoxSides;
|
|
979
|
+
/**
|
|
980
|
+
* Returns the total padding and individual sides from `padding{Side}` CSS properties.
|
|
981
|
+
*
|
|
982
|
+
* @param {TinyElement} el - The target DOM element.
|
|
983
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
|
|
984
|
+
*/
|
|
985
|
+
static padding(el: TinyElement): HtmlElBoxSides;
|
|
986
|
+
static addClass(el: TinyElement | TinyElement[], ...tokens: string[]): void;
|
|
987
|
+
static removeClass(el: TinyElement | TinyElement[], ...tokens: string[]): void;
|
|
988
|
+
/**
|
|
989
|
+
* Replaces an existing class name with a new one.
|
|
990
|
+
* @param {TinyElement|TinyElement[]} el - Target element.
|
|
991
|
+
* @param {string} token - The class name to be replaced.
|
|
992
|
+
* @param {string} newToken - The new class name to apply.
|
|
993
|
+
* @returns {boolean[]} Whether the replacement was successful.
|
|
994
|
+
* @throws {TypeError} If either argument is not a string.
|
|
995
|
+
*/
|
|
996
|
+
static replaceClass(el: TinyElement | TinyElement[], token: string, newToken: string): boolean[];
|
|
997
|
+
/**
|
|
998
|
+
* Returns the class name at the specified index.
|
|
999
|
+
* @param {TinyElement} el - Target element.
|
|
1000
|
+
* @param {number} index - The index of the class name.
|
|
1001
|
+
* @returns {string|null} The class name at the index or null if not found.
|
|
1002
|
+
* @throws {TypeError} If the index is not a number.
|
|
1003
|
+
*/
|
|
1004
|
+
static classItem(el: TinyElement, index: number): string | null;
|
|
1005
|
+
/**
|
|
1006
|
+
* Toggles a class name on the element with an optional force boolean.
|
|
1007
|
+
* @param {TinyElement|TinyElement[]} el - Target element.
|
|
1008
|
+
* @param {string} token - The class name to toggle.
|
|
1009
|
+
* @param {boolean} [force] - If true, adds the class; if false, removes it.
|
|
1010
|
+
* @returns {boolean[]} Whether the class is present after the toggle.
|
|
1011
|
+
* @throws {TypeError} If token is not a string or force is not a boolean.
|
|
1012
|
+
*/
|
|
1013
|
+
static toggleClass(el: TinyElement | TinyElement[], token: string, force?: boolean): boolean[];
|
|
1014
|
+
/**
|
|
1015
|
+
* Checks if the element contains the given class name.
|
|
1016
|
+
* @param {TinyElement} el - Target element.
|
|
1017
|
+
* @param {string} token - The class name to check.
|
|
1018
|
+
* @returns {boolean} True if the class is present, false otherwise.
|
|
1019
|
+
* @throws {TypeError} If token is not a string.
|
|
1020
|
+
*/
|
|
1021
|
+
static hasClass(el: TinyElement, token: string): boolean;
|
|
1022
|
+
/**
|
|
1023
|
+
* Returns the number of classes applied to the element.
|
|
1024
|
+
* @param {TinyElement} el - Target element.
|
|
1025
|
+
* @returns {number} The number of classes.
|
|
1026
|
+
*/
|
|
1027
|
+
static classLength(el: TinyElement): number;
|
|
1028
|
+
/**
|
|
1029
|
+
* Returns all class names as an array of strings.
|
|
1030
|
+
* @param {TinyElement} el - Target element.
|
|
1031
|
+
* @returns {string[]} An array of class names.
|
|
1032
|
+
*/
|
|
1033
|
+
static classList(el: TinyElement): string[];
|
|
1034
|
+
/**
|
|
1035
|
+
* Returns the tag name of the element.
|
|
1036
|
+
* @param {TinyElement} el - Target element.
|
|
1037
|
+
* @returns {string} The tag name in uppercase.
|
|
1038
|
+
*/
|
|
1039
|
+
static tagName(el: TinyElement): string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Returns the ID of the element.
|
|
1042
|
+
* @param {TinyElement} el - Target element.
|
|
1043
|
+
* @returns {string} The element's ID.
|
|
1044
|
+
*/
|
|
1045
|
+
static id(el: TinyElement): string;
|
|
1046
|
+
/**
|
|
1047
|
+
* Returns the text content of the element.
|
|
1048
|
+
* @param {TinyElement} el - Target element.
|
|
1049
|
+
* @returns {string|null} The text content or null if none.
|
|
1050
|
+
*/
|
|
1051
|
+
static text(el: TinyElement): string | null;
|
|
1052
|
+
/**
|
|
1053
|
+
* Set text content of elements.
|
|
1054
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1055
|
+
* @param {string} value
|
|
1056
|
+
*/
|
|
1057
|
+
static setText(el: TinyElement | TinyElement[], value: string): void;
|
|
1058
|
+
/**
|
|
1059
|
+
* Remove all child nodes from each element.
|
|
1060
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1061
|
+
*/
|
|
1062
|
+
static empty(el: TinyElement | TinyElement[]): void;
|
|
1063
|
+
/**
|
|
1064
|
+
* Get the innerHTML of the element.
|
|
1065
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1066
|
+
* @returns {string}
|
|
1067
|
+
*/
|
|
1068
|
+
static html(el: TinyElement | TinyElement[]): string;
|
|
1069
|
+
/**
|
|
1070
|
+
* Set the innerHTML of each element.
|
|
1071
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1072
|
+
* @param {string} value
|
|
1073
|
+
*/
|
|
1074
|
+
static setHtml(el: TinyElement | TinyElement[], value: string): void;
|
|
1075
|
+
/** @readonly */
|
|
1076
|
+
static readonly _valHooks: {
|
|
1077
|
+
option: {
|
|
1078
|
+
/**
|
|
1079
|
+
* @param {HTMLOptionElement} elem
|
|
1080
|
+
* @returns {string|null}
|
|
1081
|
+
*/
|
|
1082
|
+
get: (elem: HTMLOptionElement) => string | null;
|
|
1083
|
+
};
|
|
1084
|
+
select: {
|
|
1085
|
+
/**
|
|
1086
|
+
* @param {HTMLSelectElement} elem
|
|
1087
|
+
* @returns {(string | null)[] | string | null}
|
|
1088
|
+
*/
|
|
1089
|
+
get: (elem: HTMLSelectElement) => (string | null)[] | string | null;
|
|
1090
|
+
/**
|
|
1091
|
+
* @param {HTMLSelectElement} elem
|
|
1092
|
+
* @param {string[]|string} value
|
|
1093
|
+
*/
|
|
1094
|
+
set: (elem: HTMLSelectElement, value: string[] | string) => string[];
|
|
1095
|
+
};
|
|
1096
|
+
radio: {
|
|
1097
|
+
/**
|
|
1098
|
+
* @param {HTMLInputElement} elem
|
|
1099
|
+
* @returns {string}
|
|
1100
|
+
*/
|
|
1101
|
+
get(elem: HTMLInputElement): string;
|
|
1102
|
+
/**
|
|
1103
|
+
* @param {HTMLInputElement} elem
|
|
1104
|
+
* @param {string[]} value
|
|
1105
|
+
*/
|
|
1106
|
+
set(elem: HTMLInputElement, value: string[]): undefined;
|
|
1107
|
+
};
|
|
1108
|
+
checkbox: {
|
|
1109
|
+
/**
|
|
1110
|
+
* @param {HTMLInputElement} elem
|
|
1111
|
+
* @returns {string}
|
|
1112
|
+
*/
|
|
1113
|
+
get(elem: HTMLInputElement): string;
|
|
1114
|
+
/**
|
|
1115
|
+
* @param {HTMLInputElement} elem
|
|
1116
|
+
* @param {boolean} value
|
|
1117
|
+
*/
|
|
1118
|
+
set(elem: HTMLInputElement, value: boolean): boolean | undefined;
|
|
1119
|
+
};
|
|
1120
|
+
};
|
|
1121
|
+
/**
|
|
1122
|
+
* Sets the value of the current HTML value element (input, select, textarea, etc.).
|
|
1123
|
+
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
1124
|
+
*
|
|
1125
|
+
* @param {TinyInputElement|TinyInputElement[]} el - Target element.
|
|
1126
|
+
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
1127
|
+
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
1128
|
+
*/
|
|
1129
|
+
static setVal(el: TinyInputElement | TinyInputElement[], value: SetValueList | ((el: InputElement, val: SetValueList) => SetValueList)): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Maps value types to their corresponding getter functions.
|
|
1132
|
+
* Each function extracts a value of a specific type from a compatible HTMLInputElement.
|
|
1133
|
+
* @readonly
|
|
1134
|
+
*/
|
|
1135
|
+
static readonly _valTypes: {
|
|
1136
|
+
/**
|
|
1137
|
+
* Gets the string value from any HTMLInputElement.
|
|
1138
|
+
* @type {(elem: HTMLInputElement) => string}
|
|
1139
|
+
*/
|
|
1140
|
+
string: (elem: HTMLInputElement) => string;
|
|
1141
|
+
/**
|
|
1142
|
+
* Gets the value as a Date object from supported input types.
|
|
1143
|
+
* Valid only for types: "date", "datetime-local", "month", "time", "week".
|
|
1144
|
+
* Returns `null` if the field is empty or invalid.
|
|
1145
|
+
* @type {(elem: HTMLInputElement & { type: "date" | "datetime-local" | "month" | "time" | "week" }) => Date | null}
|
|
1146
|
+
*/
|
|
1147
|
+
date: (elem: HTMLInputElement & {
|
|
1148
|
+
type: "date" | "datetime-local" | "month" | "time" | "week";
|
|
1149
|
+
}) => Date | null;
|
|
1150
|
+
/**
|
|
1151
|
+
* Gets the numeric value from supported input types.
|
|
1152
|
+
* Valid for types: "number", "range", "date", "time".
|
|
1153
|
+
* Returns `NaN` if the value is invalid or empty.
|
|
1154
|
+
* @type {(elem: HTMLInputElement & { type: "number" | "range" | "date" | "time" }) => number}
|
|
1155
|
+
*/
|
|
1156
|
+
number: (elem: HTMLInputElement & {
|
|
1157
|
+
type: "number" | "range" | "date" | "time";
|
|
1158
|
+
}) => number;
|
|
1159
|
+
};
|
|
1160
|
+
/**
|
|
1161
|
+
* Gets the value of an input element according to the specified type.
|
|
1162
|
+
*
|
|
1163
|
+
* @param {InputElement} elem - The input element to extract the value from.
|
|
1164
|
+
* @param {GetValueTypes} type - The type of value to retrieve ("string", "date", or "number").
|
|
1165
|
+
* @param {string} where - The context/method name using this validation.
|
|
1166
|
+
* @returns {any} The extracted value, depending on the type.
|
|
1167
|
+
* @throws {Error} If the element is not an HTMLInputElement or if the type handler is invalid.
|
|
1168
|
+
* @readonly
|
|
1169
|
+
*/
|
|
1170
|
+
static readonly _getValByType(elem: InputElement, type: GetValueTypes, where: string): any;
|
|
1171
|
+
/**
|
|
1172
|
+
* Retrieves the raw value from the HTML input element.
|
|
1173
|
+
* If a custom value hook exists, it will be used first.
|
|
1174
|
+
*
|
|
1175
|
+
* @param {TinyInputElement} el - Target element.
|
|
1176
|
+
* @param {GetValueTypes} type - The type of value to retrieve ("string", "date", or "number").
|
|
1177
|
+
* @param {string} where - The context/method name using this validation.
|
|
1178
|
+
* @returns {any} The raw value retrieved from the element or hook.
|
|
1179
|
+
* @readonly
|
|
1180
|
+
*/
|
|
1181
|
+
static readonly _val(el: TinyInputElement, where: string, type: GetValueTypes): any;
|
|
1182
|
+
/**
|
|
1183
|
+
* Gets the value of the current HTML value element.
|
|
1184
|
+
*
|
|
1185
|
+
* @param {TinyInputElement} el - Target element.
|
|
1186
|
+
* @returns {SetValueList} The normalized value, with carriage returns removed.
|
|
1187
|
+
*/
|
|
1188
|
+
static val(el: TinyInputElement): SetValueList;
|
|
1189
|
+
/**
|
|
1190
|
+
* Gets the text of the current HTML value element (for text).
|
|
1191
|
+
*
|
|
1192
|
+
* @param {TinyInputElement} el - Target element.
|
|
1193
|
+
* @returns {string} The text value.
|
|
1194
|
+
* @throws {Error} If the element is not a string value.
|
|
1195
|
+
*/
|
|
1196
|
+
static valTxt(el: TinyInputElement): string;
|
|
1197
|
+
/**
|
|
1198
|
+
* Internal helper to get a value from an input expected to return an array.
|
|
1199
|
+
*
|
|
1200
|
+
* @param {TinyInputElement} el - Target element.
|
|
1201
|
+
* @param {string} where - The method name or context using this validation (for error reporting).
|
|
1202
|
+
* @param {GetValueTypes} type - The type of value to retrieve ("string", "date", or "number").
|
|
1203
|
+
* @returns {SetValueBase[]} - The validated value as an array.
|
|
1204
|
+
* @throws {Error} If the returned value is not an array.
|
|
1205
|
+
* @readonly
|
|
1206
|
+
*/
|
|
1207
|
+
static readonly _valArr(el: TinyInputElement, where: string, type: GetValueTypes): SetValueBase[];
|
|
1208
|
+
/**
|
|
1209
|
+
* Gets the raw value as a generic array of the current HTML value element (for select).
|
|
1210
|
+
*
|
|
1211
|
+
* @param {TinyInputElement} el - Target element.
|
|
1212
|
+
* @returns {SetValueBase[]} - The value cast as a generic array.
|
|
1213
|
+
* @throws {Error} If the value is not a valid array.
|
|
1214
|
+
*/
|
|
1215
|
+
static valArr(el: TinyInputElement): SetValueBase[];
|
|
1216
|
+
/**
|
|
1217
|
+
* Gets the current value parsed as a number (for number/text).
|
|
1218
|
+
*
|
|
1219
|
+
* @param {TinyInputElement} el - Target element.
|
|
1220
|
+
* @returns {number} The numeric value.
|
|
1221
|
+
* @throws {Error} If the element is not a number-compatible input or value is NaN.
|
|
1222
|
+
*/
|
|
1223
|
+
static valNb(el: TinyInputElement): number;
|
|
1224
|
+
/**
|
|
1225
|
+
* Gets the current value parsed as a Date (for time/date).
|
|
1226
|
+
*
|
|
1227
|
+
* @param {TinyInputElement} el - Target element.
|
|
1228
|
+
* @returns {Date} The date value.
|
|
1229
|
+
* @throws {Error} If the element is not a date-compatible input.
|
|
1230
|
+
*/
|
|
1231
|
+
static valDate(el: TinyInputElement): Date;
|
|
1232
|
+
/**
|
|
1233
|
+
* Checks if the input element is boolean (for checkboxes/radios).
|
|
1234
|
+
*
|
|
1235
|
+
* @param {TinyInputElement} el - Target element.
|
|
1236
|
+
* @returns {boolean} True if the input is considered checked (value === "on"), false otherwise.
|
|
1237
|
+
* @throws {Error} If the element is not a checkbox/radio input.
|
|
1238
|
+
*/
|
|
1239
|
+
static valBool(el: TinyInputElement): boolean;
|
|
1240
|
+
/**
|
|
1241
|
+
* Registers an event listener on the specified element.
|
|
1242
|
+
*
|
|
1243
|
+
* @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
|
|
1244
|
+
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
1245
|
+
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
1246
|
+
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
1247
|
+
*/
|
|
1248
|
+
static on(el: TinyEventTarget | TinyEventTarget[], event: string, handler: EventRegistryHandle, options?: EventRegistryOptions): void;
|
|
1249
|
+
/**
|
|
1250
|
+
* Registers an event listener that runs only once, then is removed.
|
|
1251
|
+
*
|
|
1252
|
+
* @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
|
|
1253
|
+
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
1254
|
+
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
1255
|
+
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
1256
|
+
*/
|
|
1257
|
+
static once(el: TinyEventTarget | TinyEventTarget[], event: string, handler: EventRegistryHandle, options?: EventRegistryOptions): void;
|
|
1258
|
+
/**
|
|
1259
|
+
* Removes a specific event listener from an element.
|
|
1260
|
+
*
|
|
1261
|
+
* @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
|
|
1262
|
+
* @param {string} event - The event type.
|
|
1263
|
+
* @param {EventRegistryHandle} handler - The function originally bound to the event.
|
|
1264
|
+
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
1265
|
+
*/
|
|
1266
|
+
static off(el: TinyEventTarget | TinyEventTarget[], event: string, handler: EventRegistryHandle, options?: boolean | EventListenerOptions): void;
|
|
1267
|
+
/**
|
|
1268
|
+
* Removes all event listeners of a specific type from the element.
|
|
1269
|
+
*
|
|
1270
|
+
* @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
|
|
1271
|
+
* @param {string} event - The event type to remove (e.g. 'click').
|
|
1272
|
+
*/
|
|
1273
|
+
static offAll(el: TinyEventTarget | TinyEventTarget[], event: string): void;
|
|
1274
|
+
/**
|
|
1275
|
+
* Removes all event listeners of all types from the element.
|
|
1276
|
+
*
|
|
1277
|
+
* @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
|
|
1278
|
+
* @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
|
|
1279
|
+
* Optional filter function to selectively remove specific handlers.
|
|
1280
|
+
*/
|
|
1281
|
+
static offAllTypes(el: TinyEventTarget | TinyEventTarget[], filterFn?: ((handler: EventListenerOrEventListenerObject, event: string) => boolean) | null): void;
|
|
1282
|
+
/**
|
|
1283
|
+
* Triggers all handlers associated with a specific event on the given element.
|
|
1284
|
+
*
|
|
1285
|
+
* @param {TinyEventTarget|TinyEventTarget[]} el - Target element where the event should be triggered.
|
|
1286
|
+
* @param {string} event - Name of the event to trigger.
|
|
1287
|
+
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
1288
|
+
*/
|
|
1289
|
+
static trigger(el: TinyEventTarget | TinyEventTarget[], event: string, payload?: Event | CustomEvent | CustomEventInit): void;
|
|
1290
|
+
/**
|
|
1291
|
+
* Property name normalization similar to jQuery's propFix.
|
|
1292
|
+
* @readonly
|
|
1293
|
+
*/
|
|
1294
|
+
static readonly _propFix: {
|
|
1295
|
+
for: string;
|
|
1296
|
+
class: string;
|
|
1297
|
+
};
|
|
1298
|
+
/**
|
|
1299
|
+
* Get an attribute on an element.
|
|
1300
|
+
* @param {TinyElement} el
|
|
1301
|
+
* @param {string} name
|
|
1302
|
+
* @returns {string|null}
|
|
1303
|
+
*/
|
|
1304
|
+
static attr(el: TinyElement, name: string): string | null;
|
|
1305
|
+
/**
|
|
1306
|
+
* Set an attribute on an element.
|
|
1307
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1308
|
+
* @param {string} name
|
|
1309
|
+
* @param {string|null} [value=null]
|
|
1310
|
+
*/
|
|
1311
|
+
static setAttr(el: TinyElement | TinyElement[], name: string, value?: string | null): void;
|
|
1312
|
+
/**
|
|
1313
|
+
* Remove attribute(s) from an element.
|
|
1314
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1315
|
+
* @param {string} name Space-separated list of attributes.
|
|
1316
|
+
*/
|
|
1317
|
+
static removeAttr(el: TinyElement | TinyElement[], name: string): void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Check if an attribute exists on an element.
|
|
1320
|
+
* @param {TinyElement} el
|
|
1321
|
+
* @param {string} name
|
|
1322
|
+
* @returns {boolean}
|
|
1323
|
+
*/
|
|
1324
|
+
static hasAttr(el: TinyElement, name: string): boolean;
|
|
1325
|
+
/**
|
|
1326
|
+
* Check if a property exists.
|
|
1327
|
+
* @param {TinyElement} el
|
|
1328
|
+
* @param {string} name
|
|
1329
|
+
* @returns {boolean}
|
|
1330
|
+
*/
|
|
1331
|
+
static hasProp(el: TinyElement, name: string): boolean;
|
|
1332
|
+
/**
|
|
1333
|
+
* Set a property on an element.
|
|
1334
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1335
|
+
* @param {string} name
|
|
1336
|
+
*/
|
|
1337
|
+
static addProp(el: TinyElement | TinyElement[], name: string): void;
|
|
1338
|
+
/**
|
|
1339
|
+
* Remove a property from an element.
|
|
1340
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1341
|
+
* @param {string} name
|
|
1342
|
+
*/
|
|
1343
|
+
static removeProp(el: TinyElement | TinyElement[], name: string): void;
|
|
1344
|
+
/**
|
|
1345
|
+
* Toggle a boolean property.
|
|
1346
|
+
* @param {TinyElement|TinyElement[]} el
|
|
1347
|
+
* @param {string} name
|
|
1348
|
+
* @param {boolean} [force]
|
|
1349
|
+
*/
|
|
1350
|
+
static toggleProp(el: TinyElement | TinyElement[], name: string, force?: boolean): void;
|
|
1351
|
+
/**
|
|
1352
|
+
* Removes an element from the DOM.
|
|
1353
|
+
* @param {TinyElement|TinyElement[]} el - The DOM element or selector to remove.
|
|
1354
|
+
*/
|
|
1355
|
+
static remove(el: TinyElement | TinyElement[]): void;
|
|
1356
|
+
/**
|
|
1357
|
+
* Returns the index of the first element within its parent or relative to a selector/element.
|
|
1358
|
+
*
|
|
1359
|
+
* @param {TinyElement} el - The element target
|
|
1360
|
+
* @param {string|TinyElement|null} [el2] - Optional target to compare index against.
|
|
1361
|
+
* @returns {number}
|
|
1362
|
+
*/
|
|
1363
|
+
static index(el: TinyElement, el2?: string | TinyElement | null): number;
|
|
1364
|
+
/**
|
|
1365
|
+
* Creates a new DOMRect object by copying the base rect and applying optional additional dimensions.
|
|
1366
|
+
*
|
|
1367
|
+
* @param {DOMRect} rect - The base rectangle to be cloned and extended.
|
|
1368
|
+
* @param {Partial<DOMRect>} extraRect - Additional dimensions to apply to the base rect (e.g., extra padding or offset).
|
|
1369
|
+
* @returns {DOMRect} - A new DOMRect object with the combined dimensions.
|
|
1370
|
+
* @readonly
|
|
1371
|
+
*/
|
|
1372
|
+
static readonly _getCustomRect(rect: DOMRect, extraRect: Partial<DOMRect>): DOMRect;
|
|
1373
|
+
/**
|
|
1374
|
+
* Determines if two HTML elements are colliding, using a simple bounding box comparison.
|
|
1375
|
+
*
|
|
1376
|
+
* @param {TinyElement} el1 - The first element to compare.
|
|
1377
|
+
* @param {TinyElement} el2 - The second element to compare.
|
|
1378
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
1379
|
+
* @returns {boolean} - `true` if the elements are colliding, `false` otherwise.
|
|
1380
|
+
*/
|
|
1381
|
+
static isCollWith(el1: TinyElement, el2: TinyElement, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
1382
|
+
/**
|
|
1383
|
+
* Determines if two HTML elements are colliding using a pixel-perfect collision algorithm.
|
|
1384
|
+
*
|
|
1385
|
+
* @param {TinyElement} el1 - The first element to compare.
|
|
1386
|
+
* @param {TinyElement} el2 - The second element to compare.
|
|
1387
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
1388
|
+
* @returns {boolean} - `true` if the elements are colliding with higher precision, `false` otherwise.
|
|
1389
|
+
*/
|
|
1390
|
+
static isCollPerfWith(el1: TinyElement, el2: TinyElement, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
1391
|
+
/**
|
|
1392
|
+
* Determines whether two elements are colliding with a directional lock mechanism.
|
|
1393
|
+
*
|
|
1394
|
+
* This function tracks the direction from which an element (`elem1`) initially collided with another,
|
|
1395
|
+
* and keeps the collision "locked" until the element exits the collision from the same direction.
|
|
1396
|
+
*
|
|
1397
|
+
* - If `isColliding` is true and no lock is stored yet, it saves the direction of entry.
|
|
1398
|
+
* - If `isColliding` is false but a previous lock exists, it checks if the element has exited
|
|
1399
|
+
* in the same direction it entered to remove the lock.
|
|
1400
|
+
*
|
|
1401
|
+
* @param {boolean} isColliding - Indicates whether `rect1` and `rect2` are currently colliding.
|
|
1402
|
+
* @param {DOMRect} rect1 - The bounding box of the first element.
|
|
1403
|
+
* @param {DOMRect} rect2 - The bounding box of the second element.
|
|
1404
|
+
* @param {Element} elem1 - The element to track collision state for.
|
|
1405
|
+
* @param {CollisionDirLock} lockDirection - The direction from which the collision was first detected.
|
|
1406
|
+
* @returns {boolean} Returns `true` if the element is still considered colliding (locked), otherwise `false`.
|
|
1407
|
+
* @readonly
|
|
1408
|
+
*/
|
|
1409
|
+
static readonly _isCollWithLock(isColliding: boolean, rect1: DOMRect, rect2: DOMRect, elem1: Element, lockDirection: CollisionDirLock): boolean;
|
|
1410
|
+
/**
|
|
1411
|
+
* Checks if two DOM elements are colliding on the screen, and locks the collision
|
|
1412
|
+
* until the element exits through the same side it entered.
|
|
1413
|
+
*
|
|
1414
|
+
* @param {TinyElement} el1 - First DOM element (e.g. draggable or moving element).
|
|
1415
|
+
* @param {TinyElement} el2 - Second DOM element (e.g. a container or boundary element).
|
|
1416
|
+
* @param {CollisionDirLock} lockDirection - Direction that must be respected to unlock the collision.
|
|
1417
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
1418
|
+
* @returns {boolean} True if collision is still active.
|
|
1419
|
+
*/
|
|
1420
|
+
static isCollWithLock(el1: TinyElement, el2: TinyElement, lockDirection: CollisionDirLock, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
1421
|
+
/**
|
|
1422
|
+
* Checks if two DOM elements are colliding on the screen, and locks the collision
|
|
1423
|
+
* until the element exits through the same side it entered.
|
|
1424
|
+
*
|
|
1425
|
+
* @param {TinyElement} el1 - First DOM element (e.g. draggable or moving element).
|
|
1426
|
+
* @param {TinyElement} el2 - Second DOM element (e.g. a container or boundary element).
|
|
1427
|
+
* @param {CollisionDirLock} lockDirection - Direction that must be respected to unlock the collision.
|
|
1428
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
1429
|
+
* @returns {boolean} True if collision is still active.
|
|
1430
|
+
*/
|
|
1431
|
+
static isCollPerfWithLock(el1: TinyElement, el2: TinyElement, lockDirection: CollisionDirLock, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
1432
|
+
/**
|
|
1433
|
+
* Resets all collision locks for a specific element (for all directions).
|
|
1434
|
+
*
|
|
1435
|
+
* @param {TinyElement} el - The element whose locks should be removed.
|
|
1436
|
+
* @returns {boolean} True if at least one lock was removed.
|
|
1437
|
+
*/
|
|
1438
|
+
static resetCollLock(el: TinyElement): boolean;
|
|
1439
|
+
/**
|
|
1440
|
+
* Resets the collision lock for a specific element and direction.
|
|
1441
|
+
*
|
|
1442
|
+
* @param {TinyElement} el - The element whose lock should be removed.
|
|
1443
|
+
* @param {CollisionDirLock} direction - The direction to clear the lock from.
|
|
1444
|
+
* @returns {boolean} True if the lock was removed.
|
|
1445
|
+
*/
|
|
1446
|
+
static resetCollLockDir(el: TinyElement, direction: CollisionDirLock): boolean;
|
|
1447
|
+
/**
|
|
1448
|
+
* Checks if the given element is at least partially visible in the viewport.
|
|
1449
|
+
*
|
|
1450
|
+
* @param {TinyElement} el - The DOM element to check.
|
|
1451
|
+
* @returns {boolean} True if the element is partially in the viewport, false otherwise.
|
|
1452
|
+
*/
|
|
1453
|
+
static isInViewport(el: TinyElement): boolean;
|
|
1454
|
+
/**
|
|
1455
|
+
* Checks if the given element is fully visible in the viewport (top and bottom).
|
|
1456
|
+
*
|
|
1457
|
+
* @param {TinyElement} el - The DOM element to check.
|
|
1458
|
+
* @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
|
|
1459
|
+
*/
|
|
1460
|
+
static isScrolledIntoView(el: TinyElement): boolean;
|
|
1461
|
+
/**
|
|
1462
|
+
* Creates an instance of TinyHtml for a specific Element.
|
|
1463
|
+
* Useful when you want to operate repeatedly on the same element using instance methods.
|
|
1464
|
+
* @param {ConstructorElValues} el - The element to wrap and manipulate.
|
|
1465
|
+
*/
|
|
1466
|
+
constructor(el: ConstructorElValues);
|
|
1467
|
+
/**
|
|
1468
|
+
* Returns the current target held by this instance.
|
|
1469
|
+
*
|
|
1470
|
+
* @returns {ConstructorElValues} - The instance's target element.
|
|
1471
|
+
*/
|
|
1472
|
+
get(): ConstructorElValues;
|
|
1473
|
+
/**
|
|
1474
|
+
* Returns the current Element held by this instance.
|
|
1475
|
+
*
|
|
1476
|
+
* @param {string} where - The method name or context calling this.
|
|
1477
|
+
* @returns {ConstructorElValues} - The instance's element.
|
|
1478
|
+
* @readonly
|
|
1479
|
+
*/
|
|
1480
|
+
readonly _getElement(where: string): ConstructorElValues;
|
|
1481
|
+
/**
|
|
1482
|
+
* Returns only the elements **not** matching the given selector or function.
|
|
1483
|
+
*
|
|
1484
|
+
* @param {WinnowRequest} selector
|
|
1485
|
+
* @returns {Element[]}
|
|
1486
|
+
*/
|
|
1487
|
+
not(selector: WinnowRequest): Element[];
|
|
1488
|
+
/**
|
|
1489
|
+
* Finds elements in your element matching a selector within a context.
|
|
1490
|
+
*
|
|
1491
|
+
* @param {string} selector
|
|
1492
|
+
* @returns {Element[]}
|
|
1493
|
+
*/
|
|
1494
|
+
find(selector: string): Element[];
|
|
1495
|
+
/**
|
|
1496
|
+
* Checks if the element matches the selector.
|
|
1497
|
+
*
|
|
1498
|
+
* @param {WinnowRequest} selector
|
|
1499
|
+
* @returns {boolean}
|
|
1500
|
+
*/
|
|
1501
|
+
is(selector: WinnowRequest): boolean;
|
|
1502
|
+
/**
|
|
1503
|
+
* Return if the element has the target(s).
|
|
1504
|
+
* @param {string|TinyElement|TinyElement[]} target - Selector or DOM element(s).
|
|
1505
|
+
* @returns {boolean} Elements that contain the target.
|
|
1506
|
+
*/
|
|
1507
|
+
has(target: string | TinyElement | TinyElement[]): boolean;
|
|
1508
|
+
/**
|
|
1509
|
+
* Finds the closest ancestor (including self) that matches the selector.
|
|
1510
|
+
*
|
|
1511
|
+
* @param {string|Element} selector - A selector string or DOM element to match.
|
|
1512
|
+
* @param {Element|null} [context] - An optional context to stop searching.
|
|
1513
|
+
* @returns {Element[]}
|
|
1514
|
+
*/
|
|
1515
|
+
closest(selector: string | Element, context?: Element | null): Element[];
|
|
1516
|
+
/**
|
|
1517
|
+
* Compares two DOM elements to determine if they refer to the same node in the document.
|
|
1518
|
+
*
|
|
1519
|
+
* This performs a strict equality check (`===`) between the two elements.
|
|
1520
|
+
*
|
|
1521
|
+
* @param {TinyNode} elem - The DOM element to compare.
|
|
1522
|
+
* @returns {boolean} `true` if both elements are the same DOM node; otherwise, `false`.
|
|
1523
|
+
*/
|
|
1524
|
+
isSameDom(elem: TinyNode): boolean;
|
|
1525
|
+
/** @type {ElementDataStore} */
|
|
1526
|
+
_data: ElementDataStore;
|
|
1527
|
+
/**
|
|
1528
|
+
* Retrieves data associated with a DOM element.
|
|
1529
|
+
*
|
|
1530
|
+
* If a `key` is provided, the corresponding value is returned.
|
|
1531
|
+
* If no `key` is given, a shallow copy of all stored data is returned.
|
|
1532
|
+
*
|
|
1533
|
+
* @param {string} [key] - The specific key to retrieve from the data store.
|
|
1534
|
+
* @param {boolean} [isPrivate=false] - Whether to access the private data store.
|
|
1535
|
+
* @returns {ElementDataStore|undefined|any} - The stored value, all data, or undefined if the key doesn't exist.
|
|
1536
|
+
*/
|
|
1537
|
+
data(key?: string, isPrivate?: boolean): ElementDataStore | undefined | any;
|
|
1538
|
+
/**
|
|
1539
|
+
* Stores a value associated with a specific key for a DOM element.
|
|
1540
|
+
*
|
|
1541
|
+
* @param {string} key - The key under which the data will be stored.
|
|
1542
|
+
* @param {any} value - The value to store.
|
|
1543
|
+
* @param {boolean} [isPrivate=false] - Whether to store the data in the private store.
|
|
1544
|
+
* @returns {void}
|
|
1545
|
+
*/
|
|
1546
|
+
setData(key: string, value: any, isPrivate?: boolean): void;
|
|
1547
|
+
/**
|
|
1548
|
+
* Returns the direct parent node of the given element, excluding document fragments.
|
|
1549
|
+
*
|
|
1550
|
+
* @returns {ParentNode|null} The parent node or null if not found.
|
|
1551
|
+
*/
|
|
1552
|
+
parent(): ParentNode | null;
|
|
1553
|
+
/**
|
|
1554
|
+
* Returns all ancestor nodes of the given element, optionally stopping before a specific ancestor.
|
|
1555
|
+
*
|
|
1556
|
+
* @param {TinyNode|string} [until] - A node or selector to stop before.
|
|
1557
|
+
* @returns {ChildNode[]} An array of ancestor nodes.
|
|
1558
|
+
*/
|
|
1559
|
+
parents(until?: TinyNode | string): ChildNode[];
|
|
1560
|
+
/**
|
|
1561
|
+
* Returns the next sibling of the given element.
|
|
1562
|
+
*
|
|
1563
|
+
* @returns {ChildNode|null} The next sibling or null if none found.
|
|
1564
|
+
*/
|
|
1565
|
+
next(): ChildNode | null;
|
|
1566
|
+
/**
|
|
1567
|
+
* Returns the previous sibling of the given element.
|
|
1568
|
+
*
|
|
1569
|
+
* @returns {ChildNode|null} The previous sibling or null if none found.
|
|
1570
|
+
*/
|
|
1571
|
+
prev(): ChildNode | null;
|
|
1572
|
+
/**
|
|
1573
|
+
* Returns all next sibling nodes after the given element.
|
|
1574
|
+
*
|
|
1575
|
+
* @returns {ChildNode[]} An array of next sibling nodes.
|
|
1576
|
+
*/
|
|
1577
|
+
nextAll(): ChildNode[];
|
|
1578
|
+
/**
|
|
1579
|
+
* Returns all previous sibling nodes before the given element.
|
|
1580
|
+
*
|
|
1581
|
+
* @returns {ChildNode[]} An array of previous sibling nodes.
|
|
1582
|
+
*/
|
|
1583
|
+
prevAll(): ChildNode[];
|
|
1584
|
+
/**
|
|
1585
|
+
* Returns all next sibling nodes up to (but not including) the node matched by a selector or element.
|
|
1586
|
+
*
|
|
1587
|
+
* @param {TinyNode|string} [until] - A node or selector to stop before.
|
|
1588
|
+
* @returns {ChildNode[]} An array of next sibling nodes.
|
|
1589
|
+
*/
|
|
1590
|
+
nextUntil(until?: TinyNode | string): ChildNode[];
|
|
1591
|
+
/**
|
|
1592
|
+
* Returns all previous sibling nodes up to (but not including) the node matched by a selector or element.
|
|
1593
|
+
*
|
|
1594
|
+
* @param {TinyNode|string} [until] - A node or selector to stop before.
|
|
1595
|
+
* @returns {ChildNode[]} An array of previous sibling nodes.
|
|
1596
|
+
*/
|
|
1597
|
+
prevUntil(until?: TinyNode | string): ChildNode[];
|
|
1598
|
+
/**
|
|
1599
|
+
* Returns all sibling nodes of the given element, excluding itself.
|
|
1600
|
+
*
|
|
1601
|
+
* @returns {ChildNode[]} An array of sibling nodes.
|
|
1602
|
+
*/
|
|
1603
|
+
siblings(): ChildNode[];
|
|
1604
|
+
/**
|
|
1605
|
+
* Returns all child nodes of the given element.
|
|
1606
|
+
*
|
|
1607
|
+
* @returns {ChildNode[]} An array of child nodes.
|
|
1608
|
+
*/
|
|
1609
|
+
children(): ChildNode[];
|
|
1610
|
+
/**
|
|
1611
|
+
* Returns the contents of the given node. For `<template>` it returns its content; for `<iframe>`, the document.
|
|
1612
|
+
*
|
|
1613
|
+
* @returns {(ChildNode|DocumentFragment)[]|Document[]} An array of child nodes or the content document of an iframe.
|
|
1614
|
+
*/
|
|
1615
|
+
contents(): (ChildNode | DocumentFragment)[] | Document[];
|
|
1616
|
+
/**
|
|
1617
|
+
* Clone the element.
|
|
1618
|
+
* @param {boolean} [deep=true]
|
|
1619
|
+
* @returns {Node}
|
|
1620
|
+
*/
|
|
1621
|
+
clone(deep?: boolean): Node;
|
|
1622
|
+
/**
|
|
1623
|
+
* Appends child elements or strings to the end of the target element(s).
|
|
1624
|
+
*
|
|
1625
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to append.
|
|
1626
|
+
*/
|
|
1627
|
+
append(...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
1628
|
+
/**
|
|
1629
|
+
* Prepends child elements or strings to the beginning of the target element(s).
|
|
1630
|
+
*
|
|
1631
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - The child elements or text to prepend.
|
|
1632
|
+
*/
|
|
1633
|
+
prepend(...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
1634
|
+
/**
|
|
1635
|
+
* Inserts elements or strings immediately before the target element(s) in the DOM.
|
|
1636
|
+
*
|
|
1637
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert before the target.
|
|
1638
|
+
*/
|
|
1639
|
+
before(...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
1640
|
+
/**
|
|
1641
|
+
* Inserts elements or strings immediately after the target element(s) in the DOM.
|
|
1642
|
+
*
|
|
1643
|
+
* @param {...(TinyNode | TinyNode[] | string)} children - Elements or text to insert after the target.
|
|
1644
|
+
*/
|
|
1645
|
+
after(...children: (TinyNode | TinyNode[] | string)[]): void;
|
|
1646
|
+
/**
|
|
1647
|
+
* Replaces the target element(s) in the DOM with new elements or text.
|
|
1648
|
+
*
|
|
1649
|
+
* @param {...(TinyNode | TinyNode[] | string)} newNodes - New elements or text to replace the target.
|
|
1650
|
+
*/
|
|
1651
|
+
replaceWith(...newNodes: (TinyNode | TinyNode[] | string)[]): void;
|
|
1652
|
+
/**
|
|
1653
|
+
* Appends the given element(s) to each target element in sequence.
|
|
1654
|
+
*
|
|
1655
|
+
* @param {TinyNode | TinyNode[]} targets - Target element(s) where content will be appended.
|
|
1656
|
+
*/
|
|
1657
|
+
appendTo(targets: TinyNode | TinyNode[]): void;
|
|
1658
|
+
/**
|
|
1659
|
+
* Prepends the given element(s) to each target element in sequence.
|
|
1660
|
+
*
|
|
1661
|
+
* @param {TinyElement | TinyElement[]} targets - Target element(s) where content will be prepended.
|
|
1662
|
+
*/
|
|
1663
|
+
prependTo(targets: TinyElement | TinyElement[]): void;
|
|
1664
|
+
/**
|
|
1665
|
+
* Inserts the element before a child of a given target, or before the target itself.
|
|
1666
|
+
*
|
|
1667
|
+
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1668
|
+
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert before, defaults to target.
|
|
1669
|
+
*/
|
|
1670
|
+
insertBefore(target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): void;
|
|
1671
|
+
/**
|
|
1672
|
+
* Inserts the element after a child of a given target, or after the target itself.
|
|
1673
|
+
*
|
|
1674
|
+
* @param {TinyNode | TinyNode[]} target - The reference element where insertion happens.
|
|
1675
|
+
* @param {TinyNode | TinyNode[] | null} [child=null] - Optional child to insert after, defaults to target.
|
|
1676
|
+
*/
|
|
1677
|
+
insertAfter(target: TinyNode | TinyNode[], child?: TinyNode | TinyNode[] | null): void;
|
|
1678
|
+
/**
|
|
1679
|
+
* Replaces all target elements with the provided element(s).
|
|
1680
|
+
* If multiple targets exist, the inserted elements are cloned accordingly.
|
|
1681
|
+
*
|
|
1682
|
+
* @param {TinyNode | TinyNode[]} targets - The elements to be replaced.
|
|
1683
|
+
*/
|
|
1684
|
+
replaceAll(targets: TinyNode | TinyNode[]): void;
|
|
1685
|
+
/**
|
|
1686
|
+
* Returns the full computed CSS styles for the given element.
|
|
1687
|
+
*
|
|
1688
|
+
* @returns {CSSStyleDeclaration} The computed style object for the element.
|
|
1689
|
+
*/
|
|
1690
|
+
css(): CSSStyleDeclaration;
|
|
1691
|
+
/**
|
|
1692
|
+
* Returns the value of a specific computed CSS property from the given element as a string.
|
|
1693
|
+
*
|
|
1694
|
+
* @param {string} prop - The name of the CSS property (camelCase or kebab-case).
|
|
1695
|
+
* @returns {string|null} The value of the CSS property as a string, or null if not found or invalid.
|
|
1696
|
+
*/
|
|
1697
|
+
cssString(prop: string): string | null;
|
|
1698
|
+
/**
|
|
1699
|
+
* Returns a subset of computed CSS styles based on the given list of properties.
|
|
1700
|
+
*
|
|
1701
|
+
* @param {string[]} prop - An array of CSS property names to retrieve.
|
|
1702
|
+
* @returns {Partial<CSSStyleDeclaration>} An object containing the requested styles.
|
|
1703
|
+
*/
|
|
1704
|
+
cssList(prop: string[]): Partial<CSSStyleDeclaration>;
|
|
1705
|
+
/**
|
|
1706
|
+
* Returns the computed CSS float value of a property.
|
|
1707
|
+
* @param {string} prop - The CSS property.
|
|
1708
|
+
* @returns {number} - The parsed float value.
|
|
1709
|
+
*/
|
|
1710
|
+
cssFloat(prop: string): number;
|
|
1711
|
+
/**
|
|
1712
|
+
* Returns computed float values of multiple CSS properties.
|
|
1713
|
+
* @param {string[]} prop - An array of CSS properties.
|
|
1714
|
+
* @returns {Record<string, number>} - Map of property to float value.
|
|
1715
|
+
*/
|
|
1716
|
+
cssFloats(prop: string[]): Record<string, number>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Focus the element.
|
|
1719
|
+
*/
|
|
1720
|
+
focus(): void;
|
|
1721
|
+
/**
|
|
1722
|
+
* Blur the element.
|
|
1723
|
+
*/
|
|
1724
|
+
blur(): void;
|
|
1725
|
+
/**
|
|
1726
|
+
* Gets the width or height of an element based on the box model.
|
|
1727
|
+
* @param {"width"|"height"} type - Dimension type.
|
|
1728
|
+
* @param {"content"|"padding"|"border"|"margin"} extra - Box model context.
|
|
1729
|
+
* @returns {number} - Computed dimension.
|
|
1730
|
+
*/
|
|
1731
|
+
getDimension(type: "width" | "height", extra: "content" | "padding" | "border" | "margin"): number;
|
|
1732
|
+
/**
|
|
1733
|
+
* Sets the height of the element.
|
|
1734
|
+
* @param {string|number} value - Height value.
|
|
1735
|
+
*/
|
|
1736
|
+
setHeight(value: string | number): void;
|
|
1737
|
+
/**
|
|
1738
|
+
* Sets the width of the element.
|
|
1739
|
+
* @param {string|number} value - Width value.
|
|
1740
|
+
*/
|
|
1741
|
+
setWidth(value: string | number): void;
|
|
1742
|
+
/**
|
|
1743
|
+
* Returns content box height.
|
|
1744
|
+
* @returns {number}
|
|
1745
|
+
*/
|
|
1746
|
+
height(): number;
|
|
1747
|
+
/**
|
|
1748
|
+
* Returns content box width.
|
|
1749
|
+
* @returns {number}
|
|
1750
|
+
*/
|
|
1751
|
+
width(): number;
|
|
1752
|
+
/**
|
|
1753
|
+
* Returns padding box height.
|
|
1754
|
+
* @returns {number}
|
|
1755
|
+
*/
|
|
1756
|
+
innerHeight(): number;
|
|
1757
|
+
/**
|
|
1758
|
+
* Returns padding box width.
|
|
1759
|
+
* @returns {number}
|
|
1760
|
+
*/
|
|
1761
|
+
innerWidth(): number;
|
|
1762
|
+
/**
|
|
1763
|
+
* Returns outer height of the element, optionally including margin.
|
|
1764
|
+
* @param {boolean} [includeMargin=false] - Whether to include margin.
|
|
1765
|
+
* @returns {number}
|
|
1766
|
+
*/
|
|
1767
|
+
outerHeight(includeMargin?: boolean): number;
|
|
1768
|
+
/**
|
|
1769
|
+
* Returns outer width of the element, optionally including margin.
|
|
1770
|
+
* @param {boolean} [includeMargin=false] - Whether to include margin.
|
|
1771
|
+
* @returns {number}
|
|
1772
|
+
*/
|
|
1773
|
+
outerWidth(includeMargin?: boolean): number;
|
|
1774
|
+
/**
|
|
1775
|
+
* Gets the offset of the element relative to the document.
|
|
1776
|
+
* @returns {{top: number, left: number}}
|
|
1777
|
+
*/
|
|
1778
|
+
offset(): {
|
|
1779
|
+
top: number;
|
|
1780
|
+
left: number;
|
|
1781
|
+
};
|
|
1782
|
+
/**
|
|
1783
|
+
* Gets the position of the element relative to its offset parent.
|
|
1784
|
+
* @returns {{top: number, left: number}}
|
|
1785
|
+
*/
|
|
1786
|
+
position(): {
|
|
1787
|
+
top: number;
|
|
1788
|
+
left: number;
|
|
1789
|
+
};
|
|
1790
|
+
/**
|
|
1791
|
+
* Gets the closest positioned ancestor element.
|
|
1792
|
+
* @returns {HTMLElement} - Offset parent element.
|
|
1793
|
+
*/
|
|
1794
|
+
offsetParent(): HTMLElement;
|
|
1795
|
+
/**
|
|
1796
|
+
* Gets the vertical scroll position.
|
|
1797
|
+
* @returns {number}
|
|
1798
|
+
*/
|
|
1799
|
+
scrollTop(): number;
|
|
1800
|
+
/**
|
|
1801
|
+
* Gets the horizontal scroll position.
|
|
1802
|
+
* @returns {number}
|
|
1803
|
+
*/
|
|
1804
|
+
scrollLeft(): number;
|
|
1805
|
+
/**
|
|
1806
|
+
* Sets the vertical scroll position.
|
|
1807
|
+
* @param {number} value - Scroll top value.
|
|
1808
|
+
*/
|
|
1809
|
+
setScrollTop(value: number): void;
|
|
1810
|
+
/**
|
|
1811
|
+
* Sets the horizontal scroll position.
|
|
1812
|
+
* @param {number} value - Scroll left value.
|
|
1813
|
+
*/
|
|
1814
|
+
setScrollLeft(value: number): void;
|
|
1815
|
+
/**
|
|
1816
|
+
* Returns the total border width and individual sides from `border{Side}Width` CSS properties.
|
|
1817
|
+
*
|
|
1818
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
|
|
1819
|
+
*/
|
|
1820
|
+
borderWidth(): HtmlElBoxSides;
|
|
1821
|
+
/**
|
|
1822
|
+
* Returns the total border size and individual sides from `border{Side}` CSS properties.
|
|
1823
|
+
*
|
|
1824
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
|
|
1825
|
+
*/
|
|
1826
|
+
border(): HtmlElBoxSides;
|
|
1827
|
+
/**
|
|
1828
|
+
* Returns the total margin and individual sides from `margin{Side}` CSS properties.
|
|
1829
|
+
*
|
|
1830
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
|
|
1831
|
+
*/
|
|
1832
|
+
margin(): HtmlElBoxSides;
|
|
1833
|
+
/**
|
|
1834
|
+
* Returns the total padding and individual sides from `padding{Side}` CSS properties.
|
|
1835
|
+
*
|
|
1836
|
+
* @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
|
|
1837
|
+
*/
|
|
1838
|
+
padding(): HtmlElBoxSides;
|
|
1839
|
+
addClass(...tokens: string[]): void;
|
|
1840
|
+
removeClass(...tokens: string[]): void;
|
|
1841
|
+
/**
|
|
1842
|
+
* Replaces an existing class name with a new one.
|
|
1843
|
+
* @param {string} token - The class name to be replaced.
|
|
1844
|
+
* @param {string} newToken - The new class name to apply.
|
|
1845
|
+
* @returns {boolean} Whether the replacement was successful.
|
|
1846
|
+
* @throws {TypeError} If either argument is not a string.
|
|
1847
|
+
*/
|
|
1848
|
+
replaceClass(token: string, newToken: string): boolean;
|
|
1849
|
+
/**
|
|
1850
|
+
* Returns the class name at the specified index.
|
|
1851
|
+
* @param {number} index - The index of the class name.
|
|
1852
|
+
* @returns {string|null} The class name at the index or null if not found.
|
|
1853
|
+
* @throws {TypeError} If the index is not a number.
|
|
1854
|
+
*/
|
|
1855
|
+
classItem(index: number): string | null;
|
|
1856
|
+
/**
|
|
1857
|
+
* Toggles a class name on the element with an optional force boolean.
|
|
1858
|
+
* @param {string} token - The class name to toggle.
|
|
1859
|
+
* @param {boolean} force - If true, adds the class; if false, removes it.
|
|
1860
|
+
* @returns {boolean} Whether the class is present after the toggle.
|
|
1861
|
+
* @throws {TypeError} If token is not a string or force is not a boolean.
|
|
1862
|
+
*/
|
|
1863
|
+
toggleClass(token: string, force: boolean): boolean;
|
|
1864
|
+
/**
|
|
1865
|
+
* Checks if the element contains the given class name.
|
|
1866
|
+
* @param {string} token - The class name to check.
|
|
1867
|
+
* @returns {boolean} True if the class is present, false otherwise.
|
|
1868
|
+
* @throws {TypeError} If token is not a string.
|
|
1869
|
+
*/
|
|
1870
|
+
hasClass(token: string): boolean;
|
|
1871
|
+
/**
|
|
1872
|
+
* Returns the number of classes applied to the element.
|
|
1873
|
+
* @returns {number} The number of classes.
|
|
1874
|
+
*/
|
|
1875
|
+
classLength(): number;
|
|
1876
|
+
/**
|
|
1877
|
+
* Returns all class names as an array of strings.
|
|
1878
|
+
* @returns {string[]} An array of class names.
|
|
1879
|
+
*/
|
|
1880
|
+
classList(): string[];
|
|
1881
|
+
/**
|
|
1882
|
+
* Returns the tag name of the element.
|
|
1883
|
+
* @returns {string} The tag name in uppercase.
|
|
1884
|
+
*/
|
|
1885
|
+
tagName(): string;
|
|
1886
|
+
/**
|
|
1887
|
+
* Returns the ID of the element.
|
|
1888
|
+
* @returns {string} The element's ID.
|
|
1889
|
+
*/
|
|
1890
|
+
id(): string;
|
|
1891
|
+
/**
|
|
1892
|
+
* Returns the text content of the element.
|
|
1893
|
+
* @returns {string|null} The text content or null if none.
|
|
1894
|
+
*/
|
|
1895
|
+
text(): string | null;
|
|
1896
|
+
/**
|
|
1897
|
+
* Set text content of the element.
|
|
1898
|
+
* @param {string} value
|
|
1899
|
+
*/
|
|
1900
|
+
setText(value: string): void;
|
|
1901
|
+
/**
|
|
1902
|
+
* Remove all child nodes of the element.
|
|
1903
|
+
*/
|
|
1904
|
+
empty(): void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Get the innerHTML of the element.
|
|
1907
|
+
* @returns {string}
|
|
1908
|
+
*/
|
|
1909
|
+
html(): string;
|
|
1910
|
+
/**
|
|
1911
|
+
* Set the innerHTML of the element.
|
|
1912
|
+
* @param {string} value
|
|
1913
|
+
*/
|
|
1914
|
+
setHtml(value: string): void;
|
|
1915
|
+
/**
|
|
1916
|
+
* Sets the value of the current HTML value element (input, select, textarea, etc.).
|
|
1917
|
+
* Accepts strings, numbers, booleans or arrays of these values, or a callback function that computes them.
|
|
1918
|
+
*
|
|
1919
|
+
* @param {SetValueList|((el: InputElement, val: SetValueList) => SetValueList)} value - The value to assign or a function that returns it.
|
|
1920
|
+
* @throws {Error} If the computed value is not a valid string or boolean.
|
|
1921
|
+
*/
|
|
1922
|
+
setVal(value: SetValueList | ((el: InputElement, val: SetValueList) => SetValueList)): void;
|
|
1923
|
+
/**
|
|
1924
|
+
* Retrieves the raw value from the HTML input element.
|
|
1925
|
+
* If a custom value hook exists, it will be used first.
|
|
1926
|
+
*
|
|
1927
|
+
* @param {GetValueTypes} type - The type of value to retrieve ("string", "date", or "number").
|
|
1928
|
+
* @param {string} where - The context/method name using this validation.
|
|
1929
|
+
* @returns {any} The raw value retrieved from the element or hook.
|
|
1930
|
+
* @readonly
|
|
1931
|
+
*/
|
|
1932
|
+
readonly _val(where: string, type: GetValueTypes): any;
|
|
1933
|
+
/**
|
|
1934
|
+
* Gets the value of the current HTML value element.
|
|
1935
|
+
*
|
|
1936
|
+
* @returns {SetValueList} The normalized value, with carriage returns removed.
|
|
1937
|
+
*/
|
|
1938
|
+
val(): SetValueList;
|
|
1939
|
+
/**
|
|
1940
|
+
* Gets the text of the current HTML value element (for text).
|
|
1941
|
+
*
|
|
1942
|
+
* @returns {string} The text value.
|
|
1943
|
+
* @throws {Error} If the element is not a string value.
|
|
1944
|
+
*/
|
|
1945
|
+
valTxt(): string;
|
|
1946
|
+
/**
|
|
1947
|
+
* Internal helper to get a value from an input expected to return an array.
|
|
1948
|
+
*
|
|
1949
|
+
* @param {string} where - The method name or context using this validation (for error reporting).
|
|
1950
|
+
* @param {GetValueTypes} type - The type of value to retrieve ("string", "date", or "number").
|
|
1951
|
+
* @returns {SetValueBase[]} - The validated value as an array.
|
|
1952
|
+
* @throws {Error} If the returned value is not an array.
|
|
1953
|
+
* @readonly
|
|
1954
|
+
*/
|
|
1955
|
+
readonly _valArr(where: string, type: GetValueTypes): SetValueBase[];
|
|
1956
|
+
/**
|
|
1957
|
+
* Gets the raw value as a generic array of the current HTML value element (for select).
|
|
1958
|
+
*
|
|
1959
|
+
* @returns {SetValueBase[]} - The value cast as a generic array.
|
|
1960
|
+
* @throws {Error} If the value is not a valid array.
|
|
1961
|
+
*/
|
|
1962
|
+
valArr(): SetValueBase[];
|
|
1963
|
+
/**
|
|
1964
|
+
* Gets the current value parsed as a number (for number/text).
|
|
1965
|
+
*
|
|
1966
|
+
* @returns {number} The numeric value.
|
|
1967
|
+
* @throws {Error} If the element is not a number-compatible input or value is NaN.
|
|
1968
|
+
*/
|
|
1969
|
+
valNb(): number;
|
|
1970
|
+
/**
|
|
1971
|
+
* Gets the current value parsed as a Date (for time/date).
|
|
1972
|
+
*
|
|
1973
|
+
* @returns {Date} The date value.
|
|
1974
|
+
* @throws {Error} If the element is not a date-compatible input.
|
|
1975
|
+
*/
|
|
1976
|
+
valDate(): Date;
|
|
1977
|
+
/**
|
|
1978
|
+
* Checks if the input element is boolean (for checkboxes/radios).
|
|
1979
|
+
*
|
|
1980
|
+
* @returns {boolean} True if the input is considered checked (value === "on"), false otherwise.
|
|
1981
|
+
* @throws {Error} If the element is not a checkbox/radio input.
|
|
1982
|
+
*/
|
|
1983
|
+
valBool(): boolean;
|
|
1984
|
+
/**
|
|
1985
|
+
* Registers an event listener on the specified element.
|
|
1986
|
+
*
|
|
1987
|
+
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
1988
|
+
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
1989
|
+
* @param {EventRegistryOptions} [options] - Optional event listener options.
|
|
1990
|
+
*/
|
|
1991
|
+
on(event: string, handler: EventRegistryHandle, options?: EventRegistryOptions): void;
|
|
1992
|
+
/**
|
|
1993
|
+
* Registers an event listener that runs only once, then is removed.
|
|
1994
|
+
*
|
|
1995
|
+
* @param {string} event - The event type (e.g. 'click', 'keydown').
|
|
1996
|
+
* @param {EventRegistryHandle} handler - The callback function to run on event.
|
|
1997
|
+
* @param {EventRegistryOptions} [options={}] - Optional event listener options.
|
|
1998
|
+
*/
|
|
1999
|
+
once(event: string, handler: EventRegistryHandle, options?: EventRegistryOptions): void;
|
|
2000
|
+
/**
|
|
2001
|
+
* Removes a specific event listener from an element.
|
|
2002
|
+
*
|
|
2003
|
+
* @param {string} event - The event type.
|
|
2004
|
+
* @param {EventRegistryHandle} handler - The function originally bound to the event.
|
|
2005
|
+
* @param {boolean|EventListenerOptions} [options] - Optional listener options.
|
|
2006
|
+
*/
|
|
2007
|
+
off(event: string, handler: EventRegistryHandle, options?: boolean | EventListenerOptions): void;
|
|
2008
|
+
/**
|
|
2009
|
+
* Removes all event listeners of a specific type from the element.
|
|
2010
|
+
*
|
|
2011
|
+
* @param {string} event - The event type to remove (e.g. 'click').
|
|
2012
|
+
*/
|
|
2013
|
+
offAll(event: string): void;
|
|
2014
|
+
/**
|
|
2015
|
+
* Removes all event listeners of all types from the element.
|
|
2016
|
+
*
|
|
2017
|
+
* @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
|
|
2018
|
+
* Optional filter function to selectively remove specific handlers.
|
|
2019
|
+
*/
|
|
2020
|
+
offAllTypes(filterFn?: ((handler: EventListenerOrEventListenerObject, event: string) => boolean) | null): void;
|
|
2021
|
+
/**
|
|
2022
|
+
* Triggers all handlers associated with a specific event on the given element.
|
|
2023
|
+
*
|
|
2024
|
+
* @param {string} event - Name of the event to trigger.
|
|
2025
|
+
* @param {Event|CustomEvent|CustomEventInit} [payload] - Optional event object or data to pass.
|
|
2026
|
+
*/
|
|
2027
|
+
trigger(event: string, payload?: Event | CustomEvent | CustomEventInit): void;
|
|
2028
|
+
/**
|
|
2029
|
+
* Get an attribute on an element.
|
|
2030
|
+
* @param {string} name
|
|
2031
|
+
* @returns {string|null}
|
|
2032
|
+
*/
|
|
2033
|
+
attr(name: string): string | null;
|
|
2034
|
+
/**
|
|
2035
|
+
* Set an attribute on an element.
|
|
2036
|
+
* @param {string} name
|
|
2037
|
+
* @param {string|null} [value=null]
|
|
2038
|
+
*/
|
|
2039
|
+
setAttr(name: string, value?: string | null): void;
|
|
2040
|
+
/**
|
|
2041
|
+
* Remove attribute(s) from an element.
|
|
2042
|
+
* @param {string} name Space-separated list of attributes.
|
|
2043
|
+
*/
|
|
2044
|
+
removeAttr(name: string): void;
|
|
2045
|
+
/**
|
|
2046
|
+
* Check if an attribute exists on an element.
|
|
2047
|
+
* @param {string} name
|
|
2048
|
+
* @returns {boolean}
|
|
2049
|
+
*/
|
|
2050
|
+
hasAttr(name: string): boolean;
|
|
2051
|
+
/**
|
|
2052
|
+
* Check if a property exists.
|
|
2053
|
+
* @param {string} name
|
|
2054
|
+
* @returns {boolean}
|
|
2055
|
+
*/
|
|
2056
|
+
hasProp(name: string): boolean;
|
|
2057
|
+
/**
|
|
2058
|
+
* Set a property on an element.
|
|
2059
|
+
* @param {string} name
|
|
2060
|
+
*/
|
|
2061
|
+
addProp(name: string): void;
|
|
2062
|
+
/**
|
|
2063
|
+
* Remove a property from an element.
|
|
2064
|
+
* @param {string} name
|
|
2065
|
+
*/
|
|
2066
|
+
removeProp(name: string): void;
|
|
2067
|
+
/**
|
|
2068
|
+
* Toggle a boolean property.
|
|
2069
|
+
* @param {string} name
|
|
2070
|
+
* @param {boolean} [force]
|
|
2071
|
+
*/
|
|
2072
|
+
toggleProp(name: string, force?: boolean): void;
|
|
2073
|
+
/**
|
|
2074
|
+
* Removes the element from the DOM.
|
|
2075
|
+
*/
|
|
2076
|
+
remove(): void;
|
|
2077
|
+
/**
|
|
2078
|
+
* Returns the index of the first element within its parent or relative to a selector/element.
|
|
2079
|
+
*
|
|
2080
|
+
* @param {string|TinyElement|null} [elem] - Optional target to compare index against.
|
|
2081
|
+
* @returns {number}
|
|
2082
|
+
*/
|
|
2083
|
+
index(elem?: string | TinyElement | null): number;
|
|
2084
|
+
/**
|
|
2085
|
+
* Determines if two HTML elements are colliding, using a simple bounding box comparison.
|
|
2086
|
+
*
|
|
2087
|
+
* @param {TinyElement} el2 - The second element to compare.
|
|
2088
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
2089
|
+
* @returns {boolean} - `true` if the elements are colliding, `false` otherwise.
|
|
2090
|
+
*/
|
|
2091
|
+
isCollWith(el2: TinyElement, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
2092
|
+
/**
|
|
2093
|
+
* Determines if two HTML elements are colliding using a pixel-perfect collision algorithm.
|
|
2094
|
+
*
|
|
2095
|
+
* @param {TinyElement} el2 - The second element to compare.
|
|
2096
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
2097
|
+
* @returns {boolean} - `true` if the elements are colliding with higher precision, `false` otherwise.
|
|
2098
|
+
*/
|
|
2099
|
+
isCollPerfWith(el2: TinyElement, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
2100
|
+
/**
|
|
2101
|
+
* Checks if two DOM elements are colliding on the screen, and locks the collision
|
|
2102
|
+
* until the element exits through the same side it entered.
|
|
2103
|
+
*
|
|
2104
|
+
* @param {TinyElement} el2 - Second DOM element (e.g. a container or boundary element).
|
|
2105
|
+
* @param {CollisionDirLock} lockDirection - Direction that must be respected to unlock the collision.
|
|
2106
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
2107
|
+
* @returns {boolean} True if collision is still active.
|
|
2108
|
+
*/
|
|
2109
|
+
isCollWithLock(el2: TinyElement, lockDirection: CollisionDirLock, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
2110
|
+
/**
|
|
2111
|
+
* Checks if two DOM elements are colliding on the screen, and locks the collision
|
|
2112
|
+
* until the element exits through the same side it entered.
|
|
2113
|
+
*
|
|
2114
|
+
* @param {TinyElement} el2 - Second DOM element (e.g. a container or boundary element).
|
|
2115
|
+
* @param {CollisionDirLock} lockDirection - Direction that must be respected to unlock the collision.
|
|
2116
|
+
* @param {Partial<ObjRect>} [extraRect] - Optional values to expand the size of the first element's rect.
|
|
2117
|
+
* @returns {boolean} True if collision is still active.
|
|
2118
|
+
*/
|
|
2119
|
+
isCollPerfWithLock(el2: TinyElement, lockDirection: CollisionDirLock, extraRect?: Partial<TinyCollision.ObjRect>): boolean;
|
|
2120
|
+
/**
|
|
2121
|
+
* Resets the collision lock for a specific element.
|
|
2122
|
+
*
|
|
2123
|
+
* This removes any previously stored collision direction for the given element,
|
|
2124
|
+
* effectively unlocking its collision state.
|
|
2125
|
+
*
|
|
2126
|
+
* @returns {boolean} Returns `true` if a lock was removed, `false` if no lock was present.
|
|
2127
|
+
*/
|
|
2128
|
+
resetCollLock(): boolean;
|
|
2129
|
+
/**
|
|
2130
|
+
* Resets the collision lock for a specific element and direction.
|
|
2131
|
+
*
|
|
2132
|
+
* @param {CollisionDirLock} direction - The direction to clear the lock from.
|
|
2133
|
+
* @returns {boolean} True if the lock was removed.
|
|
2134
|
+
*/
|
|
2135
|
+
resetCollLockDir(direction: CollisionDirLock): boolean;
|
|
2136
|
+
/**
|
|
2137
|
+
* Checks if the given element is at least partially visible in the viewport.
|
|
2138
|
+
*
|
|
2139
|
+
* @returns {boolean} True if the element is partially in the viewport, false otherwise.
|
|
2140
|
+
*/
|
|
2141
|
+
isInViewport(): boolean;
|
|
2142
|
+
/**
|
|
2143
|
+
* Checks if the given element is fully visible in the viewport (top and bottom).
|
|
2144
|
+
*
|
|
2145
|
+
* @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
|
|
2146
|
+
*/
|
|
2147
|
+
isScrolledIntoView(): boolean;
|
|
2148
|
+
#private;
|
|
2149
|
+
}
|
|
2150
|
+
import * as TinyCollision from '../basics/collision.mjs';
|
|
2151
|
+
//# sourceMappingURL=TinyHtml.d.mts.map
|