FreeDatas2HTML/src/interfaces.ts

105 lines
2.6 KiB
TypeScript
Raw Normal View History

export interface Counter
{
displayElement?: DOMElement; // peut être undefined si on ne souhaite pas d'affichage automatique dans la page
value?: number; // undefined jusqu'à recevoir sa première valeur
}
export interface DatasRenders // interface à respecter par toute alternative à la classe Render par défaut
{
rend2HTML(datas: any[]): string;
}
export interface DatasRendersSettings // interface spécifique à la classe Render par défaut.
{
allBegining: string;
allEnding: string;
fieldsBegining?: string;
fieldsEnding?: string;
fieldDisplaying?: string;
linesBegining: string;
linesEnding: string;
lineBegining: string;
lineEnding: string;
dataDisplaying: string;
}
export interface DOMElement
{
id: string;
eltDOM?: HTMLElement;
}
export interface Paginations
{
options?: PaginationsOptions;
selectedValue: number|undefined;
pages: PaginationsPages;
options2HTML(): void;
pages2HTML(nbTotal:number) : void;
}
export interface PaginationsOptions
{
displayElement: DOMElement;
name?: string;
values: number[];
};
export interface PaginationsPages
{
displayElement: DOMElement;
name?: string;
values?: number[];
selectedValue?: number;
}
export interface Datas
{
[key: string]: string;
}
export interface ParseErrors
{
code?: string;
message: string;
2021-10-18 11:27:53 +02:00
row: number; // -1 quand bug avant de traiter les lignes
type?: string;
}
export interface ParseResults
{
datas: {[index: string]:string}[];
errors: ParseErrors[];
fields: string[];
}
export interface Parsers
{
datasRemoteSource: RemoteSources;
setRemoteSource(settings : RemoteSourceSettings): void;
2021-10-13 12:41:34 +02:00
datas2Parse?: string;
document2Parse?: HTMLDocument;
parseResults: ParseResults|undefined;
parse(): Promise<void>;
}
export interface RemoteSourceSettings
{
url: string;
headers?: { key:string, value:string }[];
withCredentials?: boolean;
}
export interface RemoteSources extends RemoteSourceSettings
{
getFetchSettings() : {};
}
export interface Selectors
{
datasViewElt: DOMElement;
datasFieldNb: number;
separator?: string|undefined;
name?: string;
values?: string[];
selector2HTML() : void;
dataIsOk(data: any) : boolean;
}
export interface SortingFields
{
datasFieldNb: number;
2021-10-19 15:49:10 +02:00
order: "asc"|"desc"|undefined;
field2HTML() : void;
}
export interface SortingFunctions
{
datasFieldNb: number;
sort(a: any,b: any, order?: "asc"|"desc"): number; // cf. https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
}