UNPKG

@equinor/fusion-react-utils

Version:
22 lines 1.03 kB
import type { HTMLAttributes, PropsWithoutRef, Ref, RefAttributes } from 'react'; export type ComponentAttributes<T = HTMLHtmlElement> = Omit<React.HTMLAttributes<T>, 'children'>; export type ComponentProps<E extends HTMLElement, P = {}> = HTMLAttributes<E> & P & { readonly ref?: Ref<E>; }; type Ctor<T> = { new (): T; }; export type WebComponent<E extends HTMLElement, P extends Record<string, unknown>> = React.ForwardRefExoticComponent<PropsWithoutRef<ComponentAttributes<E> & P> & RefAttributes<E>>; /** * Wraps a custom element as a React Component * * @param elementClass HTMLElement - Custom element to wrap * @param tag string - tag name which the element uses in DOM */ export declare const createComponent: <E extends HTMLElement, P extends Record<string, unknown>>(elementClass: Ctor<E>, tag: string, options?: { events?: Record<string, string>; functions?: Set<keyof E>; displayName?: string; }) => WebComponent<E, P>; export default createComponent; //# sourceMappingURL=create-element.d.ts.map