-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathangular-mesa.d.ts
198 lines (184 loc) · 7.81 KB
/
angular-mesa.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
declare namespace angular.apMesa {
type PAGING_STRATEGY = 'PAGINATE' | 'SCROLL' | 'NONE';
interface ITableProvider {
setDefaultOptions: (defaults: ITableOptions) => null;
}
interface ITableService {
setDefaultOptions: (defaults: ITableOptions) => null;
getDefaultOptions: () => ITableOptions;
}
interface ITableColumn {
// Identifies the column.
id: string;
// The field on each row that this column displays or uses in its format function.
key: string;
// The column heading text (or template or templateUrl). If not present, id is used.
label?: string;
labelTemplate?: string;
labelTemplateUrl?: string;
// If specified, defines row sort function this column uses. See Row Sorting below.
sort?: ITableSorter | string | true;
// or string no undefined If specified, defines row filter function this column uses. See Row Filtering below.
filter?: ITableFilterer | string | true;
// Defines the placeholder text for the filter input, when filter is enabled
filterPlaceholder?: string;
// or string no '' If specified, defines cell format function. See the Cell Formatting section below.
format?: ITableFormatter | string;
// width of column, can include units, e.g. '30px'
width?: string | number;
// If true, column will not be resizable.
lockWidth?: boolean;
// Name of a registered angular filter to use on row[column.key]
ngFilter?: string;
// A string template for the cell contents.
template?: string;
// A template url used with ng-include for cell contents
templateUrl?: string;
// A tooltip for a column header.
title?: string;
// Marks the column as a "selector" column.
selector?: boolean;
// CSS classes to be added to the <th> element
classes?: string;
}
interface ITableSorter {
(rowA: any, rowB: any, options: ITableOptions, column: ITableColumn): number;
}
interface ITableFilterer {
(term: string, value: any, formattedValue: string, row: any, column: ITableColumn, options: ITableOptions): boolean;
}
interface ITableFormatter {
(value: any, row: any, column: ITableColumn, options: ITableOptions): any;
}
interface IInitialSort {
id: string;
dir: '-' | '+';
}
interface IActiveFilter {
column: ITableColumn;
value: string;
}
interface IActiveSort {
column: ITableColumn;
direction: 'ASC' | 'DESC';
}
interface IGetDataResponse {
total: number;
rows: any[];
}
interface ITableStorage {
setItem: (key: string, value: string | ITableStorageState) => ng.IPromise<any> | any;
getItem: (key: string) => ng.IPromise<string | ITableStorageState> | string | ITableStorageState;
removeItem: (key: string) => ng.IPromise<any> | any;
}
interface ITableApi {
isSelectedAll: () => boolean;
selectAll: () => void;
deselectAll: () => void;
toggleSelectAll: () => void;
setLoading: (isLoading: boolean, triggerDigest?: boolean) => void;
reset: () => void;
clearFilters: () => void;
// Resets rows' sorting order to whatever options.initialSorts. You can also pass an explicit array of IInitialSort objects.
resetRowSort: (sorts?: IInitialSort[]) => void;
hasActiveFilters: () => boolean;
toggleFiltersRow: (showFiltersRow?: boolean) => void;
isFilterRowEnabled: () => boolean;
setFilter: (columnId, value) => void;
}
interface ITableOptions {
// Number of pixels to pre-render before and after the viewport (default: 10)
rowPadding?: number;
// The classes to use for the sorting icons
sortClasses?: [string, string, string];
// undefined
storage?: ITableStorage;
// Arbitrary "version" hash used to identify and compare items in storage.
storageHash?: string;
// Used as the key to store and retrieve items from storage, if it is specified.
storageKey?: string;
// If true, will use JSON.stringify to serialize the state of the table before passing to storage.setItem.
// Also means that it will use JSON.parse to deserialize state in storage.getItem
stringifyStorage?: boolean;
// Array of objects defining an initial sort order. Each object must have id and dir, can be "+" for ascending, "-" for descending.
initialSorts?: IInitialSort[];
// String to show when data is loading
loadingText?: string;
// String to show when no rows are visible
noRowsText?: string;
// Path to template for td when loading
loadingTemplateUrl?: string;
// undefined Promise object for table data loading. Used to resolve loading state when data is available.
loadingPromise?: ng.IPromise<any>;
// undefined Path to template for td when there is an error loading table data.
loadingErrorTemplateUrl?: string;
// 'error loading results' string to show when loading fails
loadingErrorText?: string;
// undefined Path to template for td when there are no rows to show.
noRowsTemplateUrl?: string;
// 100 Wait time when debouncing the scroll event. Used when updating rows. Milliseconds.
scrollDebounce?: number;
// 1 The background-size css attribute of the placeholder rows is set to bgSizeMultiplier * rowHeight.
bgSizeMultiplier?: number;
// 40 When there are no rows to calculate the height, this number is used as the fallback
defaultRowHeight?: number;
// 300 The pixel height for the body of the table. Note that unless fixedHeight is set to true, this will behave as a max-height.
bodyHeight?: number;
// false If true, the table will fill the calculated height of the parent element. Note that this overrides bodyHeight. The table will listen for 'apMesa:resize' events from the rootScope to recalculate the height.
fillHeight?: boolean;
// false If true, the table body will always have a height of bodyHeight, regardless of whether the rows fill up the vertical space.
fixedHeight?: boolean;
// Provides access to select table controller methods, including selectAll, deselectAll, isSelectedAll, setLoading, etc.
onRegisterApi?: (api: ITableApi) => any;
// {} Customize the way to get column value. If not specified, get columen value by row[column.key]
getter?: (key: string, row: any) => string;
// undefined A template reference to be used for the expandable row feature. See Expandable Rows below.
expandableTemplateUrl?: string;
expandableTemplate?: string;
// SCROLL
pagingStrategy?: PAGING_STRATEGY;
rowsPerPage?: number;
rowsPerPageChoices?: number[];
rowsPerPageMessage?: string;
showRowsPerPageCtrls?: boolean;
maxPageLinks?: number;
// Async server-side interaction support
getData?: (
offset: number,
limit: number,
activeFilters: IActiveFilter[],
activeSorts: IActiveSort[]
) => ng.IPromise<IGetDataResponse>;
// If true, will show a number indicating stacked sort priority of each column being sorted.
showSortPriority?: boolean;
// If true, a column's filter state will be removed when that column is hidden.
clearFilterOnColumnHide?: boolean;
// If true, a column's sort state will be removed when that column is hidden.
clearSortOnColumnHide?: boolean;
}
interface IRowScope extends ng.IScope {
toggleRowExpand: Function;
rowIsExpanded: boolean;
refreshExpandedHeight: Function;
row: any;
options: ITableOptions;
}
interface ICellScope extends ng.IScope {
toggleRowExpand: Function;
rowIsExpanded: boolean;
refreshExpandedHeight: Function;
row: any;
column: ITableColumn;
options: ITableOptions;
}
interface ITableStorageState {
sortOrder: IInitialSort[];
searchTerms: { [columnId: string]: string };
enabledColumns: string[];
options: {
rowLimit: number;
pagingStrategy: PAGING_STRATEGY;
storageHash?: string;
};
}
}