import type { DirectiveResult } from 'lit-html/async-directive.js'; import type { RefOrCallback } from 'lit-html/directives/ref.js'; declare const explicitSymbol: unique symbol; declare global { namespace LitJSX { interface ExplicitBrand { [explicitSymbol]?: never; } /** * Marks a type as explicitly required when used in JSX props. \ * This allows making certain props required, while keeping the rest optional. * * Example: * ``` * class MyElement extends LitElement { * name: LitJSX.Explicit; * size: number; * } * ``` * In this example, `name` is required while `size` is optional. */ type Explicit = T & ExplicitBrand; type IsMandatory = T extends { [explicitSymbol]?: never; } ? (typeof explicitSymbol extends keyof T ? true : false) : false; type UnwrapMandatory = T extends Explicit ? U : T; type PartialExceptRequired = { [P in keyof T as IsMandatory extends true ? P : never]: UnwrapMandatory } & { [P in keyof T as IsMandatory extends true ? never : P]?: T[P] }; type IfEquals = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : never; type WritableKeys = { [P in keyof T]-?: IfEquals< { [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P > }[keyof T]; type TrimReadonly = Pick>; interface DataProps { [key: `data-${ string }`]: string | undefined; } type SpecialProps = Omit & { /** * Opt into the lit-jsx custom-element transform. * * Example: `` * * This is only required when not using type-inference option. * or using javascript without type checking. */ static?: true; /** * The children of this JSX element. * * Example: `
Children here
` \ * Example with expression: `
{someValue}
` * * This property should generally not be set directly, but rather via * the content between the opening and closing tags of the JSX element. */ children?: LitJSX.Child; /** * A reference to the underlying element. * * Example: `
` \ * Example with callback: `
{ ... }}>
` */ ref?: RefOrCallback>>; /** * An object defining CSS classes. * * Example: `
` */ classList?: { [k: string]: boolean | undefined; }; /** * An object defining CSS properties. * * Example: `
` */ styleList?: CSSProperties; /** * A string or object defining CSS classes or styles. \ * When a string is provided, it is set directly on the `class` or `style` attribute. \ * When an object is provided, its keys and values are set as CSS properties. * * Example 1: `
` \ * Example 2: `
` */ class?: { [k: string]: boolean | undefined; } | string; /** * A string or object defining CSS styles. \ * When a string is provided, it is set directly on the `style` attribute. \ * When an object is provided, its keys and values are set as CSS properties. * * Example 1: `
` \ * Example 2: `
` */ style?: CSSProperties | string; /** * This property takes in one or more element directives. * This is akin to applying a directive through `
`. */ directive?: DirectiveResult | DirectiveResult[]; } & DataProps; type JSXElementProps = SpecialProps>>; type ElementMapToJSXElements> = { [K in keyof T]: JSXElementProps; }; type Child = unknown; type Element = unknown; type AnyTagName = string & Record; interface IntrinsicElements extends NativeHTMLElements, NativeSVGElements, NativeMathMLElements, SemanticTags {} type TagName = keyof IntrinsicElements | AnyTagName; type DynamicTagProps = Tag extends keyof IntrinsicElements ? IntrinsicElements[Tag] : (Tag extends keyof HTMLElementTagNameMap ? JSXElementProps : JSXElementProps); type DynamicTag = ((props: DynamicTagProps) => Element); type Component

= (props: P) => Element; type ClassComponent = abstract new (...args: any[]) => Instance; type ComponentLike

= | Component

| ClassComponent; type ComponentProps = T extends Component ? P : T extends ClassComponent ? JSXElementProps> : T extends abstract new (...args: any[]) => infer I ? JSXElementProps> : {}; } // eslint-disable-next-line no-var var as: { /** * Informs the compiler that the value should be bound as a property value.\ * This binds the expression value as a property, using the `.` syntax e.g `.key=${value}`\ * This function call is removed during compilation, therefore it has no runtime effect. */ prop: (value: T) => T; /** * Informs the compiler that the value should be bound as a boolean attribute.\ * This allows the template to bind the value using the `?` syntax, e.g. `?disabled=${true}`\ * This function call is removed during compilation, therefore it has no runtime effect. */ bool: (value: boolean) => boolean; /** * Creates a component-like value for an intrinsic tag, so it can be used in * JSX as a dynamic tag identifier. * * The returned component requires `static`. * Example: * const Tag = as.tag('a'); * */ tag: (tag: Tag) => LitJSX.DynamicTag; }; }