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