@timmo001/groundwork-ui 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/on.ts +16 -2
package/package.json
CHANGED
package/src/on.ts
CHANGED
|
@@ -12,12 +12,26 @@ export type { GwEventMap } from "./events.js";
|
|
|
12
12
|
|
|
13
13
|
type EventTag = keyof GwEventMap;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Each event-firing element's class, by tag. An app only declares the tags it
|
|
17
|
+
* imports, so the ones it doesn't load are `never` rather than an error.
|
|
18
|
+
*/
|
|
19
|
+
type Loaded = {
|
|
20
|
+
[T in EventTag]: T extends keyof HTMLElementTagNameMap
|
|
21
|
+
? HTMLElementTagNameMap[T]
|
|
22
|
+
: never;
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
/** A `gw-` element that fires events of its own. */
|
|
16
|
-
export type GwEventTarget =
|
|
26
|
+
export type GwEventTarget = Loaded[EventTag];
|
|
17
27
|
|
|
18
28
|
/** The events an element fires, found from the tag its class is defined for. */
|
|
19
29
|
export type GwEventsOf<E extends GwEventTarget> = {
|
|
20
|
-
[T in EventTag]:
|
|
30
|
+
[T in EventTag]: [Loaded[T]] extends [never]
|
|
31
|
+
? never
|
|
32
|
+
: E extends Loaded[T]
|
|
33
|
+
? GwEventMap[T]
|
|
34
|
+
: never;
|
|
21
35
|
}[EventTag];
|
|
22
36
|
|
|
23
37
|
/**
|