1 |
|
2 | import { LoDashStatic } from 'lodash';
|
3 | export declare type Listener = (...args: any[]) => any;
|
4 | export interface JQueryQuickTable {
|
5 | <T>(initFunc?: ((table: QuickTable<T>) => void) | null): QuickTable<T> | QuickTables<T>;
|
6 | columnId(column: number | ColumnId): ColumnId;
|
7 | rowId(row: number | RowId, isHead?: boolean): RowId;
|
8 | cellId(row: number | RowId | CellId, column?: number | ColumnId, isHead?: boolean): CellId;
|
9 | types: TypeManager;
|
10 | }
|
11 | export declare interface TypeDefinition {
|
12 | preSort?: (data: any) => any;
|
13 | preFilter?: (data: any) => string;
|
14 | compare?: (a: any, b: any) => number;
|
15 | render?: (data: any) => string;
|
16 | }
|
17 | export declare class TypeManager {
|
18 | defineType(name: string, typeDef: TypeDefinition): this;
|
19 | compare(type: string | null | undefined, a: any, b: any): number;
|
20 | render(type: string | null | undefined, data: any): string;
|
21 | matches(type: string | null | undefined, r: RegExp, data: any): boolean;
|
22 | }
|
23 | export declare interface ColumnDef<T> {
|
24 | cellType?: string;
|
25 | data?: string;
|
26 | type?: string;
|
27 | render?: (data: any, row: T) => string;
|
28 | html?: boolean;
|
29 | cssClass?: string;
|
30 | }
|
31 | export declare class ColumnId {
|
32 | get columnIndex(): number;
|
33 | toString(): string;
|
34 | }
|
35 | export declare function columnId(column: number | ColumnId): ColumnId;
|
36 | export declare class CellId {
|
37 | get rowId(): RowId;
|
38 | get columnId(): ColumnId;
|
39 | get rowIndex(): number;
|
40 | get isHead(): boolean;
|
41 | get columnIndex(): number;
|
42 | toString(): string;
|
43 | }
|
44 | export declare class RowId {
|
45 | get rowIndex(): number;
|
46 | get isHead(): boolean;
|
47 | toString(): string;
|
48 | }
|
49 | export declare function rowId(row: number | RowId, isHead?: boolean): RowId;
|
50 | export declare function cellId(row: number | RowId | CellId, column?: number | ColumnId, isHead?: boolean): CellId;
|
51 | export declare class EventEmitter {
|
52 | on(event: string, handler: Listener): this;
|
53 | trigger(event: string, ...args: any[]): this;
|
54 | forward(event: string, proxy: EventEmitter): this;
|
55 | }
|
56 | export declare class QTPartition<T extends QTIterable<T, E>, E> {
|
57 | get included(): T;
|
58 | get excluded(): T;
|
59 | withIncluded(func: (included: T) => void): this;
|
60 | withExcluded(func: (excluded: T) => void): this;
|
61 | partitionOut(iter: (e: E) => boolean): QTPartition<T, E>;
|
62 | partitionIn(iter: (e: E) => boolean): QTPartition<T, E>;
|
63 | }
|
64 | export declare type QTColumnPartition<T> = QTPartition<Columns<T>, Column<T>>;
|
65 | export declare type QTRowPartition<T> = QTPartition<Rows<T>, Row<T>>;
|
66 | export declare type QTCellPartition<T> = QTPartition<Cells<T>, Cell<T>>;
|
67 | export declare type QTTablePartition<T> = QTPartition<QuickTables<T>, QuickTable<T>>;
|
68 | export declare class QTIterable<T extends QTIterable<T, E>, E> {
|
69 | forEach(iter: (e: E) => void): this;
|
70 | each(iter: (e: E) => void): this;
|
71 | map<R>(iter: (e: E) => R): R[];
|
72 | flatMap<R>(iter: (e: E) => R): R[];
|
73 | some(iter: (e: E) => boolean): boolean;
|
74 | every(iter: (e: E) => boolean): boolean;
|
75 | find(iter: (e: E) => boolean): E | undefined;
|
76 | findLast(iter: (e: E) => boolean): E | undefined;
|
77 | filter(iter: (e: E) => boolean): T;
|
78 | joinWith(...parts: T[]): T;
|
79 | partition(iter: (e: E) => boolean): QTPartition<T, E>;
|
80 | partitionOutOver<I>(list: I[], iter: (e: E, l: I, i: number) => boolean): QTPartition<T, E>;
|
81 | partitionInOver<I>(list: I[], iter: (e: E, l: I, i: number) => boolean): QTPartition<T, E>;
|
82 | toArray(): E[];
|
83 | }
|
84 | export declare class Cell<T> {
|
85 | get quickTable(): QuickTable<T>;
|
86 | get cellId(): CellId;
|
87 | get rowIndex(): number;
|
88 | get isHead(): boolean;
|
89 | get columnIndex(): number;
|
90 | get rowId(): RowId;
|
91 | get columnId(): ColumnId;
|
92 | get row(): Row<T> | null;
|
93 | get column(): Column<T> | null;
|
94 | get $(): JQuery;
|
95 | get htmlData(): string;
|
96 | set htmlData(htmlData: string);
|
97 | get textData(): string;
|
98 | set textData(textData: string);
|
99 | get data(): any;
|
100 | get rawData(): any;
|
101 | }
|
102 | export declare class Cells<T> extends QTIterable<Cells<T>, Cell<T>> {
|
103 | get quickTable(): QuickTable<T>;
|
104 | get cellIds(): CellId[];
|
105 | get cells(): Cell<T>[];
|
106 | get $(): JQuery;
|
107 | get htmlData(): string[];
|
108 | get textData(): string[];
|
109 | get data(): any[];
|
110 | get rawData(): any[];
|
111 | get length(): number;
|
112 | }
|
113 | export declare class Column<T> extends EventEmitter {
|
114 | get quickTable(): QuickTable<T>;
|
115 | get columnId(): ColumnId;
|
116 | get index(): number;
|
117 | get $head(): JQuery;
|
118 | get $body(): JQuery;
|
119 | get $(): JQuery;
|
120 | get visible(): boolean;
|
121 | set visible(visible: boolean);
|
122 | cell(row: number | RowId, isHead?: boolean): Cell<T> | null;
|
123 | headerCell(row: number | RowId): Cell<T> | null;
|
124 | cellId(row: number | RowId, isHead?: boolean): CellId;
|
125 | get headerCellIds(): CellId[];
|
126 | get bodyCellIds(): CellId[];
|
127 | get cellIds(): CellId[];
|
128 | get headerCells(): Cells<T>;
|
129 | get bodyCells(): Cells<T>;
|
130 | get cells(): Cells<T>;
|
131 | setFilter(search: string, regex?: boolean, smart?: boolean, caseInsensitive?: boolean): this;
|
132 | resetFilter(): this;
|
133 | applyFilters(): this;
|
134 | }
|
135 | export declare class Columns<T> extends QTIterable<Columns<T>, Column<T>> {
|
136 | get quickTable(): QuickTable<T>;
|
137 | get columnIds(): ColumnId[];
|
138 | get columns(): Column<T>[];
|
139 | get $head(): JQuery;
|
140 | get $body(): JQuery;
|
141 | get $(): JQuery;
|
142 | get headerCellIds(): CellId[];
|
143 | get bodyCellIds(): CellId[];
|
144 | get cellIds(): CellId[];
|
145 | get headerCells(): Cells<T>;
|
146 | get bodyCells(): Cells<T>;
|
147 | get cells(): Cells<T>;
|
148 | set visible(visible: boolean);
|
149 | get length(): number;
|
150 | rowCells(row: number | RowId, isHead?: boolean): Cells<T>;
|
151 | headerRowCells(row: number | RowId): Cells<T>;
|
152 | }
|
153 | export declare class Row<T> extends EventEmitter {
|
154 | get quickTable(): QuickTable<T>;
|
155 | get rowId(): RowId;
|
156 | get isHead(): boolean;
|
157 | get index(): number;
|
158 | get $(): JQuery;
|
159 | get $cells(): JQuery;
|
160 | get visible(): boolean;
|
161 | set visible(visible: boolean);
|
162 | cell(column: number | ColumnId): Cell<T> | null;
|
163 | cellId(column: number | ColumnId): CellId;
|
164 | get cellIds(): CellId[];
|
165 | get cells(): Cells<T>;
|
166 | get length(): number;
|
167 | get cellHtmlData(): string[];
|
168 | get cellTextData(): string[];
|
169 | get cellData(): any[];
|
170 | get cellRawData(): any[];
|
171 | get data(): string[] | T;
|
172 | }
|
173 | export declare class Rows<T> extends QTIterable<Rows<T>, Row<T>> {
|
174 | get quickTable(): QuickTable<T>;
|
175 | get rowIds(): RowId[];
|
176 | get rows(): Row<T>[];
|
177 | get $(): JQuery;
|
178 | get $cells(): JQuery;
|
179 | get length(): number;
|
180 | columnCellIds(column: number | ColumnId): CellId[];
|
181 | columnCells(column: number | ColumnId): Cells<T>;
|
182 | get cellIds(): CellId[];
|
183 | get cells(): Cells<T>;
|
184 | get cellHtmlData(): string[][];
|
185 | get cellTextData(): string[][];
|
186 | get cellData(): any[][];
|
187 | get cellRawData(): any[][];
|
188 | get data(): Array<string[] | T>;
|
189 | set visible(visible: boolean);
|
190 | }
|
191 | export declare class QTDo<T, S> {
|
192 | get quickTable(): QuickTable<T>;
|
193 | get selection(): S | null;
|
194 | do(action: (selection: S) => void): void;
|
195 | get<R>(getter: (selection: S) => (R | null)): R | null;
|
196 | }
|
197 | export declare class QTWhen<T> {
|
198 | get quickTable(): QuickTable<T>;
|
199 | column(column: number | ColumnId): QTDo<T, Column<T>>;
|
200 | row(row: number | RowId, isHead?: boolean): QTDo<T, Row<T>>;
|
201 | headerRow(row: number | RowId): QTDo<T, Row<T>>;
|
202 | cell(row: number | RowId | CellId, column?: number | ColumnId, isHead?: boolean): QTDo<T, Cell<T>>;
|
203 | headerCell(row: number | RowId, column?: number | ColumnId): QTDo<T, Cell<T>>;
|
204 | }
|
205 | export declare type SortDef = [number, 'asc' | 'desc'];
|
206 | export declare class QuickTable<T> extends EventEmitter {
|
207 | get autoDraw(): boolean;
|
208 | set autoDraw(autoDraw: boolean);
|
209 | get clearOnLoad(): boolean;
|
210 | set clearOnLoad(clearOnLoad: boolean);
|
211 | get id(): any;
|
212 | set id(id: any);
|
213 | get clickHandler(): ((this: HTMLTableCellElement, value: any, row: T | string[], index: number) => void) | null;
|
214 | set clickHandler(value: ((this: HTMLTableCellElement, value: any, row: T | string[], index: number) => void) | null);
|
215 | chain(func: (table: this) => void): this;
|
216 | get emptyMessage(): string;
|
217 | set emptyMessage(value: string);
|
218 | get loadingMessage(): string;
|
219 | set loadingMessage(value: string);
|
220 | get loading(): boolean;
|
221 | set loading(value: boolean);
|
222 | get sortOrders(): SortDef[];
|
223 | set sortOrders(sortOrders: SortDef[]);
|
224 | toggleSort(columnIndex: number): this;
|
225 | addSort(columnIndex: number, order?: 'asc' | 'desc'): this;
|
226 | applyFilters(): this;
|
227 | resetFilters(): this;
|
228 | clearFilters(): this;
|
229 | get when(): QTWhen<T>;
|
230 | get $(): JQuery;
|
231 | getSection(isHead: boolean): JQuery;
|
232 | get $head(): JQuery;
|
233 | get $body(): JQuery;
|
234 | get columnCount(): number;
|
235 | get columns(): Columns<T>;
|
236 | get columnIds(): ColumnId[];
|
237 | column(column: number | ColumnId): Column<T> | null;
|
238 | columnId(column: number | ColumnId): ColumnId;
|
239 | getColumns(...columns: (number | ColumnId)[]): Columns<T>;
|
240 | getRowCount(isHead: boolean): number;
|
241 | get rowCount(): number;
|
242 | get headerRowCount(): number;
|
243 | getAllRows(isHead: boolean): Rows<T>;
|
244 | getAllRowIds(isHead: boolean): RowId[];
|
245 | get rows(): Rows<T>;
|
246 | get headerRows(): Rows<T>;
|
247 | get rowIds(): RowId[];
|
248 | get headerRowIds(): RowId[];
|
249 | getBodyRows(...rows: (number | RowId)[]): Rows<T>;
|
250 | getHeaderRows(...rows: (number | RowId)[]): Rows<T>;
|
251 | getRows(...rowIds: RowId[]): Rows<T>;
|
252 | row(row: number | RowId, isHead?: boolean): Row<T> | null;
|
253 | rowId(row: number | RowId, isHead?: boolean): RowId;
|
254 | headerRow(row: number | RowId): Row<T> | null;
|
255 | headerRowId(row: number | RowId): RowId;
|
256 | cell(row: number | RowId | CellId, column?: number | ColumnId, isHead?: boolean): Cell<T> | null;
|
257 | headerCell(row: number | RowId, column: number | ColumnId): Cell<T> | null;
|
258 | get columnDefs(): ColumnDef<T>[];
|
259 | set columnDefs(columnDefs: ColumnDef<T>[]);
|
260 | get rawData(): string[][] | T[];
|
261 | get rawSortedData(): string[][] | T[];
|
262 | get sortedData(): string[][] | T[] | null;
|
263 | get cellHtmlData(): string[][];
|
264 | get cellTextData(): string[][];
|
265 | sortData(forceSort?: boolean): this;
|
266 | get data(): string[][] | T[] | null;
|
267 | set data(data: string[][] | T[] | null);
|
268 | draw(): this;
|
269 | }
|
270 | export declare class QuickTables<T> extends QTIterable<QuickTables<T>, QuickTable<T>> {
|
271 | get tables(): QuickTable<T>[];
|
272 | get length(): number;
|
273 | get(index: number): QuickTable<T>;
|
274 | getById(id: any): QuickTable<T> | undefined;
|
275 | getAll(...indexes: number[]): QuickTables<T>;
|
276 | getAllById(...ids: any[]): QuickTables<T>;
|
277 | draw(): this;
|
278 | }
|
279 | export declare function setup(jQuery: JQueryStatic, lodash: LoDashStatic): void;
|
280 |
|
\ | No newline at end of file |