@oscarpalmer/toretto 0.39.0 → 0.39.2

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/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { isEventTarget, isHTMLOrSVGElement } from "./internal/is.js";
2
+ import { getAttribute, getAttributes } from "./attribute/get.js";
2
3
  import { isChildNode, isInDocument } from "./is.js";
4
+ import { booleanAttributes } from "./internal/attribute.js";
5
+ import { setAttribute, setAttributes } from "./attribute/set.js";
3
6
  import { isBadAttribute, isBooleanAttribute, isEmptyNonBooleanAttribute, isInvalidBooleanAttribute } from "./attribute/index.js";
4
7
  import { getData, setData } from "./data.js";
5
8
  import { dispatch, getPosition, off, on } from "./event/index.js";
@@ -9,4 +12,4 @@ import { getFocusable, getTabbable, isFocusable, isTabbable } from "./focusable.
9
12
  import { html, sanitize } from "./html/index.js";
10
13
  import supportsTouch from "./touch.js";
11
14
  import { getStyle, getStyles, getTextDirection, setStyle, setStyles, toggleStyles } from "./style.js";
12
- export { findElement as $, findElement, findElements as $$, findElements, dispatch, findAncestor, findRelatives, getData, getDistance, getElementUnderPointer, getFocusable, getPosition, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEmptyNonBooleanAttribute, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setData, setStyle, setStyles, supportsTouch, toggleStyles };
15
+ export { findElement as $, findElement, findElements as $$, findElements, booleanAttributes, dispatch, findAncestor, findRelatives, getAttribute, getAttributes, getData, getDistance, getElementUnderPointer, getFocusable, getPosition, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEmptyNonBooleanAttribute, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAttribute, setAttributes, setData, setStyle, setStyles, supportsTouch, toggleStyles };
@@ -529,14 +529,44 @@ var memoizedCapitalize;
529
529
  function getBoolean(value, defaultValue) {
530
530
  return typeof value === "boolean" ? value : defaultValue ?? false;
531
531
  }
532
+ function getAttributeValue(element, name, parseValue) {
533
+ const normalized = kebabCase(name);
534
+ const attribute = element.attributes[normalized];
535
+ const value = attribute instanceof Attr ? attribute.value : void 0;
536
+ return EXPRESSION_DATA_PREFIX.test(normalized) && typeof value === "string" && parseValue ? parse(value) ?? value : value;
537
+ }
532
538
  function getStyleValue(element, property, computed) {
533
539
  const name = camelCase(property);
534
540
  return computed ? getComputedStyle(element)[name] : element.style[name];
535
541
  }
536
542
  const EXPRESSION_DATA_PREFIX = /^data-/i;
543
+ function getAttribute(element, name, parseValues) {
544
+ if (isHTMLOrSVGElement(element) && typeof name === "string") return getAttributeValue(element, name, parseValues !== false);
545
+ }
546
+ /**
547
+ * Get specific attributes from an element
548
+ * @param element Element to get attributes from
549
+ * @param names Attribute names
550
+ * @param parseData Parse data values? _(defaults to `true`)_
551
+ * @returns Object of named attributes
552
+ */
553
+ function getAttributes(element, names, parseData) {
554
+ const attributes = {};
555
+ if (!(isHTMLOrSVGElement(element) && Array.isArray(names))) return attributes;
556
+ const shouldParse = parseData !== false;
557
+ const { length } = names;
558
+ for (let index = 0; index < length; index += 1) {
559
+ const name = names[index];
560
+ if (typeof name === "string") attributes[name] = getAttributeValue(element, name, shouldParse);
561
+ }
562
+ return attributes;
563
+ }
537
564
  function setAttribute(element, first, second, third) {
538
565
  setElementValue(element, first, second, third, updateAttribute);
539
566
  }
567
+ function setAttributes(element, attributes, dispatch) {
568
+ setElementValues(element, attributes, null, dispatch, updateAttribute);
569
+ }
540
570
  function isBadAttribute(first, second) {
541
571
  return _isBadAttribute(first, second, true);
542
572
  }
@@ -1418,4 +1448,4 @@ function updateStyleProperty(element, key, value) {
1418
1448
  }
1419
1449
  const ATTRIBUTE_DIRECTION = "dir";
1420
1450
  const EXPRESSION_DIRECTION = /^(ltr|rtl)$/i;
1421
- export { findElement as $, findElement, findElements as $$, findElements, dispatch, findAncestor, findRelatives, getData, getDistance, getElementUnderPointer, getFocusable, getPosition, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEmptyNonBooleanAttribute, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setData, setStyle, setStyles, supportsTouch, toggleStyles };
1451
+ export { findElement as $, findElement, findElements as $$, findElements, booleanAttributes, dispatch, findAncestor, findRelatives, getAttribute, getAttributes, getData, getDistance, getElementUnderPointer, getFocusable, getPosition, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEmptyNonBooleanAttribute, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAttribute, setAttributes, setData, setStyle, setStyles, supportsTouch, toggleStyles };
package/package.json CHANGED
@@ -10,6 +10,7 @@
10
10
  "devDependencies": {
11
11
  "@types/node": "^25.4",
12
12
  "@vitest/coverage-istanbul": "^4",
13
+ "dts-bundle-generator": "^9.5",
13
14
  "jsdom": "^28.1",
14
15
  "oxfmt": "^0.39",
15
16
  "oxlint": "^1.54",
@@ -23,7 +24,7 @@
23
24
  "./package.json": "./package.json",
24
25
  ".": {
25
26
  "types": "./types/index.d.ts",
26
- "default": "./dist/index.js"
27
+ "default": "./dist/toretto.full.js"
27
28
  },
28
29
  "./attribute": {
29
30
  "types": "./types/attribute/index.d.ts",
@@ -84,7 +85,7 @@
84
85
  "url": "git+https://github.com/oscarpalmer/toretto.git"
85
86
  },
86
87
  "scripts": {
87
- "build": "npm run clean && npx vite build && npm run rolldown:build && npx tsc",
88
+ "build": "npm run clean && npx vite build && npm run rolldown:build && npx tsc && npx dts-bundle-generator --config ./dts.config.ts --silent",
88
89
  "clean": "rm -rf ./dist && rm -rf ./types && rm -f ./tsconfig.tsbuildinfo",
89
90
  "rolldown:build": "npx rolldown -c",
90
91
  "rolldown:watch": "npx rolldown -c ./rolldown.config.js --watch",
@@ -93,5 +94,5 @@
93
94
  },
94
95
  "type": "module",
95
96
  "types": "types/index.d.ts",
96
- "version": "0.39.0"
97
+ "version": "0.39.2"
97
98
  }
package/src/index.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  import supportsTouch from './touch';
2
2
 
3
3
  export {
4
+ booleanAttributes,
5
+ getAttribute,
6
+ getAttributes,
4
7
  isBadAttribute,
5
8
  isBooleanAttribute,
6
9
  isEmptyNonBooleanAttribute,
7
10
  isInvalidBooleanAttribute,
11
+ setAttribute,
12
+ setAttributes,
8
13
  } from './attribute/index';
9
14
  export * from './data';
10
15
  export * from './event/index';
package/types/index.d.ts CHANGED
@@ -1,11 +1,502 @@
1
- import supportsTouch from './touch';
2
- export { isBadAttribute, isBooleanAttribute, isEmptyNonBooleanAttribute, isInvalidBooleanAttribute, } from './attribute/index';
3
- export * from './data';
4
- export * from './event/index';
5
- export * from './find/index';
6
- export * from './focusable';
7
- export * from './html/index';
8
- export * from './is';
9
- export * from './models';
10
- export * from './style';
11
- export { supportsTouch };
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type SupporsTouch = {
4
+ /**
5
+ * Are touch events supported?
6
+ */
7
+ readonly value: boolean;
8
+ /**
9
+ * Are touch events supported?
10
+ */
11
+ get(): boolean;
12
+ /**
13
+ * Re-evaluate if touch events are supported
14
+ */
15
+ update(): boolean;
16
+ };
17
+ /**
18
+ * Does the device support touch events?
19
+ */
20
+ export declare const supportsTouch: SupporsTouch;
21
+ /**
22
+ * Attribute for an element
23
+ */
24
+ export type Attribute = {
25
+ name: string;
26
+ value: unknown;
27
+ };
28
+ /**
29
+ * Event listener for custom events
30
+ */
31
+ export type CustomEventListener = (event: CustomEvent) => void;
32
+ /**
33
+ * The position of an event
34
+ */
35
+ export type EventPosition = {
36
+ x: number;
37
+ y: number;
38
+ };
39
+ /**
40
+ * Event listener that can be removed
41
+ */
42
+ export type RemovableEventListener = () => void;
43
+ /**
44
+ * Selector that be searched for
45
+ */
46
+ export type Selector = string | Node | Node[] | NodeList;
47
+ /**
48
+ * Text direction for an element
49
+ */
50
+ export type TextDirection = "ltr" | "rtl";
51
+ /**
52
+ * List of boolean attributes
53
+ */
54
+ export declare const booleanAttributes: readonly string[];
55
+ /**
56
+ * Get the value of a specific attribute from an element
57
+ * @param element Element to get attribute from
58
+ * @param name Attribute name
59
+ * @param parse Parse value? _(defaults to `true`)_
60
+ * @returns Attribute value _(or `undefined`)_
61
+ */
62
+ export declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
63
+ /**
64
+ * Get the value of a specific attribute from an element
65
+ * @param element Element to get attribute from
66
+ * @param name Attribute name
67
+ * @returns Attribute value _(or `undefined`)_
68
+ */
69
+ export declare function getAttribute(element: Element, name: string): unknown;
70
+ /**
71
+ * Get specific attributes from an element
72
+ * @param element Element to get attributes from
73
+ * @param names Attribute names
74
+ * @param parseData Parse data values? _(defaults to `true`)_
75
+ * @returns Object of named attributes
76
+ */
77
+ export declare function getAttributes<Key extends string>(element: Element, names: Key[], parseData?: boolean): Record<Key, unknown>;
78
+ export type DispatchedAttribute = "checked" | "open" | "value";
79
+ /**
80
+ * Set an attribute on an element
81
+ *
82
+ * _(Or remove it, if value is `null` or `undefined`)_
83
+ * @param element Element for attribute
84
+ * @param name Attribute name
85
+ * @param value Attribute value
86
+ * @param dispatch Dispatch event for attribute? _(defaults to `true`)_
87
+ */
88
+ export declare function setAttribute<Name extends DispatchedAttribute>(element: Element, name: Name, value?: unknown, dispatch?: boolean): void;
89
+ /**
90
+ * Set an attribute on an element
91
+ *
92
+ * _(Or remove it, if value is `null` or `undefined`)_
93
+ * @param element Element for attribute
94
+ * @param name Attribute name
95
+ * @param value Attribute value
96
+ */
97
+ export declare function setAttribute(element: Element, name: string, value?: unknown): void;
98
+ /**
99
+ * Set an attribute on an element
100
+ *
101
+ * _(Or remove it, if value is `null` or `undefined`)_
102
+ * @param element Element for attribute
103
+ * @param attribute Attribute to set
104
+ * @param dispatch Dispatch event for attribute? _(defaults to `true`)_
105
+ */
106
+ export declare function setAttribute(element: Element, attribute: Attr | Attribute, dispatch?: boolean): void;
107
+ /**
108
+ * Set one or more attributes on an element
109
+ *
110
+ * _(Or remove them, if their value is `null` or `undefined`)_
111
+ * @param element Element for attributes
112
+ * @param attributes Attributes to set
113
+ * @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
114
+ */
115
+ export declare function setAttributes(element: Element, attributes: Array<Attr | Attribute>, dispatch?: boolean): void;
116
+ /**
117
+ * Set one or more attributes on an element
118
+ *
119
+ * _(Or remove them, if their value is `null` or `undefined`)_
120
+ * @param element Element for attributes
121
+ * @param attributes Attributes to set
122
+ * @param dispatch Dispatch events for relevant attributes? _(defaults to `true`)_
123
+ */
124
+ export declare function setAttributes(element: Element, attributes: Record<string, unknown>, dispatch?: boolean): void;
125
+ /**
126
+ * Is the attribute considered bad and potentially harmful?
127
+ * @param attribute Attribute to check
128
+ * @returns `true` if attribute is considered bad
129
+ */
130
+ export declare function isBadAttribute(attribute: Attr | Attribute): boolean;
131
+ /**
132
+ * Is the attribute considered bad and potentially harmful?
133
+ * @param name Attribute name
134
+ * @param value Attribute value
135
+ * @returns `true` if attribute is considered bad
136
+ */
137
+ export declare function isBadAttribute(name: string, value: string): boolean;
138
+ /**
139
+ * Is the attribute a boolean attribute?
140
+ * @param name Attribute to check
141
+ * @returns `true` if attribute is a boolean attribute
142
+ */
143
+ export declare function isBooleanAttribute(attribute: Attr | Attribute): boolean;
144
+ /**
145
+ * Is the attribute a boolean attribute?
146
+ * @param name Attribute name
147
+ * @returns `true` if attribute is a boolean attribute
148
+ */
149
+ export declare function isBooleanAttribute(name: string): boolean;
150
+ /**
151
+ * Is the attribute empty and not a boolean attribute?
152
+ * @param attribute Attribute to check
153
+ * @returns `true` if attribute is empty and not a boolean attribute
154
+ */
155
+ export declare function isEmptyNonBooleanAttribute(attribute: Attr | Attribute): boolean;
156
+ /**
157
+ * Is the attribute empty and not a boolean attribute?
158
+ * @param name Attribute name
159
+ * @param value Attribute value
160
+ * @returns `true` if attribute is empty and not a boolean attribute
161
+ */
162
+ export declare function isEmptyNonBooleanAttribute(name: string, value: string): boolean;
163
+ /**
164
+ * Is the attribute an invalid boolean attribute?
165
+ *
166
+ * _(I.e., its value is not empty or the same as its name)_
167
+ * @param attribute Attribute to check
168
+ * @returns `true` if attribute is an invalid boolean attribute
169
+ */
170
+ export declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean;
171
+ /**
172
+ * Is the attribute an invalid boolean attribute?
173
+ *
174
+ * _(I.e., its value is not empty or the same as its name)_
175
+ * @param name Attribute name
176
+ * @param value Attribute value
177
+ * @returns `true` if attribute is an invalid boolean attribute
178
+ */
179
+ export declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
180
+ /**
181
+ * A generic object
182
+ */
183
+ export type PlainObject = Record<PropertyKey, unknown>;
184
+ /**
185
+ * Get a keyed data value from an element
186
+ * @param element Element to get data from
187
+ * @param key Data key
188
+ * @param parse Parse values? _(defaults to `true`)_
189
+ * @returns Data value
190
+ */
191
+ export declare function getData(element: Element, key: string, parse?: boolean): unknown;
192
+ /**
193
+ * Get keyed data values from an element
194
+ * @param element Element to get data from
195
+ * @param keys Keys of the data values to get
196
+ * @param parse Parse values? _(defaults to `true`)_
197
+ * @returns Keyed data values
198
+ */
199
+ export declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
200
+ /**
201
+ * Set data values on an element
202
+ * @param element Element to set data on
203
+ * @param data Data to set
204
+ */
205
+ export declare function setData(element: Element, data: PlainObject): void;
206
+ /**
207
+ * Set a data value on an element
208
+ * @param element Element to set data on
209
+ * @param key Data key
210
+ * @param value Data value
211
+ */
212
+ export declare function setData(element: Element, key: string, value: unknown): void;
213
+ /**
214
+ * Dispatch an event for a target
215
+ * @param target Event target
216
+ * @param type Type of event
217
+ * @param options Options for event _(bubbles and is cancelable by default)_
218
+ */
219
+ export declare function dispatch<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, options?: CustomEventInit): void;
220
+ /**
221
+ * Dispatch an event for a target
222
+ * @param target Event target
223
+ * @param type Type of event
224
+ * @param options Options for event _(bubbles and is cancelable by default)_
225
+ */
226
+ export declare function dispatch(target: EventTarget, type: string, options?: CustomEventInit): void;
227
+ /**
228
+ * Get the X- and Y-coordinates from a pointer event
229
+ * @param event Pointer event
230
+ * @returns X- and Y-coordinates
231
+ */
232
+ export declare function getPosition(event: MouseEvent | TouchEvent): EventPosition | undefined;
233
+ /**
234
+ * Remove an event listener
235
+ * @param target Event target
236
+ * @param type Type of event
237
+ * @param listener Event listener
238
+ * @param options Options for event
239
+ */
240
+ export declare function off(target: EventTarget, type: keyof HTMLElementEventMap, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
241
+ /**
242
+ * Remove an event listener
243
+ * @param target Event target
244
+ * @param type Type of event
245
+ * @param listener Event listener
246
+ * @param options Options for event
247
+ */
248
+ export declare function off(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: EventListenerOptions): void;
249
+ /**
250
+ * Add an event listener
251
+ * @param target Event target
252
+ * @param type Type of event
253
+ * @param listener Event listener
254
+ * @param options Options for event _(passive by default)_
255
+ */
256
+ export declare function on<Type extends keyof HTMLElementEventMap>(target: EventTarget, type: Type, listener: (event: HTMLElementEventMap[Type]) => void, options?: AddEventListenerOptions): RemovableEventListener;
257
+ /**
258
+ * Add an event listener
259
+ * @param target Event target
260
+ * @param type Type of event
261
+ * @param listener Event listener
262
+ * @param options Options for event _(passive by default)_
263
+ */
264
+ export declare function on(target: EventTarget, type: string, listener: EventListener | CustomEventListener, options?: AddEventListenerOptions): RemovableEventListener;
265
+ /**
266
+ * Find the closest ancestor element that matches the tag name
267
+ *
268
+ * - If no match is found, `null` is returned
269
+ * - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
270
+ * @param origin Origin to start from
271
+ * @param tagName Tag name to match
272
+ * @returns Found ancestor or `null`
273
+ */
274
+ export declare function findAncestor<TagName extends keyof HTMLElementTagNameMap>(origin: Element | Event | EventTarget, tagName: TagName): HTMLElementTagNameMap[TagName] | null;
275
+ /**
276
+ * Find the closest ancestor element that matches the selector _(string or callback)_
277
+ *
278
+ * - If no match is found, `null` is returned
279
+ * - _(If you want to search upwards, downwards, and sideways, use {@link findRelatives})_
280
+ * @param origin Origin to start from
281
+ * @param selector Selector to match
282
+ * @returns Found ancestor or `null`
283
+ */
284
+ export declare function findAncestor(origin: Element | Event | EventTarget, selector: string | ((element: Element) => boolean)): Element | null;
285
+ /**
286
+ * Finds the closest elements to the origin element that matches the tag name
287
+ *
288
+ * Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
289
+ * @param origin Element to start from
290
+ * @param tagName Tag name to match
291
+ * @param context Context to search within
292
+ * @returns Found elements
293
+ */
294
+ export declare function findRelatives<TagName extends keyof HTMLElementTagNameMap>(origin: Element, tagName: TagName, context?: Document | Element): HTMLElementTagNameMap[TagName][];
295
+ /**
296
+ * Finds the closest elements to the origin element that matches the selector
297
+ *
298
+ * Traverses up, down, and sideways in the _DOM_-tree. _(If you only want to traverse up, use {@link findAncestor})_
299
+ * @param origin Element to start from
300
+ * @param selector Selector to match
301
+ * @param context Context to search within
302
+ * @returns Found elements
303
+ */
304
+ export declare function findRelatives(origin: Element, selector: string, context?: Document | Element): Element[];
305
+ /**
306
+ * Get the distance between two elements _(i.e., the amount of nodes of between them)_
307
+ * @param origin Origin element
308
+ * @param target Target element
309
+ * @returns Distance between elements, or `-1` if distance cannot be calculated
310
+ */
311
+ export declare function getDistance(origin: Element, target: Element): number;
312
+ /**
313
+ * Find the first element that matches the tag name
314
+ * @param tagName Tag name of element to find
315
+ * @param context Context to search within _(defaults to `document`)_
316
+ * @returns Found element or `null`
317
+ */
318
+ export declare function findElement<TagName extends keyof HTMLElementTagNameMap>(tagName: TagName, context?: Selector | null): HTMLElementTagNameMap[TagName] | null;
319
+ /**
320
+ * Find the first element that matches the selector
321
+ * @param selector Selector to find element for
322
+ * @param context Context to search within _(defaults to `document`)_
323
+ * @returns Found element or `null`
324
+ */
325
+ export declare function findElement(selector: string, context?: Selector | null): Element | null;
326
+ /**
327
+ * Find elements that match the selector
328
+ * @param tagName tagName to find elements for
329
+ * @param context Context to search within _(defaults to `document`)_
330
+ * @returns Found elements
331
+ */
332
+ export declare function findElements(tagName: keyof HTMLElementTagNameMap, context?: Selector | null): HTMLElementTagNameMap[typeof tagName][];
333
+ /**
334
+ * Find elements that match the selector
335
+ * @param selector Selector to find elements for
336
+ * @param context Context to search within _(defaults to `document`)_
337
+ * @returns Found elements
338
+ */
339
+ export declare function findElements(selector: Selector, context?: Selector | null): Element[];
340
+ /**
341
+ * Get the most specific element under the pointer
342
+ *
343
+ * - Ignores elements with `pointer-events: none` and `visibility: hidden`
344
+ * - _(If `skipIgnore` is `true`, no elements are ignored)_
345
+ * @param skipIgnore Skip ignored elements?
346
+ * @returns Found element or `null`
347
+ */
348
+ export declare function getElementUnderPointer(skipIgnore?: boolean): Element | null;
349
+ /**
350
+ * Get a list of focusable elements within a parent element
351
+ * @param parent Parent element
352
+ * @returns Focusable elements
353
+ */
354
+ export declare function getFocusable(parent: Element): Element[];
355
+ /**
356
+ * Get a list of tabbable elements within a parent element
357
+ * @param parent Parent element
358
+ * @returns Tabbable elements
359
+ */
360
+ export declare function getTabbable(parent: Element): Element[];
361
+ /**
362
+ * Is the element focusable?
363
+ * @param element Element to check
364
+ * @returns `true` if focusable, otherwise `false`
365
+ */
366
+ export declare function isFocusable(element: Element): boolean;
367
+ /**
368
+ * Is the element tabbable?
369
+ * @param element Element to check
370
+ * @returns `true` if tabbable, otherwise `false`
371
+ */
372
+ export declare function isTabbable(element: Element): boolean;
373
+ export type Html = {
374
+ /**
375
+ * Create nodes from an HTML string or a template element
376
+ * @param value HTML string or id for a template element
377
+ * @param options Options for creating nodes
378
+ * @returns Created nodes
379
+ */
380
+ (value: string, options?: HtmlOptions): Node[];
381
+ /**
382
+ * Create nodes from a template element
383
+ * @param template Template element
384
+ * @param options Options for creating nodes
385
+ * @returns Created nodes
386
+ */
387
+ (template: HTMLTemplateElement, options?: HtmlOptions): Node[];
388
+ /**
389
+ * Clear cache of template elements
390
+ */
391
+ clear(): void;
392
+ /**
393
+ * Remove cached template element for an HTML string or id
394
+ * @param template HTML string or id for a template element
395
+ */
396
+ remove(template: string): void;
397
+ };
398
+ export type HtmlOptions = {
399
+ /**
400
+ * Cache template element for the HTML string? _(defaults to `true`)_
401
+ */
402
+ cache?: boolean;
403
+ };
404
+ export declare const html: Html;
405
+ /**
406
+ * Sanitize one or more nodes, recursively
407
+ * @param value Node or nodes to sanitize
408
+ * @param options Sanitization options
409
+ * @returns Sanitized nodes
410
+ */
411
+ export declare function sanitize(value: Node | Node[]): Node[];
412
+ /**
413
+ * Is the value an event target?
414
+ * @param value Value to check
415
+ * @returns `true` if it's an event target, otherwise `false`
416
+ */
417
+ export declare function isEventTarget(value: unknown): value is EventTarget;
418
+ /**
419
+ * Is the value an HTML or SVG element?
420
+ * @param value Value to check
421
+ * @returns `true` if it's an HTML or SVG element, otherwise `false`
422
+ */
423
+ export declare function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement;
424
+ /**
425
+ * Is the value a child node?
426
+ * @param value Value to check
427
+ * @returns `true` if it's a child node, otherwise `false`
428
+ */
429
+ export declare function isChildNode(value: unknown): value is ChildNode;
430
+ /**
431
+ * Is the node inside a document?
432
+ * @param node Node to check
433
+ * @returns `true` if it's inside a document, otherwise `false`
434
+ */
435
+ export declare function isInDocument(node: Node): boolean;
436
+ /**
437
+ * Is the node inside a specific document?
438
+ * @param node Node to check
439
+ * @param document Document to check within
440
+ * @returns `true` if it's inside the document, otherwise `false`
441
+ */
442
+ export declare function isInDocument(node: Node, document: Document): boolean;
443
+ export type StyleToggler = {
444
+ /**
445
+ * Set the provided styles on the element
446
+ */
447
+ set(): void;
448
+ /**
449
+ * Remove the provided styles from the element _(and sets any previous styles)_
450
+ */
451
+ remove(): void;
452
+ };
453
+ /**
454
+ * Get a style from an element
455
+ * @param element Element to get the style from
456
+ * @param property Style name
457
+ * @param computed Get the computed style? _(defaults to `false`)_
458
+ * @returns Style value
459
+ */
460
+ export declare function getStyle(element: Element, property: keyof CSSStyleDeclaration, computed?: boolean): string | undefined;
461
+ /**
462
+ * Get styles from an element
463
+ * @param element Element to get the styles from
464
+ * @param properties Styles to get
465
+ * @param computed Get the computed styles? _(defaults to `false`)_
466
+ * @returns Style values
467
+ */
468
+ export declare function getStyles<Property extends keyof CSSStyleDeclaration>(element: Element, properties: Property[], computed?: boolean): Record<Property, string | undefined>;
469
+ /**
470
+ * Get the text direction of an element
471
+ * @param element Element to get the text direction from
472
+ * @param computed Get the computed text direction? _(defaults to `false`)_
473
+ * @returns Text direction
474
+ */
475
+ export declare function getTextDirection(element: Element, computed?: boolean): TextDirection;
476
+ /**
477
+ * Set a style on an element
478
+ * @param element Element to set the style on
479
+ * @param property Style name
480
+ * @param value Style value
481
+ */
482
+ export declare function setStyle(element: Element, property: keyof CSSStyleDeclaration, value?: string): void;
483
+ /**
484
+ * Set styles on an element
485
+ * @param element Element to set the styles on
486
+ * @param styles Styles to set
487
+ */
488
+ export declare function setStyles(element: Element, styles: Partial<CSSStyleDeclaration>): void;
489
+ /**
490
+ * Toggle styles for an element
491
+ * @param element Element to style
492
+ * @param styles Styles to be set or removed
493
+ * @returns Style toggler
494
+ */
495
+ export declare function toggleStyles(element: Element, styles: Partial<CSSStyleDeclaration>): StyleToggler;
496
+
497
+ export {
498
+ findElement as $,
499
+ findElements as $$,
500
+ };
501
+
502
+ export {};