/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
///
export declare type EventName = string & {
__event_type: T;
};
declare type EventNames = Record;
declare type EventListeners = {
[K in keyof R]: R[K] extends EventName ? (e: R[K]['__event_type']) => void : (e: Event) => void;
};
declare type ReactProps = Omit, keyof E>;
declare type ElementWithoutPropsOrEventListeners = Omit>;
export declare type WebComponentProps = Partial & ElementWithoutPropsOrEventListeners & EventListeners>;
export declare type ReactWebComponent = React.ForwardRefExoticComponent> & React.RefAttributes>;
interface Options {
tagName: string;
elementClass: Constructor;
react: typeof window.React;
events?: E;
displayName?: string;
}
declare type Constructor = {
new (): T;
};
/**
* Creates a React component for a custom element. Properties are distinguished
* from attributes automatically, and events can be configured so they are
* added to the custom element as event listeners.
*
* @param options An options bag containing the parameters needed to generate
* a wrapped web component.
*
* @param options.react The React module, typically imported from the `react` npm
* package.
* @param options.tagName The custom element tag name registered via
* `customElements.define`.
* @param options.elementClass The custom element class registered via
* `customElements.define`.
* @param options.events An object listing events to which the component can listen. The
* object keys are the event property names passed in via React props and the
* object values are the names of the corresponding events generated by the
* custom element. For example, given `{onactivate: 'activate'}` an event
* function may be passed via the component's `onactivate` prop and will be
* called when the custom element fires its `activate` event.
* @param options.displayName A React component display name, used in debugging
* messages. Default value is inferred from the name of custom element class
* registered via `customElements.define`.
*/
export declare function createComponent(options: Options): ReactWebComponent;
/**
* @deprecated Use `createComponent(options)` instead of individual arguments.
*
* Creates a React component for a custom element. Properties are distinguished
* from attributes automatically, and events can be configured so they are
* added to the custom element as event listeners.
*
* @param React The React module, typically imported from the `react` npm
* package.
* @param tagName The custom element tag name registered via
* `customElements.define`.
* @param elementClass The custom element class registered via
* `customElements.define`.
* @param events An object listing events to which the component can listen. The
* object keys are the event property names passed in via React props and the
* object values are the names of the corresponding events generated by the
* custom element. For example, given `{onactivate: 'activate'}` an event
* function may be passed via the component's `onactivate` prop and will be
* called when the custom element fires its `activate` event.
* @param displayName A React component display name, used in debugging
* messages. Default value is inferred from the name of custom element class
* registered via `customElements.define`.
*/
export declare function createComponent(ReactOrOptions: typeof window.React, tagName: string, elementClass: Constructor, events?: E, displayName?: string): ReactWebComponent;
export {};
//# sourceMappingURL=create-component.d.ts.map