@sigil-dev/types 0.9.32 → 0.10.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/index.d.ts +31 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -130,7 +130,38 @@ interface GrimoireState {
|
|
|
130
130
|
data?: Record<string, unknown>;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* What `<Window>`, `<Document>` and `<Body>` take: event handlers, which the
|
|
135
|
+
* compiler attaches to `window`, `document` or `document.body` (and removes
|
|
136
|
+
* with the component). `onKeydown` and `onKeyDown` both mean "keydown".
|
|
137
|
+
*/
|
|
138
|
+
type GlobalTargetProps<M> = {
|
|
139
|
+
[K in keyof M & string as `on${Capitalize<K>}`]?: (event: M[K]) => unknown;
|
|
140
|
+
} & {
|
|
141
|
+
// any other event, by the name the compiler lowercases
|
|
142
|
+
[handler: `on${string}`]: ((event: any) => unknown) | undefined;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* `<Body onClick={…} />`: handlers on `document.body`. Only a name for the
|
|
147
|
+
* compiler, which replaces it; there is no `Body` at runtime.
|
|
148
|
+
*/
|
|
149
|
+
declare const Body: (props: GlobalTargetProps<HTMLElementEventMap>) => unknown;
|
|
150
|
+
|
|
151
|
+
interface Document {
|
|
152
|
+
/**
|
|
153
|
+
* Not a real property: what `<Document onVisibilitychange={…} />` takes.
|
|
154
|
+
* TypeScript reads `<Document>` as a class and its props from here.
|
|
155
|
+
*/
|
|
156
|
+
readonly props?: GlobalTargetProps<DocumentEventMap>;
|
|
157
|
+
}
|
|
158
|
+
|
|
133
159
|
interface Window {
|
|
160
|
+
/**
|
|
161
|
+
* Not a real property: what `<Window onKeydown={…} />` takes. TypeScript
|
|
162
|
+
* reads `<Window>` as a class and its props from here.
|
|
163
|
+
*/
|
|
164
|
+
readonly props?: GlobalTargetProps<WindowEventMap>;
|
|
134
165
|
/**
|
|
135
166
|
* Mirrors `__grimoire_state__`. The element carries the authoritative
|
|
136
167
|
* copy, but a late patch script can arrive before the element is parsed,
|