// A type that describes a constructor function which returns an instance of T
export type CustomElementConstructorOf<T extends HTMLElement> = { // The 'new' signature ensures it can be instantiated new (): T;
} & typeof HTMLElement;
import { Audio } from "./audio.js"; import { Button } from "./button.js"; import { Card } from "./card.js"; import { Checkbox } from "./checkbox.js"; import { Column } from "./column.js"; import { DateTimeInput } from "./datetime-input.js"; import { Divider } from "./divider.js"; import { Icon } from "./icon.js"; import { Image } from "./image.js"; import { List } from "./list.js"; import { MultipleChoice } from "./multiple-choice.js"; import { Modal } from "./modal.js"; import { Root } from "./root.js"; import { Row } from "./row.js"; import { Slider } from "./slider.js"; import { Surface } from "./surface.js"; import { Tabs } from "./tabs.js"; import { TextField } from "./text-field.js"; import { Text } from "./text.js"; import { Video } from "./video.js";
export * as Context from "./context/theme.js";
export * as Utils from "./utils/utils.js";
export { ComponentRegistry, componentRegistry } from "./component-registry.js";
export { registerCustomComponents } from "./custom-components/index.js";
/** *Type-safelyretrievesacustomelementconstructorusingthetagNamemap. *@paramtagNameThetagnametolookup(mustexistinHTMLElementTagNameMap). *@returnsThespecificconstructortypeorundefined.
*/
export functioninstanceOf<T extends keyof A2UITagNameMap>(tagName: T) { // Use a type assertion: we tell TypeScript to trust that the value returned // by customElements.get(tagName) matches the type defined in our map. const ctor = customElements.get(tagName) as
| CustomElementConstructorOf<A2UITagNameMap[T]>
| undefined; if (!ctor) {
console.warn("No element definition for", tagName); return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.