@oscarpalmer/toretto 0.44.0 → 0.46.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/attribute/get.attribute.d.mts +2 -0
- package/dist/attribute/get.attribute.mjs +1 -0
- package/dist/attribute/index.d.mts +6 -0
- package/dist/attribute/set.attribute.d.mts +5 -0
- package/dist/create.d.mts +2 -0
- package/dist/data.d.mts +4 -0
- package/dist/event/index.d.mts +9 -1
- package/dist/event/index.mjs +2 -0
- package/dist/find/index.d.mts +14 -1
- package/dist/find/index.mjs +36 -1
- package/dist/find/relative.d.mts +5 -0
- package/dist/find/relative.mjs +1 -0
- package/dist/focusable.d.mts +4 -0
- package/dist/focusable.mjs +4 -0
- package/dist/html/index.d.mts +3 -0
- package/dist/html/index.mjs +1 -0
- package/dist/index.d.mts +96 -8
- package/dist/index.mjs +131 -12
- package/dist/internal/is.d.mts +19 -1
- package/dist/internal/is.mjs +21 -1
- package/dist/internal/property.mjs +9 -2
- package/dist/is.d.mts +5 -2
- package/dist/is.mjs +3 -2
- package/dist/models.d.mts +1 -8
- package/dist/property/get.property.d.mts +2 -0
- package/dist/property/get.property.mjs +2 -0
- package/dist/property/set.property.d.mts +3 -0
- package/dist/property/set.property.mjs +1 -0
- package/dist/style.d.mts +7 -0
- package/dist/style.mjs +5 -0
- package/dist/touch.d.mts +4 -0
- package/package.json +6 -6
- package/src/attribute/get.attribute.ts +2 -0
- package/src/attribute/index.ts +6 -0
- package/src/attribute/set.attribute.ts +5 -0
- package/src/create.ts +2 -0
- package/src/data.ts +4 -0
- package/src/event/index.ts +10 -1
- package/src/find/index.ts +64 -1
- package/src/find/relative.ts +5 -0
- package/src/focusable.ts +4 -0
- package/src/html/index.ts +4 -0
- package/src/internal/is.ts +35 -0
- package/src/internal/property.ts +14 -2
- package/src/is.ts +4 -1
- package/src/models.ts +0 -8
- package/src/property/get.property.ts +2 -0
- package/src/property/set.property.ts +3 -0
- package/src/style.ts +7 -0
- package/src/touch.ts +4 -0
package/dist/index.d.mts
CHANGED
|
@@ -6,10 +6,14 @@ type SupporsTouch = {
|
|
|
6
6
|
readonly value: boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Are touch events supported?
|
|
9
|
+
*
|
|
10
|
+
* @returns `true` if touch events are supported, otherwise `false`
|
|
9
11
|
*/
|
|
10
12
|
get(): boolean;
|
|
11
13
|
/**
|
|
12
14
|
* Re-evaluate if touch events are supported
|
|
15
|
+
*
|
|
16
|
+
* @returns `true` if touch events are supported, otherwise `false`
|
|
13
17
|
*/
|
|
14
18
|
update(): boolean;
|
|
15
19
|
};
|
|
@@ -30,13 +34,6 @@ type Attribute = {
|
|
|
30
34
|
* Event listener for custom events
|
|
31
35
|
*/
|
|
32
36
|
type CustomEventListener = (event: CustomEvent) => void;
|
|
33
|
-
/**
|
|
34
|
-
* The position of an event
|
|
35
|
-
*/
|
|
36
|
-
type EventPosition = {
|
|
37
|
-
x: number;
|
|
38
|
-
y: number;
|
|
39
|
-
};
|
|
40
37
|
/**
|
|
41
38
|
* Event listener that can be removed
|
|
42
39
|
*/
|
|
@@ -68,6 +65,7 @@ type DataPrefixedName = `data-${string}`;
|
|
|
68
65
|
declare function getAttribute(element: Element, name: DataPrefixedName, parse?: boolean): unknown;
|
|
69
66
|
/**
|
|
70
67
|
* Get the value of a specific attribute from an element
|
|
68
|
+
*
|
|
71
69
|
* @param element Element to get attribute from
|
|
72
70
|
* @param name Attribute name
|
|
73
71
|
* @returns Attribute value _(or `undefined`)_
|
|
@@ -75,6 +73,7 @@ declare function getAttribute(element: Element, name: DataPrefixedName, parse?:
|
|
|
75
73
|
declare function getAttribute(element: Element, name: string): unknown;
|
|
76
74
|
/**
|
|
77
75
|
* Get specific attributes from an element
|
|
76
|
+
*
|
|
78
77
|
* @param element Element to get attributes from
|
|
79
78
|
* @param names Attribute names
|
|
80
79
|
* @param parseData Parse data values? _(defaults to `true`)_
|
|
@@ -88,6 +87,7 @@ type DispatchedAttributeName = 'checked' | 'open' | 'value';
|
|
|
88
87
|
* Set an attribute on an element
|
|
89
88
|
*
|
|
90
89
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
90
|
+
*
|
|
91
91
|
* @param element Element for attribute
|
|
92
92
|
* @param name Attribute name
|
|
93
93
|
* @param value Attribute value
|
|
@@ -98,6 +98,7 @@ declare function setAttribute(element: Element, name: DispatchedAttributeName, v
|
|
|
98
98
|
* Set an attribute on an element
|
|
99
99
|
*
|
|
100
100
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
101
|
+
*
|
|
101
102
|
* @param element Element for attribute
|
|
102
103
|
* @param name Attribute name
|
|
103
104
|
* @param value Attribute value
|
|
@@ -107,6 +108,7 @@ declare function setAttribute(element: Element, name: string, value?: unknown):
|
|
|
107
108
|
* Set an attribute on an element
|
|
108
109
|
*
|
|
109
110
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
111
|
+
*
|
|
110
112
|
* @param element Element for attribute
|
|
111
113
|
* @param attribute Attribute to set
|
|
112
114
|
* @param dispatch Dispatch event for attribute? _(defaults to `true`)_
|
|
@@ -116,6 +118,7 @@ declare function setAttribute(element: Element, attribute: Attr | Attribute, dis
|
|
|
116
118
|
* Set one or more attributes on an element
|
|
117
119
|
*
|
|
118
120
|
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
121
|
+
*
|
|
119
122
|
* @param element Element for attributes
|
|
120
123
|
* @param attributes Attributes to set
|
|
121
124
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
@@ -125,6 +128,7 @@ declare function setAttributes(element: Element, attributes: Array<Attr | Attrib
|
|
|
125
128
|
* Set one or more attributes on an element
|
|
126
129
|
*
|
|
127
130
|
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
131
|
+
*
|
|
128
132
|
* @param element Element for attributes
|
|
129
133
|
* @param attributes Attributes to set
|
|
130
134
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
@@ -134,12 +138,14 @@ declare function setAttributes(element: Element, attributes: Record<string, unkn
|
|
|
134
138
|
//#region src/attribute/index.d.ts
|
|
135
139
|
/**
|
|
136
140
|
* Is the attribute considered bad and potentially harmful?
|
|
141
|
+
*
|
|
137
142
|
* @param attribute Attribute to check
|
|
138
143
|
* @returns `true` if attribute is considered bad
|
|
139
144
|
*/
|
|
140
145
|
declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
141
146
|
/**
|
|
142
147
|
* Is the attribute considered bad and potentially harmful?
|
|
148
|
+
*
|
|
143
149
|
* @param name Attribute name
|
|
144
150
|
* @param value Attribute value
|
|
145
151
|
* @returns `true` if attribute is considered bad
|
|
@@ -147,12 +153,14 @@ declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
|
147
153
|
declare function isBadAttribute(name: string, value: string): boolean;
|
|
148
154
|
/**
|
|
149
155
|
* Is the attribute a boolean attribute?
|
|
156
|
+
*
|
|
150
157
|
* @param name Attribute to check
|
|
151
158
|
* @returns `true` if attribute is a boolean attribute
|
|
152
159
|
*/
|
|
153
160
|
declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
154
161
|
/**
|
|
155
162
|
* Is the attribute a boolean attribute?
|
|
163
|
+
*
|
|
156
164
|
* @param name Attribute name
|
|
157
165
|
* @returns `true` if attribute is a boolean attribute
|
|
158
166
|
*/
|
|
@@ -161,6 +169,7 @@ declare function isBooleanAttribute(name: string): boolean;
|
|
|
161
169
|
* Is the attribute an invalid boolean attribute?
|
|
162
170
|
*
|
|
163
171
|
* _(I.e., its value is not empty or the same as its name)_
|
|
172
|
+
*
|
|
164
173
|
* @param attribute Attribute to check
|
|
165
174
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
166
175
|
*/
|
|
@@ -169,6 +178,7 @@ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean
|
|
|
169
178
|
* Is the attribute an invalid boolean attribute?
|
|
170
179
|
*
|
|
171
180
|
* _(I.e., its value is not empty or the same as its name)_
|
|
181
|
+
*
|
|
172
182
|
* @param name Attribute name
|
|
173
183
|
* @param value Attribute value
|
|
174
184
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
@@ -176,6 +186,16 @@ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean
|
|
|
176
186
|
declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
|
|
177
187
|
//#endregion
|
|
178
188
|
//#region node_modules/@oscarpalmer/atoms/dist/models.d.mts
|
|
189
|
+
/**
|
|
190
|
+
* Position of an event
|
|
191
|
+
*/
|
|
192
|
+
type EventPosition = {
|
|
193
|
+
x: number;
|
|
194
|
+
y: number;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* A generic async callback function
|
|
198
|
+
*/
|
|
179
199
|
/**
|
|
180
200
|
* A generic object
|
|
181
201
|
*/
|
|
@@ -195,6 +215,7 @@ type Properties<Target extends Element> = { [Property in keyof Target]?: Target[
|
|
|
195
215
|
type Styles$1 = Partial<Record<keyof CSSStyleDeclaration, unknown>>;
|
|
196
216
|
/**
|
|
197
217
|
* Creates an HTML element with the specified tag name together with optional properties, attributes, and styles
|
|
218
|
+
*
|
|
198
219
|
* @param tag Tag name
|
|
199
220
|
* @param properties Element properties
|
|
200
221
|
* @param attributes Element attributes
|
|
@@ -204,6 +225,7 @@ type Styles$1 = Partial<Record<keyof CSSStyleDeclaration, unknown>>;
|
|
|
204
225
|
declare function createElement<TagName extends keyof HTMLElementTagNameMap>(tag: TagName, properties?: Properties<HTMLElementTagNameMap[TagName]>, attributes?: Record<string, unknown>, styles?: Styles$1): HTMLElementTagNameMap[TagName];
|
|
205
226
|
/**
|
|
206
227
|
* Creates an HTML element with the specified tag name together with optional properties, attributes, and styles
|
|
228
|
+
*
|
|
207
229
|
* @param tag Tag name
|
|
208
230
|
* @param properties Element properties
|
|
209
231
|
* @param attributes Element attributes
|
|
@@ -215,6 +237,7 @@ declare function createElement(tag: string, properties?: Properties<HTMLElement>
|
|
|
215
237
|
//#region src/data.d.ts
|
|
216
238
|
/**
|
|
217
239
|
* Get a keyed data value from an element
|
|
240
|
+
*
|
|
218
241
|
* @param element Element to get data from
|
|
219
242
|
* @param key Data key
|
|
220
243
|
* @param parse Parse values? _(defaults to `true`)_
|
|
@@ -223,6 +246,7 @@ declare function createElement(tag: string, properties?: Properties<HTMLElement>
|
|
|
223
246
|
declare function getData(element: Element, key: string, parse?: boolean): unknown;
|
|
224
247
|
/**
|
|
225
248
|
* Get keyed data values from an element
|
|
249
|
+
*
|
|
226
250
|
* @param element Element to get data from
|
|
227
251
|
* @param keys Keys of the data values to get
|
|
228
252
|
* @param parse Parse values? _(defaults to `true`)_
|
|
@@ -231,12 +255,14 @@ declare function getData(element: Element, key: string, parse?: boolean): unknow
|
|
|
231
255
|
declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
|
|
232
256
|
/**
|
|
233
257
|
* Set data values on an element
|
|
258
|
+
*
|
|
234
259
|
* @param element Element to set data on
|
|
235
260
|
* @param data Data to set
|
|
236
261
|
*/
|
|
237
262
|
declare function setData(element: Element, data: PlainObject): void;
|
|
238
263
|
/**
|
|
239
264
|
* Set a data value on an element
|
|
265
|
+
*
|
|
240
266
|
* @param element Element to set data on
|
|
241
267
|
* @param key Data key
|
|
242
268
|
* @param value Data value
|
|
@@ -246,6 +272,7 @@ declare function setData(element: Element, key: string, value: unknown): void;
|
|
|
246
272
|
//#region src/event/index.d.ts
|
|
247
273
|
/**
|
|
248
274
|
* Dispatch an event for a target
|
|
275
|
+
*
|
|
249
276
|
* @param target Event target
|
|
250
277
|
* @param type Type of event
|
|
251
278
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
@@ -253,6 +280,7 @@ declare function setData(element: Element, key: string, value: unknown): void;
|
|
|
253
280
|
declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
|
|
254
281
|
/**
|
|
255
282
|
* Dispatch an event for a target
|
|
283
|
+
*
|
|
256
284
|
* @param target Event target
|
|
257
285
|
* @param type Type of event
|
|
258
286
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
@@ -260,12 +288,14 @@ declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventT
|
|
|
260
288
|
declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
|
|
261
289
|
/**
|
|
262
290
|
* Get the X- and Y-coordinates from a pointer event
|
|
291
|
+
*
|
|
263
292
|
* @param event Pointer event
|
|
264
293
|
* @returns X- and Y-coordinates
|
|
265
294
|
*/
|
|
266
295
|
declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
|
|
267
296
|
/**
|
|
268
297
|
* Remove an event listener
|
|
298
|
+
*
|
|
269
299
|
* @param target Event target
|
|
270
300
|
* @param type Type of event
|
|
271
301
|
* @param listener Event listener
|
|
@@ -274,6 +304,7 @@ declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | un
|
|
|
274
304
|
declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
275
305
|
/**
|
|
276
306
|
* Remove an event listener
|
|
307
|
+
*
|
|
277
308
|
* @param target Event target
|
|
278
309
|
* @param type Type of event
|
|
279
310
|
* @param listener Event listener
|
|
@@ -282,6 +313,7 @@ declare function off(target: EventTarget, type: keyof HTMLElementEventMap, liste
|
|
|
282
313
|
declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
283
314
|
/**
|
|
284
315
|
* Add an event listener
|
|
316
|
+
*
|
|
285
317
|
* @param target Event target
|
|
286
318
|
* @param type Type of event
|
|
287
319
|
* @param listener Event listener
|
|
@@ -290,6 +322,7 @@ declare function off(target: EventTarget, type: string, listener: EventListener
|
|
|
290
322
|
declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
|
|
291
323
|
/**
|
|
292
324
|
* Add an event listener
|
|
325
|
+
*
|
|
293
326
|
* @param target Event target
|
|
294
327
|
* @param type Type of event
|
|
295
328
|
* @param listener Event listener
|
|
@@ -303,6 +336,7 @@ declare function on(target: EventTarget, type: string, listener: EventListener |
|
|
|
303
336
|
*
|
|
304
337
|
* - If no match is found, `null` is returned
|
|
305
338
|
* - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
|
|
339
|
+
*
|
|
306
340
|
* @param origin Origin to start from
|
|
307
341
|
* @param tagName Tag name to match
|
|
308
342
|
* @returns Found ancestor or `null`
|
|
@@ -313,6 +347,7 @@ declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origi
|
|
|
313
347
|
*
|
|
314
348
|
* - If no match is found, `null` is returned
|
|
315
349
|
* - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
|
|
350
|
+
*
|
|
316
351
|
* @param origin Origin to start from
|
|
317
352
|
* @param selector Selector to match
|
|
318
353
|
* @returns Found ancestor or `null`
|
|
@@ -322,6 +357,7 @@ declare function findAncestor(origin: Element | Event | EventTarget, selector: s
|
|
|
322
357
|
* Finds the closest elements to the origin element that matches the tag name
|
|
323
358
|
*
|
|
324
359
|
* Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
|
|
360
|
+
*
|
|
325
361
|
* @param origin Element to start from
|
|
326
362
|
* @param tagName Tag name to match
|
|
327
363
|
* @param context Context to search within
|
|
@@ -332,6 +368,7 @@ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(orig
|
|
|
332
368
|
* Finds the closest elements to the origin element that matches the selector
|
|
333
369
|
*
|
|
334
370
|
* Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
|
|
371
|
+
*
|
|
335
372
|
* @param origin Element to start from
|
|
336
373
|
* @param selector Selector to match
|
|
337
374
|
* @param context Context to search within
|
|
@@ -340,6 +377,7 @@ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(orig
|
|
|
340
377
|
declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
|
|
341
378
|
/**
|
|
342
379
|
* Get the distance between two elements _(i.e., the amount of nodes of between them)_
|
|
380
|
+
*
|
|
343
381
|
* @param origin Origin element
|
|
344
382
|
* @param target Target element
|
|
345
383
|
* @returns Distance between elements, or `-1` if distance cannot be calculated
|
|
@@ -349,6 +387,7 @@ declare function getDistance(origin: Element, target: Element): number;
|
|
|
349
387
|
//#region src/find/index.d.ts
|
|
350
388
|
/**
|
|
351
389
|
* Find the first element that matches the tag name
|
|
390
|
+
*
|
|
352
391
|
* @param tagName Tag name of element to find
|
|
353
392
|
* @param context Context to search within _(defaults to `document`)_
|
|
354
393
|
* @returns Found element or `null`
|
|
@@ -356,6 +395,7 @@ declare function getDistance(origin: Element, target: Element): number;
|
|
|
356
395
|
declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
|
|
357
396
|
/**
|
|
358
397
|
* Find the first element that matches the selector
|
|
398
|
+
*
|
|
359
399
|
* @param selector Selector to find element for
|
|
360
400
|
* @param context Context to search within _(defaults to `document`)_
|
|
361
401
|
* @returns Found element or `null`
|
|
@@ -363,6 +403,7 @@ declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagNam
|
|
|
363
403
|
declare function findElement(selector: string, context?: Selector | null): Element | null;
|
|
364
404
|
/**
|
|
365
405
|
* Find elements that match the selector
|
|
406
|
+
*
|
|
366
407
|
* @param tagName tagName to find elements for
|
|
367
408
|
* @param context Context to search within _(defaults to `document`)_
|
|
368
409
|
* @returns Found elements
|
|
@@ -370,16 +411,25 @@ declare function findElement(selector: string, context?: Selector | null): Eleme
|
|
|
370
411
|
declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
|
|
371
412
|
/**
|
|
372
413
|
* Find elements that match the selector
|
|
414
|
+
*
|
|
373
415
|
* @param selector Selector to find elements for
|
|
374
416
|
* @param context Context to search within _(defaults to `document`)_
|
|
375
417
|
* @returns Found elements
|
|
376
418
|
*/
|
|
377
419
|
declare function findElements(selector: Selector, context?: Selector | null): Element[];
|
|
420
|
+
/**
|
|
421
|
+
* Get elements from an event position
|
|
422
|
+
*
|
|
423
|
+
* @param position Event position
|
|
424
|
+
* @returns Elements at the event position
|
|
425
|
+
*/
|
|
426
|
+
declare function getElementFromPosition(position: EventPosition): Element[];
|
|
378
427
|
/**
|
|
379
428
|
* Get the most specific element under the pointer
|
|
380
429
|
*
|
|
381
430
|
* - Ignores elements with `pointer-events: none` and `visibility: hidden`
|
|
382
431
|
* - _(If `skipIgnore` is `true`, no elements are ignored)_
|
|
432
|
+
*
|
|
383
433
|
* @param skipIgnore Skip ignored elements?
|
|
384
434
|
* @returns Found element or `null`
|
|
385
435
|
*/
|
|
@@ -388,24 +438,28 @@ declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
|
|
|
388
438
|
//#region src/focusable.d.ts
|
|
389
439
|
/**
|
|
390
440
|
* Get a list of focusable elements within a parent element
|
|
441
|
+
*
|
|
391
442
|
* @param parent Parent element
|
|
392
443
|
* @returns Focusable elements
|
|
393
444
|
*/
|
|
394
445
|
declare function getFocusable(parent: Element): Element[];
|
|
395
446
|
/**
|
|
396
447
|
* Get a list of tabbable elements within a parent element
|
|
448
|
+
*
|
|
397
449
|
* @param parent Parent element
|
|
398
450
|
* @returns Tabbable elements
|
|
399
451
|
*/
|
|
400
452
|
declare function getTabbable(parent: Element): Element[];
|
|
401
453
|
/**
|
|
402
454
|
* Is the element focusable?
|
|
455
|
+
*
|
|
403
456
|
* @param element Element to check
|
|
404
457
|
* @returns `true` if focusable, otherwise `false`
|
|
405
458
|
*/
|
|
406
459
|
declare function isFocusable(element: Element): boolean;
|
|
407
460
|
/**
|
|
408
461
|
* Is the element tabbable?
|
|
462
|
+
*
|
|
409
463
|
* @param element Element to check
|
|
410
464
|
* @returns `true` if tabbable, otherwise `false`
|
|
411
465
|
*/
|
|
@@ -420,11 +474,13 @@ type HtmlOptions = {
|
|
|
420
474
|
};
|
|
421
475
|
/**
|
|
422
476
|
* Create nodes from a template string
|
|
477
|
+
*
|
|
423
478
|
* @returns Created nodes
|
|
424
479
|
*/
|
|
425
480
|
declare function html(strings: TemplateStringsArray, ...values: unknown[]): Node[];
|
|
426
481
|
/**
|
|
427
482
|
* Create nodes from an HTML string or a template element
|
|
483
|
+
*
|
|
428
484
|
* @param value HTML string or id for a template element
|
|
429
485
|
* @param options Options for creating nodes
|
|
430
486
|
* @returns Created nodes
|
|
@@ -432,6 +488,7 @@ declare function html(strings: TemplateStringsArray, ...values: unknown[]): Node
|
|
|
432
488
|
declare function html(value: string, options?: HtmlOptions): Node[];
|
|
433
489
|
/**
|
|
434
490
|
* Create nodes from a template element
|
|
491
|
+
*
|
|
435
492
|
* @param template Template element
|
|
436
493
|
* @param options Options for creating nodes
|
|
437
494
|
* @returns Created nodes
|
|
@@ -450,34 +507,53 @@ declare namespace html {
|
|
|
450
507
|
declare function sanitize(value: Node | Node[]): Node[];
|
|
451
508
|
//#endregion
|
|
452
509
|
//#region src/internal/is.d.ts
|
|
510
|
+
/**
|
|
511
|
+
* Is the value an event position?
|
|
512
|
+
*
|
|
513
|
+
* @param value Value to check
|
|
514
|
+
* @returns `true` if it's an event position, otherwise `false`
|
|
515
|
+
*/
|
|
516
|
+
declare function isEventPosition(value: unknown): value is EventPosition;
|
|
453
517
|
/**
|
|
454
518
|
* Is the value an event target?
|
|
519
|
+
*
|
|
455
520
|
* @param value Value to check
|
|
456
521
|
* @returns `true` if it's an event target, otherwise `false`
|
|
457
522
|
*/
|
|
458
523
|
declare function isEventTarget(value: unknown): value is EventTarget;
|
|
459
524
|
/**
|
|
460
525
|
* Is the value an HTML or SVG element?
|
|
526
|
+
*
|
|
461
527
|
* @param value Value to check
|
|
462
528
|
* @returns `true` if it's an HTML or SVG element, otherwise `false`
|
|
463
529
|
*/
|
|
464
530
|
declare function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement;
|
|
531
|
+
/**
|
|
532
|
+
* Is the value an input element? _(`<input>`, `<select>`, or `<textarea>`)_
|
|
533
|
+
*
|
|
534
|
+
* @param value Value to check
|
|
535
|
+
* @returns `true` if it's an input element, otherwise `false`
|
|
536
|
+
*/
|
|
537
|
+
declare function isInputElement(value: unknown): value is HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
465
538
|
//#endregion
|
|
466
539
|
//#region src/is.d.ts
|
|
467
540
|
/**
|
|
468
541
|
* Is the value a child node?
|
|
542
|
+
*
|
|
469
543
|
* @param value Value to check
|
|
470
544
|
* @returns `true` if it's a child node, otherwise `false`
|
|
471
545
|
*/
|
|
472
546
|
declare function isChildNode(value: unknown): value is ChildNode;
|
|
473
547
|
/**
|
|
474
548
|
* Is the node inside a document?
|
|
549
|
+
*
|
|
475
550
|
* @param node Node to check
|
|
476
551
|
* @returns `true` if it's inside a document, otherwise `false`
|
|
477
552
|
*/
|
|
478
553
|
declare function isInDocument(node: Node): boolean;
|
|
479
554
|
/**
|
|
480
555
|
* Is the node inside a specific document?
|
|
556
|
+
*
|
|
481
557
|
* @param node Node to check
|
|
482
558
|
* @param document Document to check within
|
|
483
559
|
* @returns `true` if it's inside the document, otherwise `false`
|
|
@@ -488,6 +564,7 @@ declare function isInDocument(node: Node, document: Document): boolean;
|
|
|
488
564
|
type GetProperties<Target extends Element> = { [Property in keyof Target as Target[Property] extends Primitive ? Property : never]?: Target[Property] };
|
|
489
565
|
/**
|
|
490
566
|
* Get the values of one or more properties on an element
|
|
567
|
+
*
|
|
491
568
|
* @param target Target element
|
|
492
569
|
* @param properties Properties to get
|
|
493
570
|
* @returns Property values
|
|
@@ -495,6 +572,7 @@ type GetProperties<Target extends Element> = { [Property in keyof Target as Targ
|
|
|
495
572
|
declare function getProperties<Target extends Element, Property extends keyof GetProperties<Target>>(target: Target, properties: Property[]): Pick<GetProperties<Target>, Property>;
|
|
496
573
|
/**
|
|
497
574
|
* Get the value of a property on an element
|
|
575
|
+
*
|
|
498
576
|
* @param target Target element
|
|
499
577
|
* @param property Property to get
|
|
500
578
|
* @returns Property value
|
|
@@ -508,6 +586,7 @@ type SetProperties<Target extends Element> = { [Property in keyof Target as Targ
|
|
|
508
586
|
* Set the values of one or more properties on an element
|
|
509
587
|
*
|
|
510
588
|
* Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
|
|
589
|
+
*
|
|
511
590
|
* @param target Target element
|
|
512
591
|
* @param properties Properties to set
|
|
513
592
|
* @param dispatch Dispatch events for properties? _(defaults to `true`)_
|
|
@@ -515,6 +594,7 @@ type SetProperties<Target extends Element> = { [Property in keyof Target as Targ
|
|
|
515
594
|
declare function setProperties<Target extends Element>(target: Target, properties: SetProperties<Target>, dispatch?: boolean): void;
|
|
516
595
|
/**
|
|
517
596
|
* Set the value for a dispatchable property on an element
|
|
597
|
+
*
|
|
518
598
|
* @param target Target element
|
|
519
599
|
* @param property Property to set
|
|
520
600
|
* @param value Value to set
|
|
@@ -523,6 +603,7 @@ declare function setProperties<Target extends Element>(target: Target, propertie
|
|
|
523
603
|
declare function setProperty<Target extends Element, Property extends DispatchedAttributeName>(target: Target, property: Property, value: DispatchedPropertyValue<Target, Property>, dispatch?: boolean): void;
|
|
524
604
|
/**
|
|
525
605
|
* Set the value for a property on an element
|
|
606
|
+
*
|
|
526
607
|
* @param target Target element
|
|
527
608
|
* @param property Property to set
|
|
528
609
|
* @param value Value to set
|
|
@@ -545,6 +626,7 @@ type Styles = Partial<Record<keyof CSSStyleValues, unknown>>;
|
|
|
545
626
|
type Variables<Value extends Record<string, string | undefined> = Record<string, string | undefined>> = { [property in keyof Value as `--${string & property}`]?: string | undefined };
|
|
546
627
|
/**
|
|
547
628
|
* Get a style from an element
|
|
629
|
+
*
|
|
548
630
|
* @param element Element to get the style from
|
|
549
631
|
* @param property Style name
|
|
550
632
|
* @param computed Get the computed style? _(defaults to `false`)_
|
|
@@ -553,6 +635,7 @@ type Variables<Value extends Record<string, string | undefined> = Record<string,
|
|
|
553
635
|
declare function getStyle(element: Element, property: keyof CSSStyleValues, computed?: boolean): string | undefined;
|
|
554
636
|
/**
|
|
555
637
|
* Get styles from an element
|
|
638
|
+
*
|
|
556
639
|
* @param element Element to get the styles from
|
|
557
640
|
* @param properties Styles to get
|
|
558
641
|
* @param computed Get the computed styles? _(defaults to `false`)_
|
|
@@ -561,17 +644,20 @@ declare function getStyle(element: Element, property: keyof CSSStyleValues, comp
|
|
|
561
644
|
declare function getStyles<Property extends keyof CSSStyleValues>(element: Element, properties: Property[], computed?: boolean): Record<Property, string | undefined>;
|
|
562
645
|
/**
|
|
563
646
|
* Get the text direction of a node or element _(or document, if element is invalid)_
|
|
647
|
+
*
|
|
564
648
|
* @param node Node or element to get the text direction from
|
|
565
649
|
* @returns Text direction
|
|
566
650
|
*/
|
|
567
651
|
declare function getTextDirection(node: Element | Node): TextDirection;
|
|
568
652
|
/**
|
|
569
653
|
* Get the text direction of the document
|
|
654
|
+
*
|
|
570
655
|
* @returns Text direction
|
|
571
656
|
*/
|
|
572
657
|
declare function getTextDirection(): TextDirection;
|
|
573
658
|
/**
|
|
574
659
|
* Set a style on an element
|
|
660
|
+
*
|
|
575
661
|
* @param element Element to set the style on
|
|
576
662
|
* @param property Style name
|
|
577
663
|
* @param value Style value
|
|
@@ -579,16 +665,18 @@ declare function getTextDirection(): TextDirection;
|
|
|
579
665
|
declare function setStyle(element: Element, property: keyof CSSStyleValues, value?: unknown): void;
|
|
580
666
|
/**
|
|
581
667
|
* Set styles on an element
|
|
668
|
+
*
|
|
582
669
|
* @param element Element to set the styles on
|
|
583
670
|
* @param styles Styles to set
|
|
584
671
|
*/
|
|
585
672
|
declare function setStyles(element: Element, styles: Styles): void;
|
|
586
673
|
/**
|
|
587
674
|
* Toggle styles for an element
|
|
675
|
+
*
|
|
588
676
|
* @param element Element to style
|
|
589
677
|
* @param styles Styles to be set or removed
|
|
590
678
|
* @returns Style toggler
|
|
591
679
|
*/
|
|
592
680
|
declare function toggleStyles(element: Element, styles: Styles): StyleToggler;
|
|
593
681
|
//#endregion
|
|
594
|
-
export { findElement as $, findElement, findElements as $$, findElements, Attribute, CustomEventListener,
|
|
682
|
+
export { findElement as $, findElement, findElements as $$, findElements, Attribute, CustomEventListener, RemovableEventListener, Selector, StyleToggler, TextDirection, booleanAttributes, createElement, dispatch, findAncestor, findRelatives, getAttribute, getAttributes, getData, getDistance, getElementFromPosition, getElementUnderPointer, getFocusable, getPosition, getProperties, getProperty, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEventPosition, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInputElement, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAttribute, setAttributes, setData, setProperties, setProperty, setStyle, setStyles, supportsTouch, toggleStyles };
|