import { type WebComponentInterface } from './WebComponentInterface'; import WebComponentType from './WebComponentType'; /** * Create a typed factory for constructing a Web Component element. * * @param component Component constructor and static metadata. * @returns Function that creates the custom element and optionally assigns an id. */ const createElementFactory = (component: WebComponentType): ((id?: string) => T & WebComponentInterface) => { return (id?: string): T & WebComponentInterface => { const element = document.createElement(component.tagName) as T & WebComponentInterface; if (id) { element.setId(id); } return element; }; }; export { createElementFactory }; export default createElementFactory;