|
1 | 1 | import { h, cloneElement, render, hydrate } from 'preact'; |
2 | 2 |
|
3 | 3 | /** |
4 | | - * @typedef {import('preact').FunctionComponent<any> | import('preact').ComponentClass<any> | import('preact').FunctionalComponent<any> } ComponentDefinition |
5 | | - * @typedef {{ shadow: false } | { shadow: true, mode?: 'open' | 'closed', adoptedStyleSheets?: CSSStyleSheet[] }} Options |
6 | | - * @typedef {HTMLElement & { _root: ShadowRoot | HTMLElement, _vdomComponent: ComponentDefinition, _vdom: ReturnType<typeof import("preact").h> | null }} PreactCustomElement |
| 4 | + * @typedef {import('./index.d.ts').PreactCustomElement} PreactCustomElement |
7 | 5 | */ |
8 | 6 |
|
| 7 | + |
9 | 8 | /** |
10 | | - * Register a preact component as web-component. |
11 | | - * @param {ComponentDefinition} Component The preact component to register |
12 | | - * @param {string} [tagName] The HTML element tag-name (must contain a hyphen and be lowercase) |
13 | | - * @param {string[]} [propNames] HTML element attributes to observe |
14 | | - * @param {Options} [options] Additional element options |
15 | | - * @example |
16 | | - * ```ts |
17 | | - * // use custom web-component class |
18 | | - * class PreactWebComponent extends Component { |
19 | | - * static tagName = 'my-web-component'; |
20 | | - * render() { |
21 | | - * return <p>Hello world!</p> |
22 | | - * } |
23 | | - * } |
24 | | - * |
25 | | - * register(PreactComponent); |
26 | | - * |
27 | | - * // use a preact component |
28 | | - * function PreactComponent({ prop }) { |
29 | | - * return <p>Hello {prop}!</p> |
30 | | - * } |
31 | | - * |
32 | | - * register(PreactComponent, 'my-component'); |
33 | | - * register(PreactComponent, 'my-component', ['prop']); |
34 | | - * register(PreactComponent, 'my-component', ['prop'], { |
35 | | - * shadow: true, |
36 | | - * mode: 'closed' |
37 | | - * }); |
38 | | - * ``` |
| 9 | + * @type {import('./index.d.ts').default} |
39 | 10 | */ |
40 | 11 | export default function register(Component, tagName, propNames, options) { |
41 | 12 | function PreactElement() { |
|
0 commit comments