@oscarpalmer/toretto 0.39.2 → 0.40.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/{types/attribute/get.d.ts → dist/attribute/get.d.mts} +6 -3
- package/dist/attribute/{get.js → get.mjs} +2 -2
- package/{types/attribute/index.d.ts → dist/attribute/index.d.mts} +16 -12
- package/dist/attribute/{index.js → index.mjs} +3 -3
- package/{types/attribute/set.d.ts → dist/attribute/set.d.mts} +10 -7
- package/dist/attribute/{set.js → set.mjs} +2 -2
- package/{types/data.d.ts → dist/data.d.mts} +9 -5
- package/dist/{data.js → data.mjs} +4 -4
- package/dist/event/delegation.d.mts +11 -0
- package/dist/event/{delegation.js → delegation.mjs} +8 -8
- package/{types/event/index.d.ts → dist/event/index.d.mts} +12 -8
- package/dist/event/{index.js → index.mjs} +4 -4
- package/{types/find/index.d.ts → dist/find/index.d.mts} +11 -8
- package/dist/find/{index.js → index.mjs} +7 -7
- package/{types/find/relative.d.ts → dist/find/relative.d.mts} +8 -5
- package/{types/focusable.d.ts → dist/focusable.d.mts} +7 -4
- package/dist/{focusable.js → focusable.mjs} +20 -20
- package/dist/html/index.d.mts +42 -0
- package/dist/html/{index.js → index.mjs} +8 -8
- package/dist/html/sanitize.d.mts +5 -0
- package/dist/html/{sanitize.js → sanitize.mjs} +4 -4
- package/{types/index.d.ts → dist/index.d.mts} +157 -128
- package/dist/{toretto.full.js → index.mjs} +85 -23
- package/dist/internal/attribute.d.mts +15 -0
- package/dist/internal/{attribute.js → attribute.mjs} +14 -14
- package/dist/internal/element-value.d.mts +6 -0
- package/dist/internal/{element-value.js → element-value.mjs} +3 -3
- package/dist/internal/get-value.d.mts +7 -0
- package/dist/internal/{get-value.js → get-value.mjs} +1 -1
- package/{types/internal/is.d.ts → dist/internal/is.d.mts} +5 -2
- package/{types/is.d.ts → dist/is.d.mts} +8 -4
- package/dist/{is.js → is.mjs} +2 -2
- package/dist/models.d.mts +33 -0
- package/dist/models.mjs +1 -0
- package/dist/style.d.mts +58 -0
- package/dist/{style.js → style.mjs} +5 -5
- package/dist/touch.d.mts +21 -0
- package/dist/{touch.js → touch.mjs} +1 -1
- package/package.json +60 -63
- package/dist/index.js +0 -15
- package/dist/models.js +0 -0
- package/types/event/delegation.d.ts +0 -7
- package/types/html/index.d.ts +0 -40
- package/types/html/sanitize.d.ts +0 -2
- package/types/internal/attribute.d.ts +0 -11
- package/types/internal/element-value.d.ts +0 -3
- package/types/internal/get-value.d.ts +0 -4
- package/types/models.d.ts +0 -30
- package/types/style.d.ts +0 -54
- package/types/touch.d.ts +0 -19
- /package/dist/find/{relative.js → relative.mjs} +0 -0
- /package/dist/internal/{is.js → is.mjs} +0 -0
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
update(): boolean;
|
|
1
|
+
//#region src/touch.d.ts
|
|
2
|
+
type SupporsTouch = {
|
|
3
|
+
/**
|
|
4
|
+
* Are touch events supported?
|
|
5
|
+
*/
|
|
6
|
+
readonly value: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Are touch events supported?
|
|
9
|
+
*/
|
|
10
|
+
get(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Re-evaluate if touch events are supported
|
|
13
|
+
*/
|
|
14
|
+
update(): boolean;
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
17
|
* Does the device support touch events?
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
declare const supportsTouch: SupporsTouch;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/models.d.ts
|
|
21
22
|
/**
|
|
22
23
|
* Attribute for an element
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
type Attribute = {
|
|
26
|
+
name: string;
|
|
27
|
+
value: unknown;
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
30
|
* Event listener for custom events
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
type CustomEventListener = (event: CustomEvent) => void;
|
|
32
33
|
/**
|
|
33
34
|
* The position of an event
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
type EventPosition = {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
* Event listener that can be removed
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
type RemovableEventListener = () => void;
|
|
43
44
|
/**
|
|
44
45
|
* Selector that be searched for
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
type Selector = string | Node | Node[] | NodeList;
|
|
47
48
|
/**
|
|
48
49
|
* Text direction for an element
|
|
49
50
|
*/
|
|
50
|
-
|
|
51
|
+
type TextDirection = 'ltr' | 'rtl';
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/internal/attribute.d.ts
|
|
51
54
|
/**
|
|
52
55
|
* List of boolean attributes
|
|
53
56
|
*/
|
|
54
|
-
|
|
57
|
+
declare const booleanAttributes: readonly string[];
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/attribute/get.d.ts
|
|
55
60
|
/**
|
|
56
61
|
* Get the value of a specific attribute from an element
|
|
57
62
|
* @param element Element to get attribute from
|
|
@@ -59,14 +64,14 @@ export declare const booleanAttributes: readonly string[];
|
|
|
59
64
|
* @param parse Parse value? _(defaults to `true`)_
|
|
60
65
|
* @returns Attribute value _(or `undefined`)_
|
|
61
66
|
*/
|
|
62
|
-
|
|
67
|
+
declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
|
|
63
68
|
/**
|
|
64
69
|
* Get the value of a specific attribute from an element
|
|
65
70
|
* @param element Element to get attribute from
|
|
66
71
|
* @param name Attribute name
|
|
67
72
|
* @returns Attribute value _(or `undefined`)_
|
|
68
73
|
*/
|
|
69
|
-
|
|
74
|
+
declare function getAttribute(element: Element, name: string): unknown;
|
|
70
75
|
/**
|
|
71
76
|
* Get specific attributes from an element
|
|
72
77
|
* @param element Element to get attributes from
|
|
@@ -74,8 +79,10 @@ export declare function getAttribute(element: Element, name: string): unknown;
|
|
|
74
79
|
* @param parseData Parse data values? _(defaults to `true`)_
|
|
75
80
|
* @returns Object of named attributes
|
|
76
81
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
declare function getAttributes<Key extends string>(element: Element, names: Key[], parseData?: boolean): Record<Key, unknown>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/attribute/set.d.ts
|
|
85
|
+
type DispatchedAttribute = 'checked' | 'open' | 'value';
|
|
79
86
|
/**
|
|
80
87
|
* Set an attribute on an element
|
|
81
88
|
*
|
|
@@ -85,7 +92,7 @@ export type DispatchedAttribute = "checked" | "open" | "value";
|
|
|
85
92
|
* @param value Attribute value
|
|
86
93
|
* @param dispatch Dispatch event for attribute? _(defaults to `true`)_
|
|
87
94
|
*/
|
|
88
|
-
|
|
95
|
+
declare function setAttribute<Name extends DispatchedAttribute>(element: Element, name: Name, value?: unknown, dispatch?: boolean): void;
|
|
89
96
|
/**
|
|
90
97
|
* Set an attribute on an element
|
|
91
98
|
*
|
|
@@ -94,7 +101,7 @@ export declare function setAttribute<Name extends DispatchedAttribute>(element:
|
|
|
94
101
|
* @param name Attribute name
|
|
95
102
|
* @param value Attribute value
|
|
96
103
|
*/
|
|
97
|
-
|
|
104
|
+
declare function setAttribute(element: Element, name: string, value?: unknown): void;
|
|
98
105
|
/**
|
|
99
106
|
* Set an attribute on an element
|
|
100
107
|
*
|
|
@@ -103,7 +110,7 @@ export declare function setAttribute(element: Element, name: string, value?: unk
|
|
|
103
110
|
* @param attribute Attribute to set
|
|
104
111
|
* @param dispatch Dispatch event for attribute? _(defaults to `true`)_
|
|
105
112
|
*/
|
|
106
|
-
|
|
113
|
+
declare function setAttribute(element: Element, attribute: Attr | Attribute, dispatch?: boolean): void;
|
|
107
114
|
/**
|
|
108
115
|
* Set one or more attributes on an element
|
|
109
116
|
*
|
|
@@ -112,7 +119,7 @@ export declare function setAttribute(element: Element, attribute: Attr | Attribu
|
|
|
112
119
|
* @param attributes Attributes to set
|
|
113
120
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
114
121
|
*/
|
|
115
|
-
|
|
122
|
+
declare function setAttributes(element: Element, attributes: Array<Attr | Attribute>, dispatch?: boolean): void;
|
|
116
123
|
/**
|
|
117
124
|
* Set one or more attributes on an element
|
|
118
125
|
*
|
|
@@ -121,45 +128,47 @@ export declare function setAttributes(element: Element, attributes: Array<Attr |
|
|
|
121
128
|
* @param attributes Attributes to set
|
|
122
129
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
123
130
|
*/
|
|
124
|
-
|
|
131
|
+
declare function setAttributes(element: Element, attributes: Record<string, unknown>, dispatch?: boolean): void;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/attribute/index.d.ts
|
|
125
134
|
/**
|
|
126
135
|
* Is the attribute considered bad and potentially harmful?
|
|
127
136
|
* @param attribute Attribute to check
|
|
128
137
|
* @returns `true` if attribute is considered bad
|
|
129
138
|
*/
|
|
130
|
-
|
|
139
|
+
declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
131
140
|
/**
|
|
132
141
|
* Is the attribute considered bad and potentially harmful?
|
|
133
142
|
* @param name Attribute name
|
|
134
143
|
* @param value Attribute value
|
|
135
144
|
* @returns `true` if attribute is considered bad
|
|
136
145
|
*/
|
|
137
|
-
|
|
146
|
+
declare function isBadAttribute(name: string, value: string): boolean;
|
|
138
147
|
/**
|
|
139
148
|
* Is the attribute a boolean attribute?
|
|
140
149
|
* @param name Attribute to check
|
|
141
150
|
* @returns `true` if attribute is a boolean attribute
|
|
142
151
|
*/
|
|
143
|
-
|
|
152
|
+
declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
144
153
|
/**
|
|
145
154
|
* Is the attribute a boolean attribute?
|
|
146
155
|
* @param name Attribute name
|
|
147
156
|
* @returns `true` if attribute is a boolean attribute
|
|
148
157
|
*/
|
|
149
|
-
|
|
158
|
+
declare function isBooleanAttribute(name: string): boolean;
|
|
150
159
|
/**
|
|
151
160
|
* Is the attribute empty and not a boolean attribute?
|
|
152
161
|
* @param attribute Attribute to check
|
|
153
162
|
* @returns `true` if attribute is empty and not a boolean attribute
|
|
154
163
|
*/
|
|
155
|
-
|
|
164
|
+
declare function isEmptyNonBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
156
165
|
/**
|
|
157
166
|
* Is the attribute empty and not a boolean attribute?
|
|
158
167
|
* @param name Attribute name
|
|
159
168
|
* @param value Attribute value
|
|
160
169
|
* @returns `true` if attribute is empty and not a boolean attribute
|
|
161
170
|
*/
|
|
162
|
-
|
|
171
|
+
declare function isEmptyNonBooleanAttribute(name: string, value: string): boolean;
|
|
163
172
|
/**
|
|
164
173
|
* Is the attribute an invalid boolean attribute?
|
|
165
174
|
*
|
|
@@ -167,7 +176,7 @@ export declare function isEmptyNonBooleanAttribute(name: string, value: string):
|
|
|
167
176
|
* @param attribute Attribute to check
|
|
168
177
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
169
178
|
*/
|
|
170
|
-
|
|
179
|
+
declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
171
180
|
/**
|
|
172
181
|
* Is the attribute an invalid boolean attribute?
|
|
173
182
|
*
|
|
@@ -176,11 +185,20 @@ export declare function isInvalidBooleanAttribute(attribute: Attr | Attribute):
|
|
|
176
185
|
* @param value Attribute value
|
|
177
186
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
178
187
|
*/
|
|
179
|
-
|
|
188
|
+
declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region node_modules/@oscarpalmer/atoms/dist/index.d.mts
|
|
180
191
|
/**
|
|
181
192
|
* A generic object
|
|
182
193
|
*/
|
|
183
|
-
|
|
194
|
+
type PlainObject = Record<PropertyKey, unknown>;
|
|
195
|
+
/**
|
|
196
|
+
* A primitive value
|
|
197
|
+
*
|
|
198
|
+
* _(Thanks, type-fest!)_
|
|
199
|
+
*/
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/data.d.ts
|
|
184
202
|
/**
|
|
185
203
|
* Get a keyed data value from an element
|
|
186
204
|
* @param element Element to get data from
|
|
@@ -188,7 +206,7 @@ export type PlainObject = Record<PropertyKey, unknown>;
|
|
|
188
206
|
* @param parse Parse values? _(defaults to `true`)_
|
|
189
207
|
* @returns Data value
|
|
190
208
|
*/
|
|
191
|
-
|
|
209
|
+
declare function getData(element: Element, key: string, parse?: boolean): unknown;
|
|
192
210
|
/**
|
|
193
211
|
* Get keyed data values from an element
|
|
194
212
|
* @param element Element to get data from
|
|
@@ -196,40 +214,42 @@ export declare function getData(element: Element, key: string, parse?: boolean):
|
|
|
196
214
|
* @param parse Parse values? _(defaults to `true`)_
|
|
197
215
|
* @returns Keyed data values
|
|
198
216
|
*/
|
|
199
|
-
|
|
217
|
+
declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
|
|
200
218
|
/**
|
|
201
219
|
* Set data values on an element
|
|
202
220
|
* @param element Element to set data on
|
|
203
221
|
* @param data Data to set
|
|
204
222
|
*/
|
|
205
|
-
|
|
223
|
+
declare function setData(element: Element, data: PlainObject): void;
|
|
206
224
|
/**
|
|
207
225
|
* Set a data value on an element
|
|
208
226
|
* @param element Element to set data on
|
|
209
227
|
* @param key Data key
|
|
210
228
|
* @param value Data value
|
|
211
229
|
*/
|
|
212
|
-
|
|
230
|
+
declare function setData(element: Element, key: string, value: unknown): void;
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/event/index.d.ts
|
|
213
233
|
/**
|
|
214
234
|
* Dispatch an event for a target
|
|
215
235
|
* @param target Event target
|
|
216
236
|
* @param type Type of event
|
|
217
237
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
218
238
|
*/
|
|
219
|
-
|
|
239
|
+
declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
|
|
220
240
|
/**
|
|
221
241
|
* Dispatch an event for a target
|
|
222
242
|
* @param target Event target
|
|
223
243
|
* @param type Type of event
|
|
224
244
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
225
245
|
*/
|
|
226
|
-
|
|
246
|
+
declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
|
|
227
247
|
/**
|
|
228
248
|
* Get the X- and Y-coordinates from a pointer event
|
|
229
249
|
* @param event Pointer event
|
|
230
250
|
* @returns X- and Y-coordinates
|
|
231
251
|
*/
|
|
232
|
-
|
|
252
|
+
declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
|
|
233
253
|
/**
|
|
234
254
|
* Remove an event listener
|
|
235
255
|
* @param target Event target
|
|
@@ -237,7 +257,7 @@ export declare function getPosition(event: MouseEvent | TouchEvent): EventPositi
|
|
|
237
257
|
* @param listener Event listener
|
|
238
258
|
* @param options Options for event
|
|
239
259
|
*/
|
|
240
|
-
|
|
260
|
+
declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
241
261
|
/**
|
|
242
262
|
* Remove an event listener
|
|
243
263
|
* @param target Event target
|
|
@@ -245,7 +265,7 @@ export declare function off(target: EventTarget, type: keyof HTMLElementEventMap
|
|
|
245
265
|
* @param listener Event listener
|
|
246
266
|
* @param options Options for event
|
|
247
267
|
*/
|
|
248
|
-
|
|
268
|
+
declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
249
269
|
/**
|
|
250
270
|
* Add an event listener
|
|
251
271
|
* @param target Event target
|
|
@@ -253,7 +273,7 @@ export declare function off(target: EventTarget, type: string, listener: EventLi
|
|
|
253
273
|
* @param listener Event listener
|
|
254
274
|
* @param options Options for event _(passive by default)_
|
|
255
275
|
*/
|
|
256
|
-
|
|
276
|
+
declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
|
|
257
277
|
/**
|
|
258
278
|
* Add an event listener
|
|
259
279
|
* @param target Event target
|
|
@@ -261,7 +281,9 @@ export declare function on<Type extends keyof HTMLElementEventMap>(target: Event
|
|
|
261
281
|
* @param listener Event listener
|
|
262
282
|
* @param options Options for event _(passive by default)_
|
|
263
283
|
*/
|
|
264
|
-
|
|
284
|
+
declare function on(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: AddEventListenerOptions): RemovableEventListener;
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/find/relative.d.ts
|
|
265
287
|
/**
|
|
266
288
|
* Find the closest ancestor element that matches the tag name
|
|
267
289
|
*
|
|
@@ -271,7 +293,7 @@ export declare function on(target: EventTarget, type: string, listener: EventLis
|
|
|
271
293
|
* @param tagName Tag name to match
|
|
272
294
|
* @returns Found ancestor or `null`
|
|
273
295
|
*/
|
|
274
|
-
|
|
296
|
+
declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origin: Element | Event | EventTarget, tagName: TagName): HTMLElementTagNameMap[TagName] | null;
|
|
275
297
|
/**
|
|
276
298
|
* Find the closest ancestor element that matches the selector _(string or callback)_
|
|
277
299
|
*
|
|
@@ -281,7 +303,7 @@ export declare function findAncestor<TagName extends keyof HTMLElementTagNameMap
|
|
|
281
303
|
* @param selector Selector to match
|
|
282
304
|
* @returns Found ancestor or `null`
|
|
283
305
|
*/
|
|
284
|
-
|
|
306
|
+
declare function findAncestor(origin: Element | Event | EventTarget, selector: string | ((element: Element) => boolean)): Element | null;
|
|
285
307
|
/**
|
|
286
308
|
* Finds the closest elements to the origin element that matches the tag name
|
|
287
309
|
*
|
|
@@ -291,7 +313,7 @@ export declare function findAncestor(origin: Element | Event | EventTarget, sele
|
|
|
291
313
|
* @param context Context to search within
|
|
292
314
|
* @returns Found elements
|
|
293
315
|
*/
|
|
294
|
-
|
|
316
|
+
declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(origin: Element, tagName: TagName, context?: Document | Element): HTMLElementTagNameMap[TagName][];
|
|
295
317
|
/**
|
|
296
318
|
* Finds the closest elements to the origin element that matches the selector
|
|
297
319
|
*
|
|
@@ -301,42 +323,44 @@ export declare function findRelatives<TagName extends keyof HTMLElementTagNameMa
|
|
|
301
323
|
* @param context Context to search within
|
|
302
324
|
* @returns Found elements
|
|
303
325
|
*/
|
|
304
|
-
|
|
326
|
+
declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
|
|
305
327
|
/**
|
|
306
328
|
* Get the distance between two elements _(i.e., the amount of nodes of between them)_
|
|
307
329
|
* @param origin Origin element
|
|
308
330
|
* @param target Target element
|
|
309
331
|
* @returns Distance between elements, or `-1` if distance cannot be calculated
|
|
310
332
|
*/
|
|
311
|
-
|
|
333
|
+
declare function getDistance(origin: Element, target: Element): number;
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/find/index.d.ts
|
|
312
336
|
/**
|
|
313
337
|
* Find the first element that matches the tag name
|
|
314
338
|
* @param tagName Tag name of element to find
|
|
315
339
|
* @param context Context to search within _(defaults to `document`)_
|
|
316
340
|
* @returns Found element or `null`
|
|
317
341
|
*/
|
|
318
|
-
|
|
342
|
+
declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
|
|
319
343
|
/**
|
|
320
344
|
* Find the first element that matches the selector
|
|
321
345
|
* @param selector Selector to find element for
|
|
322
346
|
* @param context Context to search within _(defaults to `document`)_
|
|
323
347
|
* @returns Found element or `null`
|
|
324
348
|
*/
|
|
325
|
-
|
|
349
|
+
declare function findElement(selector: string, context?: Selector | null): Element | null;
|
|
326
350
|
/**
|
|
327
351
|
* Find elements that match the selector
|
|
328
352
|
* @param tagName tagName to find elements for
|
|
329
353
|
* @param context Context to search within _(defaults to `document`)_
|
|
330
354
|
* @returns Found elements
|
|
331
355
|
*/
|
|
332
|
-
|
|
356
|
+
declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
|
|
333
357
|
/**
|
|
334
358
|
* Find elements that match the selector
|
|
335
359
|
* @param selector Selector to find elements for
|
|
336
360
|
* @param context Context to search within _(defaults to `document`)_
|
|
337
361
|
* @returns Found elements
|
|
338
362
|
*/
|
|
339
|
-
|
|
363
|
+
declare function findElements(selector: Selector, context?: Selector | null): Element[];
|
|
340
364
|
/**
|
|
341
365
|
* Get the most specific element under the pointer
|
|
342
366
|
*
|
|
@@ -345,110 +369,120 @@ export declare function findElements(selector: Selector, context?: Selector | nu
|
|
|
345
369
|
* @param skipIgnore Skip ignored elements?
|
|
346
370
|
* @returns Found element or `null`
|
|
347
371
|
*/
|
|
348
|
-
|
|
372
|
+
declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/focusable.d.ts
|
|
349
375
|
/**
|
|
350
376
|
* Get a list of focusable elements within a parent element
|
|
351
377
|
* @param parent Parent element
|
|
352
378
|
* @returns Focusable elements
|
|
353
379
|
*/
|
|
354
|
-
|
|
380
|
+
declare function getFocusable(parent: Element): Element[];
|
|
355
381
|
/**
|
|
356
382
|
* Get a list of tabbable elements within a parent element
|
|
357
383
|
* @param parent Parent element
|
|
358
384
|
* @returns Tabbable elements
|
|
359
385
|
*/
|
|
360
|
-
|
|
386
|
+
declare function getTabbable(parent: Element): Element[];
|
|
361
387
|
/**
|
|
362
388
|
* Is the element focusable?
|
|
363
389
|
* @param element Element to check
|
|
364
390
|
* @returns `true` if focusable, otherwise `false`
|
|
365
391
|
*/
|
|
366
|
-
|
|
392
|
+
declare function isFocusable(element: Element): boolean;
|
|
367
393
|
/**
|
|
368
394
|
* Is the element tabbable?
|
|
369
395
|
* @param element Element to check
|
|
370
396
|
* @returns `true` if tabbable, otherwise `false`
|
|
371
397
|
*/
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
398
|
+
declare function isTabbable(element: Element): boolean;
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/html/index.d.ts
|
|
401
|
+
type Html = {
|
|
402
|
+
/**
|
|
403
|
+
* Create nodes from an HTML string or a template element
|
|
404
|
+
* @param value HTML string or id for a template element
|
|
405
|
+
* @param options Options for creating nodes
|
|
406
|
+
* @returns Created nodes
|
|
407
|
+
*/
|
|
408
|
+
(value: string, options?: HtmlOptions): Node[];
|
|
409
|
+
/**
|
|
410
|
+
* Create nodes from a template element
|
|
411
|
+
* @param template Template element
|
|
412
|
+
* @param options Options for creating nodes
|
|
413
|
+
* @returns Created nodes
|
|
414
|
+
*/
|
|
415
|
+
(template: HTMLTemplateElement, options?: HtmlOptions): Node[];
|
|
416
|
+
/**
|
|
417
|
+
* Clear cache of template elements
|
|
418
|
+
*/
|
|
419
|
+
clear(): void;
|
|
420
|
+
/**
|
|
421
|
+
* Remove cached template element for an HTML string or id
|
|
422
|
+
* @param template HTML string or id for a template element
|
|
423
|
+
*/
|
|
424
|
+
remove(template: string): void;
|
|
397
425
|
};
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
426
|
+
type HtmlOptions = {
|
|
427
|
+
/**
|
|
428
|
+
* Cache template element for the HTML string? _(defaults to `true`)_
|
|
429
|
+
*/
|
|
430
|
+
cache?: boolean;
|
|
403
431
|
};
|
|
404
|
-
|
|
432
|
+
declare const html: Html;
|
|
405
433
|
/**
|
|
406
434
|
* Sanitize one or more nodes, recursively
|
|
407
435
|
* @param value Node or nodes to sanitize
|
|
408
436
|
* @param options Sanitization options
|
|
409
437
|
* @returns Sanitized nodes
|
|
410
438
|
*/
|
|
411
|
-
|
|
439
|
+
declare function sanitize(value: Node | Node[]): Node[];
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/internal/is.d.ts
|
|
412
442
|
/**
|
|
413
443
|
* Is the value an event target?
|
|
414
444
|
* @param value Value to check
|
|
415
445
|
* @returns `true` if it's an event target, otherwise `false`
|
|
416
446
|
*/
|
|
417
|
-
|
|
447
|
+
declare function isEventTarget(value: unknown): value is EventTarget;
|
|
418
448
|
/**
|
|
419
449
|
* Is the value an HTML or SVG element?
|
|
420
450
|
* @param value Value to check
|
|
421
451
|
* @returns `true` if it's an HTML or SVG element, otherwise `false`
|
|
422
452
|
*/
|
|
423
|
-
|
|
453
|
+
declare function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement;
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/is.d.ts
|
|
424
456
|
/**
|
|
425
457
|
* Is the value a child node?
|
|
426
458
|
* @param value Value to check
|
|
427
459
|
* @returns `true` if it's a child node, otherwise `false`
|
|
428
460
|
*/
|
|
429
|
-
|
|
461
|
+
declare function isChildNode(value: unknown): value is ChildNode;
|
|
430
462
|
/**
|
|
431
463
|
* Is the node inside a document?
|
|
432
464
|
* @param node Node to check
|
|
433
465
|
* @returns `true` if it's inside a document, otherwise `false`
|
|
434
466
|
*/
|
|
435
|
-
|
|
467
|
+
declare function isInDocument(node: Node): boolean;
|
|
436
468
|
/**
|
|
437
469
|
* Is the node inside a specific document?
|
|
438
470
|
* @param node Node to check
|
|
439
471
|
* @param document Document to check within
|
|
440
472
|
* @returns `true` if it's inside the document, otherwise `false`
|
|
441
473
|
*/
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
474
|
+
declare function isInDocument(node: Node, document: Document): boolean;
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/style.d.ts
|
|
477
|
+
type StyleToggler = {
|
|
478
|
+
/**
|
|
479
|
+
* Set the provided styles on the element
|
|
480
|
+
*/
|
|
481
|
+
set(): void;
|
|
482
|
+
/**
|
|
483
|
+
* Remove the provided styles from the element _(and sets any previous styles)_
|
|
484
|
+
*/
|
|
485
|
+
remove(): void;
|
|
452
486
|
};
|
|
453
487
|
/**
|
|
454
488
|
* Get a style from an element
|
|
@@ -457,7 +491,7 @@ export type StyleToggler = {
|
|
|
457
491
|
* @param computed Get the computed style? _(defaults to `false`)_
|
|
458
492
|
* @returns Style value
|
|
459
493
|
*/
|
|
460
|
-
|
|
494
|
+
declare function getStyle(element: Element, property: keyof CSSStyleDeclaration, computed?: boolean): string | undefined;
|
|
461
495
|
/**
|
|
462
496
|
* Get styles from an element
|
|
463
497
|
* @param element Element to get the styles from
|
|
@@ -465,38 +499,33 @@ export declare function getStyle(element: Element, property: keyof CSSStyleDecla
|
|
|
465
499
|
* @param computed Get the computed styles? _(defaults to `false`)_
|
|
466
500
|
* @returns Style values
|
|
467
501
|
*/
|
|
468
|
-
|
|
502
|
+
declare function getStyles<Property extends keyof CSSStyleDeclaration>(element: Element, properties: Property[], computed?: boolean): Record<Property, string | undefined>;
|
|
469
503
|
/**
|
|
470
504
|
* Get the text direction of an element
|
|
471
505
|
* @param element Element to get the text direction from
|
|
472
506
|
* @param computed Get the computed text direction? _(defaults to `false`)_
|
|
473
507
|
* @returns Text direction
|
|
474
508
|
*/
|
|
475
|
-
|
|
509
|
+
declare function getTextDirection(element: Element, computed?: boolean): TextDirection;
|
|
476
510
|
/**
|
|
477
511
|
* Set a style on an element
|
|
478
512
|
* @param element Element to set the style on
|
|
479
513
|
* @param property Style name
|
|
480
514
|
* @param value Style value
|
|
481
515
|
*/
|
|
482
|
-
|
|
516
|
+
declare function setStyle(element: Element, property: keyof CSSStyleDeclaration, value?: string): void;
|
|
483
517
|
/**
|
|
484
518
|
* Set styles on an element
|
|
485
519
|
* @param element Element to set the styles on
|
|
486
520
|
* @param styles Styles to set
|
|
487
521
|
*/
|
|
488
|
-
|
|
522
|
+
declare function setStyles(element: Element, styles: Partial<CSSStyleDeclaration>): void;
|
|
489
523
|
/**
|
|
490
524
|
* Toggle styles for an element
|
|
491
525
|
* @param element Element to style
|
|
492
526
|
* @param styles Styles to be set or removed
|
|
493
527
|
* @returns Style toggler
|
|
494
528
|
*/
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
export {
|
|
498
|
-
findElement as $,
|
|
499
|
-
findElements as $$,
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
export {};
|
|
529
|
+
declare function toggleStyles(element: Element, styles: Partial<CSSStyleDeclaration>): StyleToggler;
|
|
530
|
+
//#endregion
|
|
531
|
+
export { findElement as $, findElement, findElements as $$, findElements, Attribute, CustomEventListener, EventPosition, RemovableEventListener, Selector, StyleToggler, TextDirection, booleanAttributes, dispatch, findAncestor, findRelatives, getAttribute, getAttributes, getData, getDistance, getElementUnderPointer, getFocusable, getPosition, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEmptyNonBooleanAttribute, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAttribute, setAttributes, setData, setStyle, setStyles, supportsTouch, toggleStyles };
|