-
Notifications
You must be signed in to change notification settings - Fork 5
/
inter.m.d.ts
202 lines (178 loc) · 4.48 KB
/
inter.m.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/***
* MIT LICENSED BY - Denis Power(Inter creator)
* Typescript declaration file for Inter version 2.2.3
* Version - 1.0.0
* Repo - https://github.com/interjs/inter/types
* GENERATED BY INTER BUILDER
*/
interface backendInterface {
new (): backendInstance;
}
interface backendInstance {
request(options: ajaxOptions): ajaxReactorInterface;
}
/***
* These are the most commonly used HTTP request methods, the others
* ones are not supported in Ajax request.
*
*/
type httpRequestMethods =
| "GET"
| "POST"
| "PUT"
| "HEAD"
| "DELETE"
| "OPTIONS"
| "PATCH";
interface ajaxOptions {
type: httpRequestMethods;
path: string;
headers?: object;
timeout?: number;
events?: {
onprogress?(args: { readonly progress: number; abort(): void }): void;
onabort?(): void;
ontimeout?(): void;
};
security?: {
username: string;
password: string;
};
body?: any;
}
type ajaxResponseCallBack = (response: ajaxResponse) => void;
interface ajaxReactorInterface {
okay(callBack: ajaxResponseCallBack): void;
error(callBack: ajaxResponseCallBack): void;
response(
okayCallBack: ajaxResponseCallBack,
errorCallBack: ajaxResponseCallBack
): void;
}
interface ajaxResponse {
readonly data: any;
readonly status: number;
readonly statusText: string;
readonly headers: object;
isObj(): boolean;
}
export declare var Backend: backendInterface;
type refValueType = string | number | null | void;
type refMethods<T> = {
setRefs?: {
[ref in keyof T]?: refValueType;
};
observe(
ref: string,
value: refValueType,
previousValue: refValueType
): boolean;
};
interface refOptionsInterface<T> {
in: string;
data: T;
}
export declare function Ref<T extends object>(
options: refOptionsInterface<T>
): refMethods<T> & T;
type renderIfMethods<T> = {
setConds: {
[prop in keyof T]?: refValueType;
};
observe(ref: keyof T, value: refValueType): boolean;
};
interface renderIfOptionsInterface<T> {
in: string;
data: {
[prop: string]: boolean;
} & T;
}
export declare function renderIf<T extends object>(
options: renderIfOptionsInterface<T>
): renderIfMethods<T> & T;
interface renderListOptionsInterface<T> {
in: string;
each: T;
optimize?: boolean;
do: doOptionsType<T>;
}
type universalReactorPropsType<T> = {
obserseve(callBack: (reactor: T) => void): boolean;
setEach: eachTypes;
};
interface ArrayReactor<T> extends universalReactorPropsType<T> {
addItems(items: any[], index?: number): boolean;
}
interface ObjectReactor<T> extends universalReactorPropsType<T> {
setProps?: T;
}
interface objectProps<T> {
setProps?: T;
defineProps?: object;
deleteProps?: Array<keyof T>;
}
type eachTypes = any[] | Object | Set<any> | Map<any, any> | number;
type PropValueType<T> = T[keyof T];
type doOptionsType<T> = T extends any[]
? (
this: returnReactorType<T>,
item: Item<T>,
index: number,
reactor: T
) => templateReturn
: T extends object
? (
this: returnReactorType<T>,
prop: string,
value: PropValueType<T>,
reactor: returnReactorType<T>
) => templateReturn
: templateReturn;
type Item<T> = T[any] extends object ? T[any] & objectProps<T[any]> : T[any];
type returnReactorType<T> = T extends any[]
? Item<T>[] & ArrayReactor<T>
: T extends object
? T & ObjectReactor<T>
: null;
export declare function renderList<T extends eachTypes>(
renderListOption: renderListOptionsInterface<T>
): returnReactorType<T>;
type HTMLTags = keyof HTMLElementTagNameMap;
type textTypes = string | number | null | void;
interface templateOptionsInterface {
tag: HTMLTags | ((this: void) => HTMLTags);
text?: textTypes | ((this: void) => textTypes);
renderIf?: boolean;
events?: {
[event in keyof GlobalEventHandlers]?: (
this: Document,
event: Event
) => void;
};
attrs?: object;
styles?: {
[style in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[style];
};
children?: templateOptionsInterface[];
}
interface templateReturn {
element: templateOptionsInterface;
}
export declare function template(
options: templateOptionsInterface
): templateReturn;
type attrType = string | number | null;
type attrs<T> = T[keyof T];
interface toAttrsMethods<T> {
setAttrs?: T[keyof T];
observe?(attr: string, value: attrType): boolean;
}
interface toAttrsOptionsInterface<T> {
in: string;
data: T;
}
export declare function toAttrs<T extends object>(
options: toAttrsOptionsInterface<T>
): {
[prop in keyof T]: toAttrsMethods<T> & T[prop];
};