@tempots/dom 36.0.1 → 37.0.1
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/README.md +47 -0
- package/dom/browser-context.d.ts +44 -31
- package/dom/dom-context.d.ts +37 -3
- package/dom/headless-context.d.ts +68 -62
- package/index.cjs +1 -1
- package/index.d.ts +5 -2
- package/index.js +1185 -2372
- package/package.json +4 -3
- package/renderable/attribute.d.ts +27 -1
- package/renderable/delegate.d.ts +169 -0
- package/renderable/keyed-foreach.d.ts +1 -0
- package/renderable/map-text.d.ts +1 -0
- package/renderable/shared.d.ts +2 -2
- package/renderable/text.d.ts +4 -4
- package/template/builder.d.ts +11 -0
- package/template/engine.d.ts +12 -0
- package/template/hydrator.d.ts +21 -0
- package/template/types.d.ts +85 -0
- package/types/domain.d.ts +1 -1
package/README.md
CHANGED
|
@@ -101,6 +101,26 @@ const button = html.button(
|
|
|
101
101
|
)
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
### Delegated Events
|
|
105
|
+
|
|
106
|
+
For containers with many similar children (e.g., lists rendered with `ForEach`), use `delegate` to attach a single event listener on the container instead of one per child:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { html, delegate, ForEach, prop } from '@tempots/dom'
|
|
110
|
+
|
|
111
|
+
const items = prop(['Apple', 'Banana', 'Cherry'])
|
|
112
|
+
|
|
113
|
+
html.ul(
|
|
114
|
+
delegate.click('li', (event) => {
|
|
115
|
+
const li = (event.target as Element).closest('li')!
|
|
116
|
+
console.log('Clicked:', li.textContent)
|
|
117
|
+
}),
|
|
118
|
+
ForEach(items, (item) => html.li(item))
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`delegate` uses the same proxy pattern as `on` — all standard events are available. It matches children using `Element.closest()` with a CSS selector. Non-bubbling events (`focus`, `blur`, `mouseenter`, `mouseleave`) should use `on` instead.
|
|
123
|
+
|
|
104
124
|
### Conditional Rendering
|
|
105
125
|
|
|
106
126
|
Render content conditionally:
|
|
@@ -131,6 +151,33 @@ const items = prop(['Apple', 'Banana', 'Cherry'])
|
|
|
131
151
|
const list = html.ul(ForEach(items, item => html.li(item)))
|
|
132
152
|
```
|
|
133
153
|
|
|
154
|
+
### Keyed Lists
|
|
155
|
+
|
|
156
|
+
When list items have stable identities (e.g., database IDs), use `KeyedForEach` for efficient reconciliation. Unlike `ForEach` which tracks items by index, `KeyedForEach` tracks items by a user-provided key function — reusing both DOM nodes and signal identities across reorders:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { html, KeyedForEach, prop } from '@tempots/dom'
|
|
160
|
+
|
|
161
|
+
const todos = prop([
|
|
162
|
+
{ id: 1, text: 'Buy groceries' },
|
|
163
|
+
{ id: 2, text: 'Walk the dog' },
|
|
164
|
+
{ id: 3, text: 'Read a book' },
|
|
165
|
+
])
|
|
166
|
+
|
|
167
|
+
const list = html.ul(
|
|
168
|
+
KeyedForEach(
|
|
169
|
+
todos,
|
|
170
|
+
(todo) => todo.id, // key function
|
|
171
|
+
(todo, pos) => html.li( // item renderer
|
|
172
|
+
todo.map((t) => t.text)
|
|
173
|
+
),
|
|
174
|
+
() => html.hr() // optional separator
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
When `todos` is reordered, `KeyedForEach` moves existing DOM elements instead of recreating them. Each item receives a `KeyedPosition` with fully reactive position fields (`index`, `counter`, `isFirst`, `isLast`, `isEven`, `isOdd`) that update automatically when items move.
|
|
180
|
+
|
|
134
181
|
### Storage-Backed Props
|
|
135
182
|
|
|
136
183
|
Tempo provides helpers that persist reactive state to Web Storage through `storedProp`,
|
package/dom/browser-context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Clear, ProviderMark, Providers } from '../types/domain';
|
|
2
|
+
import { Primitive } from '@tempots/core';
|
|
2
3
|
import { DOMContext, HandlerOptions } from './dom-context';
|
|
3
4
|
import { HeadlessContext } from './headless-context';
|
|
4
5
|
/**
|
|
@@ -105,7 +106,7 @@ export declare class BrowserContext implements DOMContext {
|
|
|
105
106
|
* @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
|
|
106
107
|
* @returns The newly created element.
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
+
createElement(tagName: string, namespace: string | undefined): HTMLElement;
|
|
109
110
|
/**
|
|
110
111
|
* Creates a new child element and appends it to the current element, returning a new context.
|
|
111
112
|
*
|
|
@@ -128,47 +129,52 @@ export declare class BrowserContext implements DOMContext {
|
|
|
128
129
|
* @param namespace - The namespace URI for the element, or undefined for HTML elements
|
|
129
130
|
* @returns A new DOMContext focused on the newly created child element
|
|
130
131
|
*/
|
|
131
|
-
|
|
132
|
+
makeChildElement(tagName: string, namespace: string | undefined): DOMContext;
|
|
132
133
|
/**
|
|
133
134
|
* Creates a new text node with the specified text content.
|
|
134
135
|
* @param text - The text content for the new text node.
|
|
135
136
|
* @returns A new `Text` node with the specified text content.
|
|
136
137
|
*/
|
|
137
|
-
|
|
138
|
+
createText(text: Primitive): Text;
|
|
138
139
|
/**
|
|
139
140
|
* Creates a new text node with the specified text content and appends it to the current element.
|
|
140
|
-
* @param text - The text content for the new text node.
|
|
141
|
+
* @param text - The text content for the new text node. Primitives are coerced to strings by the DOM.
|
|
141
142
|
* @returns A new `DOMContext` with a reference to the new text node.
|
|
142
143
|
*/
|
|
143
|
-
|
|
144
|
+
makeChildText(text: Primitive): DOMContext;
|
|
144
145
|
/**
|
|
145
146
|
* Sets the text content of the current element.
|
|
146
|
-
* @param text - The text content to set.
|
|
147
|
+
* @param text - The text content to set. Primitives are coerced to strings by the DOM.
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
+
setText(text: Primitive): void;
|
|
149
150
|
/**
|
|
150
151
|
* Gets the text content of the current element or text node.
|
|
151
152
|
* @returns The text content of the current element or text node.
|
|
152
153
|
*/
|
|
153
|
-
|
|
154
|
+
getText(): string;
|
|
154
155
|
/**
|
|
155
|
-
* Creates a new `DOMContext` with a reference to a newly created
|
|
156
|
-
* The
|
|
156
|
+
* Creates a new `DOMContext` with a reference to a newly created Comment node.
|
|
157
|
+
* The Comment node is appended or inserted to the current `DOMContext`.
|
|
157
158
|
* The new `DOMContext` with the reference is returned.
|
|
158
159
|
*/
|
|
159
|
-
|
|
160
|
+
makeRef(): DOMContext;
|
|
161
|
+
/**
|
|
162
|
+
* Creates a lightweight Comment marker node and appends/inserts it.
|
|
163
|
+
* Used as boundary references for keyed list items and conditional renderables.
|
|
164
|
+
*/
|
|
165
|
+
makeMarker(): DOMContext;
|
|
160
166
|
/**
|
|
161
167
|
* Appends or inserts a child node to the element, depending on whether a reference node is provided.
|
|
162
168
|
*
|
|
163
169
|
* @param child - The child node to append or insert.
|
|
164
170
|
*/
|
|
165
|
-
|
|
171
|
+
appendOrInsert(child: Node): void;
|
|
166
172
|
/**
|
|
167
173
|
* Creates a new `DOMContext` instance with the provided `element`.
|
|
168
174
|
* @param element - The DOM element to use in the new `DOMContext` instance.
|
|
169
175
|
* @returns A new `DOMContext` instance with the provided `element`.
|
|
170
176
|
*/
|
|
171
|
-
|
|
177
|
+
withElement(element: HTMLElement): BrowserContext;
|
|
172
178
|
/**
|
|
173
179
|
* Creates a portal to render content in a different part of the DOM tree.
|
|
174
180
|
*
|
|
@@ -213,14 +219,14 @@ export declare class BrowserContext implements DOMContext {
|
|
|
213
219
|
* @returns A new DOMContext focused on the portal target element
|
|
214
220
|
* @throws {Error} When the selector doesn't match any element in the document
|
|
215
221
|
*/
|
|
216
|
-
|
|
222
|
+
makePortal(selector: string | HTMLElement): DOMContext;
|
|
217
223
|
/**
|
|
218
224
|
* Creates a new `DOMContext` instance with the specified reference.
|
|
219
225
|
*
|
|
220
|
-
* @param reference - The optional `
|
|
226
|
+
* @param reference - The optional `Node` to use as the reference for the new `DOMContext`.
|
|
221
227
|
* @returns A new `DOMContext` instance with the specified reference.
|
|
222
228
|
*/
|
|
223
|
-
|
|
229
|
+
withReference(reference: Node | undefined): DOMContext;
|
|
224
230
|
/**
|
|
225
231
|
* Sets a provider for the given provider mark.
|
|
226
232
|
*
|
|
@@ -228,7 +234,7 @@ export declare class BrowserContext implements DOMContext {
|
|
|
228
234
|
* @param value - The provider to set for the given mark.
|
|
229
235
|
* @returns A new `DOMContext` instance with the specified provider.
|
|
230
236
|
*/
|
|
231
|
-
|
|
237
|
+
setProvider<T>(mark: ProviderMark<T>, value: T, onUse: undefined | (() => void)): DOMContext;
|
|
232
238
|
/**
|
|
233
239
|
* Retrieves a provider for the given provider mark.
|
|
234
240
|
*
|
|
@@ -236,26 +242,26 @@ export declare class BrowserContext implements DOMContext {
|
|
|
236
242
|
* @returns The provider for the given mark.
|
|
237
243
|
* @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
|
|
238
244
|
*/
|
|
239
|
-
|
|
245
|
+
getProvider<T>(mark: ProviderMark<T>): {
|
|
240
246
|
value: T;
|
|
241
247
|
onUse: (() => void) | undefined;
|
|
242
248
|
};
|
|
243
|
-
|
|
249
|
+
clear(removeTree: boolean): void;
|
|
244
250
|
/**
|
|
245
251
|
* Adds classes to the element.
|
|
246
252
|
* @param tokens - The class names to add.
|
|
247
253
|
*/
|
|
248
|
-
|
|
254
|
+
addClasses(tokens: string[]): void;
|
|
249
255
|
/**
|
|
250
256
|
* Removes classes from the element.
|
|
251
257
|
* @param tokens - The class names to remove.
|
|
252
258
|
*/
|
|
253
|
-
|
|
259
|
+
removeClasses(tokens: string[]): void;
|
|
254
260
|
/**
|
|
255
261
|
* Gets the classes of the element.
|
|
256
262
|
* @returns The classes of the element.
|
|
257
263
|
*/
|
|
258
|
-
|
|
264
|
+
getClasses(): string[];
|
|
259
265
|
/**
|
|
260
266
|
* Adds an event listener to the element.
|
|
261
267
|
* @param event - The event to listen for.
|
|
@@ -263,43 +269,50 @@ export declare class BrowserContext implements DOMContext {
|
|
|
263
269
|
* @param options - The options for the event listener.
|
|
264
270
|
* @returns A function to remove the event listener.
|
|
265
271
|
*/
|
|
266
|
-
|
|
272
|
+
on<E>(event: string, listener: (event: E, ctx: BrowserContext) => void, options?: HandlerOptions): Clear;
|
|
267
273
|
/**
|
|
268
274
|
* Returns `true` if the context is a browser DOM context.
|
|
269
275
|
* @returns `true` if the context is a browser DOM context.
|
|
270
276
|
* @deprecated Use `isBrowser()` instead.
|
|
271
277
|
*/
|
|
272
|
-
|
|
278
|
+
isBrowserDOM(): this is BrowserContext;
|
|
273
279
|
/**
|
|
274
280
|
* Returns `true` if the context is a browser context.
|
|
275
281
|
* @returns `true` if the context is a browser context.
|
|
276
282
|
*/
|
|
277
|
-
|
|
283
|
+
isBrowser(): this is BrowserContext;
|
|
278
284
|
/**
|
|
279
285
|
* Returns `true` if the context is a headless DOM context.
|
|
280
286
|
* @returns `true` if the context is a headless DOM context.
|
|
281
287
|
*/
|
|
282
|
-
|
|
288
|
+
isHeadlessDOM(): this is HeadlessContext;
|
|
283
289
|
/**
|
|
284
290
|
* Returns `true` if the context is a headless context.
|
|
285
291
|
* @returns `true` if the context is a headless context.
|
|
286
292
|
*/
|
|
287
|
-
|
|
293
|
+
isHeadless(): this is HeadlessContext;
|
|
288
294
|
/**
|
|
289
295
|
* Sets the style of the element.
|
|
290
296
|
* @param name - The name of the style to set.
|
|
291
297
|
* @param value - The value of the style to set.
|
|
292
298
|
*/
|
|
293
|
-
|
|
299
|
+
setStyle(name: string, value: string): void;
|
|
294
300
|
/**
|
|
295
301
|
* Gets the style of the element.
|
|
296
302
|
* @param name - The name of the style to get.
|
|
297
303
|
* @returns The value of the style.
|
|
298
304
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
getStyle(name: string): string;
|
|
306
|
+
makeAccessors(name: string): {
|
|
301
307
|
get: () => any;
|
|
302
308
|
set: (value: unknown) => void;
|
|
303
309
|
};
|
|
304
|
-
|
|
310
|
+
getWindow(): Window & typeof globalThis;
|
|
311
|
+
moveRangeBefore(startRef: DOMContext, endRef: DOMContext, targetRef: DOMContext): void;
|
|
312
|
+
removeRange(startRef: DOMContext, endRef: DOMContext): void;
|
|
313
|
+
removeAllBefore(ref: DOMContext): void;
|
|
314
|
+
private _detachedParent;
|
|
315
|
+
private _detachedNext;
|
|
316
|
+
detach(): void;
|
|
317
|
+
reattach(): void;
|
|
305
318
|
}
|
package/dom/dom-context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Clear, ProviderMark } from '../types/domain';
|
|
2
|
-
import { makeProviderMark } from '@tempots/core';
|
|
2
|
+
import { Primitive, makeProviderMark } from '@tempots/core';
|
|
3
3
|
import { BrowserContext } from './browser-context';
|
|
4
4
|
import { HeadlessContext } from './headless-context';
|
|
5
5
|
export { makeProviderMark };
|
|
@@ -37,12 +37,12 @@ export interface DOMContext {
|
|
|
37
37
|
* @param text - The text content for the new text node.
|
|
38
38
|
* @returns A new `DOMContext` with a reference to the new text node.
|
|
39
39
|
*/
|
|
40
|
-
makeChildText(text:
|
|
40
|
+
makeChildText(text: Primitive): DOMContext;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the text content of the current element.
|
|
43
43
|
* @param text - The text content to set.
|
|
44
44
|
*/
|
|
45
|
-
setText(text:
|
|
45
|
+
setText(text: Primitive): void;
|
|
46
46
|
/**
|
|
47
47
|
* Gets the text content of the current element or text node.
|
|
48
48
|
* @returns The text content of the current element or text node.
|
|
@@ -144,4 +144,38 @@ export interface DOMContext {
|
|
|
144
144
|
get(): unknown;
|
|
145
145
|
set(value: unknown): void;
|
|
146
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Moves a range of sibling nodes (from `startRef` to `endRef` inclusive)
|
|
149
|
+
* before `targetRef`. All three refs must be children of the same parent element.
|
|
150
|
+
*
|
|
151
|
+
* Used by `KeyedForEach` to reorder keyed items without recreating DOM nodes.
|
|
152
|
+
*
|
|
153
|
+
* @param startRef - The context whose reference marks the start of the range.
|
|
154
|
+
* @param endRef - The context whose reference marks the end of the range.
|
|
155
|
+
* @param targetRef - The context before which the range will be inserted.
|
|
156
|
+
*/
|
|
157
|
+
moveRangeBefore(startRef: DOMContext, endRef: DOMContext, targetRef: DOMContext): void;
|
|
158
|
+
/**
|
|
159
|
+
* Removes all sibling nodes between `startRef` and `endRef` (inclusive).
|
|
160
|
+
* Used for bulk removal of keyed entries.
|
|
161
|
+
*/
|
|
162
|
+
removeRange(startRef: DOMContext, endRef: DOMContext): void;
|
|
163
|
+
/**
|
|
164
|
+
* Creates a lightweight marker node (Comment node) as a boundary reference.
|
|
165
|
+
*/
|
|
166
|
+
makeMarker(): DOMContext;
|
|
167
|
+
/**
|
|
168
|
+
* Removes all sibling nodes before the given reference marker in one
|
|
169
|
+
* operation. Used as a fast path for clearing entire lists.
|
|
170
|
+
*/
|
|
171
|
+
removeAllBefore(ref: DOMContext): void;
|
|
172
|
+
/**
|
|
173
|
+
* Detaches the context's container element from the live DOM tree.
|
|
174
|
+
* Use before bulk insertions to avoid incremental layout recalculations.
|
|
175
|
+
*/
|
|
176
|
+
detach(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Re-attaches the container element after a detach.
|
|
179
|
+
*/
|
|
180
|
+
reattach(): void;
|
|
147
181
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Prop } from '@tempots/core';
|
|
1
|
+
import { Primitive, Prop } from '@tempots/core';
|
|
2
2
|
import { ProviderMark, Clear, Providers } from '../types/domain';
|
|
3
3
|
import { BrowserContext } from './browser-context';
|
|
4
4
|
import { DOMContext, HandlerOptions } from './dom-context';
|
|
@@ -24,11 +24,11 @@ declare abstract class HeadlessBase {
|
|
|
24
24
|
private readonly properties;
|
|
25
25
|
readonly children: HeadlessNode[];
|
|
26
26
|
constructor(parent: HeadlessBase | undefined);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
isElement(): this is HeadlessBase;
|
|
28
|
+
isText(): this is HeadlessText;
|
|
29
|
+
getText(): string;
|
|
30
|
+
removeChild(child: HeadlessNode): void;
|
|
31
|
+
remove(): void;
|
|
32
32
|
abstract isPortal(): this is HeadlessPortal;
|
|
33
33
|
/**
|
|
34
34
|
* Generates HTML output as an async stream of string chunks.
|
|
@@ -39,32 +39,32 @@ declare abstract class HeadlessBase {
|
|
|
39
39
|
* @yields String chunks of HTML content.
|
|
40
40
|
*/
|
|
41
41
|
abstract toHTMLStream(options?: StreamOptions): AsyncGenerator<string>;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
getPortals(): HeadlessPortal[];
|
|
43
|
+
elements(): HeadlessBase[];
|
|
44
44
|
abstract toHTML(): string;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
hasInnerHTML(): boolean;
|
|
46
|
+
getInnerHTML(): string;
|
|
47
|
+
getInnerText(): string;
|
|
48
|
+
hasInnerText(): boolean;
|
|
49
|
+
hasChildren(): boolean;
|
|
50
|
+
hasClasses(): boolean;
|
|
51
|
+
hasStyles(): boolean;
|
|
52
|
+
hasAttributes(): boolean;
|
|
53
|
+
hasHandlers(): boolean;
|
|
54
|
+
hasRenderableProperties(): boolean;
|
|
55
|
+
getById(id: string): HeadlessBase | undefined;
|
|
56
|
+
trigger<E>(event: string, detail: E): void;
|
|
57
|
+
click(): void;
|
|
58
|
+
on<E>(event: string, listener: (event: E, ctx: HeadlessContext) => void, ctx: HeadlessContext, options?: HandlerOptions): Clear;
|
|
59
|
+
addClasses(tokens: string[]): void;
|
|
60
|
+
removeClasses(tokens: string[]): void;
|
|
61
|
+
getClasses(): string[];
|
|
62
|
+
getAttributes(): [string, unknown][];
|
|
63
|
+
getVisibleAttributes(): (["class", string[]] | ["style", string | Record<string, string>] | [string, string])[];
|
|
64
|
+
setStyle(name: string, value: string): void;
|
|
65
|
+
getStyle(name: string): string;
|
|
66
|
+
getStyles(): Record<string, string>;
|
|
67
|
+
makeAccessors(name: string): {
|
|
68
68
|
get(): unknown;
|
|
69
69
|
set(value: unknown): void;
|
|
70
70
|
};
|
|
@@ -73,13 +73,13 @@ export declare class HeadlessElement extends HeadlessBase {
|
|
|
73
73
|
readonly tagName: string;
|
|
74
74
|
readonly namespace: string | undefined;
|
|
75
75
|
constructor(tagName: string, namespace: string | undefined, parent: HeadlessBase | undefined);
|
|
76
|
-
|
|
76
|
+
isPortal(): this is HeadlessPortal;
|
|
77
77
|
/**
|
|
78
78
|
* Builds the attributes string for this element.
|
|
79
79
|
* Returns an object containing the attributes string and any innerHTML value.
|
|
80
80
|
*/
|
|
81
|
-
private
|
|
82
|
-
|
|
81
|
+
private buildAttributesString;
|
|
82
|
+
toHTML(generatePlaceholders?: boolean): string;
|
|
83
83
|
/**
|
|
84
84
|
* Generates HTML output as an async stream of string chunks.
|
|
85
85
|
* Yields the opening tag, then each child's content, then the closing tag.
|
|
@@ -92,14 +92,14 @@ export declare class HeadlessElement extends HeadlessBase {
|
|
|
92
92
|
export declare class HeadlessPortal extends HeadlessBase {
|
|
93
93
|
readonly selector: string | HTMLElement;
|
|
94
94
|
constructor(selector: string | HTMLElement, parent: HeadlessBase | undefined);
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
isPortal(): this is HeadlessPortal;
|
|
96
|
+
toHTML(): string;
|
|
97
97
|
/**
|
|
98
98
|
* Portals don't render inline - they render at their target selector.
|
|
99
99
|
* This method yields nothing for the inline position.
|
|
100
100
|
*/
|
|
101
101
|
toHTMLStream(options?: StreamOptions): AsyncGenerator<string>;
|
|
102
|
-
|
|
102
|
+
contentToHTML(generatePlaceholders?: boolean): string;
|
|
103
103
|
/**
|
|
104
104
|
* Streams the portal's content HTML.
|
|
105
105
|
* Unlike toHTMLStream, this yields the actual content for rendering at the target location.
|
|
@@ -113,10 +113,10 @@ export declare class HeadlessText {
|
|
|
113
113
|
text: string;
|
|
114
114
|
readonly id: string;
|
|
115
115
|
constructor(text: string);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
isElement(): this is HeadlessElement;
|
|
117
|
+
isText(): this is HeadlessText;
|
|
118
|
+
getText(): string;
|
|
119
|
+
toHTML(): string;
|
|
120
120
|
/**
|
|
121
121
|
* Streams the text content as a single chunk.
|
|
122
122
|
*
|
|
@@ -135,13 +135,14 @@ export declare class HeadlessContext implements DOMContext {
|
|
|
135
135
|
readonly container: HeadlessContainer;
|
|
136
136
|
readonly providers: Providers;
|
|
137
137
|
constructor(element: HeadlessBase, reference: HeadlessNode | undefined, container: HeadlessContainer, providers: Providers);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
appendOrInsert(element: HeadlessNode): void;
|
|
139
|
+
makeChildElement(tagName: string, namespace: string | undefined): DOMContext;
|
|
140
|
+
makeChildText(text: Primitive): DOMContext;
|
|
141
|
+
setText(text: Primitive): void;
|
|
142
|
+
getText(): string;
|
|
143
|
+
makeRef(): DOMContext;
|
|
144
|
+
makeMarker(): DOMContext;
|
|
145
|
+
makePortal(selector: string | HTMLElement): DOMContext;
|
|
145
146
|
/**
|
|
146
147
|
* Sets a provider for the given provider mark.
|
|
147
148
|
*
|
|
@@ -149,25 +150,30 @@ export declare class HeadlessContext implements DOMContext {
|
|
|
149
150
|
* @param value - The provider to set for the given mark.
|
|
150
151
|
* @returns A new `DOMContext` instance with the specified provider.
|
|
151
152
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
setProvider<T>(mark: ProviderMark<T>, value: T, onUse: undefined | (() => void)): DOMContext;
|
|
154
|
+
getProvider<T>(mark: ProviderMark<T>): {
|
|
154
155
|
value: T;
|
|
155
156
|
onUse: (() => void) | undefined;
|
|
156
157
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
158
|
+
clear(removeTree: boolean): void;
|
|
159
|
+
on<E>(event: string, listener: (event: E, ctx: HeadlessContext) => void): Clear;
|
|
160
|
+
addClasses(tokens: string[]): void;
|
|
161
|
+
removeClasses(tokens: string[]): void;
|
|
162
|
+
getClasses(): string[];
|
|
163
|
+
isBrowserDOM(): this is BrowserContext;
|
|
164
|
+
isBrowser(): this is BrowserContext;
|
|
165
|
+
isHeadlessDOM(): this is HeadlessContext;
|
|
166
|
+
isHeadless(): this is HeadlessContext;
|
|
167
|
+
setStyle(name: string, value: string): void;
|
|
168
|
+
getStyle(name: string): string;
|
|
169
|
+
makeAccessors(name: string): {
|
|
169
170
|
get(): unknown;
|
|
170
171
|
set(value: unknown): void;
|
|
171
172
|
};
|
|
173
|
+
moveRangeBefore(startRef: DOMContext, endRef: DOMContext, targetRef: DOMContext): void;
|
|
174
|
+
removeRange(startRef: DOMContext, endRef: DOMContext): void;
|
|
175
|
+
removeAllBefore(ref: DOMContext): void;
|
|
176
|
+
detach(): void;
|
|
177
|
+
reattach(): void;
|
|
172
178
|
}
|
|
173
179
|
export {};
|