@glint/template 1.5.2 → 1.5.3-unstable.18ae940

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.
@@ -9,7 +9,12 @@ import {
9
9
  TemplateContext,
10
10
  NamedArgs,
11
11
  } from '../integration';
12
- import { ElementForTagName } from './types';
12
+ import {
13
+ AttributesForElement,
14
+ ElementForTagName,
15
+ MathMlElementForTagName,
16
+ SVGElementForTagName,
17
+ } from './types';
13
18
 
14
19
  /**
15
20
  * Used during emit to denote an object literal that corresponds
@@ -38,15 +43,29 @@ export declare function emitContent(value: ContentValue): void;
38
43
  *
39
44
  * Would produce code like:
40
45
  *
41
- * emitElement('div', (𝛄) => {
42
- * applySplattributes(𝚪.element, 𝛄.element);
43
- * applyAttributes(𝛄.element, { class: 'hello' });
44
- * applyModifier(𝛄.element, resolve(on)({}, 'click', this.clicked));
46
+ * emitElement('div', (__glintY__) => {
47
+ * applySplattributes(__glintRef__.element, __glintY__.element);
48
+ * applyAttributes(__glintY__.element, { class: 'hello' });
49
+ * applyModifier(__glintY__.element, resolve(on)({}, 'click', this.clicked));
45
50
  * });
46
51
  */
47
- export declare function emitElement<Name extends string>(
48
- name: Name
49
- ): { element: ElementForTagName<Name> };
52
+ export declare function emitElement<Name extends keyof HTMLElementTagNameMap | 'math' | 'svg'>(
53
+ name: Name,
54
+ ): {
55
+ element: Name extends 'math'
56
+ ? MathMlElementForTagName<'math'>
57
+ : Name extends 'svg'
58
+ ? SVGElementForTagName<'svg'>
59
+ : ElementForTagName<Name>;
60
+ };
61
+
62
+ export declare function emitSVGElement<Name extends keyof SVGElementTagNameMap>(
63
+ name: Name,
64
+ ): { element: SVGElementForTagName<Name> };
65
+
66
+ export declare function emitMathMlElement<Name extends keyof MathMLElementTagNameMap>(
67
+ name: Name,
68
+ ): { element: MathMlElementForTagName<Name> };
50
69
 
51
70
  /*
52
71
  * Emits the given value as an entity that expects to receive blocks
@@ -60,12 +79,12 @@ export declare function emitElement<Name extends string>(
60
79
  * This form of invocation is the only one in a template that may have
61
80
  * blocks bound to it. The final line above would produce code like:
62
81
  *
63
- * emitComponent(resolve(Value)({ foo: bar })), (𝛄) => {
64
- * applyModifier(𝛄.element, resolve(baz)({}));
82
+ * emitComponent(resolve(Value)({ foo: bar })), (__glintY__) => {
83
+ * applyModifier(__glintY__.element, resolve(baz)({}));
65
84
  * });
66
85
  */
67
86
  export declare function emitComponent<T extends ComponentReturn<any, any>>(
68
- component: T
87
+ component: T,
69
88
  ): {
70
89
  element: T extends ComponentReturn<any, infer El> ? El : any;
71
90
  blockParams: T extends ComponentReturn<infer Yields, any> ? Required<Yields> : any;
@@ -80,8 +99,10 @@ export declare function emitComponent<T extends ComponentReturn<any, any>>(
80
99
  */
81
100
  export declare function templateExpression<
82
101
  Signature extends AnyFunction = () => ComponentReturn<{}>,
83
- Context extends AnyContext = TemplateContext<void, {}, {}, void>
84
- >(f: (𝚪: Context, χ: never) => void): new () => InvokableInstance<Signature> & HasContext<Context>;
102
+ Context extends AnyContext = TemplateContext<void, {}, {}, void>,
103
+ >(
104
+ f: (__glintRef__: Context, __glintDSL__: never) => void,
105
+ ): new () => InvokableInstance<Signature> & HasContext<Context>;
85
106
 
86
107
  /*
87
108
  * Wraps a template body that's backed by a known value (typically a class), either
@@ -98,7 +119,7 @@ export declare function templateExpression<
98
119
  */
99
120
  export declare function templateForBackingValue<Args extends unknown[], Context extends AnyContext>(
100
121
  backingValue: abstract new (...args: Args) => HasContext<Context>,
101
- body: (𝚪: Context, χ: never) => void
122
+ body: (__glintRef__: Context, __glintDSL__: never) => void,
102
123
  ): abstract new () => unknown;
103
124
 
104
125
  /*
@@ -108,11 +129,11 @@ export declare function templateForBackingValue<Args extends unknown[], Context
108
129
  *
109
130
  * Is equivalent to:
110
131
  *
111
- * yieldToBlock(𝚪, 'name')(foo, bar);
132
+ * yieldToBlock(__glintRef__, 'name')(foo, bar);
112
133
  */
113
134
  export declare function yieldToBlock<Context extends AnyContext, K extends keyof Context['blocks']>(
114
- 𝚪: Context,
115
- to: K
135
+ __glintRef__: Context,
136
+ to: K,
116
137
  ): (...values: NonNullable<Context['blocks'][K]>) => void;
117
138
 
118
139
  /*
@@ -124,7 +145,7 @@ export declare function yieldToBlock<Context extends AnyContext, K extends keyof
124
145
  */
125
146
  export declare function applySplattributes<
126
147
  SourceElement extends Element,
127
- TargetElement extends SourceElement
148
+ TargetElement extends SourceElement,
128
149
  >(source: SourceElement, target: TargetElement): void;
129
150
 
130
151
  /*
@@ -133,7 +154,10 @@ export declare function applySplattributes<
133
154
  * <div foo={{bar}}></div>
134
155
  * <AnotherComponent foo={{bar}} />
135
156
  */
136
- export declare function applyAttributes(element: Element, attrs: Record<string, AttrValue>): void;
157
+ export declare function applyAttributes<T extends Element>(
158
+ element: T,
159
+ attrs: Partial<AttributesForElement<T>>,
160
+ ): void;
137
161
 
138
162
  /*
139
163
  * Applies a modifier to an element or component.