@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/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempots/dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.1",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"main": "./index.cjs",
|
|
6
7
|
"module": "./index.js",
|
|
7
8
|
"types": "./index.d.ts",
|
|
@@ -14,8 +15,8 @@
|
|
|
14
15
|
},
|
|
15
16
|
"license": "Apache-2.0",
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@tempots/core": "^
|
|
18
|
-
"@tempots/render": "^0.0.
|
|
18
|
+
"@tempots/core": "^3.0.0",
|
|
19
|
+
"@tempots/render": "^0.0.3"
|
|
19
20
|
},
|
|
20
21
|
"description": "Fully-typed frontend framework alternative to React and Angular",
|
|
21
22
|
"keywords": [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Renderable, SplitNValue } from '../types/domain';
|
|
2
|
-
import { Value } from '@tempots/core';
|
|
2
|
+
import { Signal, Value } from '@tempots/core';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a renderable for an HTML attribute with the specified name and value.
|
|
5
5
|
*
|
|
@@ -759,3 +759,29 @@ export declare const mathAttr: {
|
|
|
759
759
|
xmlns: (value: SplitNValue<string>) => Renderable;
|
|
760
760
|
xref: (value: SplitNValue<string>) => Renderable;
|
|
761
761
|
};
|
|
762
|
+
/**
|
|
763
|
+
* Creates a renderable that toggles a CSS class based on O(1) selection matching.
|
|
764
|
+
*
|
|
765
|
+
* Instead of creating a `computed` per row that re-evaluates when the source changes
|
|
766
|
+
* (O(n) for n rows), this uses `createSelector` from `@tempots/core` to only update
|
|
767
|
+
* the two rows that actually change (the previously selected and newly selected).
|
|
768
|
+
*
|
|
769
|
+
* A shared selector is automatically created per source signal and cached via WeakMap.
|
|
770
|
+
*
|
|
771
|
+
* @param source - The signal containing the currently selected value.
|
|
772
|
+
* @param key - The static key to compare against (e.g., the row's ID).
|
|
773
|
+
* @param activeClass - The CSS class(es) to toggle (space-separated). Defaults to `'danger'`.
|
|
774
|
+
* @param equals - Optional equality function. Defaults to `===`.
|
|
775
|
+
* @returns A renderable that adds/removes the class based on selection state.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```ts
|
|
779
|
+
* const selected = prop(0)
|
|
780
|
+
* html.tr(
|
|
781
|
+
* selectedClass(selected, item.id, 'danger'),
|
|
782
|
+
* // ...
|
|
783
|
+
* )
|
|
784
|
+
* ```
|
|
785
|
+
* @public
|
|
786
|
+
*/
|
|
787
|
+
export declare const selectedClass: <T>(source: Signal<T>, key: T, activeClass?: string, equals?: (a: T, b: T) => boolean) => Renderable;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Renderable } from '../types/domain';
|
|
2
|
+
import { DOMContext, HandlerOptions } from '../dom/dom-context';
|
|
3
|
+
/**
|
|
4
|
+
* Provides type-safe delegated event handlers for all HTML events.
|
|
5
|
+
*
|
|
6
|
+
* The `delegate` object is a proxy that creates event handlers attached to the
|
|
7
|
+
* **container element** rather than individual children. Events are matched
|
|
8
|
+
* against a CSS selector using `Element.closest()`, making this ideal for lists
|
|
9
|
+
* and other containers with many similar children.
|
|
10
|
+
*
|
|
11
|
+
* Unlike `on`, which attaches one listener per element, `delegate` attaches a
|
|
12
|
+
* single listener on the container regardless of how many children match.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Delegated click on list items — one listener on the <ul>
|
|
17
|
+
* html.ul(
|
|
18
|
+
* delegate.click('li', (event, ctx) => {
|
|
19
|
+
* const li = (event.target as Element).closest('li')!
|
|
20
|
+
* console.log('Clicked:', li.textContent)
|
|
21
|
+
* }),
|
|
22
|
+
* ForEach(items, (item) => html.li(item))
|
|
23
|
+
* )
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Delegated click on buttons inside a toolbar
|
|
29
|
+
* html.div(
|
|
30
|
+
* delegate.click('button', (event) => {
|
|
31
|
+
* const btn = (event.target as Element).closest('button')!
|
|
32
|
+
* console.log('Button clicked:', btn.dataset.action)
|
|
33
|
+
* }),
|
|
34
|
+
* html.button(attr.data('action', 'save'), 'Save'),
|
|
35
|
+
* html.button(attr.data('action', 'cancel'), 'Cancel')
|
|
36
|
+
* )
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Delegated events rely on event bubbling. Events that do not bubble (such as
|
|
41
|
+
* `focus`, `blur`, `mouseenter`, `mouseleave`) will not be captured by
|
|
42
|
+
* delegation. Use the regular `on` handler for those events.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export declare const delegate: {
|
|
47
|
+
abort: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
48
|
+
afterprint: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
49
|
+
animationcancel: (selector: string, handler: (event: AnimationEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
50
|
+
animationend: (selector: string, handler: (event: AnimationEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
51
|
+
animationiteration: (selector: string, handler: (event: AnimationEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
52
|
+
animationstart: (selector: string, handler: (event: AnimationEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
53
|
+
auxclick: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
54
|
+
beforeinput: (selector: string, handler: (event: InputEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
55
|
+
beforeprint: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
56
|
+
beforeunload: (selector: string, handler: (event: BeforeUnloadEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
57
|
+
blur: (selector: string, handler: (event: FocusEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
58
|
+
cancel: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
59
|
+
canplay: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
60
|
+
canplaythrough: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
61
|
+
change: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
62
|
+
click: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
63
|
+
close: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
64
|
+
compositionend: (selector: string, handler: (event: CompositionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
65
|
+
compositionstart: (selector: string, handler: (event: CompositionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
66
|
+
compositionupdate: (selector: string, handler: (event: CompositionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
67
|
+
contextmenu: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
68
|
+
copy: (selector: string, handler: (event: ClipboardEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
69
|
+
cuechange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
70
|
+
cut: (selector: string, handler: (event: ClipboardEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
71
|
+
dblclick: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
72
|
+
drag: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
73
|
+
dragend: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
74
|
+
dragenter: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
75
|
+
dragexit: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
76
|
+
dragleave: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
77
|
+
dragover: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
78
|
+
dragstart: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
79
|
+
drop: (selector: string, handler: (event: DragEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
80
|
+
durationchange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
81
|
+
emptied: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
82
|
+
ended: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
83
|
+
error: (selector: string, handler: (event: ErrorEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
84
|
+
focus: (selector: string, handler: (event: FocusEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
85
|
+
focusin: (selector: string, handler: (event: FocusEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
86
|
+
focusout: (selector: string, handler: (event: FocusEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
87
|
+
formdata: (selector: string, handler: (event: FormDataEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
88
|
+
fullscreenchange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
89
|
+
fullscreenerror: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
90
|
+
gotpointercapture: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
91
|
+
hashchange: (selector: string, handler: (event: HashChangeEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
92
|
+
input: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
93
|
+
invalid: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
94
|
+
keydown: (selector: string, handler: (event: KeyboardEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
95
|
+
keypress: (selector: string, handler: (event: KeyboardEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
96
|
+
keyup: (selector: string, handler: (event: KeyboardEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
97
|
+
languagechange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
98
|
+
load: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
99
|
+
loadeddata: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
100
|
+
loadedmetadata: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
101
|
+
loadend: (selector: string, handler: (event: ProgressEvent<EventTarget>, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
102
|
+
loadstart: (selector: string, handler: (event: ProgressEvent<EventTarget>, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
103
|
+
lostpointercapture: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
104
|
+
message: (selector: string, handler: (event: MessageEvent<any>, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
105
|
+
messageerror: (selector: string, handler: (event: MessageEvent<any>, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
106
|
+
mousedown: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
107
|
+
mouseenter: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
108
|
+
mouseleave: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
109
|
+
mousemove: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
110
|
+
mouseout: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
111
|
+
mouseover: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
112
|
+
mouseup: (selector: string, handler: (event: MouseEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
113
|
+
offline: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
114
|
+
online: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
115
|
+
orientationchange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
116
|
+
pagehide: (selector: string, handler: (event: PageTransitionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
117
|
+
pageshow: (selector: string, handler: (event: PageTransitionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
118
|
+
paste: (selector: string, handler: (event: ClipboardEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
119
|
+
pause: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
120
|
+
play: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
121
|
+
playing: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
122
|
+
pointercancel: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
123
|
+
pointerdown: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
124
|
+
pointerenter: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
125
|
+
pointerleave: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
126
|
+
pointerlockchange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
127
|
+
pointerlockerror: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
128
|
+
pointermove: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
129
|
+
pointerout: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
130
|
+
pointerover: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
131
|
+
pointerrawupdate: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
132
|
+
pointerup: (selector: string, handler: (event: PointerEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
133
|
+
popstate: (selector: string, handler: (event: PopStateEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
134
|
+
progress: (selector: string, handler: (event: ProgressEvent<EventTarget>, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
135
|
+
ratechange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
136
|
+
readystatechange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
137
|
+
rejectionhandled: (selector: string, handler: (event: PromiseRejectionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
138
|
+
reset: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
139
|
+
resize: (selector: string, handler: (event: UIEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
140
|
+
scroll: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
141
|
+
scrollend: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
142
|
+
securitypolicyviolation: (selector: string, handler: (event: SecurityPolicyViolationEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
143
|
+
seeked: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
144
|
+
seeking: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
145
|
+
select: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
146
|
+
selectionchange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
147
|
+
selectstart: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
148
|
+
slotchange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
149
|
+
stalled: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
150
|
+
storage: (selector: string, handler: (event: StorageEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
151
|
+
submit: (selector: string, handler: (event: SubmitEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
152
|
+
suspend: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
153
|
+
timeupdate: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
154
|
+
toggle: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
155
|
+
touchcancel: (selector: string, handler: (event: TouchEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
156
|
+
touchend: (selector: string, handler: (event: TouchEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
157
|
+
touchmove: (selector: string, handler: (event: TouchEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
158
|
+
touchstart: (selector: string, handler: (event: TouchEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
159
|
+
transitioncancel: (selector: string, handler: (event: TransitionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
160
|
+
transitionend: (selector: string, handler: (event: TransitionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
161
|
+
transitionrun: (selector: string, handler: (event: TransitionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
162
|
+
transitionstart: (selector: string, handler: (event: TransitionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
163
|
+
unhandledrejection: (selector: string, handler: (event: PromiseRejectionEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
164
|
+
unload: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
165
|
+
visibilitychange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
166
|
+
volumechange: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
167
|
+
waiting: (selector: string, handler: (event: Event, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
168
|
+
wheel: (selector: string, handler: (event: WheelEvent, ctx: DOMContext) => void, options?: HandlerOptions) => Renderable;
|
|
169
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KeyedForEach } from './shared';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MapText } from './shared';
|
package/renderable/shared.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DOMContext } from '../dom/dom-context';
|
|
2
2
|
import { DOM_RENDERABLE_TYPE } from '../types/domain';
|
|
3
3
|
export declare const domKit: import('@tempots/render').RenderKit<DOMContext, typeof DOM_RENDERABLE_TYPE>;
|
|
4
|
-
export declare const Empty: import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Fragment: (...children: import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>[]) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, When: (condition: import('@tempots/core').Value<boolean>, then: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Unless: (condition: import('@tempots/core').Value<boolean>, then: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, ForEach: <T>(value: import('@tempots/core').Value<T[]>, item: (value: import('@tempots/core').Signal<T>, position: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, separator?: ((pos: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Repeat: (times: import('@tempots/core').Value<number>, element: (index: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, separator?: ((pos: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOf: <T extends Record<string, unknown>>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfField: <T extends { [_ in K]: string; }, K extends string>(match: import('@tempots/core').Value<T>, field: K, cases: import('@tempots/render').OneOfFieldOptions<T, K, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfKind: <T extends {
|
|
4
|
+
export declare const Empty: import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Fragment: (...children: import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>[]) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, When: (condition: import('@tempots/core').Value<boolean>, then: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Unless: (condition: import('@tempots/core').Value<boolean>, then: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, ForEach: <T>(value: import('@tempots/core').Value<T[]>, item: (value: import('@tempots/core').Signal<T>, position: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, separator?: ((pos: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, KeyedForEach: <T, K>(value: import('@tempots/core').Value<T[]>, key: (item: T) => K, item: (value: import('@tempots/core').Signal<T>, position: import('@tempots/core').KeyedPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, separator?: ((pos: import('@tempots/core').KeyedPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Repeat: (times: import('@tempots/core').Value<number>, element: (index: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, separator?: ((pos: import('@tempots/core').ElementPosition) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOf: <T extends Record<string, unknown>>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfField: <T extends { [_ in K]: string; }, K extends string>(match: import('@tempots/core').Value<T>, field: K, cases: import('@tempots/render').OneOfFieldOptions<T, K, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfKind: <T extends {
|
|
5
5
|
kind: string;
|
|
6
6
|
}>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfKindOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfType: <T extends {
|
|
7
7
|
type: string;
|
|
8
|
-
}>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfTypeOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfValue: <T extends symbol | number | string>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfValueOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfTuple: <T extends string, V>(match: import('@tempots/core').Value<[T, V]>, cases: import('@tempots/render').OneOfTupleOptions<T, V, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, MapSignal: <T>(value: import('@tempots/core').Value<T>, fn: (value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Ensure: <T>(value: import('@tempots/render').NillifyValue<T>, then: (value: import('@tempots/core').Signal<T & {} extends infer T_1 ? { [P in keyof T_1]: T_1[P]; } : never>) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, EnsureAll: <T extends readonly import('@tempots/core').Value<unknown>[]>(...signals: { [K in keyof T]: import('@tempots/render').NillifyValue<T[K]>; }) => (callback: (...values: { [K_1 in keyof T]: import('@tempots/core').Signal<(T[K_1] extends import('@tempots/core').Value<infer U> ? U : never) & {} extends infer T_1 ? { [P in keyof T_1]: T_1[P]; } : never>; }) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, NotEmpty: <T>(value: import('@tempots/core').Value<T[]>, display: (value: import('@tempots/core').Signal<T[]>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, whenEmpty?: (() => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Task: <T>(task: () => Promise<T>, options: import('@tempots/render').TaskOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE> | ((value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>)) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Async: <T>(promise: Promise<T>, options: import('@tempots/render').AsyncOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE> | ((value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>)) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OnDispose: (...fns: (import('@tempots/render').DisposeCallback<DOMContext> | import('@tempots/render').WithDispose<DOMContext>)[]) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Conjunction: (separator: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, options?: import('@tempots/render').ConjunctionOptions<DOMContext, typeof DOM_RENDERABLE_TYPE> | undefined) => (pos: import('@tempots/core').Signal<import('@tempots/core').ElementPosition>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, WithScope: (fn: (scope: import('@tempots/core').DisposalScope) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, WithProvider: (fn: (opts: import('@tempots/render').ProviderOptions<DOMContext>) => void | import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Provide: <T, O>(provider: import('@tempots/render').Provider<T, O, DOMContext>, options: O, child: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Use: <T>(provider: import('@tempots/render').Provider<T, unknown, DOMContext>, child: (provider: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, UseMany: <P extends import('@tempots/render').Provider<unknown, unknown, DOMContext>[]>(...providers: P) => (child: (...values: import('@tempots/render').ToProviderTypes<P>) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, handleValueOrSignal: <T, R>(value: import('@tempots/core').Value<T>, onSignal: (signal: import('@tempots/core').Signal<T>) => R, onStatic: (literal: T) => R) => R, createReactiveRenderable: <T>(ctx: DOMContext, signal: import('@tempots/core').Signal<T>, render: (value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Clear, renderableOfTNode: (child: import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>;
|
|
8
|
+
}>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfTypeOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfValue: <T extends symbol | number | string>(match: import('@tempots/core').Value<T>, cases: import('@tempots/render').OneOfValueOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OneOfTuple: <T extends string, V>(match: import('@tempots/core').Value<[T, V]>, cases: import('@tempots/render').OneOfTupleOptions<T, V, DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, MapSignal: <T>(value: import('@tempots/core').Value<T>, fn: (value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, MapText: <T>(source: import('@tempots/core').Signal<T>, fn: (value: T) => string) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Ensure: <T>(value: import('@tempots/render').NillifyValue<T>, then: (value: import('@tempots/core').Signal<T & {} extends infer T_1 ? { [P in keyof T_1]: T_1[P]; } : never>) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, EnsureAll: <T extends readonly import('@tempots/core').Value<unknown>[]>(...signals: { [K in keyof T]: import('@tempots/render').NillifyValue<T[K]>; }) => (callback: (...values: { [K_1 in keyof T]: import('@tempots/core').Signal<(T[K_1] extends import('@tempots/core').Value<infer U> ? U : never) & {} extends infer T_1 ? { [P in keyof T_1]: T_1[P]; } : never>; }) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, otherwise?: (() => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, NotEmpty: <T>(value: import('@tempots/core').Value<T[]>, display: (value: import('@tempots/core').Signal<T[]>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, whenEmpty?: (() => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>) | undefined) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Task: <T>(task: () => Promise<T>, options: import('@tempots/render').TaskOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE> | ((value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>)) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Async: <T>(promise: Promise<T>, options: import('@tempots/render').AsyncOptions<T, DOMContext, typeof DOM_RENDERABLE_TYPE> | ((value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>)) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, OnDispose: (...fns: (import('@tempots/render').DisposeCallback<DOMContext> | import('@tempots/render').WithDispose<DOMContext>)[]) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Conjunction: (separator: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>, options?: import('@tempots/render').ConjunctionOptions<DOMContext, typeof DOM_RENDERABLE_TYPE> | undefined) => (pos: import('@tempots/core').Signal<import('@tempots/core').ElementPosition>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, WithScope: (fn: (scope: import('@tempots/core').DisposalScope) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, WithProvider: (fn: (opts: import('@tempots/render').ProviderOptions<DOMContext>) => void | import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Provide: <T, O>(provider: import('@tempots/render').Provider<T, O, DOMContext>, options: O, child: () => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, Use: <T>(provider: import('@tempots/render').Provider<T, unknown, DOMContext>, child: (provider: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, UseMany: <P extends import('@tempots/render').Provider<unknown, unknown, DOMContext>[]>(...providers: P) => (child: (...values: import('@tempots/render').ToProviderTypes<P>) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>, handleValueOrSignal: <T, R>(value: import('@tempots/core').Value<T>, onSignal: (signal: import('@tempots/core').Signal<T>) => R, onStatic: (literal: T) => R) => R, createReactiveRenderable: <T>(ctx: DOMContext, signal: import('@tempots/core').Signal<T>, render: (value: T) => import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Clear, renderableOfTNode: (child: import('@tempots/core').TNode<DOMContext, typeof DOM_RENDERABLE_TYPE>) => import('@tempots/core').Renderable<DOMContext, typeof DOM_RENDERABLE_TYPE>;
|
package/renderable/text.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Renderable } from '../types/domain';
|
|
2
|
-
import { Signal, Value } from '@tempots/core';
|
|
2
|
+
import { Primitive, Signal, Value } from '@tempots/core';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
export declare const _staticText: (text:
|
|
6
|
+
export declare const _staticText: (text: Primitive) => Renderable;
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
export declare const _signalText: (signal: Signal<
|
|
10
|
+
export declare const _signalText: (signal: Signal<Primitive>) => Renderable;
|
|
11
11
|
/**
|
|
12
12
|
* Creates a renderable text node.
|
|
13
13
|
*
|
|
@@ -15,4 +15,4 @@ export declare const _signalText: (signal: Signal<string>) => Renderable;
|
|
|
15
15
|
* @returns A renderable text node.
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
|
-
export declare const TextNode: (value: Value<
|
|
18
|
+
export declare const TextNode: (value: Value<Primitive>) => Renderable;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CompiledTemplate, TemplateNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Walk a renderable tree with kind metadata and build a DOM template
|
|
4
|
+
* programmatically (no innerHTML — avoids HTML parser normalization
|
|
5
|
+
* issues with `<tr>`, `<td>`, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Returns null if the tree contains an unknown kind that can't be templated.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildTemplate(renderable: TemplateNode, doc: Document): CompiledTemplate | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TemplateEngine } from '@tempots/render';
|
|
2
|
+
import { DOMContext } from '../dom/dom-context';
|
|
3
|
+
import { DOM_RENDERABLE_TYPE } from '../types/domain';
|
|
4
|
+
/**
|
|
5
|
+
* DOM-specific template engine for cloneNode(true) optimization.
|
|
6
|
+
*
|
|
7
|
+
* Builds templates programmatically (no innerHTML) to avoid HTML parser
|
|
8
|
+
* normalization issues with elements like `<tr>`, `<td>`, etc.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const domTemplateEngine: TemplateEngine<DOMContext, typeof DOM_RENDERABLE_TYPE>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CompiledTemplate, DynamicTextSlot, RenderableSlot } from './types';
|
|
2
|
+
import { Clear } from '@tempots/core';
|
|
3
|
+
import { DOMContext } from '../dom/dom-context';
|
|
4
|
+
/**
|
|
5
|
+
* Clone a compiled template and wire up dynamic bindings.
|
|
6
|
+
*
|
|
7
|
+
* Optimizations vs naive approach:
|
|
8
|
+
* - Pre-allocated topNodes array (no Array.from) — minimal allocation
|
|
9
|
+
* - Pre-allocated clears array — saves dynamic resizing
|
|
10
|
+
* - Dynamic-text onChange stored directly as Clear — no wrapper closure
|
|
11
|
+
*
|
|
12
|
+
* Returns `{ clear, startCtx }` where startCtx is a DOMContext whose
|
|
13
|
+
* reference is the first top-level node of the clone. This lets
|
|
14
|
+
* KeyedForEach skip creating a separate Comment start marker.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function hydrateClone(template: CompiledTemplate, ctx: DOMContext, slots: readonly (DynamicTextSlot | RenderableSlot)[]): {
|
|
19
|
+
clear: Clear;
|
|
20
|
+
startCtx: DOMContext;
|
|
21
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Clear, Signal } from '@tempots/core';
|
|
2
|
+
import { DOMContext } from '../dom/dom-context';
|
|
3
|
+
/**
|
|
4
|
+
* Describes a dynamic slot in a compiled template.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface SlotInfo {
|
|
9
|
+
/** childNodes indices from the template fragment root to the target node */
|
|
10
|
+
path: number[];
|
|
11
|
+
/** The kind of dynamic binding this slot represents */
|
|
12
|
+
kind: 'dynamic-attr' | 'dynamic-text' | 'slot';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A compiled DOM template ready for cloning.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export interface CompiledTemplate {
|
|
20
|
+
/** The template fragment to clone via `cloneNode(true)` */
|
|
21
|
+
fragment: DocumentFragment;
|
|
22
|
+
/** Slot descriptors in build order (matches extractSlots order) */
|
|
23
|
+
slots: SlotInfo[];
|
|
24
|
+
/** Number of top-level child nodes in the fragment */
|
|
25
|
+
topNodeCount: number;
|
|
26
|
+
}
|
|
27
|
+
/** An element renderable with tag name and children. */
|
|
28
|
+
export interface ElementNode {
|
|
29
|
+
readonly kind: 'element';
|
|
30
|
+
readonly tag: string;
|
|
31
|
+
readonly ns?: string;
|
|
32
|
+
readonly children: readonly TemplateNode[];
|
|
33
|
+
}
|
|
34
|
+
/** A static attribute baked into the template. */
|
|
35
|
+
export interface StaticAttrNode {
|
|
36
|
+
readonly kind: 'static-attr';
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly value: string;
|
|
39
|
+
}
|
|
40
|
+
/** A dynamic attribute that needs runtime binding. */
|
|
41
|
+
export interface DynamicAttrNode {
|
|
42
|
+
readonly kind: 'dynamic-attr';
|
|
43
|
+
readonly render: (ctx: DOMContext) => Clear;
|
|
44
|
+
}
|
|
45
|
+
/** A static text node baked into the template. */
|
|
46
|
+
export interface StaticTextNode {
|
|
47
|
+
readonly kind: 'static-text';
|
|
48
|
+
readonly text: string;
|
|
49
|
+
}
|
|
50
|
+
/** A dynamic text node bound to a signal. */
|
|
51
|
+
export interface DynamicTextNode {
|
|
52
|
+
readonly kind: 'dynamic-text';
|
|
53
|
+
readonly source: Signal<unknown>;
|
|
54
|
+
readonly transform: (v: unknown) => string;
|
|
55
|
+
}
|
|
56
|
+
/** A fragment that inlines its children (no DOM node). */
|
|
57
|
+
export interface FragmentNode {
|
|
58
|
+
readonly kind: 'fragment';
|
|
59
|
+
readonly children: readonly TemplateNode[];
|
|
60
|
+
}
|
|
61
|
+
/** An empty renderable (no DOM output). */
|
|
62
|
+
export interface EmptyNode {
|
|
63
|
+
readonly kind: 'empty';
|
|
64
|
+
}
|
|
65
|
+
/** An opaque renderable without kind metadata (e.g. When, ForEach). */
|
|
66
|
+
export interface OpaqueNode {
|
|
67
|
+
readonly kind?: undefined;
|
|
68
|
+
readonly render: (ctx: DOMContext) => Clear;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Discriminated union of all renderable node shapes the template engine
|
|
72
|
+
* can encounter when walking a renderable tree.
|
|
73
|
+
*
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
export type TemplateNode = ElementNode | StaticAttrNode | DynamicAttrNode | StaticTextNode | DynamicTextNode | FragmentNode | EmptyNode | OpaqueNode;
|
|
77
|
+
/** A dynamic-text slot carries a signal source and transform function. */
|
|
78
|
+
export interface DynamicTextSlot {
|
|
79
|
+
readonly source: Signal<unknown>;
|
|
80
|
+
readonly transform: (v: unknown) => string;
|
|
81
|
+
}
|
|
82
|
+
/** A renderable slot (dynamic-attr or opaque) carries a render function. */
|
|
83
|
+
export interface RenderableSlot {
|
|
84
|
+
readonly render: (ctx: DOMContext) => Clear;
|
|
85
|
+
}
|
package/types/domain.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ export declare const domRenderable: <CTX extends DOMContext = DOMContext>(render
|
|
|
127
127
|
* @typeParam CTX - The type of DOMContext (defaults to DOMContext)
|
|
128
128
|
* @public
|
|
129
129
|
*/
|
|
130
|
-
export type TNode<CTX extends DOMContext = DOMContext> = Renderable<CTX> | string | Signal<string> | undefined | null | Renderable<CTX>[];
|
|
130
|
+
export type TNode<CTX extends DOMContext = DOMContext> = Renderable<CTX> | string | number | boolean | Signal<string> | Signal<number> | Signal<boolean> | undefined | null | Renderable<CTX>[];
|
|
131
131
|
export type { Providers } from '@tempots/render';
|
|
132
132
|
/**
|
|
133
133
|
* Represents the size of an object with width and height.
|