@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
|
@@ -10,6 +10,7 @@ type DataPrefixedName = `data-${string}`;
|
|
|
10
10
|
declare function getAttribute(element: Element, name: DataPrefixedName, parse?: boolean): unknown;
|
|
11
11
|
/**
|
|
12
12
|
* Get the value of a specific attribute from an element
|
|
13
|
+
*
|
|
13
14
|
* @param element Element to get attribute from
|
|
14
15
|
* @param name Attribute name
|
|
15
16
|
* @returns Attribute value _(or `undefined`)_
|
|
@@ -17,6 +18,7 @@ declare function getAttribute(element: Element, name: DataPrefixedName, parse?:
|
|
|
17
18
|
declare function getAttribute(element: Element, name: string): unknown;
|
|
18
19
|
/**
|
|
19
20
|
* Get specific attributes from an element
|
|
21
|
+
*
|
|
20
22
|
* @param element Element to get attributes from
|
|
21
23
|
* @param names Attribute names
|
|
22
24
|
* @param parseData Parse data values? _(defaults to `true`)_
|
|
@@ -6,12 +6,14 @@ import { setAttribute, setAttributes } from "./set.attribute.mjs";
|
|
|
6
6
|
//#region src/attribute/index.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Is the attribute considered bad and potentially harmful?
|
|
9
|
+
*
|
|
9
10
|
* @param attribute Attribute to check
|
|
10
11
|
* @returns `true` if attribute is considered bad
|
|
11
12
|
*/
|
|
12
13
|
declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
13
14
|
/**
|
|
14
15
|
* Is the attribute considered bad and potentially harmful?
|
|
16
|
+
*
|
|
15
17
|
* @param name Attribute name
|
|
16
18
|
* @param value Attribute value
|
|
17
19
|
* @returns `true` if attribute is considered bad
|
|
@@ -19,12 +21,14 @@ declare function isBadAttribute(attribute: Attr | Attribute): boolean;
|
|
|
19
21
|
declare function isBadAttribute(name: string, value: string): boolean;
|
|
20
22
|
/**
|
|
21
23
|
* Is the attribute a boolean attribute?
|
|
24
|
+
*
|
|
22
25
|
* @param name Attribute to check
|
|
23
26
|
* @returns `true` if attribute is a boolean attribute
|
|
24
27
|
*/
|
|
25
28
|
declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
26
29
|
/**
|
|
27
30
|
* Is the attribute a boolean attribute?
|
|
31
|
+
*
|
|
28
32
|
* @param name Attribute name
|
|
29
33
|
* @returns `true` if attribute is a boolean attribute
|
|
30
34
|
*/
|
|
@@ -33,6 +37,7 @@ declare function isBooleanAttribute(name: string): boolean;
|
|
|
33
37
|
* Is the attribute an invalid boolean attribute?
|
|
34
38
|
*
|
|
35
39
|
* _(I.e., its value is not empty or the same as its name)_
|
|
40
|
+
*
|
|
36
41
|
* @param attribute Attribute to check
|
|
37
42
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
38
43
|
*/
|
|
@@ -41,6 +46,7 @@ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean
|
|
|
41
46
|
* Is the attribute an invalid boolean attribute?
|
|
42
47
|
*
|
|
43
48
|
* _(I.e., its value is not empty or the same as its name)_
|
|
49
|
+
*
|
|
44
50
|
* @param name Attribute name
|
|
45
51
|
* @param value Attribute value
|
|
46
52
|
* @returns `true` if attribute is an invalid boolean attribute
|
|
@@ -6,6 +6,7 @@ type DispatchedAttributeName = 'checked' | 'open' | 'value';
|
|
|
6
6
|
* Set an attribute on an element
|
|
7
7
|
*
|
|
8
8
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
9
|
+
*
|
|
9
10
|
* @param element Element for attribute
|
|
10
11
|
* @param name Attribute name
|
|
11
12
|
* @param value Attribute value
|
|
@@ -16,6 +17,7 @@ declare function setAttribute(element: Element, name: DispatchedAttributeName, v
|
|
|
16
17
|
* Set an attribute on an element
|
|
17
18
|
*
|
|
18
19
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
20
|
+
*
|
|
19
21
|
* @param element Element for attribute
|
|
20
22
|
* @param name Attribute name
|
|
21
23
|
* @param value Attribute value
|
|
@@ -25,6 +27,7 @@ declare function setAttribute(element: Element, name: string, value?: unknown):
|
|
|
25
27
|
* Set an attribute on an element
|
|
26
28
|
*
|
|
27
29
|
* _(Or remove it, if value is `null` or `undefined`)_
|
|
30
|
+
*
|
|
28
31
|
* @param element Element for attribute
|
|
29
32
|
* @param attribute Attribute to set
|
|
30
33
|
* @param dispatch Dispatch event for attribute? _(defaults to `true`)_
|
|
@@ -34,6 +37,7 @@ declare function setAttribute(element: Element, attribute: Attr | Attribute, dis
|
|
|
34
37
|
* Set one or more attributes on an element
|
|
35
38
|
*
|
|
36
39
|
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
40
|
+
*
|
|
37
41
|
* @param element Element for attributes
|
|
38
42
|
* @param attributes Attributes to set
|
|
39
43
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
|
@@ -43,6 +47,7 @@ declare function setAttributes(element: Element, attributes: Array<Attr | Attrib
|
|
|
43
47
|
* Set one or more attributes on an element
|
|
44
48
|
*
|
|
45
49
|
* _(Or remove them, if their value is `null` or `undefined`)_
|
|
50
|
+
*
|
|
46
51
|
* @param element Element for attributes
|
|
47
52
|
* @param attributes Attributes to set
|
|
48
53
|
* @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
|
package/dist/create.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ type Properties<Target extends Element> = { [Property in keyof Target]?: Target[
|
|
|
5
5
|
type Styles = Partial<Record<keyof CSSStyleDeclaration, unknown>>;
|
|
6
6
|
/**
|
|
7
7
|
* Creates an HTML element with the specified tag name together with optional properties, attributes, and styles
|
|
8
|
+
*
|
|
8
9
|
* @param tag Tag name
|
|
9
10
|
* @param properties Element properties
|
|
10
11
|
* @param attributes Element attributes
|
|
@@ -14,6 +15,7 @@ type Styles = Partial<Record<keyof CSSStyleDeclaration, unknown>>;
|
|
|
14
15
|
declare function createElement<TagName extends keyof HTMLElementTagNameMap>(tag: TagName, properties?: Properties<HTMLElementTagNameMap[TagName]>, attributes?: Record<string, unknown>, styles?: Styles): HTMLElementTagNameMap[TagName];
|
|
15
16
|
/**
|
|
16
17
|
* Creates an HTML element with the specified tag name together with optional properties, attributes, and styles
|
|
18
|
+
*
|
|
17
19
|
* @param tag Tag name
|
|
18
20
|
* @param properties Element properties
|
|
19
21
|
* @param attributes Element attributes
|
package/dist/data.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
|
3
3
|
//#region src/data.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Get a keyed data value from an element
|
|
6
|
+
*
|
|
6
7
|
* @param element Element to get data from
|
|
7
8
|
* @param key Data key
|
|
8
9
|
* @param parse Parse values? _(defaults to `true`)_
|
|
@@ -11,6 +12,7 @@ import { PlainObject } from "@oscarpalmer/atoms/models";
|
|
|
11
12
|
declare function getData(element: Element, key: string, parse?: boolean): unknown;
|
|
12
13
|
/**
|
|
13
14
|
* Get keyed data values from an element
|
|
15
|
+
*
|
|
14
16
|
* @param element Element to get data from
|
|
15
17
|
* @param keys Keys of the data values to get
|
|
16
18
|
* @param parse Parse values? _(defaults to `true`)_
|
|
@@ -19,12 +21,14 @@ declare function getData(element: Element, key: string, parse?: boolean): unknow
|
|
|
19
21
|
declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
|
|
20
22
|
/**
|
|
21
23
|
* Set data values on an element
|
|
24
|
+
*
|
|
22
25
|
* @param element Element to set data on
|
|
23
26
|
* @param data Data to set
|
|
24
27
|
*/
|
|
25
28
|
declare function setData(element: Element, data: PlainObject): void;
|
|
26
29
|
/**
|
|
27
30
|
* Set a data value on an element
|
|
31
|
+
*
|
|
28
32
|
* @param element Element to set data on
|
|
29
33
|
* @param key Data key
|
|
30
34
|
* @param value Data value
|
package/dist/event/index.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CustomEventListener,
|
|
1
|
+
import { CustomEventListener, RemovableEventListener } from "../models.mjs";
|
|
2
|
+
import { EventPosition } from "@oscarpalmer/atoms/models";
|
|
2
3
|
|
|
3
4
|
//#region src/event/index.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Dispatch an event for a target
|
|
7
|
+
*
|
|
6
8
|
* @param target Event target
|
|
7
9
|
* @param type Type of event
|
|
8
10
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
@@ -10,6 +12,7 @@ import { CustomEventListener, EventPosition, RemovableEventListener } from "../m
|
|
|
10
12
|
declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
|
|
11
13
|
/**
|
|
12
14
|
* Dispatch an event for a target
|
|
15
|
+
*
|
|
13
16
|
* @param target Event target
|
|
14
17
|
* @param type Type of event
|
|
15
18
|
* @param options Options for event _(bubbles and is cancelable by default)_
|
|
@@ -17,12 +20,14 @@ declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventT
|
|
|
17
20
|
declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
|
|
18
21
|
/**
|
|
19
22
|
* Get the X- and Y-coordinates from a pointer event
|
|
23
|
+
*
|
|
20
24
|
* @param event Pointer event
|
|
21
25
|
* @returns X- and Y-coordinates
|
|
22
26
|
*/
|
|
23
27
|
declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
|
|
24
28
|
/**
|
|
25
29
|
* Remove an event listener
|
|
30
|
+
*
|
|
26
31
|
* @param target Event target
|
|
27
32
|
* @param type Type of event
|
|
28
33
|
* @param listener Event listener
|
|
@@ -31,6 +36,7 @@ declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | un
|
|
|
31
36
|
declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
32
37
|
/**
|
|
33
38
|
* Remove an event listener
|
|
39
|
+
*
|
|
34
40
|
* @param target Event target
|
|
35
41
|
* @param type Type of event
|
|
36
42
|
* @param listener Event listener
|
|
@@ -39,6 +45,7 @@ declare function off(target: EventTarget, type: keyof HTMLElementEventMap, liste
|
|
|
39
45
|
declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
|
|
40
46
|
/**
|
|
41
47
|
* Add an event listener
|
|
48
|
+
*
|
|
42
49
|
* @param target Event target
|
|
43
50
|
* @param type Type of event
|
|
44
51
|
* @param listener Event listener
|
|
@@ -47,6 +54,7 @@ declare function off(target: EventTarget, type: string, listener: EventListener
|
|
|
47
54
|
declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
|
|
48
55
|
/**
|
|
49
56
|
* Add an event listener
|
|
57
|
+
*
|
|
50
58
|
* @param target Event target
|
|
51
59
|
* @param type Type of event
|
|
52
60
|
* @param listener Event listener
|
package/dist/event/index.mjs
CHANGED
|
@@ -32,6 +32,7 @@ function dispatch(target, type, options) {
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Get the X- and Y-coordinates from a pointer event
|
|
35
|
+
*
|
|
35
36
|
* @param event Pointer event
|
|
36
37
|
* @returns X- and Y-coordinates
|
|
37
38
|
*/
|
|
@@ -52,6 +53,7 @@ function getPosition(event) {
|
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* Remove an event listener
|
|
56
|
+
*
|
|
55
57
|
* @param target Event target
|
|
56
58
|
* @param type Type of event
|
|
57
59
|
* @param listener Event listener
|
package/dist/find/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Selector } from "../models.mjs";
|
|
2
2
|
import { findAncestor, findRelatives, getDistance } from "./relative.mjs";
|
|
3
|
+
import { EventPosition } from "@oscarpalmer/atoms/models";
|
|
3
4
|
|
|
4
5
|
//#region src/find/index.d.ts
|
|
5
6
|
/**
|
|
6
7
|
* Find the first element that matches the tag name
|
|
8
|
+
*
|
|
7
9
|
* @param tagName Tag name of element to find
|
|
8
10
|
* @param context Context to search within _(defaults to `document`)_
|
|
9
11
|
* @returns Found element or `null`
|
|
@@ -11,6 +13,7 @@ import { findAncestor, findRelatives, getDistance } from "./relative.mjs";
|
|
|
11
13
|
declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
|
|
12
14
|
/**
|
|
13
15
|
* Find the first element that matches the selector
|
|
16
|
+
*
|
|
14
17
|
* @param selector Selector to find element for
|
|
15
18
|
* @param context Context to search within _(defaults to `document`)_
|
|
16
19
|
* @returns Found element or `null`
|
|
@@ -18,6 +21,7 @@ declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagNam
|
|
|
18
21
|
declare function findElement(selector: string, context?: Selector | null): Element | null;
|
|
19
22
|
/**
|
|
20
23
|
* Find elements that match the selector
|
|
24
|
+
*
|
|
21
25
|
* @param tagName tagName to find elements for
|
|
22
26
|
* @param context Context to search within _(defaults to `document`)_
|
|
23
27
|
* @returns Found elements
|
|
@@ -25,19 +29,28 @@ declare function findElement(selector: string, context?: Selector | null): Eleme
|
|
|
25
29
|
declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
|
|
26
30
|
/**
|
|
27
31
|
* Find elements that match the selector
|
|
32
|
+
*
|
|
28
33
|
* @param selector Selector to find elements for
|
|
29
34
|
* @param context Context to search within _(defaults to `document`)_
|
|
30
35
|
* @returns Found elements
|
|
31
36
|
*/
|
|
32
37
|
declare function findElements(selector: Selector, context?: Selector | null): Element[];
|
|
38
|
+
/**
|
|
39
|
+
* Get elements from an event position
|
|
40
|
+
*
|
|
41
|
+
* @param position Event position
|
|
42
|
+
* @returns Elements at the event position
|
|
43
|
+
*/
|
|
44
|
+
declare function getElementFromPosition(position: EventPosition): Element[];
|
|
33
45
|
/**
|
|
34
46
|
* Get the most specific element under the pointer
|
|
35
47
|
*
|
|
36
48
|
* - Ignores elements with `pointer-events: none` and `visibility: hidden`
|
|
37
49
|
* - _(If `skipIgnore` is `true`, no elements are ignored)_
|
|
50
|
+
*
|
|
38
51
|
* @param skipIgnore Skip ignored elements?
|
|
39
52
|
* @returns Found element or `null`
|
|
40
53
|
*/
|
|
41
54
|
declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
|
|
42
55
|
//#endregion
|
|
43
|
-
export { findElement as $, findElement, findElements as $$, findElements, findAncestor, findRelatives, getDistance, getElementUnderPointer };
|
|
56
|
+
export { findElement as $, findElement, findElements as $$, findElements, findAncestor, findRelatives, getDistance, getElementFromPosition, getElementUnderPointer };
|
package/dist/find/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isEventPosition } from "../internal/is.mjs";
|
|
1
2
|
import { findAncestor, findRelatives, getDistance } from "./relative.mjs";
|
|
2
3
|
//#region src/find/index.ts
|
|
3
4
|
function findElement(selector, context) {
|
|
@@ -42,10 +43,42 @@ function findElements(selector, context) {
|
|
|
42
43
|
return findElementOrElements(selector, context, false);
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
46
|
+
* Get elements from an event position
|
|
47
|
+
*
|
|
48
|
+
* @param position Event position
|
|
49
|
+
* @returns Elements at the event position
|
|
50
|
+
*/
|
|
51
|
+
function getElementFromPosition(position) {
|
|
52
|
+
if (!isEventPosition(position) || typeof document.elementFromPoint !== "function") return [];
|
|
53
|
+
const { x, y } = position;
|
|
54
|
+
const elements = [];
|
|
55
|
+
const events = [];
|
|
56
|
+
let current;
|
|
57
|
+
while (true) {
|
|
58
|
+
current = document.elementFromPoint(x, y);
|
|
59
|
+
if (current == null || elements.indexOf(current) !== -1) break;
|
|
60
|
+
if (!(current instanceof HTMLElement)) continue;
|
|
61
|
+
elements.push(current);
|
|
62
|
+
events.push({
|
|
63
|
+
value: current.style.getPropertyValue(STYLE_POINTER_EVENTS),
|
|
64
|
+
priority: current.style.getPropertyPriority(STYLE_POINTER_EVENTS)
|
|
65
|
+
});
|
|
66
|
+
current.style.setProperty(STYLE_POINTER_EVENTS, STYLE_NONE, STYLE_IMPORTANT);
|
|
67
|
+
}
|
|
68
|
+
const { length } = elements;
|
|
69
|
+
for (let index = 0; index < length; index += 1) {
|
|
70
|
+
const element = elements[index];
|
|
71
|
+
const event = events[index];
|
|
72
|
+
if (element instanceof HTMLElement) element.style.setProperty(STYLE_POINTER_EVENTS, event.value ?? "", event.priority);
|
|
73
|
+
}
|
|
74
|
+
return elements;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
45
77
|
* Get the most specific element under the pointer
|
|
46
78
|
*
|
|
47
79
|
* - Ignores elements with `pointer-events: none` and `visibility: hidden`
|
|
48
80
|
* - _(If `skipIgnore` is `true`, no elements are ignored)_
|
|
81
|
+
*
|
|
49
82
|
* @param skipIgnore Skip ignored elements?
|
|
50
83
|
* @returns Found element or `null`
|
|
51
84
|
*/
|
|
@@ -67,8 +100,10 @@ function isContext(value) {
|
|
|
67
100
|
const QUERY_SELECTOR_ALL = "querySelectorAll";
|
|
68
101
|
const QUERY_SELECTOR_SINGLE = "querySelector";
|
|
69
102
|
const STYLE_HIDDEN = "hidden";
|
|
103
|
+
const STYLE_IMPORTANT = "important";
|
|
70
104
|
const STYLE_NONE = "none";
|
|
105
|
+
const STYLE_POINTER_EVENTS = "pointer-events";
|
|
71
106
|
const SUFFIX_HOVER = ":hover";
|
|
72
107
|
const TAG_HEAD = "HEAD";
|
|
73
108
|
//#endregion
|
|
74
|
-
export { findElement as $, findElement, findElements as $$, findElements, findAncestor, findRelatives, getDistance, getElementUnderPointer };
|
|
109
|
+
export { findElement as $, findElement, findElements as $$, findElements, findAncestor, findRelatives, getDistance, getElementFromPosition, getElementUnderPointer };
|
package/dist/find/relative.d.mts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* - If no match is found, `null` is returned
|
|
6
6
|
* - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
|
|
7
|
+
*
|
|
7
8
|
* @param origin Origin to start from
|
|
8
9
|
* @param tagName Tag name to match
|
|
9
10
|
* @returns Found ancestor or `null`
|
|
@@ -14,6 +15,7 @@ declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origi
|
|
|
14
15
|
*
|
|
15
16
|
* - If no match is found, `null` is returned
|
|
16
17
|
* - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
|
|
18
|
+
*
|
|
17
19
|
* @param origin Origin to start from
|
|
18
20
|
* @param selector Selector to match
|
|
19
21
|
* @returns Found ancestor or `null`
|
|
@@ -23,6 +25,7 @@ declare function findAncestor(origin: Element | Event | EventTarget, selector: s
|
|
|
23
25
|
* Finds the closest elements to the origin element that matches the tag name
|
|
24
26
|
*
|
|
25
27
|
* Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
|
|
28
|
+
*
|
|
26
29
|
* @param origin Element to start from
|
|
27
30
|
* @param tagName Tag name to match
|
|
28
31
|
* @param context Context to search within
|
|
@@ -33,6 +36,7 @@ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(orig
|
|
|
33
36
|
* Finds the closest elements to the origin element that matches the selector
|
|
34
37
|
*
|
|
35
38
|
* Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
|
|
39
|
+
*
|
|
36
40
|
* @param origin Element to start from
|
|
37
41
|
* @param selector Selector to match
|
|
38
42
|
* @param context Context to search within
|
|
@@ -41,6 +45,7 @@ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(orig
|
|
|
41
45
|
declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
|
|
42
46
|
/**
|
|
43
47
|
* Get the distance between two elements _(i.e., the amount of nodes of between them)_
|
|
48
|
+
*
|
|
44
49
|
* @param origin Origin element
|
|
45
50
|
* @param target Target element
|
|
46
51
|
* @returns Distance between elements, or `-1` if distance cannot be calculated
|
package/dist/find/relative.mjs
CHANGED
|
@@ -37,6 +37,7 @@ function findRelatives(origin, selector, context) {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Get the distance between two elements _(i.e., the amount of nodes of between them)_
|
|
40
|
+
*
|
|
40
41
|
* @param origin Origin element
|
|
41
42
|
* @param target Target element
|
|
42
43
|
* @returns Distance between elements, or `-1` if distance cannot be calculated
|
package/dist/focusable.d.mts
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
//#region src/focusable.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Get a list of focusable elements within a parent element
|
|
4
|
+
*
|
|
4
5
|
* @param parent Parent element
|
|
5
6
|
* @returns Focusable elements
|
|
6
7
|
*/
|
|
7
8
|
declare function getFocusable(parent: Element): Element[];
|
|
8
9
|
/**
|
|
9
10
|
* Get a list of tabbable elements within a parent element
|
|
11
|
+
*
|
|
10
12
|
* @param parent Parent element
|
|
11
13
|
* @returns Tabbable elements
|
|
12
14
|
*/
|
|
13
15
|
declare function getTabbable(parent: Element): Element[];
|
|
14
16
|
/**
|
|
15
17
|
* Is the element focusable?
|
|
18
|
+
*
|
|
16
19
|
* @param element Element to check
|
|
17
20
|
* @returns `true` if focusable, otherwise `false`
|
|
18
21
|
*/
|
|
19
22
|
declare function isFocusable(element: Element): boolean;
|
|
20
23
|
/**
|
|
21
24
|
* Is the element tabbable?
|
|
25
|
+
*
|
|
22
26
|
* @param element Element to check
|
|
23
27
|
* @returns `true` if tabbable, otherwise `false`
|
|
24
28
|
*/
|
package/dist/focusable.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/focusable.ts
|
|
2
2
|
/**
|
|
3
3
|
* Get a list of focusable elements within a parent element
|
|
4
|
+
*
|
|
4
5
|
* @param parent Parent element
|
|
5
6
|
* @returns Focusable elements
|
|
6
7
|
*/
|
|
@@ -15,6 +16,7 @@ function getItem(element, tabbable) {
|
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Get a list of tabbable elements within a parent element
|
|
19
|
+
*
|
|
18
20
|
* @param parent Parent element
|
|
19
21
|
* @returns Tabbable elements
|
|
20
22
|
*/
|
|
@@ -74,6 +76,7 @@ function isEditable(element) {
|
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
78
|
* Is the element focusable?
|
|
79
|
+
*
|
|
77
80
|
* @param element Element to check
|
|
78
81
|
* @returns `true` if focusable, otherwise `false`
|
|
79
82
|
*/
|
|
@@ -109,6 +112,7 @@ function isSummarised(item) {
|
|
|
109
112
|
}
|
|
110
113
|
/**
|
|
111
114
|
* Is the element tabbable?
|
|
115
|
+
*
|
|
112
116
|
* @param element Element to check
|
|
113
117
|
* @returns `true` if tabbable, otherwise `false`
|
|
114
118
|
*/
|
package/dist/html/index.d.mts
CHANGED
|
@@ -7,11 +7,13 @@ type HtmlOptions = {
|
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Create nodes from a template string
|
|
10
|
+
*
|
|
10
11
|
* @returns Created nodes
|
|
11
12
|
*/
|
|
12
13
|
declare function html(strings: TemplateStringsArray, ...values: unknown[]): Node[];
|
|
13
14
|
/**
|
|
14
15
|
* Create nodes from an HTML string or a template element
|
|
16
|
+
*
|
|
15
17
|
* @param value HTML string or id for a template element
|
|
16
18
|
* @param options Options for creating nodes
|
|
17
19
|
* @returns Created nodes
|
|
@@ -19,6 +21,7 @@ declare function html(strings: TemplateStringsArray, ...values: unknown[]): Node
|
|
|
19
21
|
declare function html(value: string, options?: HtmlOptions): Node[];
|
|
20
22
|
/**
|
|
21
23
|
* Create nodes from a template element
|
|
24
|
+
*
|
|
22
25
|
* @param template Template element
|
|
23
26
|
* @param options Options for creating nodes
|
|
24
27
|
* @returns Created nodes
|