@oscarpalmer/toretto 0.39.2 → 0.41.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.
Files changed (55) hide show
  1. package/{types/attribute/get.d.ts → dist/attribute/get.d.mts} +6 -3
  2. package/dist/attribute/{get.js → get.mjs} +2 -2
  3. package/{types/attribute/index.d.ts → dist/attribute/index.d.mts} +16 -12
  4. package/dist/attribute/{index.js → index.mjs} +3 -3
  5. package/{types/attribute/set.d.ts → dist/attribute/set.d.mts} +10 -7
  6. package/dist/attribute/{set.js → set.mjs} +2 -2
  7. package/{types/data.d.ts → dist/data.d.mts} +9 -5
  8. package/dist/{data.js → data.mjs} +4 -4
  9. package/dist/event/delegation.d.mts +11 -0
  10. package/dist/event/{delegation.js → delegation.mjs} +8 -8
  11. package/{types/event/index.d.ts → dist/event/index.d.mts} +12 -8
  12. package/dist/event/{index.js → index.mjs} +4 -4
  13. package/{types/find/index.d.ts → dist/find/index.d.mts} +11 -8
  14. package/dist/find/{index.js → index.mjs} +7 -7
  15. package/{types/find/relative.d.ts → dist/find/relative.d.mts} +8 -5
  16. package/{types/focusable.d.ts → dist/focusable.d.mts} +7 -4
  17. package/dist/{focusable.js → focusable.mjs} +20 -20
  18. package/dist/html/index.d.mts +42 -0
  19. package/dist/html/{index.js → index.mjs} +8 -8
  20. package/dist/html/sanitize.d.mts +5 -0
  21. package/dist/html/{sanitize.js → sanitize.mjs} +4 -4
  22. package/{types/index.d.ts → dist/index.d.mts} +157 -128
  23. package/dist/{toretto.full.js → index.mjs} +78 -173
  24. package/dist/internal/attribute.d.mts +15 -0
  25. package/dist/internal/{attribute.js → attribute.mjs} +14 -14
  26. package/dist/internal/element-value.d.mts +6 -0
  27. package/dist/internal/{element-value.js → element-value.mjs} +3 -3
  28. package/dist/internal/get-value.d.mts +7 -0
  29. package/dist/internal/{get-value.js → get-value.mjs} +1 -1
  30. package/{types/internal/is.d.ts → dist/internal/is.d.mts} +5 -2
  31. package/{types/is.d.ts → dist/is.d.mts} +8 -4
  32. package/dist/{is.js → is.mjs} +2 -2
  33. package/dist/models.d.mts +33 -0
  34. package/dist/models.mjs +1 -0
  35. package/dist/style.d.mts +58 -0
  36. package/dist/{style.js → style.mjs} +5 -5
  37. package/dist/touch.d.mts +21 -0
  38. package/dist/{touch.js → touch.mjs} +1 -1
  39. package/package.json +60 -63
  40. package/src/data.ts +1 -1
  41. package/src/find/index.ts +1 -1
  42. package/src/internal/attribute.ts +1 -1
  43. package/dist/index.js +0 -15
  44. package/dist/models.js +0 -0
  45. package/types/event/delegation.d.ts +0 -7
  46. package/types/html/index.d.ts +0 -40
  47. package/types/html/sanitize.d.ts +0 -2
  48. package/types/internal/attribute.d.ts +0 -11
  49. package/types/internal/element-value.d.ts +0 -3
  50. package/types/internal/get-value.d.ts +0 -4
  51. package/types/models.d.ts +0 -30
  52. package/types/style.d.ts +0 -54
  53. package/types/touch.d.ts +0 -19
  54. /package/dist/find/{relative.js → relative.mjs} +0 -0
  55. /package/dist/internal/{is.js → is.mjs} +0 -0
@@ -1,3 +1,4 @@
1
+ //#region src/attribute/get.d.ts
1
2
  /**
2
3
  * Get the value of a specific attribute from an element
3
4
  * @param element Element to get attribute from
@@ -5,14 +6,14 @@
5
6
  * @param parse Parse value? _(defaults to `true`)_
6
7
  * @returns Attribute value _(or `undefined`)_
7
8
  */
8
- export declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
9
+ declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
9
10
  /**
10
11
  * Get the value of a specific attribute from an element
11
12
  * @param element Element to get attribute from
12
13
  * @param name Attribute name
13
14
  * @returns Attribute value _(or `undefined`)_
14
15
  */
15
- export declare function getAttribute(element: Element, name: string): unknown;
16
+ declare function getAttribute(element: Element, name: string): unknown;
16
17
  /**
17
18
  * Get specific attributes from an element
18
19
  * @param element Element to get attributes from
@@ -20,4 +21,6 @@ export declare function getAttribute(element: Element, name: string): unknown;
20
21
  * @param parseData Parse data values? _(defaults to `true`)_
21
22
  * @returns Object of named attributes
22
23
  */
23
- export declare function getAttributes<Key extends string>(element: Element, names: Key[], parseData?: boolean): Record<Key, unknown>;
24
+ declare function getAttributes<Key extends string>(element: Element, names: Key[], parseData?: boolean): Record<Key, unknown>;
25
+ //#endregion
26
+ export { getAttribute, getAttributes };
@@ -1,5 +1,5 @@
1
- import { getAttributeValue } from "../internal/get-value.js";
2
- import { isHTMLOrSVGElement } from "../internal/is.js";
1
+ import { isHTMLOrSVGElement } from "../internal/is.mjs";
2
+ import { getAttributeValue } from "../internal/get-value.mjs";
3
3
  //#region src/attribute/get.ts
4
4
  function getAttribute(element, name, parseValues) {
5
5
  if (isHTMLOrSVGElement(element) && typeof name === "string") return getAttributeValue(element, name, parseValues !== false);
@@ -1,42 +1,47 @@
1
- import type { Attribute } from '../models';
1
+ import { getAttribute, getAttributes } from "./get.mjs";
2
+ import { Attribute } from "../models.mjs";
3
+ import { booleanAttributes } from "../internal/attribute.mjs";
4
+ import { setAttribute, setAttributes } from "./set.mjs";
5
+
6
+ //#region src/attribute/index.d.ts
2
7
  /**
3
8
  * Is the attribute considered bad and potentially harmful?
4
9
  * @param attribute Attribute to check
5
10
  * @returns `true` if attribute is considered bad
6
11
  */
7
- export declare function isBadAttribute(attribute: Attr | Attribute): boolean;
12
+ declare function isBadAttribute(attribute: Attr | Attribute): boolean;
8
13
  /**
9
14
  * Is the attribute considered bad and potentially harmful?
10
15
  * @param name Attribute name
11
16
  * @param value Attribute value
12
17
  * @returns `true` if attribute is considered bad
13
18
  */
14
- export declare function isBadAttribute(name: string, value: string): boolean;
19
+ declare function isBadAttribute(name: string, value: string): boolean;
15
20
  /**
16
21
  * Is the attribute a boolean attribute?
17
22
  * @param name Attribute to check
18
23
  * @returns `true` if attribute is a boolean attribute
19
24
  */
20
- export declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
25
+ declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
21
26
  /**
22
27
  * Is the attribute a boolean attribute?
23
28
  * @param name Attribute name
24
29
  * @returns `true` if attribute is a boolean attribute
25
30
  */
26
- export declare function isBooleanAttribute(name: string): boolean;
31
+ declare function isBooleanAttribute(name: string): boolean;
27
32
  /**
28
33
  * Is the attribute empty and not a boolean attribute?
29
34
  * @param attribute Attribute to check
30
35
  * @returns `true` if attribute is empty and not a boolean attribute
31
36
  */
32
- export declare function isEmptyNonBooleanAttribute(attribute: Attr | Attribute): boolean;
37
+ declare function isEmptyNonBooleanAttribute(attribute: Attr | Attribute): boolean;
33
38
  /**
34
39
  * Is the attribute empty and not a boolean attribute?
35
40
  * @param name Attribute name
36
41
  * @param value Attribute value
37
42
  * @returns `true` if attribute is empty and not a boolean attribute
38
43
  */
39
- export declare function isEmptyNonBooleanAttribute(name: string, value: string): boolean;
44
+ declare function isEmptyNonBooleanAttribute(name: string, value: string): boolean;
40
45
  /**
41
46
  * Is the attribute an invalid boolean attribute?
42
47
  *
@@ -44,7 +49,7 @@ export declare function isEmptyNonBooleanAttribute(name: string, value: string):
44
49
  * @param attribute Attribute to check
45
50
  * @returns `true` if attribute is an invalid boolean attribute
46
51
  */
47
- export declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean;
52
+ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean;
48
53
  /**
49
54
  * Is the attribute an invalid boolean attribute?
50
55
  *
@@ -53,7 +58,6 @@ export declare function isInvalidBooleanAttribute(attribute: Attr | Attribute):
53
58
  * @param value Attribute value
54
59
  * @returns `true` if attribute is an invalid boolean attribute
55
60
  */
56
- export declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
57
- export { booleanAttributes } from '../internal/attribute';
58
- export * from './get';
59
- export * from './set';
61
+ declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
62
+ //#endregion
63
+ export { booleanAttributes, getAttribute, getAttributes, isBadAttribute, isBooleanAttribute, isEmptyNonBooleanAttribute, isInvalidBooleanAttribute, setAttribute, setAttributes };
@@ -1,6 +1,6 @@
1
- import { getAttribute, getAttributes } from "./get.js";
2
- import { _isBadAttribute, _isBooleanAttribute, _isEmptyNonBooleanAttribute, _isInvalidBooleanAttribute, booleanAttributes } from "../internal/attribute.js";
3
- import { setAttribute, setAttributes } from "./set.js";
1
+ import { _isBadAttribute, _isBooleanAttribute, _isEmptyNonBooleanAttribute, _isInvalidBooleanAttribute, booleanAttributes } from "../internal/attribute.mjs";
2
+ import { getAttribute, getAttributes } from "./get.mjs";
3
+ import { setAttribute, setAttributes } from "./set.mjs";
4
4
  //#region src/attribute/index.ts
5
5
  function isBadAttribute(first, second) {
6
6
  return _isBadAttribute(first, second, true);
@@ -1,4 +1,6 @@
1
- import type { Attribute } from '../models';
1
+ import { Attribute } from "../models.mjs";
2
+
3
+ //#region src/attribute/set.d.ts
2
4
  type DispatchedAttribute = 'checked' | 'open' | 'value';
3
5
  /**
4
6
  * Set an attribute on an element
@@ -9,7 +11,7 @@ type DispatchedAttribute = 'checked' | 'open' | 'value';
9
11
  * @param value Attribute value
10
12
  * @param dispatch Dispatch event for attribute? _(defaults to `true`)_
11
13
  */
12
- export declare function setAttribute<Name extends DispatchedAttribute>(element: Element, name: Name, value?: unknown, dispatch?: boolean): void;
14
+ declare function setAttribute<Name extends DispatchedAttribute>(element: Element, name: Name, value?: unknown, dispatch?: boolean): void;
13
15
  /**
14
16
  * Set an attribute on an element
15
17
  *
@@ -18,7 +20,7 @@ export declare function setAttribute<Name extends DispatchedAttribute>(element:
18
20
  * @param name Attribute name
19
21
  * @param value Attribute value
20
22
  */
21
- export declare function setAttribute(element: Element, name: string, value?: unknown): void;
23
+ declare function setAttribute(element: Element, name: string, value?: unknown): void;
22
24
  /**
23
25
  * Set an attribute on an element
24
26
  *
@@ -27,7 +29,7 @@ export declare function setAttribute(element: Element, name: string, value?: unk
27
29
  * @param attribute Attribute to set
28
30
  * @param dispatch Dispatch event for attribute? _(defaults to `true`)_
29
31
  */
30
- export declare function setAttribute(element: Element, attribute: Attr | Attribute, dispatch?: boolean): void;
32
+ declare function setAttribute(element: Element, attribute: Attr | Attribute, dispatch?: boolean): void;
31
33
  /**
32
34
  * Set one or more attributes on an element
33
35
  *
@@ -36,7 +38,7 @@ export declare function setAttribute(element: Element, attribute: Attr | Attribu
36
38
  * @param attributes Attributes to set
37
39
  * @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
38
40
  */
39
- export declare function setAttributes(element: Element, attributes: Array<Attr | Attribute>, dispatch?: boolean): void;
41
+ declare function setAttributes(element: Element, attributes: Array<Attr | Attribute>, dispatch?: boolean): void;
40
42
  /**
41
43
  * Set one or more attributes on an element
42
44
  *
@@ -45,5 +47,6 @@ export declare function setAttributes(element: Element, attributes: Array<Attr |
45
47
  * @param attributes Attributes to set
46
48
  * @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
47
49
  */
48
- export declare function setAttributes(element: Element, attributes: Record<string, unknown>, dispatch?: boolean): void;
49
- export {};
50
+ declare function setAttributes(element: Element, attributes: Record<string, unknown>, dispatch?: boolean): void;
51
+ //#endregion
52
+ export { setAttribute, setAttributes };
@@ -1,5 +1,5 @@
1
- import { setElementValue, setElementValues } from "../internal/element-value.js";
2
- import { updateAttribute } from "../internal/attribute.js";
1
+ import { updateAttribute } from "../internal/attribute.mjs";
2
+ import { setElementValue, setElementValues } from "../internal/element-value.mjs";
3
3
  //#region src/attribute/set.ts
4
4
  function setAttribute(element, first, second, third) {
5
5
  setElementValue(element, first, second, third, updateAttribute);
@@ -1,4 +1,6 @@
1
- import type { PlainObject } from '@oscarpalmer/atoms';
1
+ import { PlainObject } from "@oscarpalmer/atoms/models";
2
+
3
+ //#region src/data.d.ts
2
4
  /**
3
5
  * Get a keyed data value from an element
4
6
  * @param element Element to get data from
@@ -6,7 +8,7 @@ import type { PlainObject } from '@oscarpalmer/atoms';
6
8
  * @param parse Parse values? _(defaults to `true`)_
7
9
  * @returns Data value
8
10
  */
9
- export declare function getData(element: Element, key: string, parse?: boolean): unknown;
11
+ declare function getData(element: Element, key: string, parse?: boolean): unknown;
10
12
  /**
11
13
  * Get keyed data values from an element
12
14
  * @param element Element to get data from
@@ -14,17 +16,19 @@ export declare function getData(element: Element, key: string, parse?: boolean):
14
16
  * @param parse Parse values? _(defaults to `true`)_
15
17
  * @returns Keyed data values
16
18
  */
17
- export declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
19
+ declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
18
20
  /**
19
21
  * Set data values on an element
20
22
  * @param element Element to set data on
21
23
  * @param data Data to set
22
24
  */
23
- export declare function setData(element: Element, data: PlainObject): void;
25
+ declare function setData(element: Element, data: PlainObject): void;
24
26
  /**
25
27
  * Set a data value on an element
26
28
  * @param element Element to set data on
27
29
  * @param key Data key
28
30
  * @param value Data value
29
31
  */
30
- export declare function setData(element: Element, key: string, value: unknown): void;
32
+ declare function setData(element: Element, key: string, value: unknown): void;
33
+ //#endregion
34
+ export { getData, setData };
@@ -1,6 +1,6 @@
1
- import { EXPRESSION_DATA_PREFIX } from "./internal/get-value.js";
2
- import { isHTMLOrSVGElement } from "./internal/is.js";
3
- import { setElementValues, updateElementValue } from "./internal/element-value.js";
1
+ import { isHTMLOrSVGElement } from "./internal/is.mjs";
2
+ import { setElementValues, updateElementValue } from "./internal/element-value.mjs";
3
+ import { EXPRESSION_DATA_PREFIX } from "./internal/get-value.mjs";
4
4
  import { parse } from "@oscarpalmer/atoms/string";
5
5
  import { kebabCase } from "@oscarpalmer/atoms/string/case";
6
6
  //#region src/data.ts
@@ -31,6 +31,6 @@ function setData(element, first, second) {
31
31
  function updateDataAttribute(element, key, value) {
32
32
  updateElementValue(element, getName(key), value, element.setAttribute, element.removeAttribute, false, true);
33
33
  }
34
- var ATTRIBUTE_DATA_PREFIX = "data-";
34
+ const ATTRIBUTE_DATA_PREFIX = "data-";
35
35
  //#endregion
36
36
  export { getData, setData };
@@ -0,0 +1,11 @@
1
+ import { CustomEventListener, RemovableEventListener } from "../models.mjs";
2
+
3
+ //#region src/event/delegation.d.ts
4
+ type EventTargetWithListeners = EventTarget & Partial<{
5
+ [key: string]: Set<EventListener | CustomEventListener>;
6
+ }>;
7
+ declare function addDelegatedListener(target: EventTargetWithListeners, type: string, name: string, listener: EventListener | CustomEventListener, passive: boolean): RemovableEventListener;
8
+ declare function getDelegatedName(target: EventTarget, type: string, options: AddEventListenerOptions): string | undefined;
9
+ declare function removeDelegatedListener(target: EventTargetWithListeners, name: string, listener: EventListener | CustomEventListener): boolean;
10
+ //#endregion
11
+ export { EventTargetWithListeners, addDelegatedListener, getDelegatedName, removeDelegatedListener };
@@ -1,4 +1,4 @@
1
- import { isEventTarget } from "../internal/is.js";
1
+ import { isEventTarget } from "../internal/is.mjs";
2
2
  //#region src/event/delegation.ts
3
3
  function addDelegatedHandler(doc, type, name, passive) {
4
4
  if (DELEGATED.has(name)) return;
@@ -51,11 +51,11 @@ function removeDelegatedListener(target, name, listener) {
51
51
  if (handlers.size === 0) target[name] = void 0;
52
52
  return true;
53
53
  }
54
- var DELEGATED = /* @__PURE__ */ new Set();
55
- var EVENT_PREFIX = "@";
56
- var EVENT_SUFFIX_ACTIVE = ":active";
57
- var EVENT_SUFFIX_PASSIVE = ":passive";
58
- var EVENT_TYPES = new Set([
54
+ const DELEGATED = /* @__PURE__ */ new Set();
55
+ const EVENT_PREFIX = "@";
56
+ const EVENT_SUFFIX_ACTIVE = ":active";
57
+ const EVENT_SUFFIX_PASSIVE = ":passive";
58
+ const EVENT_TYPES = new Set([
59
59
  "beforeinput",
60
60
  "click",
61
61
  "dblclick",
@@ -79,7 +79,7 @@ var EVENT_TYPES = new Set([
79
79
  "touchmove",
80
80
  "touchstart"
81
81
  ]);
82
- var HANDLER_ACTIVE = delegatedEventHandler.bind(false);
83
- var HANDLER_PASSIVE = delegatedEventHandler.bind(true);
82
+ const HANDLER_ACTIVE = delegatedEventHandler.bind(false);
83
+ const HANDLER_PASSIVE = delegatedEventHandler.bind(true);
84
84
  //#endregion
85
85
  export { addDelegatedListener, getDelegatedName, removeDelegatedListener };
@@ -1,24 +1,26 @@
1
- import type { CustomEventListener, EventPosition, RemovableEventListener } from '../models';
1
+ import { CustomEventListener, EventPosition, RemovableEventListener } from "../models.mjs";
2
+
3
+ //#region src/event/index.d.ts
2
4
  /**
3
5
  * Dispatch an event for a target
4
6
  * @param target Event target
5
7
  * @param type Type of event
6
8
  * @param options Options for event _(bubbles and is cancelable by default)_
7
9
  */
8
- export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
10
+ declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
9
11
  /**
10
12
  * Dispatch an event for a target
11
13
  * @param target Event target
12
14
  * @param type Type of event
13
15
  * @param options Options for event _(bubbles and is cancelable by default)_
14
16
  */
15
- export declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
17
+ declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
16
18
  /**
17
19
  * Get the X- and Y-coordinates from a pointer event
18
20
  * @param event Pointer event
19
21
  * @returns X- and Y-coordinates
20
22
  */
21
- export declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
23
+ declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
22
24
  /**
23
25
  * Remove an event listener
24
26
  * @param target Event target
@@ -26,7 +28,7 @@ export declare function getPosition(event: MouseEvent | TouchEvent): EventPositi
26
28
  * @param listener Event listener
27
29
  * @param options Options for event
28
30
  */
29
- export declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
31
+ declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
30
32
  /**
31
33
  * Remove an event listener
32
34
  * @param target Event target
@@ -34,7 +36,7 @@ export declare function off(target: EventTarget, type: keyof HTMLElementEventMap
34
36
  * @param listener Event listener
35
37
  * @param options Options for event
36
38
  */
37
- export declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
39
+ declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
38
40
  /**
39
41
  * Add an event listener
40
42
  * @param target Event target
@@ -42,7 +44,7 @@ export declare function off(target: EventTarget, type: string, listener: EventLi
42
44
  * @param listener Event listener
43
45
  * @param options Options for event _(passive by default)_
44
46
  */
45
- export declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
47
+ declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
46
48
  /**
47
49
  * Add an event listener
48
50
  * @param target Event target
@@ -50,4 +52,6 @@ export declare function on<Type extends keyof HTMLElementEventMap>(target: Event
50
52
  * @param listener Event listener
51
53
  * @param options Options for event _(passive by default)_
52
54
  */
53
- export declare function on(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: AddEventListenerOptions): RemovableEventListener;
55
+ declare function on(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: AddEventListenerOptions): RemovableEventListener;
56
+ //#endregion
57
+ export { dispatch, getPosition, off, on };
@@ -1,6 +1,6 @@
1
- import { getBoolean } from "../internal/get-value.js";
2
- import { isEventTarget } from "../internal/is.js";
3
- import { addDelegatedListener, getDelegatedName, removeDelegatedListener } from "./delegation.js";
1
+ import { isEventTarget } from "../internal/is.mjs";
2
+ import { getBoolean } from "../internal/get-value.mjs";
3
+ import { addDelegatedListener, getDelegatedName, removeDelegatedListener } from "./delegation.mjs";
4
4
  import { isPlainObject } from "@oscarpalmer/atoms/is";
5
5
  import { noop } from "@oscarpalmer/atoms/function";
6
6
  //#region src/event/index.ts
@@ -74,6 +74,6 @@ function on(target, type, listener, options) {
74
74
  target.removeEventListener(type, listener, extended);
75
75
  };
76
76
  }
77
- var PROPERTY_DETAIL = "detail";
77
+ const PROPERTY_DETAIL = "detail";
78
78
  //#endregion
79
79
  export { dispatch, getPosition, off, on };
@@ -1,32 +1,35 @@
1
- import type { Selector } from '../models';
1
+ import { Selector } from "../models.mjs";
2
+ import { findAncestor, findRelatives, getDistance } from "./relative.mjs";
3
+
4
+ //#region src/find/index.d.ts
2
5
  /**
3
6
  * Find the first element that matches the tag name
4
7
  * @param tagName Tag name of element to find
5
8
  * @param context Context to search within _(defaults to `document`)_
6
9
  * @returns Found element or `null`
7
10
  */
8
- export declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
11
+ declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
9
12
  /**
10
13
  * Find the first element that matches the selector
11
14
  * @param selector Selector to find element for
12
15
  * @param context Context to search within _(defaults to `document`)_
13
16
  * @returns Found element or `null`
14
17
  */
15
- export declare function findElement(selector: string, context?: Selector | null): Element | null;
18
+ declare function findElement(selector: string, context?: Selector | null): Element | null;
16
19
  /**
17
20
  * Find elements that match the selector
18
21
  * @param tagName tagName to find elements for
19
22
  * @param context Context to search within _(defaults to `document`)_
20
23
  * @returns Found elements
21
24
  */
22
- export declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
25
+ declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
23
26
  /**
24
27
  * Find elements that match the selector
25
28
  * @param selector Selector to find elements for
26
29
  * @param context Context to search within _(defaults to `document`)_
27
30
  * @returns Found elements
28
31
  */
29
- export declare function findElements(selector: Selector, context?: Selector | null): Element[];
32
+ declare function findElements(selector: Selector, context?: Selector | null): Element[];
30
33
  /**
31
34
  * Get the most specific element under the pointer
32
35
  *
@@ -35,6 +38,6 @@ export declare function findElements(selector: Selector, context?: Selector | nu
35
38
  * @param skipIgnore Skip ignored elements?
36
39
  * @returns Found element or `null`
37
40
  */
38
- export declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
39
- export { findElement as $, findElements as $$ };
40
- export { findAncestor, findRelatives, getDistance } from './relative';
41
+ declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
42
+ //#endregion
43
+ export { findElement as $, findElement, findElements as $$, findElements, findAncestor, findRelatives, getDistance, getElementUnderPointer };
@@ -1,4 +1,4 @@
1
- import { findAncestor, findRelatives, getDistance } from "./relative.js";
1
+ import { findAncestor, findRelatives, getDistance } from "./relative.mjs";
2
2
  //#region src/find/index.ts
3
3
  function findElement(selector, context) {
4
4
  return findElementOrElements(selector, context, true);
@@ -64,11 +64,11 @@ function getElementUnderPointer(skipIgnore) {
64
64
  function isContext(value) {
65
65
  return typeof value?.querySelector === "function" && typeof value?.querySelectorAll === "function";
66
66
  }
67
- var QUERY_SELECTOR_ALL = "querySelectorAll";
68
- var QUERY_SELECTOR_SINGLE = "querySelector";
69
- var STYLE_HIDDEN = "hidden";
70
- var STYLE_NONE = "none";
71
- var SUFFIX_HOVER = ":hover";
72
- var TAG_HEAD = "HEAD";
67
+ const QUERY_SELECTOR_ALL = "querySelectorAll";
68
+ const QUERY_SELECTOR_SINGLE = "querySelector";
69
+ const STYLE_HIDDEN = "hidden";
70
+ const STYLE_NONE = "none";
71
+ const SUFFIX_HOVER = ":hover";
72
+ const TAG_HEAD = "HEAD";
73
73
  //#endregion
74
74
  export { findElement as $, findElement, findElements as $$, findElements, findAncestor, findRelatives, getDistance, getElementUnderPointer };
@@ -1,3 +1,4 @@
1
+ //#region src/find/relative.d.ts
1
2
  /**
2
3
  * Find the closest ancestor element that matches the tag name
3
4
  *
@@ -7,7 +8,7 @@
7
8
  * @param tagName Tag name to match
8
9
  * @returns Found ancestor or `null`
9
10
  */
10
- export declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origin: Element | Event | EventTarget, tagName: TagName): HTMLElementTagNameMap[TagName] | null;
11
+ declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origin: Element | Event | EventTarget, tagName: TagName): HTMLElementTagNameMap[TagName] | null;
11
12
  /**
12
13
  * Find the closest ancestor element that matches the selector _(string or callback)_
13
14
  *
@@ -17,7 +18,7 @@ export declare function findAncestor<TagName extends keyof HTMLElementTagNameMap
17
18
  * @param selector Selector to match
18
19
  * @returns Found ancestor or `null`
19
20
  */
20
- export declare function findAncestor(origin: Element | Event | EventTarget, selector: string | ((element: Element) => boolean)): Element | null;
21
+ declare function findAncestor(origin: Element | Event | EventTarget, selector: string | ((element: Element) => boolean)): Element | null;
21
22
  /**
22
23
  * Finds the closest elements to the origin element that matches the tag name
23
24
  *
@@ -27,7 +28,7 @@ export declare function findAncestor(origin: Element | Event | EventTarget, sele
27
28
  * @param context Context to search within
28
29
  * @returns Found elements
29
30
  */
30
- export declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(origin: Element, tagName: TagName, context?: Document | Element): HTMLElementTagNameMap[TagName][];
31
+ declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(origin: Element, tagName: TagName, context?: Document | Element): HTMLElementTagNameMap[TagName][];
31
32
  /**
32
33
  * Finds the closest elements to the origin element that matches the selector
33
34
  *
@@ -37,11 +38,13 @@ export declare function findRelatives<TagName extends keyof HTMLElementTagNameMa
37
38
  * @param context Context to search within
38
39
  * @returns Found elements
39
40
  */
40
- export declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
41
+ declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
41
42
  /**
42
43
  * Get the distance between two elements _(i.e., the amount of nodes of between them)_
43
44
  * @param origin Origin element
44
45
  * @param target Target element
45
46
  * @returns Distance between elements, or `-1` if distance cannot be calculated
46
47
  */
47
- export declare function getDistance(origin: Element, target: Element): number;
48
+ declare function getDistance(origin: Element, target: Element): number;
49
+ //#endregion
50
+ export { findAncestor, findRelatives, getDistance };
@@ -1,24 +1,27 @@
1
+ //#region src/focusable.d.ts
1
2
  /**
2
3
  * Get a list of focusable elements within a parent element
3
4
  * @param parent Parent element
4
5
  * @returns Focusable elements
5
6
  */
6
- export declare function getFocusable(parent: Element): Element[];
7
+ declare function getFocusable(parent: Element): Element[];
7
8
  /**
8
9
  * Get a list of tabbable elements within a parent element
9
10
  * @param parent Parent element
10
11
  * @returns Tabbable elements
11
12
  */
12
- export declare function getTabbable(parent: Element): Element[];
13
+ declare function getTabbable(parent: Element): Element[];
13
14
  /**
14
15
  * Is the element focusable?
15
16
  * @param element Element to check
16
17
  * @returns `true` if focusable, otherwise `false`
17
18
  */
18
- export declare function isFocusable(element: Element): boolean;
19
+ declare function isFocusable(element: Element): boolean;
19
20
  /**
20
21
  * Is the element tabbable?
21
22
  * @param element Element to check
22
23
  * @returns `true` if tabbable, otherwise `false`
23
24
  */
24
- export declare function isTabbable(element: Element): boolean;
25
+ declare function isTabbable(element: Element): boolean;
26
+ //#endregion
27
+ export { getFocusable, getTabbable, isFocusable, isTabbable };
@@ -119,30 +119,30 @@ function isValidElement(element, filters, tabbable) {
119
119
  const item = getItem(element, tabbable);
120
120
  return !filters.some((filter) => filter(item));
121
121
  }
122
- var ATTRIBUTE_CONTENTEDITABLE = "contenteditable";
123
- var ATTRIBUTE_INERT = "inert";
124
- var ATTRIBUTE_TABINDEX = "tabindex";
125
- var EXPRESSION_DISABLEABLE = /^(button|input|select|textarea)$/i;
126
- var EXPRESSION_SPECIAL_TABINDEX = /^(audio|details|video)$/i;
127
- var EXPRESSION_SUMMARY = /^summary$/i;
128
- var EXPRESSION_TRUEISH = /^(|true)$/i;
129
- var FILTERS_FOCUSABLE = [
122
+ const ATTRIBUTE_CONTENTEDITABLE = "contenteditable";
123
+ const ATTRIBUTE_INERT = "inert";
124
+ const ATTRIBUTE_TABINDEX = "tabindex";
125
+ const EXPRESSION_DISABLEABLE = /^(button|input|select|textarea)$/i;
126
+ const EXPRESSION_SPECIAL_TABINDEX = /^(audio|details|video)$/i;
127
+ const EXPRESSION_SUMMARY = /^summary$/i;
128
+ const EXPRESSION_TRUEISH = /^(|true)$/i;
129
+ const FILTERS_FOCUSABLE = [
130
130
  isDisabled,
131
131
  isInert,
132
132
  isHidden,
133
133
  isSummarised
134
134
  ];
135
- var FILTERS_TABBABLE = [
135
+ const FILTERS_TABBABLE = [
136
136
  isNotTabbable,
137
137
  isNotTabbableRadio,
138
138
  ...FILTERS_FOCUSABLE
139
139
  ];
140
- var SELECTOR_DETAILS_CLOSED_CHILDREN = "details:not([open]) *";
141
- var SELECTOR_FIELDSET_DISABLED = "fieldset[disabled] *";
142
- var SELECTOR_SUMMARY_FIRST = "details > summary:first-of-type";
143
- var SELECTOR_RADIO_PREFIX = "input[type=\"radio\"][name=\"";
144
- var SELECTOR_RADIO_SUFFIX = "\"]";
145
- var SELECTOR_FULL = [
140
+ const SELECTOR_DETAILS_CLOSED_CHILDREN = "details:not([open]) *";
141
+ const SELECTOR_FIELDSET_DISABLED = "fieldset[disabled] *";
142
+ const SELECTOR_SUMMARY_FIRST = "details > summary:first-of-type";
143
+ const SELECTOR_RADIO_PREFIX = "input[type=\"radio\"][name=\"";
144
+ const SELECTOR_RADIO_SUFFIX = "\"]";
145
+ const SELECTOR_FULL = [
146
146
  "[contenteditable]:not([contenteditable=\"false\"])",
147
147
  "[tabindex]:not(slot)",
148
148
  "a[href]",
@@ -155,10 +155,10 @@ var SELECTOR_FULL = [
155
155
  "textarea",
156
156
  "video[controls]"
157
157
  ].map((selector) => `${selector}:not([inert])`).join(",");
158
- var STYLE_HIDDEN = "hidden";
159
- var STYLE_NONE = "none";
160
- var TABINDEX_BASE = 0;
161
- var TABINDEX_DEFAULT = -1;
162
- var TYPE_RADIO = "radio";
158
+ const STYLE_HIDDEN = "hidden";
159
+ const STYLE_NONE = "none";
160
+ const TABINDEX_BASE = 0;
161
+ const TABINDEX_DEFAULT = -1;
162
+ const TYPE_RADIO = "radio";
163
163
  //#endregion
164
164
  export { getFocusable, getTabbable, isFocusable, isTabbable };
@@ -0,0 +1,42 @@
1
+ //#region src/html/index.d.ts
2
+ type Html = {
3
+ /**
4
+ * Create nodes from an HTML string or a template element
5
+ * @param value HTML string or id for a template element
6
+ * @param options Options for creating nodes
7
+ * @returns Created nodes
8
+ */
9
+ (value: string, options?: HtmlOptions): Node[];
10
+ /**
11
+ * Create nodes from a template element
12
+ * @param template Template element
13
+ * @param options Options for creating nodes
14
+ * @returns Created nodes
15
+ */
16
+ (template: HTMLTemplateElement, options?: HtmlOptions): Node[];
17
+ /**
18
+ * Clear cache of template elements
19
+ */
20
+ clear(): void;
21
+ /**
22
+ * Remove cached template element for an HTML string or id
23
+ * @param template HTML string or id for a template element
24
+ */
25
+ remove(template: string): void;
26
+ };
27
+ type HtmlOptions = {
28
+ /**
29
+ * Cache template element for the HTML string? _(defaults to `true`)_
30
+ */
31
+ cache?: boolean;
32
+ };
33
+ declare const html: Html;
34
+ /**
35
+ * Sanitize one or more nodes, recursively
36
+ * @param value Node or nodes to sanitize
37
+ * @param options Sanitization options
38
+ * @returns Sanitized nodes
39
+ */
40
+ declare function sanitize(value: Node | Node[]): Node[];
41
+ //#endregion
42
+ export { html, sanitize };