@tempots/dom 23.0.1 → 24.0.0-next.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/dom/attr.d.ts CHANGED
@@ -1,58 +1,3 @@
1
- /**
2
- * Sets a boolean property on an HTML element.
3
- *
4
- * If the `value` is `null`, the property is set to `null`. Otherwise, the
5
- * property is set to the boolean value of `value`.
6
- *
7
- * @param attributeName - The name of the boolean property to set.
8
- * @returns A function that takes an `Element` and a `value` and sets the
9
- * boolean property on the element.
10
- * @internal
11
- */
12
- export declare const _setBooleanProperty: (attributeName: string) => (element: Element, value: unknown) => void;
13
- /**
14
- * Sets a numeric property on an HTML element.
15
- *
16
- * If the provided `value` is `null`, the property will be set to `null`.
17
- * Otherwise, the property will be set to the numeric value of the provided `value`.
18
- *
19
- * @param attributeName - The name of the property to set on the element.
20
- * @returns A function that takes an `Element` and a `value` and sets the property.
21
- * @internal
22
- */
23
- export declare const _setNumberProperty: (attributeName: string) => (element: Element, value: unknown) => void;
24
- /**
25
- * Sets a date property on an element.
26
- *
27
- * If the `value` is `null`, the date property is set to `null`. Otherwise, the
28
- * date property is set to the provided `value`.
29
- *
30
- * @param attributeName - The name of the date property to set on the element.
31
- * @returns A function that takes an element and a value, and sets the date
32
- * property on the element.
33
- * @internal
34
- */
35
- export declare const _setDateProperty: (attributeName: string) => (element: Element, value: unknown) => void;
36
- /**
37
- * Sets a string property on an `Element` object.
38
- *
39
- * If the provided `value` is `null`, the property will be set to `null`.
40
- * Otherwise, the `value` will be converted to a string and set as the property.
41
- *
42
- * @param attributeName - The name of the property to set on the `Element`.
43
- * @returns A function that takes an `Element` and a `value` and sets the property.
44
- * @internal
45
- */
46
- export declare const _setStringProperty: (attributeName: string) => (element: Element, value: unknown) => void;
47
- /**
48
- * Sets the specified attribute on the given element to the provided value.
49
- * If the value is `null`, the attribute will be removed from the element.
50
- *
51
- * @param attributeName - The name of the attribute to set.
52
- * @returns A function that takes an element and a value, and sets the attribute on the element.
53
- * @internal
54
- */
55
- export declare const _setAttribute: (attributeName: string) => (element: Element, value: unknown) => void;
56
1
  /**
57
2
  * Creates a setter function for an element attribute based on the attribute's type.
58
3
  *
@@ -64,7 +9,7 @@ export declare const _setAttribute: (attributeName: string) => (element: Element
64
9
  * @returns A function that sets the attribute value on an element.
65
10
  * @internal
66
11
  */
67
- export declare const _makeSetter: (attributeName: string) => ((element: Element, value: unknown) => void);
12
+ export declare const _makeSetter: (attributeName: string, element: Element) => (value: unknown) => void;
68
13
  /**
69
14
  * Creates a getter function for a specific HTML element attribute.
70
15
  *
@@ -77,4 +22,4 @@ export declare const _makeSetter: (attributeName: string) => ((element: Element,
77
22
  * specified attribute.
78
23
  * @internal
79
24
  */
80
- export declare const _makeGetter: <T>(attributeName: string) => ((element: Element) => T);
25
+ export declare const _makeGetter: (attributeName: string, element: Element) => () => any;
@@ -0,0 +1,198 @@
1
+ import { Clear, ProviderMark, Providers } from '../types/domain';
2
+ import { DOMContext } from './dom-context';
3
+ import { HeadlessContext } from './headless-context';
4
+ /**
5
+ * `DOMContext` is an immutable class that represents the context of a DOM element.
6
+ * It provides methods and properties to manipulate and interact with the DOM element.
7
+ *
8
+ * A reference in a DOMContext is to mark a position within a set of sibblings.
9
+ * It is used to insert new elements before the reference.
10
+ *
11
+ * @public
12
+ */
13
+ export declare class BrowserContext implements DOMContext {
14
+ /**
15
+ * The `Document` instance associated with this context.
16
+ */
17
+ readonly document: Document;
18
+ /**
19
+ * The `Element` instance associated with this context.
20
+ */
21
+ readonly element: HTMLElement;
22
+ /**
23
+ * An optional `Node` instance that serves as a reference for this context.
24
+ */
25
+ readonly reference: Node | undefined;
26
+ /**
27
+ * The `Providers` instance associated with this context.
28
+ */
29
+ readonly providers: Providers;
30
+ /**
31
+ * Creates a new `DOMContext` instance for the given `Element` and optional reference `Node`.
32
+ *
33
+ * @param element - The `HTMLElement` to create the `DOMContext` for.
34
+ * @param ref - An optional reference `Node` to associate with the `DOMContext`.
35
+ * @returns A new `DOMContext` instance.
36
+ */
37
+ static of(element: HTMLElement, ref?: Node | undefined): DOMContext;
38
+ /**
39
+ * Constructs a new `DOMContext` instance.
40
+ *
41
+ * @param document - The `Document` instance associated with this context.
42
+ * @param element - The `Element` instance associated with this context.
43
+ * @param reference - An optional `Node` instance that serves as a reference for this context.
44
+ * @param providers - The `Providers` instance associated with this context.
45
+ * @param isFirstLevel - A boolean value indicating whether this context is at the first level, meaning the outermost node in the generated DOM.
46
+ */
47
+ constructor(
48
+ /**
49
+ * The `Document` instance associated with this context.
50
+ */
51
+ document: Document,
52
+ /**
53
+ * The `Element` instance associated with this context.
54
+ */
55
+ element: HTMLElement,
56
+ /**
57
+ * An optional `Node` instance that serves as a reference for this context.
58
+ */
59
+ reference: Node | undefined,
60
+ /**
61
+ * The `Providers` instance associated with this context.
62
+ */
63
+ providers: Providers);
64
+ /**
65
+ * Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace.
66
+ *
67
+ * @param tagName - The tag name of the element to create.
68
+ * @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
69
+ * @returns The newly created element.
70
+ */
71
+ readonly createElement: (tagName: string, namespace: string | undefined) => HTMLElement;
72
+ /**
73
+ * Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace and appends it to the current element.
74
+ *
75
+ * @param tagName - The tag name of the element to create.
76
+ * @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
77
+ * @returns The newly created element.
78
+ */
79
+ readonly makeChildElement: (tagName: string, namespace: string | undefined) => DOMContext;
80
+ /**
81
+ * Creates a new text node with the specified text content.
82
+ * @param text - The text content for the new text node.
83
+ * @returns A new `Text` node with the specified text content.
84
+ */
85
+ readonly createText: (text: string) => Text;
86
+ /**
87
+ * Creates a new text node with the specified text content and appends it to the current element.
88
+ * @param text - The text content for the new text node.
89
+ * @returns A new `DOMContext` with a reference to the new text node.
90
+ */
91
+ readonly makeChildText: (text: string) => DOMContext;
92
+ /**
93
+ * Sets the text content of the current element.
94
+ * @param text - The text content to set.
95
+ */
96
+ readonly setText: (text: string) => void;
97
+ /**
98
+ * Gets the text content of the current element or text node.
99
+ * @returns The text content of the current element or text node.
100
+ */
101
+ readonly getText: () => string;
102
+ /**
103
+ * Creates a new `DOMContext` with a reference to a newly created text node.
104
+ * The text node is appended or inserted to the current `DOMContext`.
105
+ * The new `DOMContext` with the reference is returned.
106
+ */
107
+ readonly makeRef: () => DOMContext;
108
+ /**
109
+ * Appends or inserts a child node to the element, depending on whether a reference node is provided.
110
+ *
111
+ * @param child - The child node to append or insert.
112
+ */
113
+ readonly appendOrInsert: (child: Node) => void;
114
+ /**
115
+ * Creates a new `DOMContext` instance with the provided `element`.
116
+ * @param element - The DOM element to use in the new `DOMContext` instance.
117
+ * @returns A new `DOMContext` instance with the provided `element`.
118
+ */
119
+ readonly withElement: (element: HTMLElement) => BrowserContext;
120
+ /**
121
+ * Creates a new `DOMContext` instance with a reference to a DOM element selected by the provided `selector`.
122
+ * @param selector - The CSS selector for the target DOM element.
123
+ * @returns A new `DOMContext` instance with a reference to the selected DOM element.
124
+ */
125
+ readonly makePortal: (selector: string) => DOMContext;
126
+ /**
127
+ * Creates a new `DOMContext` instance with the specified reference.
128
+ *
129
+ * @param reference - The optional `Text` node to use as the reference for the new `DOMContext`.
130
+ * @returns A new `DOMContext` instance with the specified reference.
131
+ */
132
+ readonly withReference: (reference: Text | undefined) => DOMContext;
133
+ /**
134
+ * Returns a new HTMLDOMContext instance with the specified providers merged into
135
+ * the existing providers.
136
+ *
137
+ * @param providers - An object containing the providers to be merged into the existing providers.
138
+ * @returns A new HTMLDOMContext instance with the merged providers.
139
+ */
140
+ readonly withProviders: (providers: { [K in ProviderMark<unknown>]: unknown; }) => DOMContext;
141
+ /**
142
+ * Retrieves a provider for the given provider mark.
143
+ *
144
+ * @param mark - The provider mark to retrieve the provider for.
145
+ * @returns The provider for the given mark.
146
+ * @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
147
+ */
148
+ readonly getProvider: <T>(mark: ProviderMark<T>) => T;
149
+ readonly clear: (removeTree: boolean) => void;
150
+ /**
151
+ * Adds classes to the element.
152
+ * @param tokens - The class names to add.
153
+ */
154
+ readonly addClasses: (tokens: string[]) => void;
155
+ /**
156
+ * Removes classes from the element.
157
+ * @param tokens - The class names to remove.
158
+ */
159
+ readonly removeClasses: (tokens: string[]) => void;
160
+ /**
161
+ * Gets the classes of the element.
162
+ * @returns The classes of the element.
163
+ */
164
+ readonly getClasses: () => string[];
165
+ /**
166
+ * Adds an event listener to the element.
167
+ * @param event - The event to listen for.
168
+ * @param listener - The listener to call when the event occurs.
169
+ * @returns A function to remove the event listener.
170
+ */
171
+ readonly on: <E>(event: string, listener: (event: E) => void) => Clear;
172
+ /**
173
+ * Returns `true` if the context is a browser DOM context.
174
+ * @returns `true` if the context is a browser DOM context.
175
+ */
176
+ readonly isBrowserDOM: () => this is BrowserContext;
177
+ /**
178
+ * Returns `true` if the context is a headless DOM context.
179
+ * @returns `true` if the context is a headless DOM context.
180
+ */
181
+ readonly isHeadlessDOM: () => this is HeadlessContext;
182
+ /**
183
+ * Sets the style of the element.
184
+ * @param name - The name of the style to set.
185
+ * @param value - The value of the style to set.
186
+ */
187
+ readonly setStyle: (name: string, value: string) => void;
188
+ /**
189
+ * Gets the style of the element.
190
+ * @param name - The name of the style to get.
191
+ * @returns The value of the style.
192
+ */
193
+ readonly getStyle: (name: string) => string;
194
+ readonly makeAccessors: (name: string) => {
195
+ get: () => any;
196
+ set: (value: unknown) => void;
197
+ };
198
+ }
@@ -1,4 +1,6 @@
1
- import { ProviderMark, Providers } from '../types/domain';
1
+ import { Clear, ProviderMark } from '../types/domain';
2
+ import { BrowserContext } from './browser-context';
3
+ import { HeadlessContext } from './headless-context';
2
4
  /**
3
5
  * `DOMContext` is an immutable class that represents the context of a DOM element.
4
6
  * It provides methods and properties to manipulate and interact with the DOM element.
@@ -8,145 +10,113 @@ import { ProviderMark, Providers } from '../types/domain';
8
10
  *
9
11
  * @public
10
12
  */
11
- export declare class DOMContext {
13
+ export interface DOMContext {
12
14
  /**
13
- * The `Document` instance associated with this context.
14
- */
15
- readonly document: Document;
16
- /**
17
- * The `Element` instance associated with this context.
18
- */
19
- readonly element: Element;
20
- /**
21
- * An optional `Node` instance that serves as a reference for this context.
22
- */
23
- readonly reference: Node | undefined;
24
- /**
25
- * The `Providers` instance associated with this context.
26
- */
27
- readonly providers: Providers;
28
- /**
29
- * A boolean value indicating whether this context is at the first level, meaning the outermost node in the generated
30
- */
31
- readonly isFirstLevel: boolean;
32
- /**
33
- * Creates a new `DOMContext` instance for the given `Element` and optional reference `Node`.
15
+ * Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace and appends it to the current element.
34
16
  *
35
- * @param element - The `Element` to create the `DOMContext` for.
36
- * @param ref - An optional reference `Node` to associate with the `DOMContext`.
37
- * @returns A new `DOMContext` instance.
17
+ * @param tagName - The tag name of the element to create.
18
+ * @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
19
+ * @returns The newly created element.
38
20
  */
39
- static of(element: Element, ref?: Node | undefined): DOMContext;
21
+ makeChildElement(tagName: string, namespace: string | undefined): DOMContext;
40
22
  /**
41
- * Constructs a new `DOMContext` instance.
42
- *
43
- * @param document - The `Document` instance associated with this context.
44
- * @param element - The `Element` instance associated with this context.
45
- * @param reference - An optional `Node` instance that serves as a reference for this context.
46
- * @param providers - The `Providers` instance associated with this context.
47
- * @param isFirstLevel - A boolean value indicating whether this context is at the first level, meaning the outermost node in the generated DOM.
23
+ * Creates a new text node with the specified text content and appends it to the current element.
24
+ * @param text - The text content for the new text node.
25
+ * @returns A new `DOMContext` with a reference to the new text node.
48
26
  */
49
- constructor(
27
+ makeChildText(text: string): DOMContext;
50
28
  /**
51
- * The `Document` instance associated with this context.
29
+ * Sets the text content of the current element.
30
+ * @param text - The text content to set.
52
31
  */
53
- document: Document,
32
+ setText(text: string): void;
54
33
  /**
55
- * The `Element` instance associated with this context.
34
+ * Gets the text content of the current element or text node.
35
+ * @returns The text content of the current element or text node.
56
36
  */
57
- element: Element,
37
+ getText(): string;
58
38
  /**
59
- * An optional `Node` instance that serves as a reference for this context.
39
+ * Creates a new `DOMContext` with a reference to a newly created text node.
40
+ * The text node is appended or inserted to the current `DOMContext`.
41
+ * The new `DOMContext` with the reference is returned.
60
42
  */
61
- reference: Node | undefined,
43
+ makeRef(): DOMContext;
62
44
  /**
63
- * The `Providers` instance associated with this context.
45
+ * Creates a new `DOMContext` instance with a reference to a DOM element selected by the provided `selector`.
46
+ * @param selector - The CSS selector for the target DOM element.
47
+ * @returns A new `DOMContext` instance with a reference to the selected DOM element.
64
48
  */
65
- providers: Providers,
49
+ makePortal(selector: string): DOMContext;
66
50
  /**
67
- * A boolean value indicating whether this context is at the first level, meaning the outermost node in the generated
51
+ * Returns a new DOMContext instance with the specified providers merged into
52
+ * the existing providers.
53
+ *
54
+ * @param providers - An object containing the providers to be merged into the existing providers.
55
+ * @returns A new DOMContext instance with the merged providers.
68
56
  */
69
- isFirstLevel: boolean);
57
+ withProviders(providers: {
58
+ [K in ProviderMark<unknown>]: unknown;
59
+ }): DOMContext;
70
60
  /**
71
- * Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace.
61
+ * Retrieves a provider for the given provider mark.
72
62
  *
73
- * @param tagName - The tag name of the element to create.
74
- * @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
75
- * @returns The newly created element.
63
+ * @param mark - The provider mark to retrieve the provider for.
64
+ * @returns The provider for the given mark.
65
+ * @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
76
66
  */
77
- readonly createElement: (tagName: string, namespace: string | undefined) => Element;
67
+ getProvider<T>(mark: ProviderMark<T>): T;
68
+ clear(removeTree: boolean): void;
78
69
  /**
79
- * Creates a new text node with the specified text content.
80
- * @param text - The text content for the new text node.
81
- * @returns A new `Text` node with the specified text content.
70
+ * Adds an event listener to the element.
71
+ * @param event - The event to listen for.
72
+ * @param listener - The listener to call when the event occurs.
73
+ * @returns A function to remove the event listener.
82
74
  */
83
- readonly createText: (text: string) => Text;
75
+ on<E>(event: string, listener: (event: E) => void): Clear;
84
76
  /**
85
- * Creates a new `DOMContext` with a reference to a newly created text node.
86
- * The text node is appended or inserted to the current `DOMContext`.
87
- * The new `DOMContext` with the reference is returned.
77
+ * Adds classes to the element.
78
+ * @param tokens - The class names to add.
88
79
  */
89
- readonly makeRef: () => DOMContext;
80
+ addClasses(tokens: string[]): void;
90
81
  /**
91
- * Appends or inserts a child node to the element, depending on whether a reference node is provided.
92
- *
93
- * @param child - The child node to append or insert.
82
+ * Removes classes from the element.
83
+ * @param tokens - The class names to remove.
94
84
  */
95
- readonly appendOrInsert: (child: Node) => void;
85
+ removeClasses(tokens: string[]): void;
96
86
  /**
97
- * Creates a new `DOMContext` instance with the provided `document`.
98
- *
99
- * @param document - The `Document` to use for the `DOMContext`.
100
- * @returns A new `DOMContext` instance.
87
+ * Gets the classes of the element.
88
+ * @returns The classes of the element.
101
89
  */
102
- readonly withDocument: (document: Document) => DOMContext;
90
+ getClasses(): string[];
103
91
  /**
104
- * Creates a new `DOMContext` instance with the provided `element`.
105
- * @param element - The DOM element to use in the new `DOMContext` instance.
106
- * @returns A new `DOMContext` instance with the provided `element`.
92
+ * Returns `true` if the context is a browser DOM context.
93
+ * @returns `true` if the context is a browser DOM context.
107
94
  */
108
- readonly withElement: (element: Element) => DOMContext;
95
+ isBrowserDOM(): this is BrowserContext;
109
96
  /**
110
- * Creates a new `DOMContext` instance with the `isFirstLevel` property set to `true`.
111
- * @returns A new `DOMContext` instance with the `isFirstLevel` property set to `true`.
97
+ * Returns `true` if the context is a headless DOM context.
98
+ * @returns `true` if the context is a headless DOM context.
112
99
  */
113
- readonly withFirstLevel: () => DOMContext;
100
+ isHeadlessDOM(): this is HeadlessContext;
114
101
  /**
115
- * Creates a new `DOMContext` instance with the specified reference.
116
- *
117
- * @param reference - The optional `Text` node to use as the reference for the new `DOMContext`.
118
- * @returns A new `DOMContext` instance with the specified reference.
102
+ * Sets the style of the element.
103
+ * @param name - The name of the style to set.
104
+ * @param value - The value of the style to set.
119
105
  */
120
- readonly withReference: (reference: Text | undefined) => DOMContext;
121
- /** Creates a new DOMContext with the provided provider value.
122
- *
123
- * @param mark - The provider mark to associate the value with.
124
- * @param value - The value to set for the provider.
125
- * @returns A new DOMContext with the updated providers.
126
- */
127
- readonly withProvider: <T>(mark: ProviderMark<T>, value: T) => DOMContext;
106
+ setStyle(name: string, value: string): void;
128
107
  /**
129
- * Returns a new DOMContext instance with the specified providers merged into
130
- * the existing providers.
131
- *
132
- * @param providers - An object containing the providers to be merged into the existing providers.
133
- * @returns A new DOMContext instance with the merged providers.
108
+ * Gets the style of the element.
109
+ * @param name - The name of the style to get.
110
+ * @returns The value of the style.
134
111
  */
135
- readonly withProviders: (providers: { [K in ProviderMark<unknown>]: unknown; }) => DOMContext;
112
+ getStyle(name: string): string;
136
113
  /**
137
- * Retrieves a provider for the given provider mark.
138
- *
139
- * @param mark - The provider mark to retrieve the provider for.
140
- * @returns The provider for the given mark.
141
- * @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
114
+ * Returns an object with methods to get and set the value of a property or attribute.
115
+ * @param name - The name of the property to create accessors for.
116
+ * @returns An object with methods to get and set the value of the property.
142
117
  */
143
- readonly getProvider: <T>(mark: ProviderMark<T>) => T;
144
- }
145
- /**
146
- * Error thrown when a provider is not found.
147
- *
148
- * @public
149
- */
150
- export declare class ProviderNotFoundError extends Error {
151
- constructor(mark: ProviderMark<unknown>);
118
+ makeAccessors(name: string): {
119
+ get(): unknown;
120
+ set(value: unknown): void;
121
+ };
152
122
  }
@@ -13,7 +13,7 @@ export declare const _removeDOMNode: (node: Node) => void;
13
13
  * @returns The `Element` for the given `node`.
14
14
  * @internal
15
15
  */
16
- export declare const _getSelfOrParentElement: (node: Node) => Element;
16
+ export declare const _getSelfOrParentElement: (node: Node) => HTMLElement;
17
17
  /**
18
18
  * Determines if the given `Node` is an `Element`.
19
19
  *
@@ -21,4 +21,4 @@ export declare const _getSelfOrParentElement: (node: Node) => Element;
21
21
  * @returns `true` if the `node` is an `Element`, `false` otherwise.
22
22
  * @internal
23
23
  */
24
- export declare const _isElement: (node: Node) => node is Element;
24
+ export declare const _isElement: (node: Node) => node is HTMLElement;
@@ -0,0 +1,9 @@
1
+ import { ProviderMark } from '../types/domain';
2
+ /**
3
+ * Error thrown when a provider is not found.
4
+ *
5
+ * @public
6
+ */
7
+ export declare class ProviderNotFoundError extends Error {
8
+ constructor(mark: ProviderMark<unknown>);
9
+ }
@@ -0,0 +1,103 @@
1
+ import { Prop } from '../std/signal';
2
+ import { ProviderMark, Clear, Providers } from '../types/domain';
3
+ import { BrowserContext } from './browser-context';
4
+ import { DOMContext } from './dom-context';
5
+ declare abstract class HeadlessBase {
6
+ readonly parent: HeadlessBase | undefined;
7
+ readonly id: string;
8
+ private readonly properties;
9
+ readonly children: HeadlessNode[];
10
+ constructor(parent: HeadlessBase | undefined);
11
+ readonly isElement: () => this is HeadlessBase;
12
+ readonly isText: () => this is HeadlessText;
13
+ readonly getText: () => string;
14
+ readonly removeChild: (child: HeadlessNode) => void;
15
+ readonly remove: () => void;
16
+ abstract isPortal(): this is HeadlessPortal;
17
+ readonly getPortals: () => HeadlessPortal[];
18
+ readonly elements: () => HeadlessBase[];
19
+ abstract toHTML(): string;
20
+ readonly hasInnerHTML: () => boolean;
21
+ readonly getInnerHTML: () => string;
22
+ readonly getInnerText: () => string;
23
+ readonly hasInnerText: () => boolean;
24
+ readonly hasChildren: () => boolean;
25
+ readonly hasClasses: () => boolean;
26
+ readonly hasStyles: () => boolean;
27
+ readonly hasAttributes: () => boolean;
28
+ readonly hasHandlers: () => boolean;
29
+ readonly hasRenderableProperties: () => boolean;
30
+ readonly getById: (id: string) => HeadlessBase | undefined;
31
+ readonly trigger: <E>(event: string, detail: E) => void;
32
+ readonly click: () => void;
33
+ readonly on: <E>(event: string, listener: (event: E) => void) => Clear;
34
+ readonly addClasses: (tokens: string[]) => void;
35
+ readonly removeClasses: (tokens: string[]) => void;
36
+ readonly getClasses: () => string[];
37
+ readonly getAttributes: () => [string, unknown][];
38
+ readonly getVisibleAttributes: () => (["class", string[]] | ["style", string | Record<string, string>] | [string, string])[];
39
+ readonly setStyle: (name: string, value: string) => void;
40
+ readonly getStyle: (name: string) => string;
41
+ readonly getStyles: () => Record<string, string>;
42
+ readonly makeAccessors: (name: string) => {
43
+ get(): unknown;
44
+ set(value: unknown): void;
45
+ };
46
+ }
47
+ export declare class HeadlessElement extends HeadlessBase {
48
+ readonly tagName: string;
49
+ readonly namespace: string | undefined;
50
+ constructor(tagName: string, namespace: string | undefined, parent: HeadlessBase | undefined);
51
+ readonly isPortal: () => this is HeadlessPortal;
52
+ readonly toHTML: () => string;
53
+ }
54
+ export declare class HeadlessPortal extends HeadlessBase {
55
+ readonly selector: string;
56
+ constructor(selector: string, parent: HeadlessBase | undefined);
57
+ readonly isPortal: () => this is HeadlessPortal;
58
+ readonly toHTML: () => string;
59
+ readonly contentToHTML: () => string;
60
+ }
61
+ export declare class HeadlessText {
62
+ text: string;
63
+ readonly id: string;
64
+ constructor(text: string);
65
+ readonly isElement: () => this is HeadlessElement;
66
+ readonly isText: () => this is HeadlessText;
67
+ readonly getText: () => string;
68
+ readonly toHTML: () => string;
69
+ }
70
+ export type HeadlessNode = HeadlessElement | HeadlessPortal | HeadlessText;
71
+ export interface HeadlessContainer {
72
+ currentURL: Prop<string>;
73
+ }
74
+ export declare class HeadlessContext implements DOMContext {
75
+ readonly element: HeadlessBase;
76
+ readonly reference: HeadlessNode | undefined;
77
+ readonly container: HeadlessContainer;
78
+ readonly providers: Providers;
79
+ constructor(element: HeadlessBase, reference: HeadlessNode | undefined, container: HeadlessContainer, providers: Providers);
80
+ readonly appendOrInsert: (element: HeadlessNode) => void;
81
+ readonly makeChildElement: (tagName: string, namespace: string | undefined) => DOMContext;
82
+ readonly makeChildText: (text: string) => DOMContext;
83
+ readonly setText: (text: string) => void;
84
+ readonly getText: () => string;
85
+ readonly makeRef: () => DOMContext;
86
+ readonly makePortal: (selector: string) => DOMContext;
87
+ readonly withProviders: (providers: { [K in ProviderMark<unknown>]: unknown; }) => DOMContext;
88
+ readonly getProvider: <T>(mark: ProviderMark<T>) => T;
89
+ readonly clear: (removeTree: boolean) => void;
90
+ readonly on: <E>(event: string, listener: (event: E) => void) => Clear;
91
+ readonly addClasses: (tokens: string[]) => void;
92
+ readonly removeClasses: (tokens: string[]) => void;
93
+ readonly getClasses: () => string[];
94
+ readonly isBrowserDOM: () => this is BrowserContext;
95
+ readonly isHeadlessDOM: () => this is HeadlessContext;
96
+ readonly setStyle: (name: string, value: string) => void;
97
+ readonly getStyle: (name: string) => string;
98
+ readonly makeAccessors: (name: string) => {
99
+ get(): unknown;
100
+ set(value: unknown): void;
101
+ };
102
+ }
103
+ export {};