mirror of
https://github.com/janishutz/fundamentals-of-webengineering.git
synced 2025-11-25 13:54:25 +00:00
++ Glue
This commit is contained in:
53
task_2_ts/ts/glue/rendering.d.ts
vendored
Normal file
53
task_2_ts/ts/glue/rendering.d.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
export interface Ref<T> {
|
||||
'set': ( data: T ) => void;
|
||||
'get': () => T;
|
||||
'addAdditionalElement': ( elements: HTMLElement, predicate: ( value: T ) => boolean ) => void;
|
||||
'addConditionalElementBind': ( elements: HTMLElement, predicate: ( value: T ) => boolean ) => void;
|
||||
'addConditionalClasses': (
|
||||
element: HTMLElement, predicate: ( value: T ) => boolean, onTrue: string[], onFalse: string[] ) => void;
|
||||
'resetConditionalClasses': () => void;
|
||||
'resetConditionalElementBinds': () => void;
|
||||
'bind': ( element: HTMLInputElement, castFunction: ( val: string ) => T ) => void;
|
||||
'onChange': ( callback: () => void ) => void;
|
||||
}
|
||||
|
||||
export interface ListRef<T> {
|
||||
'set': ( data: T[] ) => void;
|
||||
'get': () => T[];
|
||||
'sort': ( compare: ( a: T, b: T ) => number ) => void;
|
||||
'resetSort': () => void;
|
||||
'filter': ( predicate: ( value: T ) => boolean ) => void;
|
||||
'setTemplate': ( newTemplate: RenderTemplate ) => void;
|
||||
'onChange': ( callback: () => void ) => void;
|
||||
}
|
||||
|
||||
export type HTMLTagNames = keyof HTMLElementTagNameMap;
|
||||
|
||||
export interface RenderTemplate {
|
||||
/**
|
||||
* What kind of element to render. Not all HTML elements supported (couldn't be arsed to do it)
|
||||
*/
|
||||
'type': HTMLTagNames;
|
||||
|
||||
/**
|
||||
* The attribute of the element to render. Leave blank if type is not object
|
||||
* Will be ignored if you also set children. If no children or attribute set,
|
||||
* will simply treat type as string and render accordingly
|
||||
*/
|
||||
'attribute'?: string;
|
||||
|
||||
/**
|
||||
* Children to render. Can be used to nest
|
||||
*/
|
||||
'children': RenderTemplate[];
|
||||
|
||||
/**
|
||||
* CSS classes to append to the element
|
||||
*/
|
||||
'cssClasses': string[];
|
||||
}
|
||||
|
||||
|
||||
export interface StringIndexedObject {
|
||||
[key: string]: unknown
|
||||
}
|
||||
Reference in New Issue
Block a user