@glint/template 1.6.3-unstable.1c9c8a8 → 1.6.3-unstable.49ffa07
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/-private/dsl/elements.d.ts +257 -140
- package/-private/dsl/lib.dom.augmentation.d.ts +138 -632
- package/-private/dsl/types.d.ts +34 -12
- package/package.json +1 -1
package/-private/dsl/types.d.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './elements';
|
|
2
2
|
import { AttrValue } from '../index';
|
|
3
|
-
import {
|
|
3
|
+
import { GlintElementRegistry } from './lib.dom.augmentation';
|
|
4
|
+
|
|
5
|
+
type Registry = GlintElementRegistry;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This doesn't generate _totally_ unique mappings, but they all have the same attributes.
|
|
9
|
+
*
|
|
10
|
+
* For example, given T = HTMLDivElement,
|
|
11
|
+
* we get back:
|
|
12
|
+
* - "HTMLTableCaptionElement"
|
|
13
|
+
* | "HTMLDivElement"
|
|
14
|
+
* | "HTMLHeadingElement"
|
|
15
|
+
* | "HTMLParagraphElement"
|
|
16
|
+
*
|
|
17
|
+
* And for the purposes of attribute lookup, that's good enough.
|
|
18
|
+
*/
|
|
19
|
+
type Lookup<T> = {
|
|
20
|
+
[K in keyof Registry]: [Registry[K]] extends [T] // check assignability in one direction
|
|
21
|
+
? [T] extends [Registry[K]] // and in the other
|
|
22
|
+
? K // if both true, exact match
|
|
23
|
+
: never
|
|
24
|
+
: never;
|
|
25
|
+
}[keyof Registry];
|
|
4
26
|
|
|
5
27
|
/**
|
|
6
28
|
* A utility for constructing the type of an environment's `resolveOrReturn` from
|
|
@@ -25,13 +47,13 @@ export type MathMlElementForTagName<Name extends string> =
|
|
|
25
47
|
|
|
26
48
|
type WithDataAttributes<T> = T & Record<`data-${string}`, AttrValue>;
|
|
27
49
|
|
|
28
|
-
export type AttributesForElement<
|
|
29
|
-
|
|
30
|
-
K
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
export type AttributesForElement<Elem extends Element, K = Lookup<Elem>> =
|
|
51
|
+
// Is K in the HTML attributes map?
|
|
52
|
+
K extends keyof GlintHtmlElementAttributesMap
|
|
53
|
+
? WithDataAttributes<GlintHtmlElementAttributesMap[K]>
|
|
54
|
+
: // Or is K in the SVG attributes map?
|
|
55
|
+
K extends keyof GlintSvgElementAttributesMap
|
|
56
|
+
? WithDataAttributes<GlintSvgElementAttributesMap[K]>
|
|
57
|
+
: // If the element can't be found: fallback to just allow general AttrValue
|
|
58
|
+
// NOTE: MathML has no attributes
|
|
59
|
+
Record<string, AttrValue>;
|
package/package.json
CHANGED