|
| 1 | +type TemplateFunction<T> = (template: TemplateStringsArray, ...values: any[]) => T; |
| 2 | +export type BoundTemplateFunction<T extends Element> = TemplateFunction<T>; |
| 3 | +export type WiredTemplateFunction = TemplateFunction<any>; |
| 4 | + |
| 5 | +export declare class Component<T = {}> { |
| 6 | + handleEvent(e: Event): void; |
| 7 | + html: WiredTemplateFunction; |
| 8 | + svg: WiredTemplateFunction; |
| 9 | + state: T; |
| 10 | + readonly defaultState: T; |
| 11 | + setState(state: Partial<T> | ((this: this, state: T) => Partial<T>)): void; |
| 12 | +} |
| 13 | + |
| 14 | +export declare function bind<T extends Element>(element: T): BoundTemplateFunction<T>; |
| 15 | + |
| 16 | +export declare function define(intent: string, callback: Function): void; |
| 17 | + |
| 18 | +export declare function wire(identity?: object | null, type?: 'html' | 'svg'): WiredTemplateFunction; |
| 19 | +export declare function wire(identity?: object | null, type_id?: string): WiredTemplateFunction; |
| 20 | + |
| 21 | +export declare const hyper: { |
| 22 | + Component: typeof Component; |
| 23 | + bind: typeof bind; |
| 24 | + define: typeof define; |
| 25 | + hyper: typeof hyper; |
| 26 | + wire: typeof wire; |
| 27 | + |
| 28 | + // hyper(null, 'html')`HTML` |
| 29 | + (identity: null | undefined, type?: 'html' | 'svg'): WiredTemplateFunction; |
| 30 | + |
| 31 | + // hyper('html')`HTML` |
| 32 | + (type: 'html' | 'svg'): WiredTemplateFunction; |
| 33 | + |
| 34 | + // hyper(element)`HTML` |
| 35 | + <T extends Element>(element: T): BoundTemplateFunction<T>; |
| 36 | + |
| 37 | + // hyper`HTML` |
| 38 | + (template: TemplateStringsArray, ...values: any[]): any; |
| 39 | + |
| 40 | + // hyper(obj, 'html:id')`HTML` |
| 41 | + // hyper(obj)`HTML` |
| 42 | + (identity: object, type?: 'html' | 'svg'): WiredTemplateFunction; |
| 43 | + (identity: object, type_id?: string): WiredTemplateFunction; |
| 44 | + |
| 45 | + // hyper()`HTML` |
| 46 | + (): WiredTemplateFunction; |
| 47 | +}; |
| 48 | + |
| 49 | +export default hyper; |
0 commit comments