forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
knockout-paging.d.ts
67 lines (55 loc) · 2.01 KB
/
knockout-paging.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
// Type definitions for knockout-paging
// Project: https://github.com/ErikSchierboom/knockout-paging
// Definitions by: Erik Schierboom <https://github.com/ErikSchierboom>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../knockout/knockout.d.ts" />
interface KnockoutStatic {
paging: KnockoutPagingOptions;
pagedObservableArray<T>(initialValue?: T[], options?: KnockoutPagedOptions): KnockoutPagedObservableArray<T>;
}
interface KnockoutPagingOptions {
defaults: KnockoutPagingDefaultOptions;
generators: {
[name: string]: KnockoutPageGenerator;
'sliding': KnockoutSlidingPageGenerator
}
}
interface KnockoutPagingDefaultOptions {
pageNumber: number;
pageSize: number;
}
interface KnockoutPagedObservableArray<T> extends KnockoutObservableArray<T> {
pageSize: KnockoutObservable<number>;
pageNumber: KnockoutObservable<number>;
pageItems: KnockoutComputed<T[]>;
pageCount: KnockoutComputed<number>;
itemCount: KnockoutComputed<number>;
firstItemOnPage: KnockoutComputed<number>;
lastItemOnPage: KnockoutComputed<number>;
hasPreviousPage: KnockoutComputed<boolean>;
hasNextPage: KnockoutComputed<boolean>;
isFirstPage: KnockoutComputed<boolean>;
isLastPage: KnockoutComputed<boolean>;
pages: KnockoutComputed<number[]>;
toNextPage(): void;
toPreviousPage(): void;
toLastPage(): void;
toFirstPage(): void;
}
interface KnockoutPagedOptions {
pageSize?: number;
pageNumber?: number;
pageGenerator?: string;
}
interface KnockoutObservableArray<T> {
extend(requestedExtenders: { 'paged': any; }): KnockoutPagedObservableArray<T>;
}
interface KnockoutPageGenerator {
generate<T>(pagedObservable: KnockoutPagedObservableArray<T>): number[];
}
interface KnockoutSlidingPageGenerator extends KnockoutPageGenerator {
windowSize: KnockoutObservable<number>;
}
interface KnockoutExtenders {
paged(target: KnockoutObservableArray<any>, options: KnockoutPagedOptions): KnockoutObservableArray<any>;
}