test: add classes to shared template props

This makes it easier to add classes in a render method. Also updates the TemplateBuilder type to not require a Harness (ex: card does not need one)

PiperOrigin-RevId: 588110635
This commit is contained in:
Elizabeth Mitchell 2023-12-05 10:11:14 -08:00 committed by Copybara-Service
parent a0baa4dc10
commit 1e8067bca7

View File

@ -6,6 +6,7 @@
import {TemplateResult} from 'lit';
import {DirectiveResult} from 'lit/directive.js';
import {ClassInfo} from 'lit/directives/class-map.js';
import {ref} from 'lit/directives/ref.js';
import {literal, StaticValue} from 'lit/static-html.js';
@ -69,7 +70,7 @@ export enum State {
* @template V Variant name types.
*/
export class TemplateBuilder<
H extends Harness = never,
H extends Harness = Harness,
V extends string = never,
> {
/**
@ -359,7 +360,7 @@ export type TemplateStateCallback<H extends Harness> = (
*
* @template H The harness type.
*/
export type TemplateProps<H extends Harness> = Partial<
export type TemplateProps<H extends Harness = Harness> = Partial<
Pick<HarnessElement<H>, Exclude<keyof HarnessElement<H>, keyof HTMLElement>>
> &
SharedTemplateProps;
@ -372,4 +373,8 @@ export interface SharedTemplateProps {
* The light DOM content of the element.
*/
content?: TemplateResult;
/**
* Classes to add to the element.
*/
classes?: ClassInfo;
}