-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.d.ts
More file actions
276 lines (228 loc) · 5.47 KB
/
index.d.ts
File metadata and controls
276 lines (228 loc) · 5.47 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/* eslint-disable no-var,camelcase */
/*!
* V4Fire Client Core
* https://github.com/V4Fire/Client
*
* Released under the MIT license
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/
/// <reference types="@v4fire/core"/>
/// <reference types="./build/stylus/ds"/>
/// <reference path="./ts-definitions/playwright.d.ts"/>
declare const MODULE: string;
declare const CSP_NONCE_STORE: string;
declare const LANG_PACKS: string;
declare var PATH: Dictionary<CanUndef<string>>;
declare var PUBLIC_PATH: CanUndef<string>;
declare const COMPONENTS: Dictionary<{parent: string; dependencies: string[]}>;
declare const TPLS: Dictionary<Dictionary<Function>>;
declare const DS: CanUndef<DesignSystem>;
declare const BLOCK_NAMES: CanUndef<string[]>;
declare const BUILD_MODE: CanUndef<string>;
declare const DS_COMPONENTS_MODS: CanUndef<{
[name: string]: Nullable<Array<string | boolean | number>>;
}>;
interface RenderOptions {
/** @default `'rootSelector'` */
selectorToInject?: string;
/** @default `'#root-component'` */
rootSelector?: string;
}
interface HTMLImageElement {
readonly init: Promise<this>;
onInit(onSuccess: () => void, onFail?: (err?: Error) => void): void;
}
/**
* Default app theme to use
* @see config/default.js
*/
declare const THEME: CanUndef<string>;
/**
* Attribute name to set a value of the theme to the root element
* @see config/default.js
*/
declare const THEME_ATTRIBUTE: CanUndef<string>;
/**
* Array of available themes in the runtime
* @see config/default.js
*/
declare const AVAILABLE_THEMES: CanUndef<string[]>;
declare const DETECT_USER_PREFERENCES: CanUndef<
Dictionary<Dictionary<{
enabled: boolean;
aliases?: Dictionary<string>;
}>>
>;
interface Event {
delegateTarget?: Element;
}
interface BoxSize {
readonly blockSize: number;
readonly inlineSize: number;
}
interface ResizeObserverObserveOptions {
box: 'content-box' | 'border-box';
}
declare let ModuleDependencies: {
cache: Dictionary;
event: {on: Function; once: Function; off: Function};
add(moduleName: string, dependencies: string[]): void;
get(module: string): Promise<string[]>;
};
interface ElementPosition {
top: number;
left: number;
}
interface Element {
getPosition(): ElementPosition;
getIndex(): number | null;
}
interface Node {
getOffset(parent?: Element | string): ElementPosition;
}
interface IntersectionObserverInit {
delay?: number;
trackVisibility?: boolean;
}
interface IntersectionObserver {
delay?: number;
trackVisibility?: boolean;
}
interface Document {
fonts: {
ready: Promise<void>;
};
}
interface RenderContentFn {
(props: Dictionary): string;
}
interface RenderParams<A extends object = Dictionary> {
/**
* Component attrs
*/
attrs?: A;
/** @see [[RenderContent]] */
content?: Dictionary<RenderContent | RenderContentFn | string>;
}
/**
* Content to render into an element
*
* @example
*
* ```typescript
* globalThis.renderComponents('b-button', {
* attrs: {
* testProp: 1
* },
*
* content: {
* default: {
* tag: 'b-button',
* content: {
* default: 'Test'
* }
* }
* }
* });
* ```
*
* This schema is the equivalent of such a template:
*
* ```ss
* < b-button :testProp = 1
* < b-button
* Test
* ```
*/
interface RenderContent {
/**
* Component name or tagName
*/
tag: string;
/**
* Component attrs
*/
attrs: Dictionary;
/** @see [[RenderContent]] */
content?: Dictionary<RenderContent | RenderContentFn | string>;
}
// eslint-disable-next-line no-var,vars-on-top
declare var
/**
* Renders the specified components
*
* @param componentName
* @param scheme
* @param [opts]
*/
renderComponents: (componentName: string, scheme: RenderParams[] | string, opts?: RenderOptions) => void,
/**
* Removes all components created via `globalThis.renderComponents`
*/
removeCreatedComponents: () => void,
/**
* Requires a module by the specified path
*/
importModule: (path: string) => any,
/**
* Jest mock API for test environment.
*/
jestMock: {
/**
* Wrapper for jest `spyOn` function.
* @see https://jestjs.io/docs/mock-functions
*/
spy: import('jest-mock').ModuleMocker['spyOn'];
/**
* Wrapper for jest `fn` function.
* @see https://jestjs.io/docs/mock-functions
*/
mock: import('jest-mock').ModuleMocker['fn'];
};
type RenderComponentsScheme = RenderComponentsVnodeParams[] | string;
interface RenderComponentsVnodeDescriptor extends RenderComponentsVnodeParams {
/**
* A simple tag name or component name
*/
type: string;
}
interface RenderComponentsVnodeParams<A extends object = Dictionary> {
/**
* A dictionary with attributes to pass to the created VNode
*/
attrs?: A;
/**
* An array of children VNode descriptors or dictionary with slot functions
*/
children?: VNodeChildren;
}
type VNodeChild = string | RenderComponentsVnodeDescriptor;
type VNodeChildren =
VNodeChild[] |
Dictionary<CanArray<VNodeChild> | ((...args: any[]) => CanArray<VNodeChild>)>;
/**
* The results returned by a mock or spy function from `jestMock`.
*/
interface JestMockResult<VAL = any> {
type: 'throw' | 'return';
value: VAL;
}
interface TouchGesturesCreateOptions {
/**
* Element to dispatch an event
*/
dispatchEl: Element | string;
/**
* Element that will be provided as a target in the dispatched event
*/
targetEl: Element | string;
/**
* Delay between steps
* @default `5`
*/
pause?: number;
}
interface TouchGesturePoint extends Partial<TouchGesturesCreateOptions> {
x: number;
y: number;
}