-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
VirtualScroller.d.ts
320 lines (304 loc) · 8.81 KB
/
VirtualScroller.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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
import { VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
type VirtualScrollerItemsType = any[] | any[][] | undefined | null;
type VirtualScrollerItemSizeType = number | number[] | undefined;
type VirtualScrollerOrientationType = 'vertical' | 'horizontal' | 'both' | undefined;
type VirtualScrollerToType = 'to-start' | 'to-end' | undefined;
export interface VirtualScrollerScrollIndexChangeEvent {
/**
* First index of the new data range to be loaded.
*/
first: number;
/**
* Last index of the new data range to be loaded.
*/
last: number;
}
/**
* @extends VirtualScrollerScrollIndexChangeEvent
*/
export interface VirtualScrollerLazyEvent extends VirtualScrollerScrollIndexChangeEvent { }
/**
* @extends VirtualScrollerScrollIndexChangeEvent
*/
export interface VirtualScrollerViewport extends VirtualScrollerScrollIndexChangeEvent { }
export interface VirtualScrollerRangeMethod {
/**
* Whether the item is first.
*/
first: number;
/**
* Whether the item is last.
*/
last: number;
/**
* Viewport info.
* @see VirtualScrollerViewport
*/
viewport: VirtualScrollerViewport;
}
export interface VirtualScrollerItemOptions {
/**
* Item index
*/
index: number;
/**
* Items count
*/
count: number;
/**
* Whether the item is first.
*/
first: boolean;
/**
* Whether the item is last.
*/
last: boolean;
/**
* Whether the item is even.
*/
even: boolean;
/**
* Whether the item is odd.
*/
odd: boolean;
/**
* Optional
*/
[key: string]: any;
}
/**
* @extends VirtualScrollerItemOptions
*/
export interface VirtualScrollerLoaderOptions extends VirtualScrollerItemOptions { }
export interface VirtualScrollerProps {
/**
* Unique identifier of the element.
*/
id?: string | undefined;
/**
* Inline style of the component.
*/
style?: any;
/**
* Style class of the component.
*/
class?: any;
/**
* An array of objects to display.
*/
items?: VirtualScrollerItemsType;
/**
* The height/width of item according to orientation.
*/
itemSize?: VirtualScrollerItemSizeType;
/**
* Height of the scroll viewport.
*/
scrollHeight?: string | undefined;
/**
* Width of the scroll viewport.
*/
scrollWidth?: string | undefined;
/**
* The orientation of scrollbar.
* @see VirtualScrollerOrientationType
* Default value is 'vertical'.
*/
orientation?: VirtualScrollerOrientationType;
/**
* Determines how many additional elements to add to the DOM outside of the view.
* According to the scrolls made up and down, extra items are added in a certain algorithm in the form of multiples of this number.
* Default value is half the number of items shown in the view.
*/
numToleratedItems?: number | undefined;
/**
* Delay in scroll before new data is loaded.
* Default value is 0.
*/
delay?: number | undefined;
/**
* Defines if data is loaded and interacted with in lazy manner.
*/
lazy?: boolean | undefined;
/**
* If disabled, the VirtualScroller feature is eliminated and the content is displayed directly.
*/
disabled?: boolean | undefined;
/**
* Used to implement a custom loader instead of using the loader feature in the VirtualScroller.
*/
loaderDisabled?: boolean | undefined;
/**
* Whether to show loader.
*/
showLoader?: boolean | undefined;
/**
* Used to implement a custom spacer instead of using the spacer feature in the VirtualScroller.
* Default value is true.
*/
showSpacer?: boolean | undefined;
/**
* Whether to load items.
*/
loading?: boolean | undefined;
/**
* Callback to invoke in lazy mode to load new data.
* @param {VirtualScrollerLazyEvent} event - Custom lazy event.
*/
onLazyLoad?: (event: VirtualScrollerLazyEvent) => void;
}
export interface VirtualScrollerSlots {
/**
* Custom content template.
* @param {Object} scope - content slot's params.
*/
content: (scope: {
/**
* An array of objects to display for virtualscroller
*/
items: any;
/**
* Style class of the content
*/
styleClass: string;
/**
* Referance of the content
* @param {HTMLElement} el - Element of 'ref' property
*/
contentRef(el: any): void;
/**
* Options of the items
* @param {number} index - Rendered index
* @return {@link VirtualScroller.VirtualScrollerItemOptions}
*/
getItemOptions(index: number): VirtualScrollerItemOptions;
/**
* Whether the data is loaded.
*/
loading: boolean;
/**
* Loader options of the items while the data is loading.
* @param {number} index - Rendered index
* @param {*} [ext] - Extra options
*/
getLoaderOptions(index: number, ext?: any): VirtualScrollerLoaderOptions;
/**
* The height/width of item according to orientation.
*/
itemSize: VirtualScrollerItemSizeType;
/**
* The number of the rendered rows.
*/
rows: number | undefined;
/**
* The number of the rendered columns.
*/
columns: number | undefined;
/**
* The style of spacer element.
*/
spacerStyle: any;
/**
* The style of content element.
*/
contentStyle: any;
/**
* Whether the orientation is vertical.
*/
vertical: boolean;
/**
* Whether the orientation is horizontal.
*/
horizontal: boolean;
/**
* Whether the orientation is both.
*/
both: boolean;
}) => VNode[];
/**
* Custom item template.
* @param {Object} scope - item slot's params.
*/
item: (scope: {
/**
* Item data.
*/
item: any;
/**
* Item options.
*/
options: VirtualScrollerItemOptions;
}) => VNode[];
/**
* Custom loader template.
* @param {Object} scope - header slot's params.
*/
loader: (scope: {
/**
* Loader options.
*/
options: VirtualScrollerLoaderOptions;
}) => VNode[];
}
export declare type VirtualScrollerEmits = {
/**
* Emitted when the numToleratedItems changes.
* @param {number} value - New number tolerated items
*/
'update:numToleratedItems': (value: number) => void;
/**
* Callback to invoke when scroll position changes.
* @param {Event} event - Browser event.
*/
'scroll': (event: Event) => void;
/**
* Callback to invoke when scroll position and item's range in view changes.
* @param {AccordionTabOpenEvent} event - Custom tab open event.
*/
'scroll-index-change': (event: VirtualScrollerScrollIndexChangeEvent) => void;
/**
* Callback to invoke in lazy mode to load new data.
* @param {VirtualScrollerLazyEvent} event - Custom lazy event.
*/
'lazy-load': (event: VirtualScrollerLazyEvent) => void;
}
declare class VirtualScroller extends ClassComponent<VirtualScrollerProps, VirtualScrollerSlots, VirtualScrollerEmits> {
/**
* Scroll to move to a specific position.
* @param {ScrollToOptions} [options] - scoll options.
*/
scrollTo(options?: ScrollToOptions): void;
/**
* Scroll to move to a specific item.
* @param {number} index - Index of item according to orientation mode.
* @param {ScrollBehavior} [behavior] - Behavior of scroll.
*/
scrollToIndex(index: number, behavior?: ScrollBehavior): void;
/**
* It is used to move the specified index into the view. It is a method that will usually be needed when keyboard support is added to the virtualScroller component.
* @param {number} index - Index of item according to orientation mode.
* @param {VirtualScrollerToType} to - Defines the location of the item in view,
* @param {ScrollBehavior} [behavior] Behavior of scroll
*/
scrollInView(index: number, to: VirtualScrollerToType, behavior?: ScrollBehavior): void;
/**
* Returns the range of items added to the DOM.
*/
getRenderedRange(): VirtualScrollerRangeMethod;
}
declare module '@vue/runtime-core' {
interface GlobalComponents {
VirtualScroller: GlobalComponentConstructor<VirtualScroller>
}
}
/**
*
* VirtualScroller is a performant approach to handle huge data efficiently.
*
* Demos:
*
* - [VirtualScroller](https://www.primefaces.org/primevue/showcase/#/virtualscroller)
*
*/
export default VirtualScroller;