@oscarpalmer/toretto 0.45.0 → 0.47.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/aria.d.mts +68 -0
- package/dist/aria.mjs +49 -0
- package/dist/attribute/get.attribute.d.mts +3 -0
- package/dist/attribute/get.attribute.mjs +3 -3
- package/dist/attribute/index.d.mts +7 -1
- package/dist/attribute/set.attribute.d.mts +5 -0
- package/dist/attribute/set.attribute.mjs +1 -1
- package/dist/create.d.mts +4 -2
- package/dist/create.mjs +1 -1
- package/dist/data.d.mts +4 -0
- package/dist/data.mjs +1 -2
- package/dist/event/delegation.mjs +3 -4
- package/dist/event/index.d.mts +9 -1
- package/dist/event/index.mjs +3 -2
- 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 +8 -4
- package/dist/html/index.mjs +4 -3
- package/dist/index.d.mts +185 -22
- package/dist/index.mjs +295 -144
- package/dist/internal/attribute.mjs +2 -2
- package/dist/internal/element-value.mjs +2 -4
- package/dist/internal/is.d.mts +15 -3
- package/dist/internal/is.mjs +15 -3
- package/dist/is.d.mts +5 -2
- package/dist/is.mjs +4 -3
- package/dist/models.d.mts +21 -8
- package/dist/property/get.property.d.mts +2 -0
- package/dist/property/get.property.mjs +4 -3
- package/dist/property/set.property.d.mts +3 -0
- package/dist/property/set.property.mjs +3 -4
- package/dist/style.d.mts +7 -0
- package/dist/style.mjs +8 -4
- package/dist/touch.d.mts +4 -0
- package/package.json +10 -6
- package/src/aria.ts +166 -0
- package/src/attribute/get.attribute.ts +5 -3
- package/src/attribute/index.ts +6 -0
- package/src/attribute/set.attribute.ts +5 -0
- package/src/create.ts +5 -3
- package/src/data.ts +11 -6
- package/src/event/delegation.ts +5 -6
- package/src/event/index.ts +11 -8
- 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 +11 -9
- package/src/index.ts +1 -0
- package/src/internal/attribute.ts +4 -2
- package/src/internal/element-value.ts +2 -3
- package/src/internal/is.ts +22 -2
- package/src/is.ts +4 -1
- package/src/models.ts +122 -8
- package/src/property/get.property.ts +6 -5
- package/src/property/set.property.ts +5 -3
- package/src/style.ts +12 -6
- 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
|
};
|
|
@@ -19,6 +23,26 @@ type SupporsTouch = {
|
|
|
19
23
|
declare const supportsTouch: SupporsTouch;
|
|
20
24
|
//#endregion
|
|
21
25
|
//#region src/models.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* _ARIA_ attribute for an element
|
|
28
|
+
*
|
|
29
|
+
* _(https://www.w3.org/TR/wai-aria-1.3/#aria-attributes)_
|
|
30
|
+
*/
|
|
31
|
+
type AriaAttribute = keyof AriaAttributes;
|
|
32
|
+
/**
|
|
33
|
+
* _ARIA_ attribute for an element without the `aria-` prefix
|
|
34
|
+
*
|
|
35
|
+
* _(https://www.w3.org/TR/wai-aria-1.3/#aria-attributes)_
|
|
36
|
+
*/
|
|
37
|
+
type AriaAttributeUnprefixed = keyof { [Key in AriaAttribute as Key extends `aria-${infer Name}` ? Name : never]: string | null; };
|
|
38
|
+
type AriaAttributes = { [Key in keyof ARIAMixin as NormalizedName<Key>]: string | null; };
|
|
39
|
+
type NormalizedName<Key extends string> = Key extends `aria${infer Name}` ? Name extends `${infer Part}Element` ? `aria-${Lowercase<Part>}` : Name extends `${infer Part}Elements` ? `aria-${Lowercase<Part>}` : `aria-${Lowercase<Name>}` : never;
|
|
40
|
+
/**
|
|
41
|
+
* _ARIA_ role for an element
|
|
42
|
+
*
|
|
43
|
+
* _(https://www.w3.org/TR/wai-aria-1.3/#role_definitions)_
|
|
44
|
+
*/
|
|
45
|
+
type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'blockquote' | 'button' | 'caption' | 'cell' | 'checkbox' | 'code' | 'columnheader' | 'combobox' | 'comment' | 'complementary' | 'contentinfo' | 'definition' | 'deletion' | 'dialog' | 'directory' | 'document' | 'emphasis' | 'feed' | 'figure' | 'form' | 'generic' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'insertion' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'mark' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'meter' | 'navigation' | 'none' | 'note' | 'option' | 'paragraph' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'sectionfooter' | 'sectionheader' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'strong' | 'subscript' | 'suggestion' | 'superscript' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'time' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
|
22
46
|
/**
|
|
23
47
|
* Attribute for an element
|
|
24
48
|
*/
|
|
@@ -30,13 +54,6 @@ type Attribute = {
|
|
|
30
54
|
* Event listener for custom events
|
|
31
55
|
*/
|
|
32
56
|
type CustomEventListener = (event: CustomEvent) => void;
|
|
33
|
-
/**
|
|
34
|
-
* The position of an event
|
|
35
|
-
*/
|
|
36
|
-
type EventPosition = {
|
|
37
|
-
x: number;
|
|
38
|
-
y: number;
|
|
39
|
-
};
|
|
40
57
|
/**
|
|
41
58
|
* Event listener that can be removed
|
|
42
59
|
*/
|
|
@@ -50,6 +67,71 @@ type Selector = string | Node | Node[] | NodeList;
|
|
|
50
67
|
*/
|
|
51
68
|
type TextDirection = 'ltr' | 'rtl';
|
|
52
69
|
//#endregion
|
|
70
|
+
//#region src/aria.d.ts
|
|
71
|
+
type AnyAriaAttribute = AriaAttribute | AriaAttributeUnprefixed;
|
|
72
|
+
type AriaAttributeItem = {
|
|
73
|
+
name: AnyAriaAttribute;
|
|
74
|
+
value?: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Get the value of a specific _ARIA_ attribute from an element
|
|
78
|
+
*
|
|
79
|
+
* @param element Element to get _ARIA_ attribute from
|
|
80
|
+
* @param name _ARIA_ name
|
|
81
|
+
* @returns _ARIA_ value _(or `undefined`)_
|
|
82
|
+
*/
|
|
83
|
+
declare function getAria(element: Element, attribute: AnyAriaAttribute): string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Get specific _ARIA_ attributes from an element
|
|
86
|
+
*
|
|
87
|
+
* @param element Element to get _ARIA_ attributes from
|
|
88
|
+
* @param names _ARIA_ attribute names
|
|
89
|
+
* @returns Object of named _ARIA_ attributes
|
|
90
|
+
*/
|
|
91
|
+
declare function getAria<Attribute extends AnyAriaAttribute>(element: Element, attributes: Attribute[]): Record<Attribute, string | undefined>;
|
|
92
|
+
/**
|
|
93
|
+
* Get the role of an element
|
|
94
|
+
*
|
|
95
|
+
* @param element Element to get role from
|
|
96
|
+
* @returns Element role _(or `undefined`)_
|
|
97
|
+
*/
|
|
98
|
+
declare function getRole(element: Element): unknown;
|
|
99
|
+
/**
|
|
100
|
+
* Set an _ARIA_ attribute on an element
|
|
101
|
+
*
|
|
102
|
+
* _(Or remove it, if value is `null` or `undefined`)_
|
|
103
|
+
*
|
|
104
|
+
* @param element Element for _ARIA_ attribute
|
|
105
|
+
* @param attribute _ARIA_ attribute to set
|
|
106
|
+
* @param value _ARIA_ attribute value
|
|
107
|
+
*/
|
|
108
|
+
declare function setAria(element: Element, attribute: AnyAriaAttribute, value?: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Set one or more _ARIA_ attributes on an element
|
|
111
|
+
*
|
|
112
|
+
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
113
|
+
*
|
|
114
|
+
* @param element Element for _ARIA_ attributes
|
|
115
|
+
* @param attributes _ARIA_ attributes to set
|
|
116
|
+
*/
|
|
117
|
+
declare function setAria(element: Element, attributes: AriaAttributeItem[]): void;
|
|
118
|
+
/**
|
|
119
|
+
* Set one or more _ARIA_ attributes on an element
|
|
120
|
+
*
|
|
121
|
+
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
122
|
+
*
|
|
123
|
+
* @param element Element for _ARIA_ attributes
|
|
124
|
+
* @param attributes _ARIA_ attributes to set
|
|
125
|
+
*/
|
|
126
|
+
declare function setAria(element: Element, attributes: Partial<Record<AnyAriaAttribute, unknown>>): void;
|
|
127
|
+
/**
|
|
128
|
+
* Set the role of an element
|
|
129
|
+
*
|
|
130
|
+
* @param element Element for role
|
|
131
|
+
* @param role Role to set _(or `undefined` to remove it)_
|
|
132
|
+
*/
|
|
133
|
+
declare function setRole(element: Element, role?: AriaRole): void;
|
|
134
|
+
//#endregion
|
|
53
135
|
//#region src/internal/attribute.d.ts
|
|
54
136
|
/**
|
|
55
137
|
* List of boolean attributes
|
|
@@ -60,6 +142,7 @@ declare const booleanAttributes: readonly string[];
|
|
|
60
142
|
type DataPrefixedName = `data-${string}`;
|
|
61
143
|
/**
|
|
62
144
|
* Get the value of a specific attribute from an element
|
|
145
|
+
*
|
|
63
146
|
* @param element Element to get attribute from
|
|
64
147
|
* @param name Attribute name
|
|
65
148
|
* @param parse Parse value? _(defaults to `true`)_
|
|
@@ -68,6 +151,7 @@ type DataPrefixedName = `data-${string}`;
|
|
|
68
151
|
declare function getAttribute(element: Element, name: DataPrefixedName, parse?: boolean): unknown;
|
|
69
152
|
/**
|
|
70
153
|
* Get the value of a specific attribute from an element
|
|
154
|
+
*
|
|
71
155
|
* @param element Element to get attribute from
|
|
72
156
|
* @param name Attribute name
|
|
73
157
|
* @returns Attribute value _(or `undefined`)_
|
|
@@ -75,6 +159,7 @@ declare function getAttribute(element: Element, name: DataPrefixedName, parse?:
|
|
|
75
159
|
declare function getAttribute(element: Element, name: string): unknown;
|
|
76
160
|
/**
|
|
77
161
|
* Get specific attributes from an element
|
|
162
|
+
*
|
|
78
163
|
* @param element Element to get attributes from
|
|
79
164
|
* @param names Attribute names
|
|
80
165
|
* @param parseData Parse data values? _(defaults to `true`)_
|
|
@@ -88,6 +173,7 @@ type DispatchedAttributeName = 'checked' | 'open' | 'value';
|
|
|
88
173
|
* Set an attribute on an element
|
|
89
174
|
*
|
|
90
175
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
176
|
+
*
|
|
91
177
|
* @param element Element for attribute
|
|
92
178
|
* @param name Attribute name
|
|
93
179
|
* @param value Attribute value
|
|
@@ -98,6 +184,7 @@ declare function setAttribute(element: Element, name: DispatchedAttributeName, v
|
|
|
98
184
|
* Set an attribute on an element
|
|
99
185
|
*
|
|
100
186
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
187
|
+
*
|
|
101
188
|
* @param element Element for attribute
|
|
102
189
|
* @param name Attribute name
|
|
103
190
|
* @param value Attribute value
|
|
@@ -107,6 +194,7 @@ declare function setAttribute(element: Element, name: string, value?: unknown):
|
|
|
107
194
|
* Set an attribute on an element
|
|
108
195
|
*
|
|
109
196
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
197
|
+
*
|
|
110
198
|
* @param element Element for attribute
|
|
111
199
|
* @param attribute Attribute to set
|
|
112
200
|
* @param dispatch Dispatch event for attribute? _(defaults to `true`)_
|
|
@@ -116,6 +204,7 @@ declare function setAttribute(element: Element, attribute: Attr | Attribute, dis
|
|
|
116
204
|
* Set one or more attributes on an element
|
|
117
205
|
*
|
|
118
206
|
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
207
|
+
*
|
|
119
208
|
* @param element Element for attributes
|
|
120
209
|
* @param attributes Attributes to set
|
|
121
210
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
@@ -125,6 +214,7 @@ declare function setAttributes(element: Element, attributes: Array<Attr | Attrib
|
|
|
125
214
|
* Set one or more attributes on an element
|
|
126
215
|
*
|
|
127
216
|
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
217
|
+
*
|
|
128
218
|
* @param element Element for attributes
|
|
129
219
|
* @param attributes Attributes to set
|
|
130
220
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
@@ -134,12 +224,14 @@ declare function setAttributes(element: Element, attributes: Record<string, unkn
|
|
|
134
224
|
//#region src/attribute/index.d.ts
|
|
135
225
|
/**
|
|
136
226
|
* Is the attribute considered bad and potentially harmful?
|
|
227
|
+
*
|
|
137
228
|
* @param attribute Attribute to check
|
|
138
229
|
* @returns `true` if attribute is considered bad
|
|
139
230
|
*/
|
|
140
231
|
declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
141
232
|
/**
|
|
142
233
|
* Is the attribute considered bad and potentially harmful?
|
|
234
|
+
*
|
|
143
235
|
* @param name Attribute name
|
|
144
236
|
* @param value Attribute value
|
|
145
237
|
* @returns `true` if attribute is considered bad
|
|
@@ -147,12 +239,14 @@ declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
|
147
239
|
declare function isBadAttribute(name: string, value: string): boolean;
|
|
148
240
|
/**
|
|
149
241
|
* Is the attribute a boolean attribute?
|
|
242
|
+
*
|
|
150
243
|
* @param name Attribute to check
|
|
151
244
|
* @returns `true` if attribute is a boolean attribute
|
|
152
245
|
*/
|
|
153
246
|
declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
154
247
|
/**
|
|
155
248
|
* Is the attribute a boolean attribute?
|
|
249
|
+
*
|
|
156
250
|
* @param name Attribute name
|
|
157
251
|
* @returns `true` if attribute is a boolean attribute
|
|
158
252
|
*/
|
|
@@ -161,6 +255,7 @@ declare function isBooleanAttribute(name: string): boolean;
|
|
|
161
255
|
* Is the attribute an invalid boolean attribute?
|
|
162
256
|
*
|
|
163
257
|
* _(I.e., its value is not empty or the same as its name)_
|
|
258
|
+
*
|
|
164
259
|
* @param attribute Attribute to check
|
|
165
260
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
166
261
|
*/
|
|
@@ -169,6 +264,7 @@ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean
|
|
|
169
264
|
* Is the attribute an invalid boolean attribute?
|
|
170
265
|
*
|
|
171
266
|
* _(I.e., its value is not empty or the same as its name)_
|
|
267
|
+
*
|
|
172
268
|
* @param name Attribute name
|
|
173
269
|
* @param value Attribute value
|
|
174
270
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
@@ -176,6 +272,13 @@ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean
|
|
|
176
272
|
declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
|
|
177
273
|
//#endregion
|
|
178
274
|
//#region node_modules/@oscarpalmer/atoms/dist/models.d.mts
|
|
275
|
+
/**
|
|
276
|
+
* Position of an event
|
|
277
|
+
*/
|
|
278
|
+
type EventPosition = {
|
|
279
|
+
x: number;
|
|
280
|
+
y: number;
|
|
281
|
+
};
|
|
179
282
|
/**
|
|
180
283
|
* A generic object
|
|
181
284
|
*/
|
|
@@ -186,15 +289,13 @@ type PlainObject = Record<PropertyKey, unknown>;
|
|
|
186
289
|
* _(Thanks, type-fest!)_
|
|
187
290
|
*/
|
|
188
291
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
189
|
-
/**
|
|
190
|
-
* Set required keys for a type
|
|
191
|
-
*/
|
|
192
292
|
//#endregion
|
|
193
293
|
//#region src/create.d.ts
|
|
194
|
-
type Properties<Target extends Element> = { [Property in keyof Target]?: Target[Property] extends Primitive ? Target[Property] : never };
|
|
294
|
+
type Properties<Target extends Element> = { [Property in keyof Target]?: Target[Property] extends Primitive ? Target[Property] : never; };
|
|
195
295
|
type Styles$1 = Partial<Record<keyof CSSStyleDeclaration, unknown>>;
|
|
196
296
|
/**
|
|
197
|
-
* Creates an
|
|
297
|
+
* Creates an _HTML_ element with the specified tag name together with optional properties, attributes, and styles
|
|
298
|
+
*
|
|
198
299
|
* @param tag Tag name
|
|
199
300
|
* @param properties Element properties
|
|
200
301
|
* @param attributes Element attributes
|
|
@@ -203,7 +304,8 @@ type Styles$1 = Partial<Record<keyof CSSStyleDeclaration, unknown>>;
|
|
|
203
304
|
*/
|
|
204
305
|
declare function createElement<TagName extends keyof HTMLElementTagNameMap>(tag: TagName, properties?: Properties<HTMLElementTagNameMap[TagName]>, attributes?: Record<string, unknown>, styles?: Styles$1): HTMLElementTagNameMap[TagName];
|
|
205
306
|
/**
|
|
206
|
-
* Creates an
|
|
307
|
+
* Creates an _HTML_ element with the specified tag name together with optional properties, attributes, and styles
|
|
308
|
+
*
|
|
207
309
|
* @param tag Tag name
|
|
208
310
|
* @param properties Element properties
|
|
209
311
|
* @param attributes Element attributes
|
|
@@ -215,6 +317,7 @@ declare function createElement(tag: string, properties?: Properties<HTMLElement>
|
|
|
215
317
|
//#region src/data.d.ts
|
|
216
318
|
/**
|
|
217
319
|
* Get a keyed data value from an element
|
|
320
|
+
*
|
|
218
321
|
* @param element Element to get data from
|
|
219
322
|
* @param key Data key
|
|
220
323
|
* @param parse Parse values? _(defaults to `true`)_
|
|
@@ -223,6 +326,7 @@ declare function createElement(tag: string, properties?: Properties<HTMLElement>
|
|
|
223
326
|
declare function getData(element: Element, key: string, parse?: boolean): unknown;
|
|
224
327
|
/**
|
|
225
328
|
* Get keyed data values from an element
|
|
329
|
+
*
|
|
226
330
|
* @param element Element to get data from
|
|
227
331
|
* @param keys Keys of the data values to get
|
|
228
332
|
* @param parse Parse values? _(defaults to `true`)_
|
|
@@ -231,12 +335,14 @@ declare function getData(element: Element, key: string, parse?: boolean): unknow
|
|
|
231
335
|
declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
|
|
232
336
|
/**
|
|
233
337
|
* Set data values on an element
|
|
338
|
+
*
|
|
234
339
|
* @param element Element to set data on
|
|
235
340
|
* @param data Data to set
|
|
236
341
|
*/
|
|
237
342
|
declare function setData(element: Element, data: PlainObject): void;
|
|
238
343
|
/**
|
|
239
344
|
* Set a data value on an element
|
|
345
|
+
*
|
|
240
346
|
* @param element Element to set data on
|
|
241
347
|
* @param key Data key
|
|
242
348
|
* @param value Data value
|
|
@@ -246,6 +352,7 @@ declare function setData(element: Element, key: string, value: unknown): void;
|
|
|
246
352
|
//#region src/event/index.d.ts
|
|
247
353
|
/**
|
|
248
354
|
* Dispatch an event for a target
|
|
355
|
+
*
|
|
249
356
|
* @param target Event target
|
|
250
357
|
* @param type Type of event
|
|
251
358
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
@@ -253,6 +360,7 @@ declare function setData(element: Element, key: string, value: unknown): void;
|
|
|
253
360
|
declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
|
|
254
361
|
/**
|
|
255
362
|
* Dispatch an event for a target
|
|
363
|
+
*
|
|
256
364
|
* @param target Event target
|
|
257
365
|
* @param type Type of event
|
|
258
366
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
@@ -260,12 +368,14 @@ declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventT
|
|
|
260
368
|
declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
|
|
261
369
|
/**
|
|
262
370
|
* Get the X- and Y-coordinates from a pointer event
|
|
371
|
+
*
|
|
263
372
|
* @param event Pointer event
|
|
264
373
|
* @returns X- and Y-coordinates
|
|
265
374
|
*/
|
|
266
375
|
declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
|
|
267
376
|
/**
|
|
268
377
|
* Remove an event listener
|
|
378
|
+
*
|
|
269
379
|
* @param target Event target
|
|
270
380
|
* @param type Type of event
|
|
271
381
|
* @param listener Event listener
|
|
@@ -274,6 +384,7 @@ declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | un
|
|
|
274
384
|
declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
275
385
|
/**
|
|
276
386
|
* Remove an event listener
|
|
387
|
+
*
|
|
277
388
|
* @param target Event target
|
|
278
389
|
* @param type Type of event
|
|
279
390
|
* @param listener Event listener
|
|
@@ -282,6 +393,7 @@ declare function off(target: EventTarget, type: keyof HTMLElementEventMap, liste
|
|
|
282
393
|
declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
283
394
|
/**
|
|
284
395
|
* Add an event listener
|
|
396
|
+
*
|
|
285
397
|
* @param target Event target
|
|
286
398
|
* @param type Type of event
|
|
287
399
|
* @param listener Event listener
|
|
@@ -290,6 +402,7 @@ declare function off(target: EventTarget, type: string, listener: EventListener
|
|
|
290
402
|
declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
|
|
291
403
|
/**
|
|
292
404
|
* Add an event listener
|
|
405
|
+
*
|
|
293
406
|
* @param target Event target
|
|
294
407
|
* @param type Type of event
|
|
295
408
|
* @param listener Event listener
|
|
@@ -303,6 +416,7 @@ declare function on(target: EventTarget, type: string, listener: EventListener |
|
|
|
303
416
|
*
|
|
304
417
|
* - If no match is found, `null` is returned
|
|
305
418
|
* - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
|
|
419
|
+
*
|
|
306
420
|
* @param origin Origin to start from
|
|
307
421
|
* @param tagName Tag name to match
|
|
308
422
|
* @returns Found ancestor or `null`
|
|
@@ -313,6 +427,7 @@ declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origi
|
|
|
313
427
|
*
|
|
314
428
|
* - If no match is found, `null` is returned
|
|
315
429
|
* - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
|
|
430
|
+
*
|
|
316
431
|
* @param origin Origin to start from
|
|
317
432
|
* @param selector Selector to match
|
|
318
433
|
* @returns Found ancestor or `null`
|
|
@@ -322,6 +437,7 @@ declare function findAncestor(origin: Element | Event | EventTarget, selector: s
|
|
|
322
437
|
* Finds the closest elements to the origin element that matches the tag name
|
|
323
438
|
*
|
|
324
439
|
* Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
|
|
440
|
+
*
|
|
325
441
|
* @param origin Element to start from
|
|
326
442
|
* @param tagName Tag name to match
|
|
327
443
|
* @param context Context to search within
|
|
@@ -332,6 +448,7 @@ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(orig
|
|
|
332
448
|
* Finds the closest elements to the origin element that matches the selector
|
|
333
449
|
*
|
|
334
450
|
* Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
|
|
451
|
+
*
|
|
335
452
|
* @param origin Element to start from
|
|
336
453
|
* @param selector Selector to match
|
|
337
454
|
* @param context Context to search within
|
|
@@ -340,6 +457,7 @@ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(orig
|
|
|
340
457
|
declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
|
|
341
458
|
/**
|
|
342
459
|
* Get the distance between two elements _(i.e., the amount of nodes of between them)_
|
|
460
|
+
*
|
|
343
461
|
* @param origin Origin element
|
|
344
462
|
* @param target Target element
|
|
345
463
|
* @returns Distance between elements, or `-1` if distance cannot be calculated
|
|
@@ -349,6 +467,7 @@ declare function getDistance(origin: Element, target: Element): number;
|
|
|
349
467
|
//#region src/find/index.d.ts
|
|
350
468
|
/**
|
|
351
469
|
* Find the first element that matches the tag name
|
|
470
|
+
*
|
|
352
471
|
* @param tagName Tag name of element to find
|
|
353
472
|
* @param context Context to search within _(defaults to `document`)_
|
|
354
473
|
* @returns Found element or `null`
|
|
@@ -356,6 +475,7 @@ declare function getDistance(origin: Element, target: Element): number;
|
|
|
356
475
|
declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
|
|
357
476
|
/**
|
|
358
477
|
* Find the first element that matches the selector
|
|
478
|
+
*
|
|
359
479
|
* @param selector Selector to find element for
|
|
360
480
|
* @param context Context to search within _(defaults to `document`)_
|
|
361
481
|
* @returns Found element or `null`
|
|
@@ -363,6 +483,7 @@ declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagNam
|
|
|
363
483
|
declare function findElement(selector: string, context?: Selector | null): Element | null;
|
|
364
484
|
/**
|
|
365
485
|
* Find elements that match the selector
|
|
486
|
+
*
|
|
366
487
|
* @param tagName tagName to find elements for
|
|
367
488
|
* @param context Context to search within _(defaults to `document`)_
|
|
368
489
|
* @returns Found elements
|
|
@@ -370,16 +491,25 @@ declare function findElement(selector: string, context?: Selector | null): Eleme
|
|
|
370
491
|
declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
|
|
371
492
|
/**
|
|
372
493
|
* Find elements that match the selector
|
|
494
|
+
*
|
|
373
495
|
* @param selector Selector to find elements for
|
|
374
496
|
* @param context Context to search within _(defaults to `document`)_
|
|
375
497
|
* @returns Found elements
|
|
376
498
|
*/
|
|
377
499
|
declare function findElements(selector: Selector, context?: Selector | null): Element[];
|
|
500
|
+
/**
|
|
501
|
+
* Get elements from an event position
|
|
502
|
+
*
|
|
503
|
+
* @param position Event position
|
|
504
|
+
* @returns Elements at the event position
|
|
505
|
+
*/
|
|
506
|
+
declare function getElementFromPosition(position: EventPosition): Element[];
|
|
378
507
|
/**
|
|
379
508
|
* Get the most specific element under the pointer
|
|
380
509
|
*
|
|
381
510
|
* - Ignores elements with `pointer-events: none` and `visibility: hidden`
|
|
382
511
|
* - _(If `skipIgnore` is `true`, no elements are ignored)_
|
|
512
|
+
*
|
|
383
513
|
* @param skipIgnore Skip ignored elements?
|
|
384
514
|
* @returns Found element or `null`
|
|
385
515
|
*/
|
|
@@ -388,24 +518,28 @@ declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
|
|
|
388
518
|
//#region src/focusable.d.ts
|
|
389
519
|
/**
|
|
390
520
|
* Get a list of focusable elements within a parent element
|
|
521
|
+
*
|
|
391
522
|
* @param parent Parent element
|
|
392
523
|
* @returns Focusable elements
|
|
393
524
|
*/
|
|
394
525
|
declare function getFocusable(parent: Element): Element[];
|
|
395
526
|
/**
|
|
396
527
|
* Get a list of tabbable elements within a parent element
|
|
528
|
+
*
|
|
397
529
|
* @param parent Parent element
|
|
398
530
|
* @returns Tabbable elements
|
|
399
531
|
*/
|
|
400
532
|
declare function getTabbable(parent: Element): Element[];
|
|
401
533
|
/**
|
|
402
534
|
* Is the element focusable?
|
|
535
|
+
*
|
|
403
536
|
* @param element Element to check
|
|
404
537
|
* @returns `true` if focusable, otherwise `false`
|
|
405
538
|
*/
|
|
406
539
|
declare function isFocusable(element: Element): boolean;
|
|
407
540
|
/**
|
|
408
541
|
* Is the element tabbable?
|
|
542
|
+
*
|
|
409
543
|
* @param element Element to check
|
|
410
544
|
* @returns `true` if tabbable, otherwise `false`
|
|
411
545
|
*/
|
|
@@ -414,24 +548,27 @@ declare function isTabbable(element: Element): boolean;
|
|
|
414
548
|
//#region src/html/index.d.ts
|
|
415
549
|
type HtmlOptions = {
|
|
416
550
|
/**
|
|
417
|
-
* Cache template element for the
|
|
551
|
+
* Cache template element for the _HTML_ string? _(defaults to `true`)_
|
|
418
552
|
*/
|
|
419
553
|
cache?: boolean;
|
|
420
554
|
};
|
|
421
555
|
/**
|
|
422
556
|
* Create nodes from a template string
|
|
557
|
+
*
|
|
423
558
|
* @returns Created nodes
|
|
424
559
|
*/
|
|
425
560
|
declare function html(strings: TemplateStringsArray, ...values: unknown[]): Node[];
|
|
426
561
|
/**
|
|
427
|
-
* Create nodes from an
|
|
428
|
-
*
|
|
562
|
+
* Create nodes from an _HTML_ string or a template element
|
|
563
|
+
*
|
|
564
|
+
* @param value _HTML_ string or ID for a template element
|
|
429
565
|
* @param options Options for creating nodes
|
|
430
566
|
* @returns Created nodes
|
|
431
567
|
*/
|
|
432
568
|
declare function html(value: string, options?: HtmlOptions): Node[];
|
|
433
569
|
/**
|
|
434
570
|
* Create nodes from a template element
|
|
571
|
+
*
|
|
435
572
|
* @param template Template element
|
|
436
573
|
* @param options Options for creating nodes
|
|
437
574
|
* @returns Created nodes
|
|
@@ -443,6 +580,7 @@ declare namespace html {
|
|
|
443
580
|
}
|
|
444
581
|
/**
|
|
445
582
|
* Sanitize one or more nodes, recursively
|
|
583
|
+
*
|
|
446
584
|
* @param value Node or nodes to sanitize
|
|
447
585
|
* @param options Sanitization options
|
|
448
586
|
* @returns Sanitized nodes
|
|
@@ -450,20 +588,30 @@ declare namespace html {
|
|
|
450
588
|
declare function sanitize(value: Node | Node[]): Node[];
|
|
451
589
|
//#endregion
|
|
452
590
|
//#region src/internal/is.d.ts
|
|
591
|
+
/**
|
|
592
|
+
* Is the value an event position?
|
|
593
|
+
*
|
|
594
|
+
* @param value Value to check
|
|
595
|
+
* @returns `true` if it's an event position, otherwise `false`
|
|
596
|
+
*/
|
|
597
|
+
declare function isEventPosition(value: unknown): value is EventPosition;
|
|
453
598
|
/**
|
|
454
599
|
* Is the value an event target?
|
|
600
|
+
*
|
|
455
601
|
* @param value Value to check
|
|
456
602
|
* @returns `true` if it's an event target, otherwise `false`
|
|
457
603
|
*/
|
|
458
604
|
declare function isEventTarget(value: unknown): value is EventTarget;
|
|
459
605
|
/**
|
|
460
|
-
* Is the value an
|
|
606
|
+
* Is the value an _HTML_ or _SVG_ element?
|
|
607
|
+
*
|
|
461
608
|
* @param value Value to check
|
|
462
|
-
* @returns `true` if it's an
|
|
609
|
+
* @returns `true` if it's an _HTML_ or _SVG_ element, otherwise `false`
|
|
463
610
|
*/
|
|
464
611
|
declare function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement;
|
|
465
612
|
/**
|
|
466
613
|
* Is the value an input element? _(`<input>`, `<select>`, or `<textarea>`)_
|
|
614
|
+
*
|
|
467
615
|
* @param value Value to check
|
|
468
616
|
* @returns `true` if it's an input element, otherwise `false`
|
|
469
617
|
*/
|
|
@@ -472,18 +620,21 @@ declare function isInputElement(value: unknown): value is HTMLInputElement | HTM
|
|
|
472
620
|
//#region src/is.d.ts
|
|
473
621
|
/**
|
|
474
622
|
* Is the value a child node?
|
|
623
|
+
*
|
|
475
624
|
* @param value Value to check
|
|
476
625
|
* @returns `true` if it's a child node, otherwise `false`
|
|
477
626
|
*/
|
|
478
627
|
declare function isChildNode(value: unknown): value is ChildNode;
|
|
479
628
|
/**
|
|
480
629
|
* Is the node inside a document?
|
|
630
|
+
*
|
|
481
631
|
* @param node Node to check
|
|
482
632
|
* @returns `true` if it's inside a document, otherwise `false`
|
|
483
633
|
*/
|
|
484
634
|
declare function isInDocument(node: Node): boolean;
|
|
485
635
|
/**
|
|
486
636
|
* Is the node inside a specific document?
|
|
637
|
+
*
|
|
487
638
|
* @param node Node to check
|
|
488
639
|
* @param document Document to check within
|
|
489
640
|
* @returns `true` if it's inside the document, otherwise `false`
|
|
@@ -491,9 +642,10 @@ declare function isInDocument(node: Node): boolean;
|
|
|
491
642
|
declare function isInDocument(node: Node, document: Document): boolean;
|
|
492
643
|
//#endregion
|
|
493
644
|
//#region src/property/get.property.d.ts
|
|
494
|
-
type GetProperties<Target extends Element> = { [Property in keyof Target as Target[Property] extends Primitive ? Property : never]?: Target[Property] };
|
|
645
|
+
type GetProperties<Target extends Element> = { [Property in keyof Target as Target[Property] extends Primitive ? Property : never]?: Target[Property]; };
|
|
495
646
|
/**
|
|
496
647
|
* Get the values of one or more properties on an element
|
|
648
|
+
*
|
|
497
649
|
* @param target Target element
|
|
498
650
|
* @param properties Properties to get
|
|
499
651
|
* @returns Property values
|
|
@@ -501,6 +653,7 @@ type GetProperties<Target extends Element> = { [Property in keyof Target as Targ
|
|
|
501
653
|
declare function getProperties<Target extends Element, Property extends keyof GetProperties<Target>>(target: Target, properties: Property[]): Pick<GetProperties<Target>, Property>;
|
|
502
654
|
/**
|
|
503
655
|
* Get the value of a property on an element
|
|
656
|
+
*
|
|
504
657
|
* @param target Target element
|
|
505
658
|
* @param property Property to get
|
|
506
659
|
* @returns Property value
|
|
@@ -509,11 +662,12 @@ declare function getProperty<Target extends Element, Property extends keyof GetP
|
|
|
509
662
|
//#endregion
|
|
510
663
|
//#region src/property/set.property.d.ts
|
|
511
664
|
type DispatchedPropertyValue<Target extends Element, Property extends DispatchedAttributeName> = Property extends keyof SetProperties<Target> ? SetProperties<Target>[Property] : never;
|
|
512
|
-
type SetProperties<Target extends Element> = { [Property in keyof Target as Target[Property] extends Primitive ? Property : never]?: Target[Property] };
|
|
665
|
+
type SetProperties<Target extends Element> = { [Property in keyof Target as Target[Property] extends Primitive ? Property : never]?: Target[Property]; };
|
|
513
666
|
/**
|
|
514
667
|
* Set the values of one or more properties on an element
|
|
515
668
|
*
|
|
516
669
|
* Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
|
|
670
|
+
*
|
|
517
671
|
* @param target Target element
|
|
518
672
|
* @param properties Properties to set
|
|
519
673
|
* @param dispatch Dispatch events for properties? _(defaults to `true`)_
|
|
@@ -521,6 +675,7 @@ type SetProperties<Target extends Element> = { [Property in keyof Target as Targ
|
|
|
521
675
|
declare function setProperties<Target extends Element>(target: Target, properties: SetProperties<Target>, dispatch?: boolean): void;
|
|
522
676
|
/**
|
|
523
677
|
* Set the value for a dispatchable property on an element
|
|
678
|
+
*
|
|
524
679
|
* @param target Target element
|
|
525
680
|
* @param property Property to set
|
|
526
681
|
* @param value Value to set
|
|
@@ -529,6 +684,7 @@ declare function setProperties<Target extends Element>(target: Target, propertie
|
|
|
529
684
|
declare function setProperty<Target extends Element, Property extends DispatchedAttributeName>(target: Target, property: Property, value: DispatchedPropertyValue<Target, Property>, dispatch?: boolean): void;
|
|
530
685
|
/**
|
|
531
686
|
* Set the value for a property on an element
|
|
687
|
+
*
|
|
532
688
|
* @param target Target element
|
|
533
689
|
* @param property Property to set
|
|
534
690
|
* @param value Value to set
|
|
@@ -548,9 +704,10 @@ type StyleToggler = {
|
|
|
548
704
|
remove(): void;
|
|
549
705
|
};
|
|
550
706
|
type Styles = Partial<Record<keyof CSSStyleValues, unknown>>;
|
|
551
|
-
type Variables<Value extends Record<string, string | undefined> = Record<string, string | undefined>> = { [property in keyof Value as `--${string & property}`]?: string | undefined };
|
|
707
|
+
type Variables<Value extends Record<string, string | undefined> = Record<string, string | undefined>> = { [property in keyof Value as `--${string & property}`]?: string | undefined; };
|
|
552
708
|
/**
|
|
553
709
|
* Get a style from an element
|
|
710
|
+
*
|
|
554
711
|
* @param element Element to get the style from
|
|
555
712
|
* @param property Style name
|
|
556
713
|
* @param computed Get the computed style? _(defaults to `false`)_
|
|
@@ -559,6 +716,7 @@ type Variables<Value extends Record<string, string | undefined> = Record<string,
|
|
|
559
716
|
declare function getStyle(element: Element, property: keyof CSSStyleValues, computed?: boolean): string | undefined;
|
|
560
717
|
/**
|
|
561
718
|
* Get styles from an element
|
|
719
|
+
*
|
|
562
720
|
* @param element Element to get the styles from
|
|
563
721
|
* @param properties Styles to get
|
|
564
722
|
* @param computed Get the computed styles? _(defaults to `false`)_
|
|
@@ -567,17 +725,20 @@ declare function getStyle(element: Element, property: keyof CSSStyleValues, comp
|
|
|
567
725
|
declare function getStyles<Property extends keyof CSSStyleValues>(element: Element, properties: Property[], computed?: boolean): Record<Property, string | undefined>;
|
|
568
726
|
/**
|
|
569
727
|
* Get the text direction of a node or element _(or document, if element is invalid)_
|
|
728
|
+
*
|
|
570
729
|
* @param node Node or element to get the text direction from
|
|
571
730
|
* @returns Text direction
|
|
572
731
|
*/
|
|
573
732
|
declare function getTextDirection(node: Element | Node): TextDirection;
|
|
574
733
|
/**
|
|
575
734
|
* Get the text direction of the document
|
|
735
|
+
*
|
|
576
736
|
* @returns Text direction
|
|
577
737
|
*/
|
|
578
738
|
declare function getTextDirection(): TextDirection;
|
|
579
739
|
/**
|
|
580
740
|
* Set a style on an element
|
|
741
|
+
*
|
|
581
742
|
* @param element Element to set the style on
|
|
582
743
|
* @param property Style name
|
|
583
744
|
* @param value Style value
|
|
@@ -585,16 +746,18 @@ declare function getTextDirection(): TextDirection;
|
|
|
585
746
|
declare function setStyle(element: Element, property: keyof CSSStyleValues, value?: unknown): void;
|
|
586
747
|
/**
|
|
587
748
|
* Set styles on an element
|
|
749
|
+
*
|
|
588
750
|
* @param element Element to set the styles on
|
|
589
751
|
* @param styles Styles to set
|
|
590
752
|
*/
|
|
591
753
|
declare function setStyles(element: Element, styles: Styles): void;
|
|
592
754
|
/**
|
|
593
755
|
* Toggle styles for an element
|
|
756
|
+
*
|
|
594
757
|
* @param element Element to style
|
|
595
758
|
* @param styles Styles to be set or removed
|
|
596
759
|
* @returns Style toggler
|
|
597
760
|
*/
|
|
598
761
|
declare function toggleStyles(element: Element, styles: Styles): StyleToggler;
|
|
599
762
|
//#endregion
|
|
600
|
-
export { findElement as $, findElement, findElements as $$, findElements, Attribute, CustomEventListener,
|
|
763
|
+
export { findElement as $, findElement, findElements as $$, findElements, AriaAttribute, AriaAttributeUnprefixed, AriaRole, Attribute, CustomEventListener, HtmlOptions, RemovableEventListener, Selector, StyleToggler, TextDirection, booleanAttributes, createElement, dispatch, findAncestor, findRelatives, getAria, getAttribute, getAttributes, getData, getDistance, getElementFromPosition, getElementUnderPointer, getFocusable, getPosition, getProperties, getProperty, getRole, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEventPosition, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInputElement, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAria, setAttribute, setAttributes, setData, setProperties, setProperty, setRole, setStyle, setStyles, supportsTouch, toggleStyles };
|